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.144.227.3
Current Path : /var/www/html/univadmin/src/ |
| Current File : /var/www/html/univadmin/src/compileQpIndent_22032022.php |
<?php
function compileQpIndent($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
return;
$deggrp = $aobj_context->mobj_data["deggrp"];
$univcopy = $aobj_context->mobj_data["univcopy"];
$univcode = $aobj_context->mobj_data["univcode"];
$fstatus = $aobj_context->mobj_data["fstatus"];
$query = "DROP TABLE IF EXISTS qpmaster, tmpqpindsum,tmpqpindtot,tmpqpinddeg";
$result = $aobj_context->pobj_db->Execute($query);
$query = "select fyear, fexamtype, fexamdate from deggrp where fdeggrp ='{$deggrp}'";
$results = $aobj_context->pobj_db->GetRow($query);
$fyear = $results['fyear'];
$fexamtype = $results['fexamtype'];
$query = "select * from degcntr where fdeggrp = '{$deggrp}' and fyear = '{$fyear}'
and fexamtype = '{$fexamtype}'";
$results = $aobj_context->pobj_db->GetAll($query);
if(count($results)==0) {
$arr['msg'] = 'Exam centres not identified for current exam.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
// $query = "CREATE TABLE qpmaster
// SELECT DISTINCT fdegree, fexamno, fsubcode, fqpcode, d.fdate AS fdoe, fsessiont AS fsession
// FROM subject s left join masdate d on s.fdatecodet = d.fdatecode
// and d.fdeggrp = '{$deggrp}' and d.fyear = '{$fyear}' and d.fexamtype = '{$fexamtype}'
// left join timetable t on s.fqpcode = t.fqpcode and and t.fdeggrp = '{$deggrp}'
// and t.fyear = '{$fyear}' and t.fexamtype = '{$fexamtype}'
// WHERE IFNULL(fqpcode,'') <> '' AND ftheory = 'T'
// AND IFNULL(fintass,'') <> 'T'
// AND fdegree in( select distinct fdegree from degree where fdeggrp = '{$deggrp}') ";
$query = "CREATE TABLE qpmaster
SELECT DISTINCT fdegree, fexamno, fsubcode, s.fqpcode, d.fdate AS fdoe, t.fsessiont AS fsession
FROM subject s
left join timetable t on
s.fqpcode = t.fqpcode and t.fdeggrp = '{$deggrp}'
and t.fyear = '{$fyear}' and t.fexamtype = '{$fexamtype}'
left join masdate d on t.fdatecodet = d.fdatecode
and d.fdeggrp = '{$deggrp}' and d.fyear = '{$fyear}' and d.fexamtype = '{$fexamtype}'
WHERE IFNULL(s.fqpcode,'') <> '' AND ftheory = 'T'
AND IFNULL(fintass,'') <> 'T'
AND fdegree in( select distinct fdegree from degree where fdeggrp = '{$deggrp}')";
//var_dump($query);
$result = $aobj_context->pobj_db->Execute($query);
$query = "create index qpmaster_inx on qpmaster(fqpcode)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "create index qpmaster_inx1 on qpmaster(fdegree, fexamno, fsubcode)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "alter table qpmaster add column fsubname varchar(200)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "update qpmaster q, subject s
set q.fsubname = s.fsubname
where q.fqpcode = s.fqpcode
and ifnull(s.fqpcode,'') <> ''";
$result = $aobj_context->pobj_db->Execute($query);
if($fstatus == 'feepaid'){
$query = "CREATE TABLE tmpqpindsum
SELECT m.fexamcodet as fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname,
s.fqpcode, s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt,
(FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS fextra,
COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS ftotal,
(FLOOR((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) / 10) * 10) +
IF((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) MOD 10 = 0, 0, 10) AS frounded,
GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
FROM qpmaster s, canddet c, degcntr m, college g, candsum cs
WHERE s.fdegree = c.fdegree AND s.fexamno = c.fexamno
AND s.fsubcode = c.fsubcode AND c.fcollcode = m.fcollcode
AND m.fexamcodet = g.fcollcode and ifnull(c.fpresent,'') = 'P' and ifnull(c.fpassmth,'') = ''
and ifnull(fthpr,'') <> 'T'
and m.fyear = '{$fyear}' and m.fexamtype = '{$fexamtype}' and m.fdeggrp = '{$deggrp}'
and c.fdegree in(select fdegree from degree where fdeggrp = '{$deggrp}')
and c.fregno = cs.fregno and c.fdegree = cs.fdegree and c.fcollcode = cs.fcollcode
and c.fyear = cs.fyear and c.fexamtype = cs.fexamtype
and c.fyear = '{$fyear}' and c.fexamtype = '{$fexamtype}'
and INSTR(cs.fhtenable,c.fexamno) >0
GROUP BY s.fqpcode, s.fsubname, m.fexamcodet, g.fcollname, g.ftown
ORDER BY m.fexamcodet, s.fqpcode";
// (c.fdegree = 'MTTF1' and (mid(c.fregno,3,2) = 18 || (mid(c.fregno,3,2) = 19 and c.fexamno ='B' )
//BCU
// and (((c.fdegree <> 'MTTF1' and mid(c.fregno,3,2) = 19 or mid(c.fregno,3,2) = 18) and c.fexamno in('D','B')) or
// (c.fdegree = 'MTTF1' and (mid(c.fregno,3,2) = 18 || (mid(c.fregno,3,2) = 19 and c.fexamno ='B' ))))
}else{
$query = "CREATE TABLE tmpqpindsum
SELECT m.fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname,
s.fqpcode, s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt,
20 as fextra, ceil(COUNT(c.fregno) /5) * 5 as ftotal,
(ceil(COUNT(c.fregno) /5) * 5) + {$univcopy} as frounded,
GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
FROM qpmaster s, canddet c, candsum m, college g, degree d, candsum cs
WHERE s.fdegree = c.fdegree AND s.fexamno = c.fexamno
AND s.fsubcode = c.fsubcode AND c.fcollcode = m.fcollcode
and c.fdegree = m.fdegree and c.fcollcode = m.fcollcode and c.fregno = m.fregno
AND m.fcntrcode = g.fcollcode and ifnull(c.fpassmth,'') = ''
and ifnull(fthpr,'') <> 'T' and m.fdegree = d.fdegree and c.fexamno = d.fexamno
and d.fdeggrp = '{$deggrp}'
and c.fregno = cs.fregno and c.fdegree = cs.fdegree and c.fcollcode = cs.fcollcode
and INSTR(cs.fhtenable,c.fexamno) >0
and c.fyear = cs.fyear and c.fexamtype = cs.fexamtype
and c.fyear = '{$fyear}' and c.fexamtype = '{$fexamtype}'
GROUP BY s.fqpcode, m.fcntrcode
ORDER BY m.fcntrcode, s.fqpcode";
#and ((mid(c.fregno,2,2) = 18 and (c.fexamno ='D' || c.fexamno ='B')) || (mid(c.fregno,2,2) = 19 and c.fexamno = 'B'))
//BCU
// and (((c.fdegree <> 'MTTF1' and mid(c.fregno,3,2) = 19 or mid(c.fregno,3,2) = 18) and c.fexamno in('D','B')) or
// (c.fdegree = 'MTTF1' and (mid(c.fregno,3,2) = 18 || (mid(c.fregno,3,2) = 19 and c.fexamno ='B' ))))
}
$result1 = $aobj_context->pobj_db->Execute($query);
if($univcode == '023' || $univcode == '041')
{
$cnd = "'20'";
}else
{
$cnd = "if(SUM(q.frounded)<100,20,if(SUM(q.frounded)<200,40,if(SUM(q.frounded)<300,60,
if(SUM(q.frounded)<400,80, if(SUM(q.frounded) < 1000, 100, if(SUM(q.frounded) < 3000, 150,
if(SUM(q.frounded) < 5000, 200, if(SUM(q.frounded) < 10000, 250, 300))))))))";
}
$query = "CREATE TABLE tmpqpindtot
SELECT q.fdoe, q.fsession, q.fqpcode, q.fsubname, '' AS fdeg,
SUM(q.frounded) AS fforcoll, $cnd as fforuniv
FROM tmpqpindsum q
GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
ORDER BY q.fdoe, q.fsession, q.fqpcode";
$result2 = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE tmpqpinddeg
SELECT fqpcode, GROUP_CONCAT(DISTINCT fdegree ORDER BY fdegree) AS fdegree
FROM qpmaster
GROUP BY fqpcode
ORDER BY fqpcode";
$result3 = $aobj_context->pobj_db->Execute($query);
if($result1 && $result2 && $result3)
{
$arr['msg'] = 'QP Indent compiled successfully.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success");
}
else
{
$arr['msg'] = 'Error While QP Indent Compilation.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
|