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.137.190.176


Current Path : /var/www/html/kus/phdadm/admin/js/
Upload File :
Current File : /var/www/html/kus/phdadm/admin/js/MainPage.js

var USER,USERTYPE;

function loadMaster()
{
  //loaddashboard();
	$.ajax({
    type: 'post',
    url: 'src/login.php',
    //data:parameters,
    success: function(response)
    {
      response = JSON.parse(response);
      var {status} = response;
      if(status === 'loggedin')
      {
        ({ USER,USERTYPE } = response);
        if(USERTYPE === 'usr')
          $('#createUserMenu').hide()
        loadApplications()
      }
      else
      {
      	alert("please login");
        window.location.href = 'index.html';
      }
    }
   });
}


function loadApplications()
{
  $('#loadtab').load('html_modules/applications.html',function()
  {
    $('#appdetl').hide();
    $.ajax({
    type: 'post',
    async:true,
    url: 'src/getautofill.php',
    success: function(response)
    {
      response = JSON.parse(response);
      var { college, degree } = response;
      console.log(degree);
      $( "#fromdeg" ).autocomplete({ source: degree 
      }).focus(function(){
         $(this).data("uiAutocomplete").search($(this).val());
        });

      $( "#todeg" ).autocomplete({
        source: degree
      }).focus(function(){
         $(this).data("uiAutocomplete").search($(this).val());
      });
      $( "#fromcoll" ).autocomplete({
        source: college
      }).focus(function(){
         $(this).data("uiAutocomplete").search($(this).val());
      });
      $( "#tocoll" ).autocomplete({
        source: college
      }).focus(function(){
         $(this).data("uiAutocomplete").search($(this).val());
      });
    }
  });

  });
}

function loaddashboard()
{
  $('#loadtab').load('html_modules/dashboard.html',function()
  {
    var parameters = `usertype=${USERTYPE}&user=${USER}`;
    $.ajax({
    type: 'post',
    url: 'src/dashboard.php',
    data:parameters,
    success: function(response)
    {
      response = JSON.parse(response);
      var {totalappcount, approvecount, notapprovecount, onlinepaysuccesscount, onlinepaycount, challanpaycount} = response;
      $('#tot_app').attr('data-to',totalappcount);
      $('#appr_app').attr('data-to',approvecount);
      $('#pend_app').attr('data-to',notapprovecount);
      $('#online_app').attr('data-to',onlinepaycount);
      $('#sbm_app').attr('data-to',challanpaycount);
      
      var {freshstudcount, secondstudcount, trirdstudcount, lateralstudcount} = response;
      $('#first_year').attr('data-to',freshstudcount);
      $('#second_year').attr('data-to',secondstudcount);
      $('#third_year').attr('data-to',trirdstudcount);
      $('#lateral_entry').attr('data-to',lateralstudcount);
      $('.count-to').countTo();
      var {onlinepaymentdone, onlinepaymentpending, sbmpaymentdone, sbmpaymentpending, challanpayackcount, challanpayackpencount} = response;
      var totamt = parseInt(onlinepaymentdone)+ parseInt(onlinepaymentpending)+parseInt(sbmpaymentdone)+parseInt(sbmpaymentpending);
      var totpaid = parseInt(onlinepaymentdone)+parseInt(sbmpaymentdone);
      var totpend = parseInt(onlinepaymentpending)+parseInt(sbmpaymentpending);
      $('#tot_amt').html(formartCurrency(totamt));
      $('#tot_paid').html(formartCurrency(totpaid));
      $('#tot_pend').html(formartCurrency(totpend));
      //Sales count to
      $('.sales-count-to').countTo(
      {
          formatter: function (value, options) 
          {
              return '$' + value.toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, ' ').replace('.', ',');
          }
      });      
      initCharts()
      function getChartJs(type) {
          var config = null;

          if (type === 'barm') {
              config = {
                  type: 'bar',
                  data: {
                      labels: ["Challan Payments", "Online Payments"],
                      datasets: [{
                          label: "Total",
                          data: [parseInt(sbmpaymentdone)+parseInt(sbmpaymentpending),parseInt(onlinepaymentdone)+ parseInt(onlinepaymentpending)],
                          backgroundColor: 'rgba(0, 188, 212, 0.8)'
                      }, {
                          label: "Done",
                          data: [sbmpaymentdone, onlinepaymentdone],
                          backgroundColor: 'rgba(80, 244, 66, 0.8)'
                      }, {
                              label: "Pending",
                              data: [sbmpaymentpending, onlinepaymentpending],
                              backgroundColor: 'rgba(233, 30, 99, 0.8)'
                          }]
                  },
                  options: {
                      responsive: true,
                      legend: false
                  }
              }
          }
          else if (type === 'bara') {
              config = {
                  type: 'bar',
                  data: {
                      labels: ["Challan Payments", "Online Payments"],
                      datasets: [{
                          label: "Total",
                          data: [challanpaycount, onlinepaycount],
                          backgroundColor: 'rgba(0, 188, 212, 0.8)'
                      }, {
                          label: "Done",
                          data: [challanpayackcount, onlinepaysuccesscount],
                          backgroundColor: 'rgba(80, 244, 66, 0.8)'
                      }, {
                          label: "Pending",
                          data: [challanpayackpencount, parseInt(onlinepaycount)-parseInt(onlinepaysuccesscount)],
                          backgroundColor: 'rgba(233, 30, 99, 0.8)'
                      }]
                  },
                  options: {
                      responsive: true,
                      legend: false
                  }
              }
          }
          
          return config;
      }
      new Chart(document.getElementById("bar_chart_app").getContext("2d"), getChartJs('bara'));
      new Chart(document.getElementById("bar_chart_amt").getContext("2d"), getChartJs('barm'));
    }
    });
    

  });
}

function formartCurrency(x)
{
  x=x.toString();
  var lastThree = x.substring(x.length-3);
  var otherNumbers = x.substring(0,x.length-3);
  if(otherNumbers != '')
      lastThree = ',' + lastThree;
  var res = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
  return 'Rs.'+res;
}

//Charts
function initCharts() {
    //Chart Bar
    $('.chart.chart-bar').sparkline(undefined, {
        type: 'bar',
        barColor: '#fff',
        negBarColor: '#fff',
        barWidth: '4px',
        height: '34px'
    });

    //Chart Pie
    $('.chart.chart-pie').sparkline(undefined, {
        type: 'pie',
        height: '50px',
        sliceColors: ['rgba(255,255,255,0.70)', 'rgba(255,255,255,0.85)', 'rgba(255,255,255,0.95)', 'rgba(255,255,255,1)']
    });

    //Chart Line
    $('.chart.chart-line').sparkline(undefined, {
        type: 'line',
        width: '60px',
        height: '45px',
        lineColor: '#fff',
        lineWidth: 1.3,
        fillColor: 'rgba(0,0,0,0)',
        spotColor: 'rgba(255,255,255,0.40)',
        maxSpotColor: 'rgba(255,255,255,0.40)',
        minSpotColor: 'rgba(255,255,255,0.40)',
        spotRadius: 3,
        highlightSpotColor: '#fff'
    });
}

function loadCreateUser()
{
  $('#loadtab').load('html_modules/createUser.html');
}

function createUser()
{
  if(!$('#createUserForm').valid()){
    return;
  }
  
  var usrname = $('#usrname').val();
  var password = $("#password").val();
  var parameters = `&usrname=${usrname}&password=${password}`;

  $.ajax({
    type: 'post',
    url: 'src/createUser.php',
    data: parameters,
    success: function(response)
    {
      response = JSON.parse(response);
      var {status,msg} = response;
      if(status == "success"){
        alert(msg);
      } else {
        alert(msg);
      }
    }
  });
}

var table;

function getAppDetails()
{
  if(!$('#appRangeForm').valid()){
    return;
  }
  var parameters = "fromdeg="+$('#fromdeg').val();
  parameters += "&todeg="+$('#todeg').val();
  parameters += "&fromcoll="+$('#fromcoll').val();
  parameters += "&tocoll="+$('#tocoll').val();
  parameters += "&fromapp="+$('#fromapp').val();
  parameters += "&toapp="+$('#toapp').val();
  parameters += "&year="+$('#year').val();

  function getcodes(param){
    
  }
  $.ajax({
      type: 'post',
      url: 'src/getapps.php',
      data:parameters,
      success: function(response)
      {
        response = JSON.parse(response);
        var {apps : app_obj_arr} = response;
        $('.js-exportable').html('');
        $('#appdetl').show();
        var app_arr = [];
        //get array of applications
        for(var i in app_obj_arr){
          var arr = $.map(app_obj_arr[i], function(el) { return el });
          app_arr.push(arr);
        }

        table = $('.js-exportable').DataTable(
		    {
          dom: 'Bfrtip',
          destroy: true,
          responsive: true,
          data: app_arr,
          columnDefs: [{
            targets: 0,
            searchable: false,
            orderable: false,
            className: 'dt-body-center',
            render: function (data, type, full, meta)
			      {
				      //console.log(data);
              return '<center><input type="checkbox" name="id[]" class="filled-in chk-col-light-blue" id="'+
              $('<div/>').text(data).html()+'" value="'+
              $('<div/>').text(data).html()+'"> <lable for="'+
              $('<div/>').text(data).html()+'"> </label></center>';
            }
          },
		      {
            targets: 9,
            searchable: false,
            orderable: false,
            className: 'dt-body-center',
            render: function (data, type, full, meta)
			      {
              return '<center><button name="id[]" class = "btn btn-primary details">Details</button></center>';
            }
          }],
          order: [[1, 'asc']],
          columns: [
            { title: "<center><input type='checkbox' name='select_all' value='1' id='select-all'/></center>" },
            { title: "App. No." },
            { title: "Name" },
            { title: "Father Name" },
            { title: "Degree" },
            { title: "Fees" },
            { title: "Pay. Type" },
			      { title: "Status" },
            { title: "User" },
			      { title: "Deatils" }
          ],
          
          "lengthMenu": [ [2, 4, 8, -1], [2, 4, 8, "All"] ],
          "pageLength": 15,
          buttons: [
              'copy', 'csv', 'excel', 'pdf', 'print'
          ]
        });
        //check already assigned user
        var rows = table.rows({ 'search': 'applied' }).nodes();
        $('input[type="checkbox"]', rows).prop('checked', this.checked);
        
        /*var check_arr = app_arr.filter((app) => { return app[7] != '';});
        for(let i in check_arr){
          $(`#${check_arr[i][0]}`).prop('checked', true);
        }*/

        $('#select-all').on('click', function(){
          // Check/uncheck all checkboxes in the table
          var rows = table.rows({ 'search': 'applied' }).nodes();
          $('input[type="checkbox"]', rows).prop('checked', this.checked);
        });


        $('.details').on( 'click', function () 
        {
          var appno = $(this).parents('tr').find('input[type="checkbox"]').val();
          var parameters = "&appno="+appno;
          $.ajax({
                type: 'post',
                url: 'src/studdet.php',
                data:parameters,
				        async: false,
                success: function(response)
                {
                  response = JSON.parse(response);         
                  var user = response.user; 
                  var disabled = "disabled";
                  if(user == 'admx')
                      disabled = '';
                      var subjectarry = ``;
                      var z = 1;
                      var sub = response.subjdet.split('~');
                      jQuery.each(sub, function( i, val ) 
                      {
                          subject = val.split('->');
                          subjectarry += `<tr>
                          <td>
                           ${z}
                          </td>
                          <td>
                            ${subject[1]}
                          </td>
                          <td>
                             ${subject[0]}
                          </td>
                        </tr>`;
                          z++;
                      });  
                      //console.log(subjectarry);  

                  $( "#idModal2" ).empty();
                  $("#idModal2").append(`<div class="body" id="body">
                  <table class = "table">
                    <th>
                      Personal Information
                    </th>
                    <tr>
                        <td >Name </td>
                        <td><input id = "name"  class = "form-control" ${disabled}  type = 'text' value = "${response.name}"></td>
                        <td>Father Name</td>
                        <td><input id = "fname" class = "form-control" ${disabled} type = 'text' value = "${response.FFATNAME}"></td>
                    </tr>
                    <tr>
                        <td>Occupation</td>
                        <td><input id = "fatocc"  class = "form-control" ${disabled} type = 'text' value = "${response.FFAT_OCC}"> </td>
                        <td>Category</td>
                        <td><input id = "fcaste" class = "form-control"  ${disabled} type = 'text' value = "${response.FCASTE}"> </td>
                    </tr>
                    <tr>
                        <td>Gender</td>
                        <td><input id = "fsex"  class = "form-control" ${disabled} type = 'text' value = "${response.FSEX}"> </td>
                        <td>Handicap</td>
                        <td><input id = "fhandicap" class = "form-control"  ${disabled} type = 'text' value = "${response.FHANDICAP}"> </td>
                    </tr>
                    <tr>
                        <td>Date Of Birth</td>
                        <td><input id = "fdob" class = "form-control"  ${disabled} type = 'text' value = "${response.fdob}"> </td>
                        <td> Aadhar Number</td>
                        <td><input id = "fadar" class = "form-control"  ${disabled} type = 'text' value = "${response.FAADHARNO}"> </td> 
                    </tr>
                    <tr>
                        <td>Mobile Numbe</td>
                        <td><input id = "fmobile" class = "form-control"  ${disabled} type = 'text' value = "${response.FCONTACT_NO}"> </td>
                        <td>LandLine Number</td>
                        <td><input id = "flandline" class = "form-control"  ${disabled} type = 'text' value = "${response.FLANDLINE}"> </td> 
                    </tr>
                    <tr>
                        <td>Email Address</td>
                        <td><input id = "femail" class = "form-control"  ${disabled} type = 'text' value = "${response.FEMAIL}"> </td>
                        <td>Annual Income</td>
                        <td><input id = "fincome" class = "form-control"  ${disabled} type = 'text' value = "${response.FINCOME}"> </td> 
                    </tr>
                     <tr>
                        <td>Permanent Address</td>
                        <td><input id = "fperadd1" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERMADD1}"> </td>
                        <td>Communication Address</td>
                        <td><input id = "fcuradd1" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURRADD1}"> </td> 
                    </tr>
                    <tr>
                        <td></td>
                        <td><input id = "fperadd2" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERMADD2}"> </td>
                        <td></td>
                        <td><input id = "fcuradd2" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURRADD2}"> </td> 
                    </tr>
                    <tr>
                        <td></td>
                        <td><input id = "fperadd3" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERMADD3}"> </td>
                        <td></td>
                        <td><input id = "fcuradd3" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURRADD3}"> </td> 
                    </tr>
                    <tr>
                        <td>District</td>
                        <td><input id = "fperdistrict" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERDISTRICT}"> </td>
                        <td>District</td>
                        <td><input id = "fcurdistrict" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURDISTRICT}"> </td> 
                    </tr>
                    <tr>
                        <td>Pincode</td>
                        <td><input id = "fperpincode" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERPINCODE}"> </td>
                        <td>Pincode</td>
                        <td><input id = "fcurpincode" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURPINCODE}"> </td> 
                    </tr>
                    <tr>
                        <td>State</td>
                        <td><input id = "fperstate" class = "form-control"  ${disabled} type = 'text' value = "${response.FPERSTATE}"> </td>
                        <td>State</td>
                        <td><input id = "fcurstate" class = "form-control"  ${disabled} type = 'text' value = "${response.FCURSTATE}"> </td> 
                    </tr> 
                  </table> 
                    <table class = "table">
                      <th>
                        Opted Course Details
                      </th>
                      <tr>
                        <td>Course</td>
                        <td><input id = "fdegree" class = "form-control"  ${disabled} type = 'text' value = "${response.fdegname }"> </td>
                        <td>Medium</td>
                        <td><input id = "fmoe" class = "form-control"  ${disabled} type = 'text' value = "${response.FENGLISH}"> </td> 
                      </tr>
                    </table>  
                    <table class = "table">
                      <th>
                        Subject Deatils
                      </th>
                      <tr>
                        <td>
                          Sl. No.
                        </td>
                        <td>
                          Subject Name
                        </td>
                        <td>
                          Subject Short Name
                        </td>
                      </tr>
                      ${subjectarry}
                    </table>
                    <table class = "table">
                      <th>
                        Fee Details
                      </th>
                      <tr>
                        <td>Payment Mode</td>
                        <td><input id = "fcollcode" class = "form-control"  ${disabled} type = 'text' value = "${response.FPAYMENTTYPE }"> </td>
                        <td>Amount</td>
                        <td><input id = "fmoe" class = "form-control"  ${disabled} type = 'text' value = "${response.FTOTFEE}"> </td> 
                        <td>Register No</td>
                        <td><input id = "fmoe" class = "form-control"  ${disabled} type = 'text' value = "${response.fregno}"> </td> 
                        <td>Reference No</td>
                        <td><input id = "fmoe" class = "form-control"  ${disabled} type = 'text' value = "${response.fappno}"> </td> 
                      </tr>
                    </table>
                    <table class = "table">
                      <th>
                        Acknowledgement
                      </th>
                       <tr>
                          <td>
                            Remarks
                          </td>
                           <td>
                              <input id = "fremarks" class = "form-control" type = 'text' value = "${response.fremarks}" >       
                           </td>
                           <td>
                            Status
                          </td>
                           <td>
                              <select  id = "status">
                                <option value = "APPROVED">
                                  Approved
                                </option>
                                <option value = "REJECT">
                                  Reject
                                </option>
                              </select>
                           </td>
                      </tr>
                    </table>
					<div class='p-b-20 p-t-20'>
						<center>
						<button type='button' class='btn btn-primary m-r-20' onclick='saveApplication("${response.fappno}")'>Save</button>
						<button type='button' class='btn btn-secondary' data-dismiss='modal'>Close</button>
						</center>
					</div>
                  </div>`);
				  $('#status').val(response.fapprstatus);
                  $('#idModal1').modal();
                }
            });
         
      } );                   

      }
    });
}


function saveApplication(appno)
{
    var remarks = $('#fremarks').val();
    var status  = $('#status').val();

     var parameters = "&appno="+appno+"&status="+status+"&remarks="+remarks;
  $.ajax({
  	type: 'post',
  	url: 'src/savestuddet.php',
  	data:parameters,
  	success: function(response)
  	{
  	  response = JSON.parse(response);
  	  var {status,msg} = response;
  	  if(status == "success")
  	  {
  		alert(msg);
  		$('#idModal1').modal('toggle');
  		return;
  	  }
  	  else 
  	  {
  		alert(msg);
  		$('#idModal1').modal('toggle');
  		return;
  	  }
  	} 
  });   
}


function saveAssignDetails()
{
  var selected_apps = [];
  table.$('input[type="checkbox"]').each(function(){
    if(this.checked){
      // Create an array of applications
      selected_apps.push(this.value);
    }
  });
  if (typeof selected_apps !== 'undefined' && selected_apps.length > 0) {
    // the array is defined and has at least one element
    var user = $('#user').val();
    var parameters = `user=${user}&apps=${selected_apps}`;
    $.ajax({
      type: 'post',
      url: 'src/saveapps.php',
      data:parameters,
      success: function(response)
      {
        response = JSON.parse(response);
        var {status,msg} = response;
        if(status == "success"){
          alert(msg);
        } else {
          alert(msg);
        }
      }
    });
  } else {
    alert("No Application selected");
  }
}

function signOut()
{
  $.ajax({
      type: 'post',
      url: 'src/logout.php',
      //data:parameters,
      success: function(response)
      {
        if(response === 'logout')
        {
          window.location.href = 'index.html';  
        }
      }
  });
}

function getDate()
{
  var today = new Date();
  var dd = today.getDate();
  var mm = today.getMonth()+1; //January is 0!

  var yyyy = today.getFullYear();
  if(dd<10){
      dd='0'+dd;
  } 
  if(mm<10){
      mm='0'+mm;
  } 
  var today = dd+'/'+mm+'/'+yyyy;
  return today;
}