const style = document.createElement("style");
style.id = "kform-change-style";
style.textContent = `

  `;

async function main() {
  const params = new URLSearchParams(window.location.search);
  const ItemID = params.get("ItemID");
  var ProjectID = "";
  var ProjectDeputy = "";
  var ProjectManagement = "";
  if (ItemID != "NewItem") {
    var Change = await getItemFromList("/pmo/", "Change", ItemID);
    ProjectID = Change.ProjectNameId;
    ProjectDeputy = Change.DeputyId;
    ProjectManagement = Change.ManagementId;
    SetGlobalVariable([
      ["ProjectID", ProjectID],
      ["ProjectDeputy", ProjectDeputy],
      ["ProjectManagement", ProjectManagement],
    ]);
  }

  SetGlobalVariable([
    ["SiteUrl", "/pmo"],
    ["ListName", "Change"],
  ]);

  createFormUI({
    container: "Form",
    sidebar: [
      {
        label: "شرح تغییر",
        icon: "/pmo/KForm/Images/Picture1.png",
      },
      {
        label: "تغییر اساسی",
        icon: "/pmo/KForm/Images/Picture2.png",
        children: [
          { 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",
      },
    ],
    steps: {
      1: ["پروژه", "منشاء", "اسناد", "حوزه", "شرح"],
      3: ["هزینه"],
      4: ["فازها", "رویدادها", "برنامه زمانبندی"],
      5: ["ذینفعان", "نیازمندی ها"],
      6: ["اهداف", "دامنه", "تحویل شدنی ها", "منابع", "معیارهای پذیرش خاتمه"],
      7: ["مشخصات", "وضعیت", "ترکیب"],
    },
  });

  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 = 0;
  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/", "Change");
  });
  document.getElementsByClassName("content-area")[0].appendChild(save_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",
    "Deputy&Management",
    [
      {
        id: "K_Deputy",
        label: "معاونت",
        size: 4,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "Deputy",
        valueField: "Id",
        textField: "Title",
        saveId: true,
        onchangefunction: async () => {
          if (GetElement("K_DeputyId") != "") {
            setLookupOptions(
              "K_ManagementId",
              `DeputyId eq ${GetElement("K_DeputyId")}`,
            );
          }
          ProjectID = document.getElementById("K_ProjectNameId").value;
          ProjectDeputy = document.getElementById("K_DeputyId").value;
          ProjectManagement = document.getElementById("K_ManagementId").value;

          SetGlobalVariable([
            ["ProjectID", ProjectID],
            ["ProjectDeputy", ProjectDeputy],
            ["ProjectManagement", ProjectManagement],
          ]);
        },
      },
      {
        id: "Management&DeputyLabel",
        type: "label",
        nullElement: true,
        labelVisible: false,
        size: 2,
      },
      {
        id: "K_Management",
        label: "مدیریت",
        size: 4,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "Management",
        valueField: "Id",
        textField: "Title",
        saveId: true,
        filter: "Id eq 0",
        onchangefunction: async () => {
          if (
            GetElement("K_DeputyId") != "" &&
            GetElement("K_ManagementId") != ""
          )
            setLookupOptions(
              "K_ProjectNameId",
              `DeputyId eq ${GetElement(
                "K_DeputyId",
              )} and ManagementId eq ${GetElement("K_ManagementId")}`,
            );
          ProjectID = document.getElementById("K_ProjectNameId").value;
          ProjectDeputy = document.getElementById("K_DeputyId").value;
          ProjectManagement = document.getElementById("K_ManagementId").value;

          SetGlobalVariable([
            ["ProjectID", ProjectID],
            ["ProjectDeputy", ProjectDeputy],
            ["ProjectManagement", ProjectManagement],
          ]);
        },
      },
    ],
    10,
    10,
  );
  createInputRow(
    "content-1-step-1",
    "Project",
    [
      {
        id: "K_ProjectName",
        label: "پروژه",
        size: 5,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "ProjectSetting",
        valueField: "Id",
        textField: "Title",
        saveId: true,
        filter: "Id eq 0",
        onchangefunction: () => {
          ProjectID = document.getElementById("K_ProjectNameId").value;
          ProjectDeputy = document.getElementById("K_DeputyId").value;
          ProjectManagement = document.getElementById("K_ManagementId").value;

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

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

  createInputRow(
    "content-1-step-2",
    "ChangeOrigin",
    [
      {
        id: "K_ChangeOrigin",
        label: "منشاء تغییر",
        type: "radio",
        options: [
          { label: "داخلی", value: "داخلی" },
          { label: "خارجی", value: "خارجی" },
        ],
        size: 1,
        onchangefunction: () => {
          setLookupOptions(
            "K_ChangeOriginDetailId",
            `ChangeOrigin eq '${GetElement("K_ChangeOrigin")}'`,
          );
        },
      },
    ],
    5,
    10,
  );
  createInputRow(
    "content-1-step-2",
    "ChangeOriginDetail",
    [
      {
        id: "K_ChangeOriginDetail",
        label: "ChangeOriginDetail",
        labelVisible: false,
        size: 5,
        type: "lookup",
        siteUrl: "/pmo/",
        listName: "ChangeOriginDetails",
        valueField: "Id",
        textField: "Title",
        saveId: false,
        filter: "Id eq 0",
      },
    ],
    5,
    10,
  );

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

  CreateGrid("content-1-step-3", {
    gridName: "ChangeDocumentsList",
    gridDisplayName: "اسناد تغییر",
    showEditButton: true,
    showColumns: false,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Change",
    dataSource: {
      site: "/pmo/",
      listName: "ChangeDocumentsList",
      query: `<View><Query><Where><Eq><FieldRef Name='Change' 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: "ChangeDocumentsList",
          defaultColumns: '[{ "ChangeId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ChangeDocumentsList",
            "Title",
            [
              {
                id: "K_Modal_ChangeDocumentsList_Title",
                label: "عنوان",
                type: "text",
                inline: true,
                size: 5,
              },
            ],
            5,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-ChangeDocumentsList",
            "FileLabel",
            [
              {
                id: "K_FileLabel",
                label: "اسناد",
                type: "label",
                labelText: "اسناد",
                nullElement: true,
                size: 1,
              },
            ],
            4,
            10,
          );
          createUploader(
            "k-modal-body-/pmo-ChangeDocumentsList",
            "/pmo",
            {
              listTitle: "ChangeDocuments",
              folderUrl: "pmo/ChangeDocuments",
            },
            { ChangeDocumentsList: rowItemId },
            `<Eq><<FieldRef Name="ChangeDocumentsList" LookupId="TRUE" /><Value Type="Integer">${rowItemId}</Value></Eq>`,
          );
        },
      );
    },
  });

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

  createInputRow(
    "content-1-step-4",
    "ChangeDomain",
    [
      {
        id: "K_ChangeDomainFundamental",
        label: "تغییرات اساسی",
        type: "radio",
        options: [
          {
            label: "محدوده (اضافه یا حذف از محدوده کاری)",
            value: "محدوده (اضافه یا حذف از محدوده کاری)",
          },
          {
            label: "زمانبندی (بسط یا فشرده‌سازی برنامه زمانی)",
            value: "زمانبندی (بسط یا فشرده‌سازی برنامه زمانی)",
          },
          {
            label: "هزینه (افزایش یا کاهش از بودجه)",
            value: "هزینه (افزایش یا کاهش از بودجه)",
          },
        ],
        size: 5,
      },
      {
        id: "K_ChangeDomainFormational",
        label: "تغییرات شکلی",
        type: "radio",
        options: [
          {
            label: "مشخصات (نام پروژه، متولی)",
            value: "مشخصات (نام پروژه، متولی)",
          },
          {
            label: "وضعیت (حذف، توقف، شروع مجدد)",
            value: "وضعیت (حذف، توقف، شروع مجدد)",
          },
          {
            label: "ترکیب (ادغام با/تفکیک از یک پروژه)",
            value: "ترکیب (ادغام با/تفکیک از یک پروژه)",
          },
        ],
        size: 5,
      },
    ],
    10,
    10,
  );

  ////////////////////////////////////// Section 5

  createInputRow(
    "content-1-step-5",
    "ChangeDescription",
    [
      {
        id: "K_ChangeDescription",
        label: "شرح تغییر",
        size: 2,
        type: "multiline",
        height: "150px",
      },
    ],
    2,
    10,
  );
  ////////////////////////////////////////////////////////////// Tab 4

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

  console.log(ProjectID);

  CreateGrid("content-4-step-1", {
    gridName: "ChangeFaze",
    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: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectPhase",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": ' + 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: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectEvent",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": "' + 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,
          );
        },
      );
    },
  });

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

  createUploader(
    "content-4-step-3",
    "/pmo",
    {
      listTitle: "ChangeScheduleFiles",
      folderUrl: "pmo/ChangeScheduleFiles",
    },
    { Change: ItemID },
    `<Eq><<FieldRef Name="Change" LookupId="TRUE" /><Value Type="Integer">${ItemID}</Value></Eq>`,
  );

  if (ItemID == "NewItem") {
    console.log("Hide");
  }

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

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

  CreateGrid("content-5-step-1", {
    gridName: "ChangeBeneficiary",
    gridDisplayName: "ذینفعان پروژه",
    showEditButton: true,
    showColumns: true,
    showDelteButton: false,
    columns: [
      {
        name: "Type",
        displayName: "نوع",
        type: "combobox",
        options: ["داخلی", "خارجی"],
        disabled: true,
        textAlign: "center",
      },
      {
        name: "Title",
        displayName: "ذینفع",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
      {
        name: "Role",
        displayName: "نقش",
        type: "lookup",
        disabled: true,
        textAlign: "center",
        lookupSite: "/pmo/",
        lookupList: "Base_Role",
        lookupColumn: "Title",
      },
    ],
    ParentList: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectStakeholders",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: "ProjectStakeholders",
          defaultColumns: '[{ "ChangeId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectStakeholders",
            "Title",
            [
              {
                id: "K_Modal_ProjectStakeholders_StakeHolderTitle",
                label: "ذینفع",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectStakeholders",
            "StakeholderType",
            [
              {
                id: "K_Modal_ProjectStakeholders_Type",
                label: "نوع",
                type: "radio",
                options: [
                  {
                    label: "داخلی",
                    value: "داخلی",
                  },
                  {
                    label: "خارجی",
                    value: "خارجی",
                  },
                ],
                size: 3,
              },
            ],
            10,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectStakeholders",
            "Title",
            [
              {
                id: "K_Modal_ProjectStakeholders_Title",
                label: "عنوان",
                type: "text",
                inline: true,
                size: 10,
              },
            ],
            10,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectStakeholders",
            "DeputyManagement",
            [
              {
                id: "K_Modal_ResponsibleShaparak_Role",
                label: "نقش",
                inline: true,
                size: 5,
                type: "lookup",
                siteUrl: "/pmo/",
                listName: "Base_Role",
                valueField: "Id",
                textField: "Title",
                saveId: true,
              },
            ],
            10,
            10,
          );
        },
      );
    },
  });

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

  CreateGrid("content-5-step-2", {
    gridName: "ChangeProjectNeeds",
    gridDisplayName: "نیازها و الزامات پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectRequirement",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": "' + 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: `ProjectNameId eq ${ProjectID}`,
              },
            ],
            5,
            10,
          );
        },
      );
    },
  });

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

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

  CreateGrid("content-6-step-1", {
    gridName: "ChangeTargets",
    gridDisplayName: "اهداف پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "عنوان",
        type: "text",
        disabled: false,
        textAlign: "right",
      },
    ],
    ParentList: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectObjective",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: "ProjectObjective",
          defaultColumns: '[{ "ChangeId": "' + ItemID + '"}]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-ProjectObjective",
            "TitleName",
            [
              {
                id: "K_Modal_ProjectObjective_ProjectObjectiveTitle1",
                label: "هدف",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-ProjectObjective",
            "Title",
            [
              {
                id: "K_Modal_ProjectObjective_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10,
          );
        },
      );
    },
  });

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

  CreateGrid("content-6-step-2", {
    gridName: "ChangeDomain1",
    gridDisplayName: "پروژه شامل",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Title",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    defaultColumns: '[{ "Type": "شامل" }]',
    ParentList: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "Scope",
      query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</Value></Eq><Eq><FieldRef Name='Type' /><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: "Scope",
          defaultColumns:
            '[{ "ChangeId": "' + ItemID + '"}, { "Type": "شامل" }]',
          gridData: gridData,
        },
        (modal) => {
          createInputRow(
            "k-modal-body-/pmo-Scope",
            "TitleName",
            [
              {
                id: "K_Modal_Scope_ScopeTitle1",
                label: "شامل...",
                type: "title",
                size: 5,
                borderBottom: "1px #195A65 solid",
                color: "#195A65",
              },
            ],
            5,
            10,
          );
          createInputRow(
            "k-modal-body-/pmo-Scope",
            "Title",
            [
              {
                id: "K_Modal_Scope_Title",
                label: "شرح",
                type: "text",
                size: 5,
              },
            ],
            5,
            10,
          );
        },
      );
    },
  });

  setTimeout(() => {
    CreateGrid("content-6-step-2", {
      gridName: "ChangeDomain2",
      gridDisplayName: "پروژه شامل نمی‌شود",
      showEditButton: true,
      showColumns: false,
      showDelteButton: false,
      columns: [
        {
          name: "Title",
          displayName: "شرح",
          type: "text",
          disabled: true,
          textAlign: "right",
        },
      ],
      defaultColumns: '[{ "Type": "غیر شامل" }]',
      defaultGlobalColumns:
        '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
      ParentList: "Change",
      dataSource: {
        site: "/pmo/",
        listName: "Scope",
        query: `<View><Query><Where><And><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</Value></Eq><Eq><FieldRef Name='Type' /><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: "Scope",
            defaultColumns:
              '[{ "ChangeId": "' + ItemID + '"}, { "Type": "غیر شامل" }]',
            gridData: gridData,
          },
          (modal) => {
            createInputRow(
              "k-modal-body-/pmo-Scope",
              "TitleName",
              [
                {
                  id: "K_Modal_Scope_ScopeTitle1",
                  label: "شامل نمی‌شود...",
                  type: "title",
                  size: 5,
                  borderBottom: "1px #195A65 solid",
                  color: "#195A65",
                },
              ],
              5,
              10,
            );
            createInputRow(
              "k-modal-body-/pmo-Scope",
              "Title",
              [
                {
                  id: "K_Modal_Scope_Title",
                  label: "شرح",
                  type: "text",
                  size: 5,
                },
              ],
              5,
              10,
            );
          },
        );
      },
    });
  }, 10);

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

  CreateGrid("content-6-step-3", {
    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: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectDeliverable",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": "' + 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: `ProjectNameId eq ${ProjectID}`,
              },
            ],
            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: `ProjectNameId eq ${ProjectID}`,
              },
            ],
            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: "ResponsibleShaparak",
                          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_ResponsibleShaparak = "";
                          var rowItemId_ResponsibleShaparak = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_ResponsibleShaparak = "new";
                            rowItemId_ResponsibleShaparak = row.ID;
                          } else {
                            rowType_ResponsibleShaparak = "edit";
                            rowItemId_ResponsibleShaparak = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "مجری - شاپرک",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_ResponsibleShaparak,
                              type: rowType_ResponsibleShaparak,
                              siteUrl: "/pmo",
                              listName: "ResponsibleShaparak",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Responsible": "شاپرک"}]',
                              gridData: gridData,
                            },
                            (modal) => {
                              createInputRow(
                                "k-modal-body-/pmo-ResponsibleShaparak",
                                "MojriTitle",
                                [
                                  {
                                    id: "K_Modal_ProjectDeliverable_MojriTitle",
                                    label: "مجری",
                                    type: "title",
                                    size: 5,
                                    borderBottom: "1px #195A65 solid",
                                    color: "#195A65",
                                  },
                                ],
                                5,
                                10,
                              );
                              createInputRow(
                                "k-modal-body-/pmo-ResponsibleShaparak",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_ResponsibleShaparak_Deputy",
                                    label: "معاونت",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Deputy",
                                    valueField: "Id",
                                    textField: "Title",
                                    saveId: true,
                                    onchangefunction: async () => {
                                      if (
                                        GetElement(
                                          "K_Modal_ResponsibleShaparak_DeputyId",
                                        ) != ""
                                      ) {
                                        setLookupOptions(
                                          "K_Modal_ResponsibleShaparak_ManagementId",
                                          `DeputyId eq ${GetElement(
                                            "K_Modal_ResponsibleShaparak_DeputyId",
                                          )}`,
                                        );
                                      }

                                      if (
                                        !rowItemId_ResponsibleShaparak
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ResponsibleShaparakItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "ResponsibleShaparak",
                                            rowItemId_ResponsibleShaparak,
                                          );
                                        SetElement(
                                          "K_Modal_ResponsibleShaparak_ManagementId",
                                          ResponsibleShaparakItem.ManagementId,
                                        );
                                        SetElement(
                                          "K_Modal_ResponsibleShaparak_UserNameId",
                                          "",
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_ResponsibleShaparak_Management",
                                    label: "مدیریت",
                                    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_ResponsibleShaparak_DeputyId",
                                          ) != "" &&
                                          GetElement(
                                            "K_Modal_ResponsibleShaparak_ManagementId",
                                          ) != ""
                                        )
                                          setLookupOptions(
                                            "K_Modal_ResponsibleShaparak_UserNameId",
                                            `DeputyId eq ${GetElement(
                                              "K_Modal_ResponsibleShaparak_DeputyId",
                                            )} and ManagementId eq ${GetElement(
                                              "K_Modal_ResponsibleShaparak_ManagementId",
                                            )}`,
                                          );
                                        if (
                                          !rowItemId_ResponsibleShaparak
                                            .toString()
                                            .includes("NewItem")
                                        ) {
                                          var ResponsibleShaparakItem =
                                            await getItemFromList(
                                              "/pmo/",
                                              "ResponsibleShaparak",
                                              rowItemId_ResponsibleShaparak,
                                            );
                                          SetElement(
                                            "K_Modal_ResponsibleShaparak_UserNameId",
                                            ResponsibleShaparakItem.UserNameId,
                                          );
                                        }
                                      }, 300);
                                    },
                                  },
                                ],
                                10,
                                10,
                              );
                              createInputRow(
                                "k-modal-body-/pmo-ResponsibleShaparak",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_ResponsibleShaparak_UserName",
                                    label: "نماینده",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Users",
                                    valueField: "UserNameId",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0",
                                  },
                                ],
                                10,
                                10,
                              );
                            },
                          );
                        },
                      },
                    );
                  } else if (
                    GetElement("K_Modal_ProjectDeliverable_Responsible") ==
                    "سازمان بیرونی"
                  ) {
                    CreateGrid(
                      "K_Modal_ProjectDeliverable_ResponsibleGridDiv",
                      {
                        gridName: "Responsible",
                        gridDisplayName: "مجری - سازمان بیرونی",
                        showEditButton: true,
                        showColumns: true,
                        showDelteButton: false,
                        columns: [
                          {
                            name: "Company",
                            displayName: "سازمان",
                            type: "text",
                            disabled: true,
                            textAlign: "center",
                            backgroundColor: "#8FAADC",
                          },
                        ],
                        ParentList: "ProjectDeliverable",
                        dataSource: {
                          site: "/pmo/",
                          listName: "ResponsibleShaparak",
                          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_ResponsibleShaparak = "";
                          var rowItemId_ResponsibleShaparak = "";
                          if (row.ID.toString().includes("NewItem")) {
                            rowType_ResponsibleShaparak = "new";
                            rowItemId_ResponsibleShaparak = row.ID;
                          } else {
                            rowType_ResponsibleShaparak = "edit";
                            rowItemId_ResponsibleShaparak = row.ID;
                          }
                          ShowKModal(
                            {
                              title: "مجری - سازمان بیرونی",
                              width: 600,
                              height: 350,
                              backgroundColor: "#D6DCE5",
                              headerColor: "#195A65",
                              id: rowItemId_ResponsibleShaparak,
                              type: rowType_ResponsibleShaparak,
                              siteUrl: "/pmo",
                              listName: "ResponsibleShaparak",
                              defaultColumns:
                                '[{ "ProjectDeliverableId": "' +
                                rowItemId +
                                '"}, {"Responsible": "سازمان بیرونی"}]',

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

                                      if (
                                        !rowItemId_ResponsibleShaparak
                                          .toString()
                                          .includes("NewItem")
                                      ) {
                                        var ResponsibleShaparakItem =
                                          await getItemFromList(
                                            "/pmo/",
                                            "ResponsibleShaparak",
                                            rowItemId_ResponsibleShaparak,
                                          );
                                        SetElement(
                                          "K_Modal_ResponsibleShaparak_ManagementId",
                                          ResponsibleShaparakItem.ManagementId,
                                        );
                                        SetElement(
                                          "K_Modal_ResponsibleShaparak_UserNameId",
                                          "",
                                        );
                                      }
                                    },
                                  },
                                  {
                                    id: "K_Modal_ResponsibleShaparak_Management",
                                    label: "مدیریت",
                                    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_ResponsibleShaparak_DeputyId",
                                          ) != "" &&
                                          GetElement(
                                            "K_Modal_ResponsibleShaparak_ManagementId",
                                          ) != ""
                                        )
                                          setLookupOptions(
                                            "K_Modal_ResponsibleShaparak_UserNameId",
                                            `DeputyId eq ${GetElement(
                                              "K_Modal_ResponsibleShaparak_DeputyId",
                                            )} and ManagementId eq ${GetElement(
                                              "K_Modal_ResponsibleShaparak_ManagementId",
                                            )}`,
                                          );
                                        if (
                                          !rowItemId_ResponsibleShaparak
                                            .toString()
                                            .includes("NewItem")
                                        ) {
                                          var ResponsibleShaparakItem =
                                            await getItemFromList(
                                              "/pmo/",
                                              "ResponsibleShaparak",
                                              rowItemId_ResponsibleShaparak,
                                            );
                                          SetElement(
                                            "K_Modal_ResponsibleShaparak_UserNameId",
                                            ResponsibleShaparakItem.UserNameId,
                                          );
                                        }
                                      }, 300);
                                    },
                                  },
                                ],
                                10,
                                10,
                              );
                              createInputRow(
                                "k-modal-body-/pmo-ResponsibleShaparak",
                                "DeputyManagement",
                                [
                                  {
                                    id: "K_Modal_ResponsibleShaparak_UserName",
                                    label: "نماینده",
                                    inline: true,
                                    size: 5,
                                    type: "lookup",
                                    siteUrl: "/pmo/",
                                    listName: "Users",
                                    valueField: "UserNameId",
                                    textField: "Title",
                                    saveId: true,
                                    filter: "Id eq 0",
                                  },
                                ],
                                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,
              },
            ],
            5,
            10,
          );
          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 4

  CreateGrid("content-6-step-4", {
    gridName: "ChangeProjectNeededResources",
    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: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectResourceForm",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": "' + 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 5

  CreateGrid("content-6-step-5", {
    gridName: "ProjectClosureAcceptanceCriteria",
    gridDisplayName: "معیارهای پذیرش خاتمه پروژه",
    showEditButton: true,
    showColumns: false,
    showDelteButton: false,
    columns: [
      {
        name: "Description",
        displayName: "شرح",
        type: "text",
        disabled: true,
        textAlign: "right",
      },
    ],
    ParentList: "Change",
    defaultGlobalColumns:
      '[{ "ProjectNameId": "ProjectID", "DeputyId": "ProjectDeputy" , "ManagementId": "ProjectManagement"}]',
    dataSource: {
      site: "/pmo/",
      listName: "ProjectClosureAcceptanceCriteria",
      query: `<View><Query><Where><Eq><FieldRef Name='ProjectName' LookupId='TRUE' /><Value Type='Lookup'>${ProjectID}</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: '[{ "ChangeId": "' + 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) => {
                    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),
            },
          );
        },
      );
    },
  });

  ////////////////////////////////////////////////////////////////////

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

  if (ItemID == "NewItem") {
    var fileUploads = document.querySelectorAll("div[type='FileUploader']");

    fileUploads.forEach((fu) => {
      fu.style.display = "none";
    });
  }
  // Jalali activation
  jalaliDatepicker.startWatch();
}

main();
