0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.223.159.143


Current Path : /var/www/oasis/js/
Upload File :
Current File : /var/www/oasis/js/subjectwisePiechart.js

function getData() {
  let url = document.URL;
  urlParams = parseURLParams(url);
  console.log(urlParams, "hiii");

  $.ajax({
    type: "GET",

    // url:
    //   "https://college.universitysolutions.in/app.php?db=" +
    //   urlParams.db[0] +
    //   "&a=degwiseGrafAnalysisPie" +
    //   "&deggrp" +
    //   urlParams.deggrp[0] +
    //   "&degexam" +
    //   urlParams.degexam[0] +
    //   "&yearmode=" +
    //   urlParams.yearmode[0],

    url:
      "https://college.universitysolutions.in/app.php?db=" +
      urlParams.db[0] +
      "&a=subwiseGrafAnalysisPie" +
      "&degree=" +
      urlParams.degree[0] +
      "&degexam=" +
      urlParams.degexam[0] +
      "&yearmode=" +
      urlParams.yearmode[0] +
      "&section=" +
      urlParams.section[0],

    success: function (res) {
      let response = JSON.parse(res);

      console.log(response);

      let univcode = response.data.univcode;
      google.charts.load("current", { packages: ["corechart"] });
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        if (response.data.arr.length > 0) {
          for (var i = 0; i < response.data.arr.length; i++) {
            for (let j = 0; j < response.data.arr[i].length; j++) {
              var options = {
                title:
                  "Section: " +
                  response.data.arr[i][j].fsection +
                  " - " +
                  " Subject: " +
                  response.data.arr[i][j].fsubshort +
                  " (" +
                  response.data.arr[i][j].fsubname +
                  ") ",
                titleTextStyle: { fontSize: 16 },
                legend: "labeled",
                pieSliceText: "label",
                width: 1000,
                height: 400,
              };

              let headings = document.createElement("div");
              headings.style.cssText = "line-height: 0.5;";
              if (j % 2 == 0) {
                let coldet = document.createElement("div");
                coldet.style.cssText = "height:100%;";
                if (univcode == "052") {
                  let heading_1 = document.createElement("p");
                  heading_1.style.cssText =
                    "font-size: 14px; font-weight: bold; text-align: center;";
                  var t = document.createTextNode("JSS MAHAVIDYAPEETHA");
                  heading_1.appendChild(t);
                  coldet.appendChild(heading_1);
                }
                let heading_2 = document.createElement("p");
                heading_2.style.cssText =
                  "font-size: 16px; font-weight: bold; text-align: center;";
                var t2 = document.createTextNode(
                  response.data.col_det.FUNIVNAME
                );
                heading_2.appendChild(t2);

                let heading_3 = document.createElement("p");
                heading_3.style.cssText =
                  "font-size: 14px; font-weight: bold; text-align: center;";
                var t3 = document.createTextNode(response.data.col_det.state);
                heading_3.appendChild(t3);
                let heading_4 = document.createElement("p");
                heading_4.style.cssText =
                  "font-size: 16px; font-weight: bold; text-align: center;";
                var t4 = document.createTextNode(
                  "College: " + response.data.obj.college_name
                );
                heading_4.appendChild(t4);
                let heading_5 = document.createElement("p");
                heading_5.style.cssText =
                  "font-size: 14px; font-weight: bold; text-align: center;";
                console.log(urlParams.reportName[0], "anitaa");

                if (urlParams.reportName[0] == "") {
                  $rep_report = "SUBJECTWISE RESULT ANALYSIS(GRADEWISE)";
                } else {
                  $rep_report = urlParams.reportName[0];
                }
                var t5 = document.createTextNode(
                  $rep_report +
                    "-" +
                    response.data.obj.fresexamdate +
                    " Examination"
                );
                heading_5.appendChild(t5);
                let heading_6 = document.createElement("p");
                heading_6.style.cssText =
                  "font-size: 14px; font-weight: bold; text-align: center;";
                var t6 = document.createTextNode(
                  response.data.obj.fexamname +
                    " - " +
                    response.data.degree.fdescpn
                );
                heading_6.appendChild(t6);

                coldet.appendChild(heading_2);
                coldet.appendChild(heading_3);
                coldet.appendChild(heading_4);
                coldet.appendChild(heading_5);
                coldet.appendChild(heading_6);

                let logo = document.createElement("div");
                logo.style.cssText = "margin-top:40px;";
                let img = document.createElement("img");
                img.style.cssText =
                  "height:70px; width:140px; position:absolute; left:10px;";
                img.setAttribute(
                  "src",
                  "https://college.universitysolutions.in/" +
                    urlParams.db[0] +
                    "/img/logo.jpg"
                );

                logo.appendChild(img);
                headings.appendChild(logo);
                headings.appendChild(coldet);
              }
              document.getElementById("piechart").appendChild(headings);

              const div = document.createElement(`div`);
              div.setAttribute("id", `div_${i + "_" + j}`);
              // div.style.cssText =
              //   "height:100vh; width:100vh; position:relative; left:30%; right:30%;";

              var chart = new google.visualization.PieChart(
                document.getElementById("piechart").appendChild(div)
              );

              let data = google.visualization.arrayToDataTable([
                ["Task", "Hours per Day"],
                ["NE", parseInt(response.data.arr[i][j].fne)],
                ["F", parseInt(response.data.arr[i][j].ff)],
                ["AB", parseInt(response.data.arr[i][j].fab)],
                ["PP", parseInt(response.data.arr[i][j].fpass)],
                ["NP", parseInt(response.data.arr[i][j].ffail)],
                ["OTHERS", parseInt(response.data.arr[i][j].fmp)],
                ["S", parseInt(response.data.arr[i][j].fs)],
                ["A", parseInt(response.data.arr[i][j].fa)],
                ["B", parseInt(response.data.arr[i][j].fb)],
                ["C", parseInt(response.data.arr[i][j].fc)],
                ["D", parseInt(response.data.arr[i][j].fd)],
                ["E", parseInt(response.data.arr[i][j].fe)],
              ]);

              chart.draw(data, options);

              let mainHeader = [
                "Subject Code",
                "No. of Students Registered",
                "No. of Students Awarded (Counts/Percentage)",
                "No. of Students with",
              ];

              let subHeader = [
                "S",
                "A",
                "B",
                "C",
                "D",
                "E",
                "NE",
                "F",
                "AB",
                "PP",
                "NP",
                "OTHERS (MP,I,TL,DR,W)",
              ];

              let values = [
                response.data.arr[i][j].fsubshort,
                response.data.arr[i][j].count,
                response.data.arr[i][j].fs,
                response.data.arr[i][j].fa,
                response.data.arr[i][j].fb,
                response.data.arr[i][j].fc,
                response.data.arr[i][j].fd,
                response.data.arr[i][j].fe,
                response.data.arr[i][j].fne,
                response.data.arr[i][j].ff,
                response.data.arr[i][j].fab,
                response.data.arr[i][j].fpass,
                response.data.arr[i][j].ffail,
                response.data.arr[i][j].fmp,
              ];

              let newDiv = document.createElement("div");
              newDiv.style.cssText = "margin-top: 10px;";
              let ptag = document.createElement("div");
              newDiv.setAttribute("class", "table-reponsive");
              let table = document.createElement("table");

              table.setAttribute("class", "table table-bordered");
              table.setAttribute("id", "table_" + i + "_" + j);

              let tableHead = document.createElement("thead");
              let tr = document.createElement("tr");

              tableHead.appendChild(tr);

              for (var k = 0; k < mainHeader.length; k++) {
                let th = document.createElement("th");
                if (k === 0 || k === 1) {
                  th.rowSpan = 2;
                } else {
                  th.colSpan = 6;
                }
                th.appendChild(document.createTextNode(mainHeader[k]));
                tr.appendChild(th);
              }

              let tr2 = document.createElement("tr");

              tableHead.appendChild(tr2);
              for (var k = 0; k < subHeader.length; k++) {
                let th = document.createElement("th");

                th.appendChild(document.createTextNode(subHeader[k]));
                tr2.appendChild(th);
              }

              let tableBody = document.createElement("tbody");
              let tr3 = document.createElement("tr");

              tableBody.appendChild(tr3);
              for (var k = 0; k < values.length; k++) {
                let td = document.createElement("td");
                td.style.cssText = "width:7%";
                td.appendChild(document.createTextNode(values[k]));
                tr3.appendChild(td);
              }
              if ((j + 1) % 2 == 0) {
                ptag.style.pageBreakAfter = "always";
              }
              table.appendChild(tableHead);
              table.appendChild(tableBody);
              newDiv.appendChild(table);
              newDiv.appendChild(ptag);
              document.getElementById("piechart").appendChild(newDiv);
            }
          }
        } else {
          alert("no data found");
          return;
        }
      }
    },
  });
}

function parseURLParams(url) {
  var queryStart = url.indexOf("?") + 1,
    queryEnd = url.indexOf("#") + 1 || url.length + 1,
    query = url.slice(queryStart, queryEnd - 1),
    pairs = query.replace(/\+/g, " ").split("&"),
    parms = {},
    i,
    n,
    v,
    nv;

  if (query === url || query === "") return;

  for (i = 0; i < pairs.length; i++) {
    nv = pairs[i].split("=", 2);
    n = decodeURIComponent(nv[0]);
    v = decodeURIComponent(nv[1]);

    if (!parms.hasOwnProperty(n)) parms[n] = [];
    parms[n].push(nv.length === 2 ? v : null);
  }
  return parms;
}