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 : 3.139.79.187


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

function getData() {
  let url = document.URL;
  urlParams = parseURLParams(url);
  console.log(urlParams.reportName[0], "anota");

  $.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] +
      "&degree=" +
      urlParams.degree[0],
    success: function (res) {
      let response = JSON.parse(res);
      console.log(response, "anitaa");
      if (response.data.data.length > 0) {
        google.charts.load("current", { packages: ["corechart"] });
        google.charts.setOnLoadCallback(drawChart);
        // return;

        let headings = document.createElement("div");
        headings.style.cssText = "line-height: 0.5;";

        let colldet = document.createElement("div");
        if (urlParams.db[0] === "jssstu") {
          let heading_1 = document.createElement("p");
          heading_1.style.cssText =
            "font-size: 16px; font-weight: bold; text-align: center;";
          var t = document.createTextNode("JSS MAHAVIDYAPEETHA");
          heading_1.appendChild(t);
          colldet.appendChild(heading_1);
        }

        let heading_2 = document.createElement("p");
        heading_2.style.cssText =
          "font-size: 18px; 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: 16px; 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: 18px; 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: 16px; font-weight: bold; text-align: center;";
        if (urlParams.reportName[0] == "") {
          $rep_report = "SUBJECTWISE RESULT ANALYSIS";
        } else {
          $rep_repor = urlParams.reportName[0];
        }
        var t5 = document.createTextNode(
          $rep_report +
            "-" +
            response.data.data[0].fdeggrp.toUpperCase() +
            " (" +
            response.data.obj.fresexamdate +
            " Examination" +
            ") [" +
            response.data.obj.fexamname +
            "]"
        );
        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(
          "DEGREE :- ( " + urlParams.degree[0] + " )"
        );
        heading_6.appendChild(t6);
        if (urlParams.db[0] !== "sjbit") {
          colldet.appendChild(heading_2);
          colldet.appendChild(heading_3);
          colldet.appendChild(heading_4);
        }

        colldet.appendChild(heading_5);
        colldet.appendChild(heading_6);

        let logo = document.createElement("div");
        logo.style.cssText = "margin-top:25px;";
        let img = document.createElement("img");

        if (urlParams.db[0] === "sjbit") {
          img.style.cssText = "height:120px; width:800px;";

          img.setAttribute(
            "src",
            "https://college.universitysolutions.in/" +
              urlParams.db[0] +
              "/img/log.jpg"
          );
        } else {
          img.style.cssText =
            "height:70px; width:140px; position:absolute; right:10px;";
          img.setAttribute(
            "src",
            "https://college.universitysolutions.in/" +
              urlParams.db[0] +
              "/img/logo.jpg"
          );
        }

        let line = document.createElement("div");
        line.style.cssText = "border:1px solid;";

        logo.appendChild(img);
        headings.appendChild(logo);
        headings.appendChild(colldet);
        headings.appendChild(line);

        document.getElementById("piechart").appendChild(headings);

        function drawChart() {
          var data = google.visualization.arrayToDataTable([
            ["Degree Group", "Count"],
            ["S", parseInt(response.data.data[0].fs)],
            ["A", parseInt(response.data.data[0].fa)],
            ["B", parseInt(response.data.data[0].fb)],
            ["C", parseInt(response.data.data[0].fc)],
            ["D", parseInt(response.data.data[0].fd)],
            ["E", parseInt(response.data.data[0].fe)],
            ["F", parseInt(response.data.data[0].ff)],
            ["AB", parseInt(response.data.data[0].fab)],
            ["NE", parseInt(response.data.data[0].fne)],
            ["Others", parseInt(response.data.data[0].fmp)],
            ["FAIL", parseInt(response.data.data[0].ffail)],
            ["PASS", parseInt(response.data.data[0].fpass)],
          ]);

          var options = {
            // title: "Degree Group: " + response.data.data[0].fdeggrp,
            titleTextStyle: { fontSize: 16 },
            legend: "labeled",
            pieSliceText: "label",
            width: 1000,
            height: 800,
          };

          const div = document.createElement(`div`);

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

          chart.draw(data, options);

          let mainHeader = ["Total Records", "No. of Records Awarded"];

          let subHeader = [
            "Count",
            "S",
            "A",
            "B",
            "C",
            "D",
            "E",
            "F",
            "AB",
            "NE",
            "Others",
            "Fail",
            "PP",
          ];

          let records = [
            parseInt(response.data.data[0].COUNT),
            parseInt(response.data.data[0].fs),
            parseInt(response.data.data[0].fa),
            parseInt(response.data.data[0].fb),
            parseInt(response.data.data[0].fc),
            parseInt(response.data.data[0].fd),
            parseInt(response.data.data[0].fe),
            parseInt(response.data.data[0].ff),
            parseInt(response.data.data[0].fab),
            parseInt(response.data.data[0].fne),
            parseInt(response.data.data[0].fmp),
            parseInt(response.data.data[0].ffail),
            parseInt(response.data.data[0].fpass),
          ];

          let tableDiv = document.createElement("div");
          tableDiv.setAttribute("class", "table-reponsive");
          let table = document.createElement("table");
          table.setAttribute("class", "table table-bordered");
          let thead = document.createElement("thead");
          let theadRow1 = document.createElement("tr");
          thead.appendChild(theadRow1);

          for (var k = 0; k < mainHeader.length; k++) {
            let th = document.createElement("th");
            if (k === 1) {
              th.colSpan = 12;
            }
            th.appendChild(document.createTextNode(mainHeader[k]));
            theadRow1.appendChild(th);
          }

          let theadRow2 = document.createElement("tr");
          for (var k = 0; k < subHeader.length; k++) {
            let th = document.createElement("th");
            th.appendChild(document.createTextNode(subHeader[k]));
            theadRow2.appendChild(th);
          }
          thead.appendChild(theadRow2);
          table.appendChild(thead);
          let tbody = document.createElement("tbody");
          table.appendChild(tbody);
          let tbodyRow = document.createElement("tr");
          tbody.appendChild(tbodyRow);
          for (i = 0; i < records.length; i++) {
            let td = document.createElement("td");

            td.appendChild(document.createTextNode(records[i]));
            tbodyRow.appendChild(td);
          }

          let tbodyRow2 = document.createElement("tr");
          tbody.appendChild(tbodyRow2);
          for (i = 0; i < records.length; i++) {
            let td = document.createElement("td");
            if (i !== 0) {
              td.appendChild(
                document.createTextNode(
                  (
                    (records[i] / parseInt(response.data.data[0].COUNT)) *
                    100
                  ).toFixed(2) + "%"
                )
              );
            }
            tbodyRow2.appendChild(td);
          }

          tableDiv.appendChild(table);
          document.getElementById("piechart").appendChild(tableDiv);
        }
      } 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;
}