var styles = `
    .my-modal {
      display: none; 
      position: fixed; 
      z-index: 9999; 
      left: 0; 
      top: 0; 
      width: 100%; 
      height: 100%; 
      overflow: auto; 
      background-color: rgba(0,0,0,0.4); 
    }
    .my-modal-content {
      margin: 15% auto; 
      padding: 20px;
      border: 1px solid #888;
      width: 80%;
      max-width: 500px;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0,0,0,0.2);
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    .my-modal-content[app-rej=app] {
      background-color: #E7FFE7;
    }
    .my-modal-content[app-rej=rej] {
      background-color: #ffe7e7ff;
    }
    .my-close {
      color: #aaa;
      float: right;
      font-size: 28px;
      font-weight: bold;
      cursor: pointer;
      position: absolute;
      left: 0;
      top: 0;
      width: 25px;
      height: 25px;
    }
    .my-close:hover { color: black; }
    .my-modal-btn {
      padding: 10px 20px;
      background-color: #0078d4;
      color: white;
      border: none;
      cursor: pointer;
      font-size: 14px;
    }
  `;

var styleSheet = document.createElement("style");
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);

async function main() {
  const params = new URLSearchParams(window.location.search);
  const ItemID = params.get("ItemID");

  createFormUI({
    container: "Form",
    sidebar: [
      {
        label: "ثبت",
        icon: "/pmo/KForm/Images/Picture1.png",
      },
      {
        label: "تعریف",
        icon: "/pmo/KForm/Images/Picture2.png",
      },
      {
        label: "بودجه",
        icon: "/pmo/KForm/Images/Picture3.png",
      },
      {
        label: "زمان",
        icon: "/pmo/KForm/Images/Picture4.png",
      },
      {
        label: "ذینفعان",
        icon: "/pmo/KForm/Images/Picture5.png",
      },
      {
        label: "محدوده",
        icon: "/pmo/KForm/Images/Picture6.png",
      },
      {
        label: "تیم",
        icon: "/pmo/KForm/Images/Picture7.png",
      },
      {
        label: "ریسک",
        icon: "/pmo/KForm/Images/Picture8.png",
      },
    ],
    steps: {
      1: ["نام", "منشاء", "اسناد بالادستی", "پروژه‌(های) مرتبط"],
      2: ["معرفی", "اهداف", "مفروضات", "محدودیت ها", "رویکرد"],
      3: ["درآمد", "هزینه"],
      4: ["فازها", "رویدادها"],
      5: ["ذینفعان", "نیازمندی ها"],
      6: ["دامنه", "تحویل شدنی ها", "منابع", "معیارهای پذیرش خاتمه"],
      7: ["افراد", "آموزش"],
      8: ["ریسک های حین اجرا", "ریسک های عدم اجرا", "ریسک های بعد اجرا"],
    },
  });

  var save_btn = document.createElement("button");
  save_btn.style.backgroundImage =
    "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC30lEQVR4nO2cS27UQBRF7wRvAQHp/RCxkURkcUh8JJgDESQMEWPCCkhmDApZMhOrm+7qKr86rr5HqkkiO/fWSf/c1pOMMcYYY4wxhssg6UrStaQHSemE1h9JHyQ9FoSnkr4BNiY1Xt8JUsZHhmWII+UKsAkJtppKuZ6FeSPpWcbx8zJrIVGl3M+CnGUe34uQ1xQppRvai5BB0qstP/8xvelpFiz6+FZsy42QsnYhLyT9+s9rwZ2k84zcQ+unr7ULuTvgBfpnZu6mUtYuJB24cnM3e/qyEO3M3URKb0L+UUNIEykWor25Q6VYiA7KHSbFQnRw7hApFqKs3ItLsRBl5971OeV9YZfiYDWOX6OQXVLGbx6LsRAdnXtYor+FqCi3hcywkKUDFf79XWvfccdiITMsZOlAgMvvOVjIjPM9UkYZz+cHWQiPZCEsuhXyu/A2ohZsZpnHDt0Imd9o9xYuZSPp3Szzp56EvMx465mg66Lh/lU/4Xg95xawqenI9UXSo4b7t8gJn0i6AWxuylxfp+yt92+RE47/ZZeSPm65X5i07qeMF4WPjNr7t9wJT4xkISwsBIaFwLAQGBYCw0JgWAgMC4FhITCwQtY2K+VB0ufpavUA2L+qJ1z7rJTbgouMOCG9zEq5OfJiI05IT7NSLhvsX/UTls5KacXZ9HVz6Ve5OCGls1LWfrMDTkj1QMHg+uMCBYPrjwsUDK4/LlAwuP64QMHg+uMCBYPrjwsUDK4/LlAwuP64QMHg+uMCBYPrjwsUDK4/LlAwuP64QMHg+uMCBYPrjwsUDK4/LlAwuP64QMHg+uMCBYPrjwsUDK4/LlAwuP64QMHg+uMCBYPrv++Epb+nk2j9cYGCwfXHBQoG1x8XKBhcf9yLWjC4/rhAweD6l06EO2Uhm4qT6apNhDtVIZvKk+m6mgiXOphM181EuNTJZLouJsKljibTrXYiXOp0Mp0xxhhjjDHGaAn+AqQCw1hP6NhdAAAAAElFTkSuQmCC)";
  save_btn.style.position = "absolute";
  save_btn.style.top = 0;
  save_btn.style.left = "-15px";
  save_btn.style.backgroundPosition = "center";
  save_btn.style.backgroundRepeat = "no-repeat";
  save_btn.style.width = "60px";
  save_btn.style.height = "60px";
  save_btn.style.margin = "0";
  save_btn.style.backgroundSize = "contain";
  save_btn.style.border = "none";
  save_btn.style.transform = "scale(0.4)";
  save_btn.style.backgroundColor = "transparent";
  save_btn.style.cursor = "pointer";
  save_btn.style.padding = "0";
  save_btn.addEventListener("click", (event) => {
    event.preventDefault();
    K_Save(true, "/pmo/", "Charter");
  });
  document.getElementsByClassName("content-area")[0].appendChild(save_btn);

  var approve_btn = document.createElement("button");
  if(ItemID == "NewItem") approve_btn.style.display = "none";
  approve_btn.style.backgroundImage =
    "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF9ElEQVR4nO1dS4xURRQt4kbFX6IJKn6iKzfGuDIxahQFxE80GpSYmKiRqKMzTJ3zmiGR0K4UZGmisNAYUUSXmrhQFGNEFJW4a1vXxIWJgsAwkECZy9SEDpmG/tR7det1neRsJjPdde+Z++rVrVu3jMnIyMjIyMjIyMjIyMjohgVTU1PXFUVxH4CXSW4guYnkVgAfkfyQ5BYAGwG8SvIV+V1r7eKun5jRO8bGxi4iuQLAmwD2AjhM0g1CAAdI7iG5GcBSa+0Fse1LAlNTU5cCeB7ALpLHBxWgB06T/LIoitWNRuPi2HarA8klJHcAOFqiCN2i5zCA9wDcbkYdfj74oWoR2J3yWHvYjGhE/KZAANeF3wK4w9QdRVFcCeADkicVON31wE8BXGHqCGvtCyQPKnCy64cA/rLWPm7qgvHx8UsAfBLbsRye25J/XQZwK8k/FTjTBeI+ktebFAFg+TCLOerl3yTvNimhKIqnSl7YuZgEcAzAoyYFAHgJwInYTmMFohRF8YjRHhmjIAZP87i19gGjEQDuJTmjwEmuQrYbjcbVRuPbVE0ncHcWtiYnJ68yGtPkAH5X4CA38pEh8BtDsR3kshin0yFuhNhS+ZjqSBQeUOAkN/KRISC5XYGTnMbIAHCTqRIk70oohe6qjAxfB3C0yh3IBco3l1zEyHhIVvDytwC+M1VAtjgVOMppjYzOzyiKYlm5asx+8W4FznLaxfBRsquKvXBXc7YGfUx14W1lCrJDgcOc9sg4g++WthXrC8xiO80lJIZwes2aNZcFF0Sq/BQ4zSUmxikCeCa4IL6809WQrcBzxnz8vIzC5zpuybYqEEM4E7SGWEJUgfNcSo+pebgimCByJECBA13CYsg8sjGkIHtDOALAEQBfA/gMwP6aP6bcGdwdSo8FgbZnd6xbt+7yuQ9duXLleXISKpCxrgwxJE0UanwA/hNfDq0GgGsDDOYrEaDk/0CnVYw5Tk5O3hjkDMewA2k0Gnee7TsqEKUVW4xgEzvJsWEH0mw2zz/X95QoSkuJGJL9XR1CkA3DDqRz7qhYlJYWMTxfG0oMP8jNww6kn9QBwomiTQzxw1sDC9HhoHcCDGR/P+fFObxz1IkRLPMbsO6qr8WYtfb+ARdjfS/6qiqBlQYHAwtRUiFc2SvktlYxPLcNLETHoLcEHlRZorSViyF8e2AhQk7qFYjSTkAM4SYzLAA0SxpcKFHaiYghXD+wECEXht0oVfNDvg21lL5NdeOLRkPqpKRIaScUGadorb3HaEgu9sC+/tOLoliWWGTMCbI4VOnooVSry6kgMoKm371RP6V4/oJKIsNzjwlo2KYKB94OESlaIqMjQl4Po4ZPY1RsQHsYUbSJ4QVZGkwQkgsjhH57EFGUiiG+WxhMEG/oNxGMaaX4NjUPd5rQkOaUkYxp9xIpGiOjg8+W1ffqiEZRqFuMaem2asoAgI9jGYbZ5gQ3zDOmJ5U+pua43ZQFWfpHNu6QbIOSfFpybAC+UODwc7Hc3loAvldgpEuB0gLXlA2SD8Y2lIlQ1m+lC+JzW/s0GEzd/MVUBalEHKHGAW4Anqy8L+MIdgFyvRLA+6ZqTExMLCL5b2zjqYzSkCdax6CIq3enmOFX5f1Aao0UOMFpoCycTWz4A6Gt2M5gfDH+UHM5jLX2loq2eZ1SHrTW3mw0wfdBmRnByDhWSdefQUBy1Sg1UsasrU8YzZBisFEQBcAJaQJqUgDJx2Jc8MXqxJB0/yqTEvycktyNOuxtC2C5SRH+7autwIkuEFvq3qb6hbyb1yTvtU3WXKYu8Dd4Jtd4GcA/0dMhZSHFa/MmJiYWmbpD9goA/KrA4a4Lfz5X94laQm7TlO5ACgRwnrv91athqtRThVSz+BKj6QgiTPs+9mndvFYFxmeL8Z7zPbVKq7Xyn71TJmv5zth2JwHOFnjLXYgbAfw4TDZZDsv4m6DfkERgs9m8MLZ9tcDatWuvkcvH5Go+OdEqYpHc6tc5wi3+Z+v97ywJdYwsIyMjIyMjIyMjIyPD1BT/AyOfDbkyzFt+AAAAAElFTkSuQmCC)";
  approve_btn.style.position = "absolute";
  approve_btn.style.top = 0;
  approve_btn.style.left = "25px";
  approve_btn.style.backgroundPosition = "center";
  approve_btn.style.backgroundRepeat = "no-repeat";
  approve_btn.style.width = "60px";
  approve_btn.style.height = "60px";
  approve_btn.style.margin = "0";
  approve_btn.style.backgroundSize = "contain";
  approve_btn.style.border = "none";
  approve_btn.style.transform = "scale(0.48)";
  approve_btn.style.backgroundColor = "transparent";
  approve_btn.style.cursor = "pointer";
  approve_btn.style.padding = "0";
  approve_btn.addEventListener("click", (event) => {
    event.preventDefault();
    

    var modal = document.createElement("div");
    modal.className = "my-modal";
    modal.id = "myModal";

    var modalContent = document.createElement("div");
    modalContent.className = "my-modal-content";
    modalContent.setAttribute("app-rej", "app")

    var closeSpan = document.createElement("span");
    closeSpan.className = "my-close";
    closeSpan.innerHTML = "&times;";

    var modalText = document.createElement("p");
    modalText.innerHTML = "در صورت تکمیل اطلاعات جهت بررسی و تایید نهایی دکمه ارسال جهت تایید را کلیک نمایید.";

    var approve_btn_final = document.createElement("button");
    approve_btn_final.style.width = "100px";
    approve_btn_final.style.height = "40px";
    approve_btn_final.style.margin = "0";
    approve_btn_final.style.border = "none";
    approve_btn_final.style.borderRadius = "10px";
    approve_btn_final.style.cursor = "pointer";
    approve_btn_final.style.padding = "0";
    approve_btn_final.style.backgroundColor = "#00926C";
    approve_btn_final.style.color = "white";
    approve_btn_final.innerText = "ارسال جهت تایید";

    modalContent.appendChild(closeSpan);
    modalContent.appendChild(modalText);
    modalContent.appendChild(approve_btn_final);
    modal.appendChild(modalContent);

    document.body.appendChild(modal);

    modal.style.display = "block";

    closeSpan.onclick = function(event) {
      event.preventDefault();
      modal.remove()
    }

    approve_btn_final.onclick = function(event) {
      event.preventDefault();
      SetElement("K_AssignToId", _spPageContextInfo.userDisplayName)
      document.getElementById("K_AssignToId").setAttribute("data-login", _spPageContextInfo.userLoginName)
      debugger;
      K_Save(true, "/pmo/", "Charter");
    }

    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
      if (event.target == modal) {
        modal.remove()
      }
    }
  });
  document.getElementsByClassName("content-area")[0].appendChild(approve_btn);

  var reject_btn = document.createElement("button");
  if(ItemID == "NewItem") reject_btn.style.display = "none";
  reject_btn.style.backgroundImage =
    "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHMUlEQVR4nO1dWYtcRRSuFsQFN/AlxiVG474bBQWXKKJgUPDBuKBiEhxkYOiu76ubCajpuAT8AYq2Mb4YY9ToiytoRDH6oBM0xKBiTMAnVzBRE4XEK2dSM5lkZnpuz7213Nt94INheqbr1PluLffUqXOUKqEMDAwckyTJzCRJziA5l+T1FnPld/KZ/E1oPSsnjUbjNAB3kFxGcg3JIZJ/kkyzAMBO+z/yv8vsd80O3a/SSJIkM0neC+AFktuzGn4akO9epbW+R9oM3e+oRKYWrfV9AN4n+Z9DEtphCEB96dKlx6tuFZLzALxMclcgEtIJILqs0Vpfq7pFjDE3APgsAuOnU+BTkrcopWqqimKMuQ3AlxEYOu0EADYCuFVVRYwxpwN4J7RhmZ+Y9QDOVmUVrfURJJcD2B3amCyOlH8BPNlsNg9XZRIAl5D8LrQB6Y6Yb7XWF6kyiN3C/h3aaHRPym7ZKqtYJUmSo+02Nrix6JeY1+v1+nEqJmk0GieQ/Cq0cRgOXy9ZsuQkFZG/aWsERkkDY3uSJGeFJuMyAD9HYIw0EvxujLkyCBkkL7fe1NBGSGOC2EQeVK9kaK3nkPwpdOcZL371Nn1ZF7lL13haEfwI4GSnZAwODh4LYHMEnU3LAACb5HXAGSEAXgrdSZYMAF5xQgbJ/tCdY0lhjHmgUDK01hdEdpCUls3NYoy5uEivbWUdhfSHbwYGBg7LTQjJxyLoTFoRLMs7OuZU6TyD4fEPgDPzjI63I+hEWjG8N+0z8AiUTysKCZ7oSGoeAxIkFuuJwcHBU+r1+jlyvuDLMADekDalbZIrPMaFDXXEBsn5Hsnon+BheNpD26uazeYhB/V7MYC9nh6GmzITAmBDIDJ8kTKOjBEBsMgHKRKbprJGFHoio28KVWoAnnNgiOcnI8M3KSSvyULI2oAjw/VImXRkHCwkF7omRXyDUwY+O3aRdEJG0aRkJmNEANxFco9De+wSD/qkCsii5nh0rFDTk1rO6Wtlp2SMsclyxzZZOGnjAD523PisaRIiUiPZ8kmGiESTOLbJhxM2rLU+0fU+vNFonKfySa1DUnKRISLvKS5tIuuUMWbGuIbl5pKPoLICwvtrWUiRKS4vGbatV13bxRhz97iW7TWy1ANWFWEotFnos2xts7RB8ilPNlk5rnXPgQvOSEH5yBCdt46LPvRIhjNSUEIyRlCv108d1YDknQEIGZ7nC1xTWkV8F4BnQtiC5IJRLQA0AylRGCmq3GSIHR4Z1cRerE8Doojpq3TT1EF4cVQbudgYWJmQpNQiIENGyOdjFcqcrsIxWp6vIUvfn42g34IdwxpJqGMEyqQF75SyiK+DsMxoNptHjgRPp11GSi02MgTDLhQJmw+tiGdSajGSIZDUUsO3oEIr4pGUWqxkWEIuFS/vdaEV8URKLWYyLOb1CGFUmNebshjZlNVb1BnXot7b9jK6bW/vxZARvRhaxXZ2GRkxkrLPdRKLczEAGVGRMta5GNz9HpCMmEjZ7363iYpDKVLISZ/yFM3iEA+PamIzPpeWDBZ4hBuKFAC3Bw1yKCogAQ6CHEJMXwcEOfgOA3JpOJSQlHFhQD4D5XwYDCUjxQZ6HCiSmN5D4+s8zvOtgiJRnN95lGsP41q2LpSqBVu38pJC8vwgwda28Y9cNi63XQPsgFp5SJHF1jEh69verXPc+KOeyUjzkgLgccc2ub/tlTaXSZBleLZVwOHiOp2F3vWVNrH1lAnOPCRDlnXqwRA7HXRAio9LnyRXT6mIFDNxrMTISFkU6K25NdX05YkMOZC6OsvDIQp9UuXEAWgzUnyRIQVjVFbRWt/sQaHJSKn5eCGbiBSPCQPkdPDGzIRYo2z0SIokfplF8lx5efTUrmDdSPIZ2U15zHOy/+wjq0iZH4+G6TbM75gQS8pbESifVgzvqpz1o3op/lgYdslRh8ojHlJLdA0APKTyihTAkppLoTvDkgPAlkLSxIr0EikzLxm7Cy8iJu6O0B1jebG4UDLGkLI6gs6lJcNa5bgS26YIOpmWAZLZtb+//yjluiIbgG2hO8v48cOkJ4FFi7yf9EoesR1+8V6xzVZoiyJIm3FhB8m5KoRIw72yeRwFgN+01leokGKjHr8PbQyGJ2NbrsoHRYosXmUsXs/iyNgsOStVTGK3xF1XNAzAa21z74aWXvnuCMUYc6HUXKowGVskolGVSfr6+g6VJwjAX6ENyOIgDtbl4gFXZRVb3rsKJ49vkpytqiJS5kcqy0Rg2LTTgASJwlFVFQBXkfygBERssLWifGa4CydSzES2yTHtyLBPl9WZIwqrKFJJVC482jl6TwAS9trR0Oe0snMZxRgzQxLTSy50cV87JGGrtCHR7d5c5FUQ7otmXCB3uO1p5RfWm5rV8H/IoiyX8uU77EjMU8OkJ2oCkVM4ebKlNKx4nCUJm03EJj/Pkc+cn9Q5kv8Bp7sesOsejoMAAAAASUVORK5CYII=)";
  reject_btn.style.position = "absolute";
  reject_btn.style.top = 0;
  reject_btn.style.left = "60px";
  reject_btn.style.backgroundPosition = "center";
  reject_btn.style.backgroundRepeat = "no-repeat";
  reject_btn.style.width = "60px";
  reject_btn.style.height = "60px";
  reject_btn.style.margin = "0";
  reject_btn.style.backgroundSize = "contain";
  reject_btn.style.border = "none";
  reject_btn.style.transform = "scale(0.4)";
  reject_btn.style.backgroundColor = "transparent";
  reject_btn.style.cursor = "pointer";
  reject_btn.style.padding = "0";
  reject_btn.addEventListener("click", (event) => {
    event.preventDefault();
    

    var modal = document.createElement("div");
    modal.className = "my-modal";
    modal.id = "myModal";

    var modalContent = document.createElement("div");
    modalContent.className = "my-modal-content";
    modalContent.setAttribute("app-rej", "rej")

    var closeSpan = document.createElement("span");
    closeSpan.className = "my-close";
    closeSpan.innerHTML = "&times;";

    var modalText = document.createElement("p");
    modalText.innerHTML = "جهت برگشت و اصلاح اطلاعات دکمه ارسال جهت اصلاح را کلیک نمایید.";

    var reject_btn_final = document.createElement("button");
    reject_btn_final.style.width = "100px";
    reject_btn_final.style.height = "40px";
    reject_btn_final.style.margin = "0";
    reject_btn_final.style.border = "none";
    reject_btn_final.style.borderRadius = "10px";
    reject_btn_final.style.cursor = "pointer";
    reject_btn_final.style.padding = "0";
    reject_btn_final.style.backgroundColor = "#9b3737ff";
    reject_btn_final.style.color = "white";
    reject_btn_final.innerText = "ارسال جهت اصلاح";

    modalContent.appendChild(closeSpan);
    modalContent.appendChild(modalText);
    modalContent.appendChild(reject_btn_final);
    modal.appendChild(modalContent);

    document.body.appendChild(modal);

    modal.style.display = "block";

    closeSpan.onclick = function(event) {
      event.preventDefault();
      modal.remove()
    }

    reject_btn_final.onclick = function(event) {
      event.preventDefault();
      SetElement("K_AssignToId", _spPageContextInfo.userDisplayName)
      document.getElementById("K_AssignToId").setAttribute("data-login", _spPageContextInfo.userLoginName)
      debugger;
      K_Save(true, "/pmo/", "Charter");
    }

    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
      if (event.target == modal) {
        modal.remove()
      }
    }
  });
  document.getElementsByClassName("content-area")[0].appendChild(reject_btn);

  var next_step_btn = document.createElement("button");
  next_step_btn.style.backgroundImage =
    "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC4UlEQVR4nO2ZPW4TURSFRyAhkJAoaaGHEiTYALAAt2wBubIs+72TkpYtsAXXyQaSBZjarSUXoBRB8kMhgzwKcuKfO3PPvHc+6fR37tEd+7OrSgghhBBCCCGEEBkD4K33DKJBjHEN4Pt4PH7uPYu4uZBU5xeAEwCPvGcqmkYhfxNj/BFC+OQ9V7HcLqRRzGwymbz0nq84thVS5xLAVwBPvecshnsK+XctCwCfvWctgl0KaeRsOp2+9p45a/Ys5PpafscYv41Go2fes2fJvoU0sowxfhkMBg+9nyErjigk1bkA8N77ObLBoJAk2ycrBJtifsr2iQpBw/YBfPR+tl7SRiHYFCPbZyoEN5HtkxWS6muR7TMVgk3OALzyfm5aHApJsn2yQnDL9gE88N4DDc6FpDoXIYR33ruggKCMVL/GZPvXeBeB/4sp2/a9C8D2Ysq0fe/F4/5iyrJ974Vjt5Rj+wTLTntcS/62771kHJZ8bZ9guenAa8nT9r0Xi+OTl+0TLDQZJQ/bJ1hkskoWtu+9RLRTzCrGOOql7XsvD+1m3jvbJ1ha6uBi+mP73stCd+mH7RMsKnV8Ldy2770g+IXT9gkWkxyvhc/2vZcCjvDYPsEyEkFUCAiiVxZ4EmM81Yc6/KOvvaASw5PhcPikYqaQq5gBeFH1Ae9lod3ox0UQRD+/gyP6gwpU0V+44AiPZVtAsNB0YK7oLNsCgsWmbCzbgp4VsaC2bAu8l4ycLNuCHlzFrDeWbYH3wrE98xDCh6o0CC9i1VvLtoCoiHXvLdsCkjLOs7BsC5zLWGZl2RY4FXGVpWVb4PB6Os3Wsi3osIhF9pZtQQdlXBZj2Ra0fBWzoizbgpbKmBdp2RYYX8SqaMu2wKiItSzbCIMyzmXZhhxRxlKW3QIHFCHLbpM9X0+y7LbZsQhZdlfsYtkAHnc2UOnccRWybA9k2WTIssmQZZMRQnjjPYMQQgghhBBCCCFEZcIfdJ1SYekvaZ0AAAAASUVORK5CYII=)";
  next_step_btn.style.position = "absolute";
  next_step_btn.style.bottom = 0;
  next_step_btn.style.left = 0;
  next_step_btn.style.backgroundPosition = "center";
  next_step_btn.style.backgroundRepeat = "no-repeat";
  next_step_btn.style.width = "60px";
  next_step_btn.style.height = "60px";
  next_step_btn.style.margin = "0";
  next_step_btn.style.marginLeft = "-10px";
  next_step_btn.style.backgroundSize = "contain";
  next_step_btn.style.border = "none";
  next_step_btn.style.transform = "rotate(180deg) scale(0.6)";
  next_step_btn.style.backgroundColor = "transparent";
  next_step_btn.style.cursor = "pointer";
  next_step_btn.style.padding = "0";
  next_step_btn.addEventListener("click", (event) => {
    event.preventDefault();
    goForward();
  });

  var previous_step_btn = document.createElement("button");
  previous_step_btn.style.backgroundImage =
    "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC4UlEQVR4nO2ZPW4TURSFRyAhkJAoaaGHEiTYALAAt2wBubIs+72TkpYtsAXXyQaSBZjarSUXoBRB8kMhgzwKcuKfO3PPvHc+6fR37tEd+7OrSgghhBBCCCGEEBkD4K33DKJBjHEN4Pt4PH7uPYu4uZBU5xeAEwCPvGcqmkYhfxNj/BFC+OQ9V7HcLqRRzGwymbz0nq84thVS5xLAVwBPvecshnsK+XctCwCfvWctgl0KaeRsOp2+9p45a/Ys5PpafscYv41Go2fes2fJvoU0sowxfhkMBg+9nyErjigk1bkA8N77ObLBoJAk2ycrBJtifsr2iQpBw/YBfPR+tl7SRiHYFCPbZyoEN5HtkxWS6muR7TMVgk3OALzyfm5aHApJsn2yQnDL9gE88N4DDc6FpDoXIYR33ruggKCMVL/GZPvXeBeB/4sp2/a9C8D2Ysq0fe/F4/5iyrJ974Vjt5Rj+wTLTntcS/62771kHJZ8bZ9guenAa8nT9r0Xi+OTl+0TLDQZJQ/bJ1hkskoWtu+9RLRTzCrGOOql7XsvD+1m3jvbJ1ha6uBi+mP73stCd+mH7RMsKnV8Ldy2770g+IXT9gkWkxyvhc/2vZcCjvDYPsEyEkFUCAiiVxZ4EmM81Yc6/KOvvaASw5PhcPikYqaQq5gBeFH1Ae9lod3ox0UQRD+/gyP6gwpU0V+44AiPZVtAsNB0YK7oLNsCgsWmbCzbgp4VsaC2bAu8l4ycLNuCHlzFrDeWbYH3wrE98xDCh6o0CC9i1VvLtoCoiHXvLdsCkjLOs7BsC5zLWGZl2RY4FXGVpWVb4PB6Os3Wsi3osIhF9pZtQQdlXBZj2Ra0fBWzoizbgpbKmBdp2RYYX8SqaMu2wKiItSzbCIMyzmXZhhxRxlKW3QIHFCHLbpM9X0+y7LbZsQhZdlfsYtkAHnc2UOnccRWybA9k2WTIssmQZZMRQnjjPYMQQgghhBBCCCFEZcIfdJ1SYekvaZ0AAAAASUVORK5CYII=)";
  previous_step_btn.style.position = "absolute";
  previous_step_btn.style.bottom = 0;
  previous_step_btn.style.left = 0;
  previous_step_btn.style.backgroundPosition = "center";
  previous_step_btn.style.backgroundRepeat = "no-repeat";
  previous_step_btn.style.width = "60px";
  previous_step_btn.style.height = "60px";
  previous_step_btn.style.margin = "0";
  previous_step_btn.style.marginLeft = "30px";
  previous_step_btn.style.backgroundSize = "contain";
  previous_step_btn.style.border = "none";
  previous_step_btn.style.transform = "scale(0.6)";
  previous_step_btn.style.backgroundColor = "transparent";
  previous_step_btn.style.cursor = "pointer";
  previous_step_btn.style.padding = "0";
  previous_step_btn.addEventListener("click", (event) => {
    event.preventDefault();
    goBackward();
  });
  document
    .getElementsByClassName("content-area")[0]
    .appendChild(previous_step_btn);
  document.getElementsByClassName("content-area")[0].appendChild(next_step_btn);

  ////////////////////////////////////////////////////////////// Tab 1

  ////////////////////////////////////// Section 1

  createInputRow(
    "content-1-step-1",
    "ProjectName",
    [
      {
        id: "K_Project",
        label: "نام پروژه",
        size: 2,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "ProjectSetting",
        valueField: "Id",
        textField: "Title",
        saveId: true,
        disabled: ItemID == "NewItem" ? false : true,
        onchangefunction: async () => {
          var ProjectID = document.getElementById("K_ProjectId").value;

          var ProjectItem = await getItemFromList(
            "/pmo/",
            "ProjectSetting",
            ProjectID
          );

          var ProjectDeputy = ProjectItem.DeputyId;
          var ProjectManagement = ProjectItem.ManagementId;

          SetElement("K_ProjectShortName", ProjectItem.Project);
          SetElement("K_ProjectCode", ProjectItem.ProjectCode);

          SetElement("K_DeputyId", ProjectDeputy);
          SetElement("K_ManagementId", ProjectManagement);

          SetGlobalVariable([
            ["ProjectID", ProjectID],
            ["ProjectDeputy", ProjectDeputy],
            ["ProjectManagement", ProjectManagement],
          ]);
        },
      },
    ],
    2,
    10
  );

  createInputRow(
    "content-1-step-1",
    "ProjectDeputyManagement",
    [
      {
        id: "K_Deputy",
        label: "معاونت",
        size: 1,
        disabled: true,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "Deputy",
        valueField: "Id",
        textField: "Title",
      },
      {
        id: "K_Management",
        label: "مدیریت",
        size: 1,
        disabled: true,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "Management",
        valueField: "Id",
        textField: "Title",
      },
    ],
    2,
    10
  );


  createInputRow(
    "content-1-step-1",
    "ProjectShortName",
    [
      {
        id: "K_ProjectShortName",
        label: "نام کوتاه پروژه",
        size: 1,
        disabled: true,
        save: false,
      },
    ],
    2,
    10
  );

  createInputRow(
    "content-1-step-1",
    "ProjectCode",
    [
      {
        id: "K_ProjectCode",
        label: "کد پروژه",
        size: 1,
        disabled: true,
        save: false,
      },
    ],
    2,
    10
  );
 /*
  createInputRow(
    "content-1-step-1",
    "ProjectCode",
    [
      {
        type: "multiuserpicker",
        id: "K_AssignTo",
        label: "کاربر",
        siteUrl: "/pmo",
        size: 5
      },
    ],
    10,
    10
  );

 
createInputRow(
  "content-1-step-1",
  "ProjectCode",
  [
    {
      type: "lookup",
      id: "K_AssignedTo",
      label: "کاربر",
      siteUrl: "/pmo/",
      listName: "Hamkaran",
      valueField: "UserNameId",
      textField: "Title",
      saveId: true,
      size: 3,
    },
  ],
  10,
  10
);
*/
  ////////////////////////////////////// Section 2
  createInputRow(
    "content-1-step-2",
    "ProjectOrigin",
    [
      {
        id: "K_ProjectOrigin",
        label: "منشاء پروژه",
        type: "radio",
        options: [
          { label: "بانک مرکزی", value: "بانک مرکزی" },
          { label: "برنامه راهبردی", value: "برنامه راهبردی" },
          { label: "داخلی", value: "داخلی" },
        ],
        size: 1,
      },
    ],
    5,
    10
  );

  ////////////////////////////////////// Section 3
  CreateGrid("content-1-step-3", {
    gridName: "CharterUpperFilesList",
    gridDisplayName: "اسناد  بالادستی",
    showEditButton: true,
    showColumns: false,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    dataSource: {
      site: "/pmo/",
      listName: "CharterUpperFilesList",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "سند بالادستی",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "CharterUpperFilesList",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-CharterUpperFilesList",
            "Title",
            [
              {
                id: "K_Modal_CharterUpperFilesList_Title",
                label: "عنوان",
                type: "text",
                inline: true,
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-CharterUpperFilesList",
            "FileLabel",
            [
              {
                id: "K_FileLabel",
                label: "اسناد",
                type: "label",
                labelText: "اسناد",
                nullElement: true,
                size: 1,
              },
            ],
            4,
            10
          );
          createUploader(
            "k-modal-body-/pmo-CharterUpperFilesList",
            "/pmo",
            {
              listTitle: "CharterUpperFiles",
              folderUrl: "pmo/CharterUpperFiles",
            },
            { CharterUpperFilesList: rowItemId },
            `<Eq><<FieldRef Name="CharterUpperFilesList" LookupId="TRUE" /><Value Type="Integer">${rowItemId}</Value></Eq>`
          );
        }
      );
    },
  });

  ////////////////////////////////////// Section 4
  CreateGrid("content-1-step-4", {
    gridName: "CharterRelatedProjectsList",
    gridDisplayName: "پروژه‌(های) مرتبط",
    showEditButton: true,
    showColumns: false,
    columns: [
      {
        name: "Project",
        displayName: "عنوان",
        type: "lookup",
        disabled: true,
        textAlign: "right",
        lookupSite: "/pmo/",
        lookupList: "ProjectSetting",
        lookupColumn: "Title",
      },
    ],
    ParentList: "Charter",
    dataSource: {
      site: "/pmo/",
      listName: "CharterRelatedProjectsList",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "پروژه مرتبط",
          width: 800,
          height: 350,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "CharterRelatedProjectsList",
          defaultColumns: '[{ "CharterId": ' + ItemID + "}]",
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-CharterRelatedProjectsList",
            "Deputy&Management",
            [
              {
                id: "K_Modal_CharterRelatedProjectsList_Deputy",
                label: "معاونت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Deputy",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                onchangefunction: async () => {
                  if (
                    GetElement("K_Modal_CharterRelatedProjectsList_DeputyId") !=
                    ""
                  ) {
                    setLookupOptions(
                      "K_Modal_CharterRelatedProjectsList_ManagementId",
                      `DeputyId eq ${GetElement(
                        "K_Modal_CharterRelatedProjectsList_DeputyId"
                      )}`
                    );
                  }

                  if (!rowItemId.toString().includes("NewItem")) {
                    var CharterRelatedProject = await getItemFromList(
                      "/pmo/",
                      "CharterRelatedProjectsList",
                      rowItemId
                    );
                    SetElement(
                      "K_Modal_CharterRelatedProjectsList_ManagementId",
                      CharterRelatedProject.ManagementId
                    );
                  }
                },
              },
              {
                id: "K_Modal_CharterRelatedProjectsList_Management",
                label: "مدیریت",
                type: "text",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Management",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: "Id eq 0",
                onchangefunction: async () => {
                  setTimeout(async () => {
                    if (
                      GetElement(
                        "K_Modal_CharterRelatedProjectsList_DeputyId"
                      ) != "" &&
                      GetElement(
                        "K_Modal_CharterRelatedProjectsList_ManagementId"
                      ) != ""
                    )
                      setLookupOptions(
                        "K_Modal_CharterRelatedProjectsList_ProjectId",
                        `DeputyId eq ${GetElement(
                          "K_Modal_CharterRelatedProjectsList_DeputyId"
                        )} and ManagementId eq ${GetElement(
                          "K_Modal_CharterRelatedProjectsList_ManagementId"
                        )}`
                      );
                    if (!rowItemId.toString().includes("NewItem")) {
                      var CharterRelatedProject = await getItemFromList(
                        "/pmo/",
                        "CharterRelatedProjectsList",
                        rowItemId
                      );
                      SetElement(
                        "K_Modal_CharterRelatedProjectsList_ProjectId",
                        CharterRelatedProject.ProjectId
                      );
                    }
                  }, 200);
                },
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-CharterRelatedProjectsList",
            "Project",
            [
              {
                id: "K_Modal_CharterRelatedProjectsList_Project",
                label: "پروژه",
                type: "text",
                inline: true,
                labelVisible: false,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "ProjectSetting",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: "Id eq 0",
              },
            ],
            5,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////////////////////////////// Tab 2

  ////////////////////////////////////// Section 1

  createInputRow(
    "content-2-step-1",
    "ProjectDescription",
    [
      {
        id: "K_ProjectIntroduction",
        label: "معرفی پروژه",
        size: 2,
        type: "multiline",
        height: "150px",
      },
    ],
    2,
    10
  );

  ////////////////////////////////////// Section 2
  createInputRow(
    "content-2-step-2",
    "ShaparakTarget",
    [
      {
        id: "K_ShaparakTarget",
        label: "هدف شرکت شاپرک",
        type: "combobox",
        options: [
          { value: "هدف ۱", label: "هدف ۱" },
          { value: "هدف ۲", label: "هدف ۲" },
          { value: "هدف ۳", label: "هدف ۳" },
        ],
        size: 1,
      },
    ],
    3,
    10
  );

  createInputRow(
    "content-2-step-2",
    "MeliAnformaticTarget",
    [
      {
        id: "K_MeliAnformaticTarget",
        label: "هدف شرکت ملی انفورماتیک",
        type: "combobox",
        options: [
          { value: "هدف ۱", label: "هدف ۱" },
          { value: "هدف ۲", label: "هدف ۲" },
          { value: "هدف ۳", label: "هدف ۳" },
        ],
        size: 1,
      },
    ],
    3,
    10
  );

  CreateGrid("content-2-step-2", {
    gridName: "CharterTargets",
    gridDisplayName: "اهداف پروژه",
    showEditButton: false,
    showColumns: false,
    showDelteButton: true,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectObjective",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////// Section 3
  CreateGrid("content-2-step-3", {
    gridName: "CharterAssumptions",
    gridDisplayName: "مفروضات پروژه",
    showEditButton: false,
    showColumns: false,
    showDelteButton: true,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    dataSource: {
      site: "/pmo/",
      listName: "CharterAssumptionsList",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////// Section 4
  CreateGrid("content-2-step-4", {
    gridName: "CharterLimitations",
    gridDisplayName: "محدودیت‌های پروژه",
    showEditButton: false,
    showColumns: false,
    showDelteButton: true,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    dataSource: {
      site: "/pmo/",
      listName: "CharterLimitationsList",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////// Section 5
  createInputRow(
    "content-2-step-5",
    "ProjectManagementApproach",
    [
      {
        id: "K_ProjectManagementApproach",
        label: "رویکرد مدیریت پروژه",
        type: "radio",
        options: [
          {
            label: "آبشاری (استاندارد PMBOK)",
            value: "آبشاری (استاندارد PMBOK)",
          },
        ],
        size: 3,
      },
    ],
    5,
    10
  );

  ////////////////////////////////////////////////////////////// Tab 3

  ////////////////////////////////////// Section 1

  createInputRow(
    "content-3-step-1",
    "IncomeEstimation",
    [
      {
        id: "K_IncomeEstimation",
        label: "برآورد درآمدی",
        type: "number",
        formatThousands: true,
        textAlign: "center",
        size: 1,
      },
      {
        id: "K_IncomeEstimationLabel",
        labelVisible: false,
        labelText: "میلیون ریال",
        type: "label",
        size: 1,
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-1",
    "IncomeModelDescription",
    [
      {
        id: "K_IncomeModelDescription",
        label: "توضیحات مدل درآمدی",
        size: 2,
        type: "multiline",
        height: "150px",
      },
    ],
    2,
    10
  );

  ////////////////////////////////////// Section 2

  createInputRow(
    "content-3-step-2",
    "CostEstimation",
    [
      {
        id: "K_CostEstimation",
        label: "هزینه برآوردی",
        type: "label",
        labelText: "میلیون ریال",
        nullElement: true,
        size: 1,
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimation",
    [
      {
        id: "K_CostEstimation",
        label: "هزینه برآوردی",
        labelVisible: false,
        type: "label",
        inline: true,
        labelText: "میلیون ریال",
        backgroundColor: "#FFC000",
        textAlign: "center",
        size: 1,
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationEquipment",
    [
      {
        id: "K_CostEstimationEquipment",
        label: "تجهیزات/ساختمان",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        size: 1,
        onchangefunction: function () {
          SetElement(
            "K_CostEstimationSum",
            parseFloat(
              normalizeNumber(GetElement("K_CostEstimationEquipment"))
            ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationSoftware"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationContractor"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationInvestment"))
              ) +
              parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
          );
        },
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationSoftware",
    [
      {
        id: "K_CostEstimationSoftware",
        label: "نرم افزار/لایسنس",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        size: 1,
        onchangefunction: function () {
          SetElement(
            "K_CostEstimationSum",
            parseFloat(
              normalizeNumber(GetElement("K_CostEstimationEquipment"))
            ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationSoftware"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationContractor"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationInvestment"))
              ) +
              parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
          );
        },
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationContractor",
    [
      {
        id: "K_CostEstimationContractor",
        label: "مشاور/پیمانکار",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        size: 1,
        onchangefunction: function () {
          SetElement(
            "K_CostEstimationSum",
            parseFloat(
              normalizeNumber(GetElement("K_CostEstimationEquipment"))
            ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationSoftware"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationContractor"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationInvestment"))
              ) +
              parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
          );
        },
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationInvestment",
    [
      {
        id: "K_CostEstimationInvestment",
        label: "سرمایه گذاری",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        size: 1,
        onchangefunction: function () {
          SetElement(
            "K_CostEstimationSum",
            parseFloat(
              normalizeNumber(GetElement("K_CostEstimationEquipment"))
            ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationSoftware"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationContractor"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationInvestment"))
              ) +
              parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
          );
        },
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationOther",
    [
      {
        id: "K_CostEstimationOther",
        label: "سایر",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        size: 1,
        onchangefunction: function () {
          SetElement(
            "K_CostEstimationSum",
            parseFloat(
              normalizeNumber(GetElement("K_CostEstimationEquipment"))
            ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationSoftware"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationContractor"))
              ) +
              parseFloat(
                normalizeNumber(GetElement("K_CostEstimationInvestment"))
              ) +
              parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
          );
        },
      },
    ],
    4,
    10
  );

  createInputRow(
    "content-3-step-2",
    "CostEstimationSum",
    [
      {
        id: "K_CostEstimationSum",
        label: "جمع",
        type: "number",
        formatThousands: true,
        inline: true,
        textAlign: "center",
        disabled: true,
        size: 1,
      },
    ],
    4,
    10
  );

  ////////////////////////////////////////////////////////////// Tab 4

  ////////////////////////////////////// Section 1

  CreateGrid("content-4-step-1", {
    gridName: "CharterFaze",
    gridDisplayName: "فازها",
    showEditButton: true,
    showColumns: true,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "فاز",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
      {
        name: "Start",
        displayName: "شروع",
        type: "date",
        disabled: true,
        textAlign: "center",
      },
      {
        name: "Finish",
        displayName: "پایان",
        type: "date",
        disabled: true,
        textAlign: "center",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectPhase",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "فاز",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectPhase",
          defaultColumns: '[{ "CharterId": ' + ItemID + "}]",
          TitleVisible: false,
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "fazeTitle",
            [
              {
                id: "K_Modal_ProjectPhase_FazeTitle",
                label: "فاز",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "Order",
            [
              {
                id: "K_Modal_ProjectPhase_Order0",
                label: "ترتیب",
                type: "combobox",
                inline: true,
                size: 5,
                options: [
                  { value: "1", label: "1" },
                  { value: "2", label: "2" },
                  { value: "3", label: "3" },
                  { value: "4", label: "4" },
                  { value: "5", label: "5" },
                  { value: "6", label: "6" },
                  { value: "7", label: "7" },
                  { value: "8", label: "8" },
                  { value: "9", label: "9" },
                  { value: "10", label: "10" },
                ],
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "Title",
            [
              {
                id: "K_Modal_ProjectPhase_Title",
                label: "عنوان",
                type: "text",
                inline: true,
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "JobDescription",
            [
              {
                id: "K_Modal_ProjectPhase_PhaseDescription",
                label: "شرح کار و خدمات فاز",
                type: "multiline",
                size: 5,
                height: "150px",
              },
            ],
            5,
            10
          );

          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "TimeTime",
            [
              {
                id: "K_Modal_ProjectPhase_TimeTitle",
                label: "زمانبندی",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );

          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "Dates",
            [
              {
                id: "K_Modal_ProjectPhase_Start",
                label: "شروع",
                type: "date",
                size: 5,
              },
              {
                id: "K_Modal_ProjectPhase_Finish",
                label: "پایان",
                type: "date",
                size: 5,
              },
            ],
            10,
            10
          );

          var startdate = new Date().setHours(0, 0, 0, 0);
          var enddate = new Date().setHours(0, 0, 0, 0);
          var diff = 0;

          document
            .getElementById("K_Modal_ProjectPhase_Start")
            .addEventListener("change", () => {
              var syear,
                smonth,
                sday = 0;

              var sdatestart = document.getElementById(
                "K_Modal_ProjectPhase_Start"
              ).value;

              if (sdatestart != "") {
                syear = parseInt(sdatestart.split("/")[0]);
                smonth = parseInt(sdatestart.split("/")[1]);
                sday = parseInt(sdatestart.split("/")[2]);

                startdate = new Date(
                  farvardin.solarToGregorian(syear, smonth, sday)
                );
              }

              var sdatefinish = document.getElementById(
                "K_Modal_ProjectPhase_Finish"
              ).value;

              if (sdatefinish != "") {
                syear = parseInt(sdatefinish.split("/")[0]);
                smonth = parseInt(sdatefinish.split("/")[1]);
                sday = parseInt(sdatefinish.split("/")[2]);

                enddate = new Date(
                  farvardin.solarToGregorian(syear, smonth, sday)
                );
              }

              diff = parseInt(enddate - startdate) / (1000 * 60 * 60 * 24);
              diff /= 31;
              diff = diff.toFixed(2);

              SetElement("K_Modal_ProjectPhase_Duration", diff);
            });

          document
            .getElementById("K_Modal_ProjectPhase_Finish")
            .addEventListener("change", () => {
              var syear,
                smonth,
                sday = 0;

              var sdatestart = document.getElementById(
                "K_Modal_ProjectPhase_Start"
              ).value;

              if (sdatestart != "") {
                syear = parseInt(sdatestart.split("/")[0]);
                smonth = parseInt(sdatestart.split("/")[1]);
                sday = parseInt(sdatestart.split("/")[2]);

                startdate = new Date(
                  farvardin.solarToGregorian(syear, smonth, sday)
                );
              }

              var sdatefinish = document.getElementById(
                "K_Modal_ProjectPhase_Finish"
              ).value;

              if (sdatefinish != "") {
                syear = parseInt(sdatefinish.split("/")[0]);
                smonth = parseInt(sdatefinish.split("/")[1]);
                sday = parseInt(sdatefinish.split("/")[2]);

                enddate = new Date(
                  farvardin.solarToGregorian(syear, smonth, sday)
                );
              }

              diff = parseInt(enddate - startdate) / (1000 * 60 * 60 * 24);
              diff /= 31;
              diff = diff.toFixed(2);

              SetElement("K_Modal_ProjectPhase_Duration", diff);
            });

          createInputRow(
            "k-modal-body-/pmo-ProjectPhase",
            "Duration",
            [
              {
                id: "K_Modal_ProjectPhase_Duration",
                label: "مدت زمان",
                type: "number",
                disabled: true,
                size: 2,
              },
            ],
            10,
            10
          );

          setTimeout(() => {
            if (!GetElement("K_Modal_ProjectPhase_Duration")) {
              SetElement("K_Modal_ProjectPhase_Duration", diff.toFixed(2));
            }
          }, 1500);
        }
      );
    },
  });

  ////////////////////////////////////// Section 2

  CreateGrid("content-4-step-2", {
    gridName: "ProjectEvent",
    gridDisplayName: "رویدادهای کلیدی",
    showEditButton: true,
    showColumns: true,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "رویداد",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
      {
        name: "DueDate",
        displayName: "موعد",
        type: "date",
        disabled: true,
        textAlign: "center",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectEvent",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "رویداد",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectEvent",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectEvent",
            "Title",
            [
              {
                id: "K_Modal_ProjectEvent_Title",
                label: "عنوان",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectEvent",
            "EventDescription",
            [
              {
                id: "K_Modal_ProjectEvent_EventDescription",
                label: "شرح رویداد",
                type: "multiline",
                height: "150px",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectEvent",
            "FileLabel",
            [
              {
                id: "K_Modal_ProjectEvent_DueDate",
                label: "موعد انجام",
                type: "date",
                size: 3,
              },
            ],
            10,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////////////////////////////// Tab 5

  ////////////////////////////////////// Section 1

  CreateGrid("content-5-step-1", {
    gridName: "CharterBeneficiary",
    gridDisplayName: "ذینفعان پروژه",
    showEditButton: false,
    showColumns: true,
    showDelteButton: true,
    columns: [
      {
        name: "Type",
        displayName: "نوع",
        type: "combobox",
        options: ["داخلی", "خارجی"],
        disabled: false,
        textAlign: "center",
      },
      {
        name: "Title",
        displayName: "ذینفع",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
      {
        name: "Role",
        displayName: "نقش",
        type: "lookup",
        disabled: false,
        textAlign: "center",
        lookupSite: "/pmo/",
        lookupList: "Base_Role",
        lookupColumn: "Title",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectStakeholders",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////// Section 2

  CreateGrid("content-5-step-2", {
    gridName: "CharterProjectNeeds",
    gridDisplayName: "نیازها و الزامات پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectRequirement",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "نیاز/الزام",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectRequirement",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectRequirement",
            "fazeTitle",
            [
              {
                id: "K_Modal_ProjectRequirement_RequirementTitle",
                label: "نیاز/الزام",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRequirement",
            "Description",
            [
              {
                id: "K_Modal_ProjectRequirement_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRequirement",
            "RelatedStakeholders",
            [
              {
                id: "K_Modal_ProjectRequirement_Stakeholder",
                label: "ذینفع (های) مرتبط",
                type: "multilookup",
                size: 5,
                siteUrl: "/pmo/",
                listName: "ProjectStakeholders",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: `CharterId eq ${ItemID}`,
              },
            ],
            5,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////////////////////////////// Tab 6

  ////////////////////////////////////// Section 1

  CreateGrid("content-6-step-1", {
    gridName: "CharterDomain1",
    gridDisplayName: "پروژه شامل",
    showEditButton: false,
    showColumns: false,
    showDelteButton: true,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    defaultColumns: '[{ "Type": "شامل" }]',
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "Scope",
      query: `<View><Query><Where><And><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq><Eq><FieldRef Name='Type' /><Value Type='Text'>شامل</Value></Eq></And></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  setTimeout(() => {
    CreateGrid("content-6-step-1", {
      gridName: "CharterDomain2",
      gridDisplayName: "پروژه شامل نمی‌شود",
      showEditButton: false,
      showColumns: false,
      showDelteButton: true,
      columns: [
        {
          name: "Title",
          displayName: "عنوان",
          type: "text",
          disabled: false,
          textAlign: "right",
        },
      ],
      defaultColumns: '[{ "Type": "غیر شامل" }]',
      defaultGlobalColumns:
        '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
      ParentList: "Charter",
      dataSource: {
        site: "/pmo/",
        listName: "Scope",
        query: `<View><Query><Where><And><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq><Eq><FieldRef Name='Type' /><Value Type='Text'>غیر شامل</Value></Eq></And></Where></Query></View>`,
      },
      onEdit: (row) => console.log("Editing row:", row),
    });
  }, 10);

  ////////////////////////////////////// Section 2

  CreateGrid("content-6-step-2", {
    gridName: "ProjectDeliverable",
    gridDisplayName: "تحویل شدنی های پروژه",
    showEditButton: true,
    showColumns: true,
    showDelteButton: false,
    columns: [
      {
        name: "RelatedPhase",
        displayName: "فاز",
        type: "lookup",
        disabled: true,
        textAlign: "center",
        lookupSite: "/pmo/",
        lookupList: "ProjectPhase",
        lookupColumn: "Title",
      },
      {
        name: "Title",
        displayName: "تحویل شدنی",
        type: "text",
        disabled: true,
        textAlign: "center",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectDeliverable",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "تحویل شدنی",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectDeliverable",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        async (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "DeliverableTitle",
            [
              {
                id: "K_Modal_ProjectDeliverable_DeliverableTitle",
                label: "تحویل شدنی",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "RelatedPhase",
            [
              {
                id: "K_Modal_ProjectDeliverable_RelatedPhase",
                label: "فاز مرتبط",
                type: "lookup",
                size: 5,
                siteUrl: "/pmo/",
                listName: "ProjectPhase",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: `CharterId eq ${ItemID}`,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "Title",
            [
              {
                id: "K_Modal_ProjectDeliverable_Title",
                label: "عنوان",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "RelatedRequirement",
            [
              {
                id: "K_Modal_ProjectDeliverable_RelatedRequirementLookup",
                label: "نیازها/الزامات مرتبط",
                type: "multilookup",
                size: 5,
                siteUrl: "/pmo/",
                listName: "ProjectRequirement",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: `CharterId eq ${ItemID}`,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "Title",
            [
              {
                id: "K_Modal_ProjectDeliverable_PlanDueDate",
                label: "موعد تحویل",
                type: "date",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "DeliverableTitle2",
            [
              {
                id: "K_Modal_ProjectDeliverable_DeliverableTitle2",
                label: "مجری",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );

          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "Responsible",
            [
              {
                id: "K_Modal_ProjectDeliverable_Responsible",
                label: "مجری",
                type: "radio",
                nullElement: true,
                options: [
                  { label: "شاپرک", value: "شاپرک" },
                  { label: "سازمان بیرونی", value: "سازمان بیرونی" },
                ],
                size: 2,
                onchangefunction: () => {
                  if (
                    GetElement("K_Modal_ProjectDeliverable_Responsible") ==
                    "شاپرک"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ResponsibleGridDiv",
                      {
                        gridName: "Responsible",
                        gridDisplayName: "مجری - شاپرک",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        columns: [
                          {
                            name: "Deputy",
                            displayName: "معاونت",
                            type: "lookup",
                            disabled: true,
                            textAlign: "center",
                            lookupSite: "/pmo/",
                            lookupList: "Deputy",
                            lookupColumn: "Title",
                            backgroundColor: "#8FAADC",
                          },
                          {
                            name: "Management",
                            displayName: "مدیریت",
                            type: "lookup",
                            disabled: true,
                            textAlign: "center",
                            lookupSite: "/pmo/",
                            lookupList: "Management",
                            lookupColumn: "Title",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "Responsible",
                          query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq><Eq><FieldRef Name='Responsible' /><Value Type='Text'>شاپرک</Value></Eq></And></Where></Query></View>`,
                        },
                        onEdit: (row, gridData) => {
                          var rowType_Responsible = "";
                          var rowItemId_Responsible = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_Responsible = "new";
                            rowItemId_Responsible = row.ID;
                          } else {
                            rowType_Responsible = "edit";
                            rowItemId_Responsible = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "مجری - شاپرک",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_Responsible,
                              type: rowType_Responsible,
                              siteUrl: "/pmo",
                              listName: "Responsible",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Responsible": "شاپرک"}]',
                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "MojriTitle",
                                [
                                  {
                                    id: "K_Modal_ProjectDeliverable_MojriTitle",
                                    label: "مجری",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_Responsible_Deputy",
                                    label: "معاونت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Deputy",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    onchangefunction: async () => {
                                      if (
                                        GetElement(
                                          "K_Modal_Responsible_DeputyId"
                                        ) != ""
                                      ) {
                                        setLookupOptions(
                                          "K_Modal_Responsible_ManagementId",
                                          `DeputyId eq ${GetElement(
                                            "K_Modal_Responsible_DeputyId"
                                          )}`
                                        );
                                      }

                                      if (
                                        !rowItemId_Responsible
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ResponsibleItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "Responsible",
                                            rowItemId_Responsible
                                          );
                                        SetElement(
                                          "K_Modal_Responsible_ManagementId",
                                          ResponsibleItem.ManagementId
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_Responsible_Management",
                                    label: "مدیریت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Management",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0"
                                  },
                                ],
                                10,
                                10
                              );
                              debugger
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "ResponsibleUserName",
                                [
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Responsible_UserName",
                                    label: "نماینده",
                                    siteUrl: "/pmo/",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                            }
                          );
                        },
                      }
                    );
                  } else if (
                    GetElement("K_Modal_ProjectDeliverable_Responsible") ==
                    "سازمان بیرونی"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ResponsibleGridDiv",
                      {
                        gridName: "Responsible",
                        gridDisplayName: "مجری - سازمان بیرونی",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        width: "50%",
                        columns: [
                          {
                            name: "Company",
                            displayName: "سازمان",
                            type: "text",
                            disabled: true,
                            textAlign: "center",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "Responsible",
                          query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq><Eq><FieldRef Name='Responsible' /><Value Type='Text'>سازمان بیرونی</Value></Eq></And></Where></Query></View>`,
                        },
                        onEdit: (row, gridData) => {
                          var rowType_Responsible = "";
                          var rowItemId_Responsible = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_Responsible = "new";
                            rowItemId_Responsible = row.ID;
                          } else {
                            rowType_Responsible = "edit";
                            rowItemId_Responsible = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "مجری - سازمان بیرونی",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_Responsible,
                              type: rowType_Responsible,
                              siteUrl: "/pmo",
                              listName: "Responsible",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Responsible": "سازمان بیرونی"}]',

                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "MojriTitle",
                                [
                                  {
                                    id: "K_Modal_Responsible_MojriTitle",
                                    label: "مجری",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "Type",
                                [
                                  {
                                    id: "K_Modal_Responsible_Type",
                                    label: "نوع",
                                    type: "combobox",
                                    inline: true,
                                    size: 5,
                                    options: [
                                      { value: "پیمانکار", label: "پیمانکار" },
                                      { value: "مشاور", label: "مشاور" },
                                      { value: "ناظر", label: "ناظر" },
                                    ],
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "Company",
                                [
                                  {
                                    id: "K_Modal_Responsible_Company",
                                    label: "نام سازمان",
                                    type: "text",
                                    size: 7,
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "UserName",
                                [
                                  {
                                    id: "K_Modal_Responsible_CompanyUser",
                                    label: "نماینده",
                                    type: "userpicker",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "ShaparakNamayande",
                                [
                                  {
                                    id: "K_Modal_ProjectDeliverable_ShaparakNamayande",
                                    label: "نماینده شاپرک",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_Responsible_Deputy",
                                    label: "معاونت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Deputy",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    onchangefunction: async () => {
                                      if (
                                        GetElement(
                                          "K_Modal_Responsible_DeputyId"
                                        ) != ""
                                      ) {
                                        setLookupOptions(
                                          "K_Modal_Responsible_ManagementId",
                                          `DeputyId eq ${GetElement(
                                            "K_Modal_Responsible_DeputyId"
                                          )}`
                                        );
                                      }

                                      if (
                                        !rowItemId_Responsible
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ResponsibleItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "Responsible",
                                            rowItemId_Responsible
                                          );
                                        SetElement(
                                          "K_Modal_Responsible_ManagementId",
                                          ResponsibleItem.ManagementId
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_Responsible_Management",
                                    label: "مدیریت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Management",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0",
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Responsible",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_Responsible_UserName",
                                    label: "نماینده",
                                    size: 5,
                                    siteUrl: "/pmo/",
                                    type: "userpicker",
                                  },
                                ],
                                10,
                                10
                              );
                            }
                          );
                        },
                      }
                    );
                  }
                },
              },
            ],
            5,
            10
          );

          var ResponsibleGridDiv = document.createElement("div");
          ResponsibleGridDiv.id =
            "K_Modal_ProjectDeliverable_ResponsibleGridDiv";
          document
            .getElementById("k-modal-body-/pmo-ProjectDeliverable")
            .appendChild(ResponsibleGridDiv);

          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "DeliverableTitle3",
            [
              {
                id: "K_Modal_ProjectDeliverable_DeliverableTitle3",
                label: "بهره بردار",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "Client",
            [
              {
                id: "K_Modal_ProjectDeliverable_Client",
                label: "مجری",
                type: "radio",
                nullElement: true,
                options: [
                  { label: "شاپرک", value: "شاپرک" },
                  { label: "بانک مرکزی", value: "بانک مرکزی" },
                  { label: "سازمان بیرونی", value: "سازمان بیرونی" },
                ],
                size: 2,
                onchangefunction: () => {
                  if (
                    GetElement("K_Modal_ProjectDeliverable_Client") ==
                    "شاپرک"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ClientGridDiv",
                      {
                        gridName: "Client",
                        gridDisplayName: "بهره بردار - شاپرک",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        columns: [
                          {
                            name: "Deputy",
                            displayName: "معاونت",
                            type: "lookup",
                            disabled: true,
                            textAlign: "center",
                            lookupSite: "/pmo/",
                            lookupList: "Deputy",
                            lookupColumn: "Title",
                            backgroundColor: "#8FAADC",
                          },
                          {
                            name: "Management",
                            displayName: "مدیریت",
                            type: "lookup",
                            disabled: true,
                            textAlign: "center",
                            lookupSite: "/pmo/",
                            lookupList: "Management",
                            lookupColumn: "Title",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "Client",
                          query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq><Eq><FieldRef Name='Client' /><Value Type='Text'>شاپرک</Value></Eq></And></Where></Query></View>`,
                        },
                        onEdit: (row, gridData) => {
                          var rowType_Client = "";
                          var rowItemId_Client = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_Client = "new";
                            rowItemId_Client = row.ID;
                          } else {
                            rowType_Client = "edit";
                            rowItemId_Client = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "بهره بردار - شاپرک",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_Client,
                              type: rowType_Client,
                              siteUrl: "/pmo",
                              listName: "Client",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Client": "شاپرک"}]',
                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientTitle",
                                [
                                  {
                                    id: "K_Modal_Client_ClientTitle",
                                    label: "بهره بردار",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_Client_Deputy",
                                    label: "معاونت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Deputy",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    onchangefunction: async () => {
                                      if (
                                        GetElement(
                                          "K_Modal_Client_DeputyId"
                                        ) != ""
                                      ) {
                                        setLookupOptions(
                                          "K_Modal_Client_ManagementId",
                                          `DeputyId eq ${GetElement(
                                            "K_Modal_Client_DeputyId"
                                          )}`
                                        );
                                      }

                                      if (
                                        !rowItemId_Client
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ClientItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "Client",
                                            rowItemId_Client
                                          );
                                        SetElement(
                                          "K_Modal_Client_ManagementId",
                                          ClientItem.ManagementId
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_Client_Management",
                                    label: "مدیریت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Management",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0"
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientUserName",
                                [
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Client_UserName",
                                    label: "نماینده",
                                    siteUrl: "/pmo/",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                            }
                          );
                        },
                      }
                    );
                  } else if (
                    GetElement("K_Modal_ProjectDeliverable_Client") ==
                    "بانک مرکزی"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ClientGridDiv",
                      {
                        gridName: "Client",
                        gridDisplayName: "بهره بردار - بانک مرکزی",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        columns: [
                          {
                            name: "CBISupervisor",
                            displayName: "ناظر",
                            type: "text",
                            disabled: true,
                            textAlign: "center",
                            backgroundColor: "#8FAADC",
                          },
                          {
                            name: "CBIClient",
                            displayName: "بهره بردار",
                            type: "text",
                            disabled: true,
                            textAlign: "center",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "Client",
                          query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq><Eq><FieldRef Name='Client' /><Value Type='Text'>بانک مرکزی</Value></Eq></And></Where></Query></View>`,
                        },
                        onEdit: (row, gridData) => {
                          var rowType_Client = "";
                          var rowItemId_Client = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_Client = "new";
                            rowItemId_Client = row.ID;
                          } else {
                            rowType_Client = "edit";
                            rowItemId_Client = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "بهره بردار - بانک مرکزی",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_Client,
                              type: rowType_Client,
                              siteUrl: "/pmo",
                              listName: "Client",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Client": "بانک مرکزی"}]',
                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientTitle",
                                [
                                  {
                                    id: "K_Modal_Client_ClientTitle",
                                    label: "ناظر",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "CBISupervisor",
                                [
                                  {
                                    type: "text",
                                    id: "K_Modal_Client_CBISupervisor",
                                    label: "اداره و گروه",
                                    textAlign: "right",
                                    size: 5,
                                  },
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Client_CBISupervisorUser",
                                    label: "نماینده",
                                    siteUrl: "/pmo/",
                                    textAlign: "right",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientTitle",
                                [
                                  {
                                    id: "K_Modal_Client_ClientTitle",
                                    label: "بهره بردار",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "CBIClient",
                                [
                                  {
                                    type: "text",
                                    id: "K_Modal_Client_CBIClient",
                                    label: "اداره و گروه",
                                    textAlign: "right",
                                    size: 5,
                                  },
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Client_CBIClientUser",
                                    label: "نماینده",
                                    siteUrl: "/pmo/",
                                    textAlign: "right",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                            }
                          );
                        },
                      }
                    );
                  } else if (
                    GetElement("K_Modal_ProjectDeliverable_Client") ==
                    "سازمان بیرونی"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ClientGridDiv",
                      {
                        gridName: "Client",
                        gridDisplayName: "بهره بردار - سازمان بیرونی",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        width: "50%",
                        columns: [
                          {
                            name: "OutsideClientName",
                            displayName: "سازمان",
                            type: "text",
                            disabled: true,
                            textAlign: "center",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "Client",
                          query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq><Eq><FieldRef Name='Client' /><Value Type='Text'>سازمان بیرونی</Value></Eq></And></Where></Query></View>`,
                        },
                        onEdit: (row, gridData) => {
                          var rowType_Client = "";
                          var rowItemId_Client = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_Client = "new";
                            rowItemId_Client = row.ID;
                          } else {
                            rowType_Client = "edit";
                            rowItemId_Client = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "بهره بردار - سازمان بیرونی",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_Client,
                              type: rowType_Client,
                              siteUrl: "/pmo",
                              listName: "Client",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Client": "سازمان بیرونی"}]',
                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientTitle",
                                [
                                  {
                                    id: "K_Modal_Client_ClientTitle",
                                    label: "بهره بردار",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "OutsideClientType",
                                [
                                  {
                                    type: "combobox",
                                    id: "K_Modal_Client_OutsideClientType",
                                    label: "نوع",
                                    textAlign: "center",
                                    options: [
                                      { label: "دولتی", value: "دولتی" },
                                      { label: "خصوصی", value: "خصوصی" },
                                    ],
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "OutsideClientType",
                                [
                                  {
                                    type: "text",
                                    id: "K_Modal_Client_OutsideClientName",
                                    label: "نام سازمان",
                                    textAlign: "right",
                                    size: 5,
                                  },
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Client_OutsideClientUser",
                                    label: "نماینده",
                                    textAlign: "right",
                                    siteUrl: "/pmo/",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientTitle",
                                [
                                  {
                                    id: "K_Modal_Client_ClientTitle",
                                    label: "نماینده شاپرک",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_Client_Deputy",
                                    label: "معاونت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Deputy",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    onchangefunction: async () => {
                                      if (
                                        GetElement(
                                          "K_Modal_Client_DeputyId"
                                        ) != ""
                                      ) {
                                        setLookupOptions(
                                          "K_Modal_Client_ManagementId",
                                          `DeputyId eq ${GetElement(
                                            "K_Modal_Client_DeputyId"
                                          )}`
                                        );
                                      }

                                      if (
                                        !rowItemId_Client
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ClientItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "Client",
                                            rowItemId_Client
                                          );
                                        SetElement(
                                          "K_Modal_Client_ManagementId",
                                          ClientItem.ManagementId
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_Client_Management",
                                    label: "مدیریت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Management",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0"
                                  },
                                ],
                                10,
                                10
                              );
                              createInputRow(
                                "k-modal-body-/pmo-Client",
                                "ClientUserName",
                                [
                                  {
                                    type: "userpicker",
                                    id: "K_Modal_Client_UserName",
                                    label: "نماینده",
                                    siteUrl: "/pmo/",
                                    size: 5,
                                  },
                                ],
                                10,
                                10
                              );
                            }
                          );
                        },
                      }
                    );
                  }
                }
              },
            ],
            5,
            10
          );

          var ClientGridDiv = document.createElement("div");
          ClientGridDiv.id =
            "K_Modal_ProjectDeliverable_ClientGridDiv";
          document
            .getElementById("k-modal-body-/pmo-ProjectDeliverable")
            .appendChild(ClientGridDiv);

          createInputRow(
            "k-modal-body-/pmo-ProjectDeliverable",
            "DeliverableTitle4",
            [
              {
                id: "K_Modal_ProjectDeliverable_DeliverableTitle4",
                label: "معیارهای پذیرش",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );

          debugger;
          CreateGrid("k-modal-body-/pmo-ProjectDeliverable", {
            gridName: "ProjectDeliverableAcceptance",
            gridDisplayName: "معیارهای پذیرش",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectDeliverable",
            dataSource: {
              site: "/pmo/",
              listName: "ProjectDeliverableAcceptanceCriteria",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectDeliverable' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });
        }
      );
    },
  });

  ////////////////////////////////////// Section 3

  CreateGrid("content-6-step-3", {
    gridName: "CharterProjectNeededResources",
    gridDisplayName: "منابع مورد نیاز پروژه",
    showEditButton: true,
    showColumns: true,
    showDelteButton: false,
    columns: [
      {
        name: "Type",
        displayName: "نوع",
        type: "text",
        disabled: true,
        textAlign: "center",
      },
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectResourceForm",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "منبع",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectResourceForm",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectResourceForm",
            "ResourceTitle",
            [
              {
                id: "K_Modal_ProjectResourceForm_ResourceTitle",
                label: "منبع",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectResourceForm",
            "ResourceType",
            [
              {
                id: "K_Modal_ProjectResourceForm_Type",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "سخت افزار", value: "سخت افزار" },
                  { label: "نرم افزار", value: "نرم افزار" },
                  { label: "لایسنس", value: "لایسنس" },
                  { label: "ابزار/تجهیز", value: "ابزار/تجهیز" },
                  {
                    label: "ساختمان/فضای فیزیکی",
                    value: "ساختمان/فضای فیزیکی",
                  },
                  { label: "قطعات یدکی", value: "قطعات یدکی" },
                  { label: "ماشین آلات", value: "ماشین آلات" },
                  { label: "خدمات", value: "خدمات" },
                  { label: "نیروی انسانی", value: "نیروی انسانی" },
                  {
                    label: "اشتراک آنلاین/آفلاین",
                    value: "اشتراک آنلاین/آفلاین",
                  },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectResourceForm",
            "ResourceTitle",
            [
              {
                id: "K_Modal_ProjectResourceForm_Title",
                label: "عنوان",
                type: "text",
                size: 10,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectResourceForm",
            "Description",
            [
              {
                id: "K_Modal_ProjectResourceForm_Description",
                label: "توضیحات",
                type: "multiline",
                height: "150px",
                size: 5,
              },
            ],
            5,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////// Section 4

  CreateGrid("content-6-step-4", {
    gridName: "ProjectClosureAcceptanceCriteria",
    gridDisplayName: "معیارهای پذیرش خاتمه پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Description",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectClosureAcceptanceCriteria",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "معیار",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectClosureAcceptanceCriteria",
          defaultColumns: '[{ "CharterId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectClosureAcceptanceCriteria",
            "ProjectClosureAcceptanceCriteriaTitle",
            [
              {
                id: "K_Modal_ProjectClosureAcceptanceCriteria_ResourceTitle",
                label: "معیار",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectClosureAcceptanceCriteria",
            "ProjectClosureAcceptanceCriteriaDescription",
            [
              {
                id: "K_Modal_ProjectClosureAcceptanceCriteria_Description",
                label: "شرح",
                type: "texy",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectClosureAcceptanceCriteria",
            "ProjectClosureAcceptanceCriteriaTitle2",
            [
              {
                id: "K_Modal_ProjectResourceForm_ProjectClosureAcceptanceCriteriaTitle2",
                label: "تایید کننده (گان)",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          CreateGrid(
            "k-modal-body-/pmo-ProjectClosureAcceptanceCriteria",
            {
              gridName: "ProjectClosureAcceptanceCriteriaClosureAssociate",
              gridDisplayName: "تایید کننده (گان)",
              showEditButton: false,
              showColumns: true,
              showDelteButton: true,
              showGridDisplayName: false,
              columns: [
                {
                  name: "Deputy",
                  displayName: "معاونت",
                  type: "lookup",
                  disabled: false,
                  textAlign: "center",
                  lookupSite: "/pmo/",
                  lookupList: "Deputy",
                  lookupColumn: "Title",
                  backgroundColor: "#8FAADC",
                  onchangefunction: async (event) => {
                    debugger;
                    if (event.target.value != "") {
                      await setRowLookupOptions(
                        event.target,
                        "Management",
                        `DeputyId eq ${event.target.value}`
                      );
                    }
                    var ClosureAssociateItem = await getItemFromList(
                      "/pmo/",
                      "ClosureAssociate",
                      parseInt(
                        event.target.id.split("_")[
                          event.target.id.split("_").length - 1
                        ]
                      )
                    );
                    setRowInputValue(
                      event.target,
                      "Management",
                      ClosureAssociateItem.ManagementId
                    );
                  },
                },
                {
                  name: "Management",
                  displayName: "مدیریت",
                  type: "lookup",
                  disabled: false,
                  textAlign: "center",
                  lookupSite: "/pmo/",
                  lookupList: "Management",
                  lookupColumn: "Title",
                  backgroundColor: "#8FAADC",
                  filter: `Id eq 0`,
                },
                {
                  name: "Responsible",
                  displayName: "مسئول",
                  type: "text",
                  disabled: false,
                  textAlign: "center",
                  backgroundColor: "#8FAADC",
                },
              ],
              ParentList: "ProjectClosureAcceptanceCriteria",
              dataSource: {
                site: "/pmo/",
                listName: "ClosureAssociate",
                query: `<View><Query><Where><Eq><FieldRef Name='ProjectClosureAcceptanceCriteria' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
              },
              onEdit: (row) => console.log("Editing row:", row),
            }
          );
        }
      );
    },
  });

  ////////////////////////////////////////////////////////////// Tab 7

  ////////////////////////////////////// Section 1

  CreateGrid("content-7-step-1", {
    gridName: "ProjectTeam",
    gridDisplayName: "تیم پروژه",
    showEditButton: false,
    showColumns: true,
    showDelteButton: true,
    columns: [
      {
        name: "NameFamilyName",
        displayName: "نام و نام خانوادگی",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
      {
        name: "Deputy",
        displayName: "معانت",
        type: "lookup",
        disabled: false,
        textAlign: "center",
        lookupSite: "/pmo/",
        lookupList: "Deputy",
        lookupColumn: "Title",
        onchangefunction: async (event) => {
          debugger;
          if (event.target.value != "") {
            await setRowLookupOptions(
              event.target,
              "Management",
              `DeputyId eq ${event.target.value}`
            );
          }
          if (
            event.target.id.split("_")[event.target.id.split("_").length - 1] !=
            "NewItem"
          ) {
            var ProjectTeamItem = await getItemFromList(
              "/pmo/",
              "ProjectTeam",
              parseInt(
                event.target.id.split("_")[
                  event.target.id.split("_").length - 1
                ]
              )
            );
            if (ProjectTeamItem != undefined) {
              setRowInputValue(
                event.target,
                "Management",
                ProjectTeamItem.ManagementId
              );
            }
          }
        },
      },
      {
        name: "Management",
        displayName: "مدیریت",
        type: "lookup",
        disabled: false,
        textAlign: "center",
        lookupSite: "/pmo/",
        lookupList: "Management",
        lookupColumn: "Title",
        filter: `Id eq 0`,
      },

      {
        name: "RoleType",
        displayName: "نوع نقش",
        type: "combobox",
        disabled: false,
        textAlign: "center",
        options: ["مدیریتی", "اجرایی"],
        onchangefunction: async (event) => {
          if (event.target.value == "اجرایی") {
            setRowComboboxOptions(event.target, "Role", [
              "طراح کسب و کار",
              "تحلیلگر",
              "مستندساز",
              "برنامه نویس",
              "آزمونگر",
              "متخصص انتقال داده",
              "کاربر",
              "متخصص زیرساخت و شبکه",
              "متخصص امنیت",
              "متخصص ریسک",
              "متخصص عملیات",
              "متخصص محتوا",
              "گرافیست",
              "متخصص تدارکات",
              "متخصص مالی",
              "متخصص منابع انسانی",
            ]);
          } else if (event.target.value == "مدیریتی") {
            setRowComboboxOptions(event.target, "Role", [
              "راهبر",
              "مدیر پروژه",
              "مشاور",
              "کنترل پروژه",
              "هماهنگ کننده",
            ]);
          }
          if (
            event.target.id.split("_")[event.target.id.split("_").length - 1] !=
            "NewItem"
          ) {
            var ProjectTeamItem = await getItemFromList(
              "/pmo/",
              "ProjectTeam",
              parseInt(
                event.target.id.split("_")[
                  event.target.id.split("_").length - 1
                ]
              )
            );
            if (ProjectTeamItem != undefined) {
              setRowInputValue(event.target, "Role", ProjectTeamItem.Role);
            }
          }
        },
      },
      {
        name: "Role",
        displayName: "نقش",
        type: "combobox",
        disabled: false,
        textAlign: "center",
        options: [],
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectTeam",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////// Section 2

  CreateGrid("content-7-step-2", {
    gridName: "ProjectTraining",
    gridDisplayName: "آموزش های مورد نیاز",
    showEditButton: false,
    showColumns: true,
    showDelteButton: true,
    columns: [
      {
        name: "Usage",
        displayName: "کاربرد",
        type: "combobox",
        disabled: false,
        textAlign: "center",
        options: [
          "اجرای پروژه (تیم اجرایی)",
          "استفاده از محصول نهایی (کاربران)",
        ],
      },
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectTraining",
      query: `<View><Query><Where><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq></Where></Query></View>`,
    },
    onEdit: (row) => console.log("Editing row:", row),
  });

  ////////////////////////////////////////////////////////////// Tab 8

  ////////////////////////////////////// Section 1

  CreateGrid("content-8-step-1", {
    gridName: "CharterProjectDuringExecutionRisks",
    gridDisplayName: "ریسک‌های حین اجرای پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    defaultColumns: '[{ "Level": "ریسک های حین اجرای پروژه" }]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectRisk",
      query: `<View><Query><Where><And><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq><Eq><FieldRef Name='Level' /><Value Type='Text'>ریسک های حین اجرای پروژه</Value></Eq></And></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "منبع",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectRisk",
          defaultColumns:
            '[{ "CharterId": "' +
            ItemID +
            '"}, { "Level": "ریسک های حین اجرای پروژه" }]',
          savedefaultColumns: false,
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "RiskTitle",
            [
              {
                id: "K_Modal_ProjectRisk_RiskTitle",
                label: "ریسک",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Title",
            [
              {
                id: "K_Modal_ProjectRisk_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Level",
            [
              {
                id: "K_Modal_ProjectRisk_Level",
                label: "طبقه",
                type: "combobox",
                options: [
                  {
                    value: "ریسک های حین اجرای پروژه",
                    label: "ریسک های حین اجرای پروژه",
                  },
                  {
                    value: "ریسک های عدم اجرای پروژه",
                    label: "ریسک های عدم اجرای پروژه",
                  },
                  {
                    value: "ریسک های پس از اجرای پروژه",
                    label: "ریسک های پس از اجرای پروژه",
                  },
                ],
                disabled: true,
                size: 5,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Type",
            [
              {
                id: "K_Modal_ProjectRisk_Type",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "مثبت", value: "مثبت" },
                  { label: "منفی", value: "منفی" },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Category",
            [
              {
                id: "K_Modal_ProjectRisk_Category",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "قانونی و نظارتی", value: "قانونی و نظارتی" },
                  { label: "راهبردی و ذینفعان", value: "راهبردی و ذینفعان" },
                  { label: "فناوری و عملیاتی", value: "فناوری و عملیاتی" },
                  { label: "مالی", value: "مالی" },
                  { label: "امنیتی و حفاظتی", value: "امنیتی و حفاظتی" },
                  { label: "شهرت و اعتبار", value: "شهرت و اعتبار" },
                  { label: "فرآیندی", value: "فرآیندی" },
                  { label: "زمانبندی", value: "زمانبندی" },
                  {
                    label:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                    value:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                  },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid1Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "پیامدها",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var ConsequencesGridDiv = document.createElement("div");
          ConsequencesGridDiv.id = "K_Modal_ProjectRisk_ConsequencesGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(ConsequencesGridDiv);

          CreateGrid("K_Modal_ProjectRisk_ConsequencesGridDiv", {
            gridName: "RiskConsequences",
            gridDisplayName: "پیامدها",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskConsequences",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });

          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid2Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "اقدامات پیشنهادی (واکنش به ریسک)",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var SuggestedActionsGridDiv = document.createElement("div");
          SuggestedActionsGridDiv.id =
            "K_Modal_ProjectRisk_SuggestedActionsGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(SuggestedActionsGridDiv);

          CreateGrid("K_Modal_ProjectRisk_SuggestedActionsGridDiv", {
            gridName: "RiskSuggestedActions",
            gridDisplayName: "اقدامات پیشنهادی (واکنش به ریسک)",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskSuggestedActions",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Time",
            [
              {
                id: "K_Modal_ProjectRisk_MonitoringValue",
                label: "دوره پایش",
                type: "number",
                size: 3,
                inline: true,
              },
              {
                id: "K_Modal_ProjectRisk_MonitoringPeriod",
                label: "",
                labelVisible: false,
                inline: true,
                type: "combobox",
                options: [
                  { label: "ماه", value: "ماه" },
                  { label: "فصل", value: "فصل" },
                  { label: "سال", value: "سال" },
                ],
                size: 4,
              },
              {
                id: "K_Modal_ProjectRisk_PeriodUnitLabel",
                labelVisible: false,
                backgroundColor: "transparent",
                labelText: "ماه، فصل، سال",
                type: "label",
                size: 3,
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_UserTitle",
                label: "مسئول",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "DeputyManagement",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsibleDeputy",
                label: "معاونت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Deputy",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                onchangefunction: async () => {
                  if (GetElement("K_Modal_ProjectRisk_ResponsibleDeputyId") != "") {
                    setLookupOptions(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      `DeputyId eq ${GetElement(
                        "K_Modal_ProjectRisk_ResponsibleDeputyId"
                      )}`
                    );
                  }

                  if (!rowItemId.toString().includes("NewItem")) {
                    var ProjectRiskItem = await getItemFromList(
                      "/pmo/",
                      "ProjectRisk",
                      rowItemId
                    );
                    SetElement(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      ProjectRiskItem.ResponsibleManagementId
                    );
                  }
                },
              },
              {
                id: "K_Modal_ProjectRisk_ResponsibleManagement",
                label: "مدیریت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Management",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: "Id eq 0",
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "UserInfo",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsiblePerson",
                label: "مسئول",
                type: "userpicker",
                siteUrl: "/pmo/",
                size: 5,
                textAlign: "right",
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_AnalysisTitle",
                label: "تحلیل",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_OccurrenceProbability",
                label: "احتمال وقوع",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
              {
                id: "K_Modal_ProjectRisk_NullElement1",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_IntensityEffect",
                label: "شدت اثر",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
            ],
            12,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_RiskScore",
                label: "امتیاز ریسک",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_NullElement2",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_RiskPriority",
                label: "شدت اثر",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
            ],
            12,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////// Section 2

  CreateGrid("content-8-step-2", {
    gridName: "CharterProjectUnExecutionRisks",
    gridDisplayName: "ریسک‌های عدم اجرای پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Charter",
    defaultColumns: '[{ "Level": "ریسک های عدم اجرای پروژه" }]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectRisk",
      query: `<View><Query><Where><And><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq><Eq><FieldRef Name='Level' /><Value Type='Text'>ریسک های عدم اجرای پروژه</Value></Eq></And></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "منبع",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectRisk",
          defaultColumns:
            '[{ "CharterId": "' +
            ItemID +
            '"}, { "Level": "ریسک های عدم اجرای پروژه" }]',
          savedefaultColumns: false,
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "RiskTitle",
            [
              {
                id: "K_Modal_ProjectRisk_RiskTitle",
                label: "ریسک",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Title",
            [
              {
                id: "K_Modal_ProjectRisk_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Level",
            [
              {
                id: "K_Modal_ProjectRisk_Level",
                label: "طبقه",
                type: "combobox",
                options: [
                  {
                    value: "ریسک های حین اجرای پروژه",
                    label: "ریسک های حین اجرای پروژه",
                  },
                  {
                    value: "ریسک های عدم اجرای پروژه",
                    label: "ریسک های عدم اجرای پروژه",
                  },
                  {
                    value: "ریسک های پس از اجرای پروژه",
                    label: "ریسک های پس از اجرای پروژه",
                  },
                ],
                disabled: true,
                size: 5,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Type",
            [
              {
                id: "K_Modal_ProjectRisk_Type",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "مثبت", value: "مثبت" },
                  { label: "منفی", value: "منفی" },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Category",
            [
              {
                id: "K_Modal_ProjectRisk_Category",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "قانونی و نظارتی", value: "قانونی و نظارتی" },
                  { label: "راهبردی و ذینفعان", value: "راهبردی و ذینفعان" },
                  { label: "فناوری و عملیاتی", value: "فناوری و عملیاتی" },
                  { label: "مالی", value: "مالی" },
                  { label: "امنیتی و حفاظتی", value: "امنیتی و حفاظتی" },
                  { label: "شهرت و اعتبار", value: "شهرت و اعتبار" },
                  { label: "فرآیندی", value: "فرآیندی" },
                  { label: "زمانبندی", value: "زمانبندی" },
                  {
                    label:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                    value:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                  },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid1Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "پیامدها",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var ConsequencesGridDiv = document.createElement("div");
          ConsequencesGridDiv.id = "K_Modal_ProjectRisk_ConsequencesGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(ConsequencesGridDiv);

          CreateGrid("K_Modal_ProjectRisk_ConsequencesGridDiv", {
            gridName: "RiskConsequences",
            gridDisplayName: "پیامدها",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskConsequences",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });

          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid2Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "اقدامات پیشنهادی (واکنش به ریسک)",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var SuggestedActionsGridDiv = document.createElement("div");
          SuggestedActionsGridDiv.id =
            "K_Modal_ProjectRisk_SuggestedActionsGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(SuggestedActionsGridDiv);

          CreateGrid("K_Modal_ProjectRisk_SuggestedActionsGridDiv", {
            gridName: "RiskSuggestedActions",
            gridDisplayName: "اقدامات پیشنهادی (واکنش به ریسک)",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskSuggestedActions",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Time",
            [
              {
                id: "K_Modal_ProjectRisk_MonitoringValue",
                label: "دوره پایش",
                type: "number",
                size: 3,
                inline: true,
              },
              {
                id: "K_Modal_ProjectRisk_MonitoringPeriod",
                label: "",
                labelVisible: false,
                inline: true,
                type: "combobox",
                options: [
                  { label: "ماه", value: "ماه" },
                  { label: "فصل", value: "فصل" },
                  { label: "سال", value: "سال" },
                ],
                size: 4,
              },
              {
                id: "K_Modal_ProjectRisk_PeriodUnitLabel",
                labelVisible: false,
                backgroundColor: "transparent",
                labelText: "ماه، فصل، سال",
                type: "label",
                size: 3,
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_UserTitle",
                label: "مسئول",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "DeputyManagement",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsibleDeputy",
                label: "معاونت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Deputy",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                onchangefunction: async () => {
                  if (GetElement("K_Modal_ProjectRisk_ResponsibleDeputyId") != "") {
                    setLookupOptions(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      `DeputyId eq ${GetElement(
                        "K_Modal_ProjectRisk_ResponsibleDeputyId"
                      )}`
                    );
                  }

                  if (!rowItemId.toString().includes("NewItem")) {
                    var ProjectRiskItem = await getItemFromList(
                      "/pmo/",
                      "ProjectRisk",
                      rowItemId
                    );
                    SetElement(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      ProjectRiskItem.ResponsibleManagementId
                    );
                  }
                },
              },
              {
                id: "K_Modal_ProjectRisk_ResponsibleManagement",
                label: "مدیریت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Management",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: "Id eq 0",
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "UserInfo",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsiblePerson",
                label: "مسئول",
                type: "userpicker",
                siteUrl: "/pmo/",
                size: 5,
                textAlign: "right",
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_AnalysisTitle",
                label: "تحلیل",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_OccurrenceProbability",
                label: "احتمال وقوع",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
              {
                id: "K_Modal_ProjectRisk_NullElement1",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_IntensityEffect",
                label: "شدت اثر",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
            ],
            12,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_RiskScore",
                label: "امتیاز ریسک",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_NullElement2",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_RiskPriority",
                label: "شدت اثر",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
            ],
            12,
            10
          );
        }
      );
    },
  });

  ////////////////////////////////////// Section 3

  CreateGrid("content-8-step-3", {
    gridName: "CharterProjectAfterExecutionRisks",
    gridDisplayName: "ریسک‌های پس از اجرای پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    defaultColumns: '[{ "Level": "ریسک های پس از اجرای پروژه" }]',
    ParentList: "Charter",
    dataSource: {
      site: "/pmo/",
      listName: "ProjectRisk",
      query: `<View><Query><Where><And><Eq><FieldRef Name='Charter' LookupId='TRUE' /><Value Type='Lookup'>${ItemID}</Value></Eq><Eq><FieldRef Name='Level' /><Value Type='Text'>ریسک های پس از اجرای پروژه</Value></Eq></And></Where></Query></View>`,
    },
    onEdit: (row, gridData) => {
      var rowType = "";
      var rowItemId = "";
      if (row.ID.toString().includes("NewItem")) {
        rowType = "new";
        rowItemId = row.ID;
      } else {
        rowType = "edit";
        rowItemId = row.ID;
      }
      ShowKModal(
        {
          title: "منبع",
          width: 800,
          height: 600,
          backgroundColor: "#DFE7F5",
          headerColor: "#195A65",
          id: rowItemId,
          type: rowType,
          siteUrl: "/pmo",
          listName: "ProjectRisk",
          defaultColumns:
            '[{ "CharterId": "' +
            ItemID +
            '"}, { "Level": "ریسک های پس از اجرای پروژه" }]',
          savedefaultColumns: false,
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "RiskTitle",
            [
              {
                id: "K_Modal_ProjectRisk_RiskTitle",
                label: "ریسک",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Title",
            [
              {
                id: "K_Modal_ProjectRisk_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Level",
            [
              {
                id: "K_Modal_ProjectRisk_Level",
                label: "طبقه",
                type: "combobox",
                options: [
                  {
                    value: "ریسک های حین اجرای پروژه",
                    label: "ریسک های حین اجرای پروژه",
                  },
                  {
                    value: "ریسک های عدم اجرای پروژه",
                    label: "ریسک های عدم اجرای پروژه",
                  },
                  {
                    value: "ریسک های پس از اجرای پروژه",
                    label: "ریسک های پس از اجرای پروژه",
                  },
                ],
                disabled: true,
                size: 5,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Type",
            [
              {
                id: "K_Modal_ProjectRisk_Type",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "مثبت", value: "مثبت" },
                  { label: "منفی", value: "منفی" },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "K_Modal_ProjectRisk_Category",
            [
              {
                id: "K_Modal_ProjectRisk_Category",
                label: "نوع",
                type: "radio",
                options: [
                  { label: "قانونی و نظارتی", value: "قانونی و نظارتی" },
                  { label: "راهبردی و ذینفعان", value: "راهبردی و ذینفعان" },
                  { label: "فناوری و عملیاتی", value: "فناوری و عملیاتی" },
                  { label: "مالی", value: "مالی" },
                  { label: "امنیتی و حفاظتی", value: "امنیتی و حفاظتی" },
                  { label: "شهرت و اعتبار", value: "شهرت و اعتبار" },
                  { label: "فرآیندی", value: "فرآیندی" },
                  { label: "زمانبندی", value: "زمانبندی" },
                  {
                    label:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                    value:
                      "خزش محدوده (توسعه و افزایش کنترل نشده محدوده پروژه)",
                  },
                ],
                size: 5,
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid1Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "پیامدها",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var ConsequencesGridDiv = document.createElement("div");
          ConsequencesGridDiv.id = "K_Modal_ProjectRisk_ConsequencesGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(ConsequencesGridDiv);

          CreateGrid("K_Modal_ProjectRisk_ConsequencesGridDiv", {
            gridName: "RiskConsequences",
            gridDisplayName: "پیامدها",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskConsequences",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });

          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Grid2Title",
            [
              {
                id: "K_Modal_ProjectRisk_Grid1Title",
                label: "اقدامات پیشنهادی (واکنش به ریسک)",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          var SuggestedActionsGridDiv = document.createElement("div");
          SuggestedActionsGridDiv.id =
            "K_Modal_ProjectRisk_SuggestedActionsGridDiv";

          document
            .getElementById("k-modal-body-/pmo-ProjectRisk")
            .appendChild(SuggestedActionsGridDiv);

          CreateGrid("K_Modal_ProjectRisk_SuggestedActionsGridDiv", {
            gridName: "RiskSuggestedActions",
            gridDisplayName: "اقدامات پیشنهادی (واکنش به ریسک)",
            showEditButton: false,
            showColumns: false,
            showDelteButton: true,
            showGridDisplayName: false,
            columns: [
              {
                name: "Title",
                displayName: "عنوان",
                type: "text",
                disabled: false,
                textAlign: "right",
              },
            ],
            ParentList: "ProjectRisk",
            dataSource: {
              site: "/pmo/",
              listName: "RiskSuggestedActions",
              query: `<View><Query><Where><Eq><FieldRef Name='ProjectRisk' LookupId='TRUE' /><Value Type='Lookup'>${rowItemId}</Value></Eq></Where></Query></View>`,
            },
            onEdit: (row) => console.log("Editing row:", row),
          });
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "Time",
            [
              {
                id: "K_Modal_ProjectRisk_MonitoringValue",
                label: "دوره پایش",
                type: "number",
                size: 3,
                inline: true,
              },
              {
                id: "K_Modal_ProjectRisk_MonitoringPeriod",
                label: "",
                labelVisible: false,
                inline: true,
                type: "combobox",
                options: [
                  { label: "ماه", value: "ماه" },
                  { label: "فصل", value: "فصل" },
                  { label: "سال", value: "سال" },
                ],
                size: 4,
              },
              {
                id: "K_Modal_ProjectRisk_PeriodUnitLabel",
                labelVisible: false,
                backgroundColor: "transparent",
                labelText: "ماه، فصل، سال",
                type: "label",
                size: 3,
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_UserTitle",
                label: "مسئول",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "DeputyManagement",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsibleDeputy",
                label: "معاونت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Deputy",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                onchangefunction: async () => {
                  if (GetElement("K_Modal_ProjectRisk_ResponsibleDeputyId") != "") {
                    setLookupOptions(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      `DeputyId eq ${GetElement(
                        "K_Modal_ProjectRisk_ResponsibleDeputyId"
                      )}`
                    );
                  }

                  if (!rowItemId.toString().includes("NewItem")) {
                    var ProjectRiskItem = await getItemFromList(
                      "/pmo/",
                      "ProjectRisk",
                      rowItemId
                    );
                    SetElement(
                      "K_Modal_ProjectRisk_ResponsibleManagementId",
                      ProjectRiskItem.ResponsibleManagementId
                    );
                  }
                },
              },
              {
                id: "K_Modal_ProjectRisk_ResponsibleManagement",
                label: "مدیریت",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Management",
                valueField: "Id",
                textField: "Title",
                saveId: true,
                filter: "Id eq 0",
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "UserInfo",
            [
              {
                id: "K_Modal_ProjectRisk_ResponsiblePerson",
                label: "مسئول",
                type: "userpicker",
                siteUrl: "/pmo/",
                size: 5,
                textAlign: "right",
                inline: true,
              },
            ],
            10,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "User",
            [
              {
                id: "K_Modal_ProjectRisk_AnalysisTitle",
                label: "تحلیل",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_OccurrenceProbability",
                label: "احتمال وقوع",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
              {
                id: "K_Modal_ProjectRisk_NullElement1",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_IntensityEffect",
                label: "شدت اثر",
                type: "combobox",
                options: [
                  { label: "خیلی کم", value: "خیلی کم" },
                  { label: "کم", value: "کم" },
                  { label: "متوسط", value: "متوسط" },
                  { label: "زیاد", value: "زیاد" },
                  { label: "خیلی زیاد", value: "خیلی زیاد" },
                ],
                size: 4,
                textAlign: "center",
              },
            ],
            12,
            10
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectRisk",
            "AnalysisCombobox",
            [
              {
                id: "K_Modal_ProjectRisk_RiskScore",
                label: "امتیاز ریسک",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_NullElement2",
                label: " ",
                nullElement: true,
                type: "label",
                size: 3,
                textAlign: "center",
                disabled: true,
              },
              {
                id: "K_Modal_ProjectRisk_RiskPriority",
                label: "شدت اثر",
                type: "number",
                size: 4,
                textAlign: "center",
                disabled: true,
              },
            ],
            12,
            10
          );
        }
      );
    },
  });
  ////////////////////////////////////////////////////////////////////

  await loadSharePointItem("/pmo/", "Charter");

  SetElement(
    "K_CostEstimationSum",
    parseFloat(normalizeNumber(GetElement("K_CostEstimationEquipment"))) +
      parseFloat(normalizeNumber(GetElement("K_CostEstimationSoftware"))) +
      parseFloat(normalizeNumber(GetElement("K_CostEstimationContractor"))) +
      parseFloat(normalizeNumber(GetElement("K_CostEstimationInvestment"))) +
      parseFloat(normalizeNumber(GetElement("K_CostEstimationOther")))
  );

  // Jalali activation
  jalaliDatepicker.startWatch();

  // Workflow
  if(ItemID != "NewItem") {
    CreateStatusBar("/pmo/", "Charter", ItemID, [
      {
        Title: "مدیر پروژه",
      }, 
      {
        Title: "مدیر",
      }, 
      {
        Title: "معاون",
      }, 
      {
        Title: "واحدهای همکار",
      }, 
      {
        Title: "فرآیندها و پروژه ها",
      }, 
      {
        Title: "راهبرد و نوآوری",
      }, 
      {
        Title: "مدیر عامل",
      }
    ], ()=>{console.log("Hello")})
  }
}

main();