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 : 13.58.105.80
<?php
// $servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
// $username = "admin";
// $password = "Logisys2104";
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 = "logisys3_ruas";
$fdeggrp = $_POST['fdeggrp'];
$type = $_POST['type'];
if ($type != 'board')
$fboard = $_POST['fboard'];
if ($type == 'board') {
$Query = "select distinct m.fboard as fboardcode, m.fboardname
FROM {$db}.tdvs_masboard m
where fdeggrp = '{$fdeggrp}' order by m.fboard";
$result = mysqli_query($conn, $Query);
$i = 0;
while ($row = mysqli_fetch_assoc($result)) {
$row1[$i] = $row;
$i++;
}
echo json_encode($row1);
return;
}
else {
$sem = $_POST['sem'];
$status = $_POST['status'];
if ($sem == "") {
$cnd = "";
} else {
$cnd = " and su.fexamno = '{$sem}'";
}
if ($status == "") {
$cnd2 = "";
} else if ($status == "Completed") {
$cnd2 = "having cnt = valdone";
} else if ($status == "Pending") {
$cnd2 = "having valpen >0";
}
$Query = "select su.fboard,su.fexamno,su.fqpcode, su.fsubname,
count(s.fregcode) as cnt,
sum(if(ifnull(s.fstatus,'') = 'final',1,0)) as valdone,
sum(if(ifnull(s.fstatus,'') = 'final',0,1)) as valpen,
sum(if(ifnull(t.fregno,'') <> '',1,0)) as decodedone,
sum(if(ifnull(t.fregno,'') <> '',0,1)) as decodepend,
sum(if(ifnull(t.fregno2,'') <> '',1,0)) as decodedone2,
sum(if(ifnull(t.fregno2,'') <> '',0,1)) as decodepend2,
sum(if(ifnull(t.fstatus,'') = 'success',1,0)) as resultpush
from {$db}.tdvs_tabhead h inner join {$db}.tdvs_tabsum s on h.fregcode = s.fregcode
and h.fqpcode = s.fqpcode
inner join {$db}.tdvs_masqp su on su.fqpcode = h.fqpcode
left join {$db}.tdvs_tabulate t on h.fregcode = t.fregcode and h.fqpcode = t.fqpcode
where su.fdeggrp = '{$fdeggrp}'
{$cnd}
group by su.fboard,s.fqpcode
{$cnd2}
order by su.fboard,su.fexamno,s.fqpcode
";
$result = mysqli_query($conn, $Query);
$i = 1;
$html .= "<tr class='bg-green'>
<th width='4%'><center>Sl. No.</center></th>
<th width='8%'><center>Board</center></th>
<th width='6%'><center>Sem</center></th>
<th width='8%'><center>Qp. Code</center></th>
<th width='48%'><center>Subject Name</center></th>
<th width='8%'><center>Total Scripts</center></th>
<th width='8%'><center>Res. Push</center></th>
<th width='8%'><center>Val. Completed</center></th>
<th width='8%'><center>Val. Pending</center></th>
<th width='8%'><center>Decodeing 1st Entry Compl.</center></th>
<th width='8%'><center>Decodeing 1st Pending</center></th>
<th width='8%'><center>Decodeing 2st Entry Compl.</center></th>
<th width='8%'><center>Decodeing 2st Pending</center></th>";
$totspresent = 0;
$totvaldone = 0;
$totvalpen = 0;
$totdecodedone = 0;
$totdecodepend = 0;
$totdecodedone2 = 0;
$totdecodepend2 = 0;
$totresultpush = 0;
$html .= "</tr>";
while ($row = mysqli_fetch_assoc($result)) {
$totspresent = $totspresent + $row['cnt'];
$totvaldone = $totvaldone + $row['valdone'];
$totvalpen = $totvalpen + $row['valpen'];
$totresultpush = $totresultpush + $row['resultpush'];
$totdecodedone = $totdecodedone + $row['decodedone'];
$totdecodepend = $totdecodepend + $row['decodepend'];
$totdecodedone2 = $totdecodedone2 + $row['decodedone2'];
$totdecodepend2 = $totdecodepend2 + $row['decodepend2'];
$html .= "<tr style = 'background-color: #f9f9f9;'>
<td><center>{$i}</center></td>
<td><center>{$row['fboard']}</center></td>
<td><center>{$row['fexamno']}</center></td>
<td><center>{$row['fqpcode']}</center></td>
<td>{$row['fsubname']}</td>
<td style='text-align:center'>" . moneyFormatIndia($row['cnt']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['resultpush']) . "</td>";
$html .= "<td style='text-align:center'>" . moneyFormatIndia($row['valdone']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['valpen']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['decodedone']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['decodepend']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['decodedone2']) . "</td>
<td style='text-align:center'>" . moneyFormatIndia($row['decodepend2']) . "</td>";
$html .= "</tr>";
$i++;
}
$html .= "<tr>
<td colspan='5' style='text-align:center'><b>Total</b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totspresent) . "</td>
<td style='text-align:center'><b>" . moneyFormatIndia($totresultpush) . "</td>";
$html .= "<td style='text-align:center'><b>" . moneyFormatIndia($totvaldone) . "<b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totvalpen) . "<b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totdecodedone) . "<b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totdecodepend) . "<b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totdecodedone2) . "<b></td>
<td style='text-align:center'><b>" . moneyFormatIndia($totdecodepend2) . "<b></td>";
$html .= "</tr>";
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.
}
|