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


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

<?php

	//include 'database.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());
	}

	$commondb = "logisys3_comexam";
	ini_set('max_execution_time', 300);
	$sql = "select fdbname, funivcode,ffolder,ucase(FDBUSER) as FDBUSER 
	from {$commondb}.dbname where 
	ifnull(fdeleted,'') <> 'T' and ifnull(ftdvs,'') = 'T'"; 
	$result = mysqli_query($conn,$sql);

	if($result)
	{		
		while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
		{
			$db = $row['fdbname'];
			$univcode = $row['funivcode'];
			$ffolder = $row['FDBUSER'];

			//Room Allotment
			if($univcode == '051')
			{
				$sql1 = "insert ignore into {$db}.tdvs_tabsum (fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE)
						select  t.fqpcode,'1001',t.fregcode,'5',t.fyear,t.fexamtype,now() 
							from {$db}.tdvs_tabsum t inner join {$db}.tdvs_tabulate td on t.fregcode = td.fregcode
							and t.fqpcode = td.fqpcode and td.fyear = t.fyear and td.fexamtype = t.fexamtype
							inner join {$db}.subject s on t.fqpcode = s.fqpcode
							and s.fqpcode = td.fqpcode
							inner join {$db}.resmarksdet r on td.fregno = r.fregno
							and r.fsubcode = s.fcsubcode
							and r.fdegree = s.fdegree
							and r.fexamno = s.fexamno
							and t.fyear = r.fyear and t.fexamtype = r.fexamtype
							and td.fyear = r.fyear and td.fexamtype = r.fexamtype
							inner join tdvs_masqp m on s.fqpcode = m.fqpcode
							and t.fqpcode = m.fqpcode
							inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
							where t.fvalno = 'R'
							and ABS(if(ifnull(r.fvalsec,'') = '',r.fmarks, r.fvalsec)-t.fsysmarks) > ((m.fsmaxmarks/100)*dg.FDEVIATION)
							and t.fstatus = 'FINAL'";
				
				$result1 = mysqli_query($conn, $sql1);
			}

			if($univcode == "051")
            {
                $cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) > (((m.fsmaxmarks/100)*dg.FDEVIATION))";
                if ($FDEVSTATUS == "T"){
                    $cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) >= (((m.fsmaxmarks/100)*dg.FDEVIATION))";
                }
            }else
            {
                $cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) > round(((m.fsmaxmarks/100)*dg.FDEVIATION))";
                if ($FDEVSTATUS == "T"){
                    $cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) >= round(((m.fsmaxmarks/100)*dg.FDEVIATION))";
                }
            }

			$sql1 = "drop table {$db}.tdvs_deviation";
			$result1 = mysqli_query($conn, $sql1);
			if($univcode == "051")
			{
				$sql1 = "create table {$db}.tdvs_deviation
 						select t1.fqpcode as fqpcode, t1.fpacket as fpacket, t1.fregcode as fregcode, 'D' as fvalno, t1.fyear as fyear, 
						t1.fexamtype as fexamtype, NOW() as FUPDDATE
                        from {$db}.tdvs_masqp m 
                        inner join {$db}.tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
                        inner join {$db}.tdvs_tabsum t1 on m.fqpcode = t1.fqpcode and t1.fvalno = '1'
                        and t1.fstatus = 'FINAL'
                        inner join {$db}.tdvs_tabsum t2 on t1.fregcode = t2.fregcode 
                         and t1.fqpcode = t2.fqpcode
                        and m.fqpcode = t2.fqpcode and t2.fvalno = '2'
                       	 and t2.fstatus = 'FINAL'
                        where if(ifnull(FDEVSTATUS,'F') = 'T',(ABS(t1.fsysmarks-t2.fsysmarks)) >= (((m.fsmaxmarks/100)*dg.FDEVIATION)),(ABS(t1.fsysmarks-t2.fsysmarks)) > (((m.fsmaxmarks/100)*dg.FDEVIATION)))";
						$result1 = mysqli_query($conn, $sql1);
			}else
			{
				$sql1 = "create table {$db}.tdvs_deviation
 						select t1.fqpcode as fqpcode, t1.fpacket as fpacket, t1.fregcode as fregcode, 'D' as fvalno, t1.fyear as fyear, 
						t1.fexamtype as fexamtype, NOW() as FUPDDATE
                        from {$db}.tdvs_masqp m 
                        inner join {$db}.tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
                        inner join {$db}.tdvs_tabsum t1 on m.fqpcode = t1.fqpcode and t1.fvalno = '1'
                        and t1.fstatus = 'FINAL'
                        inner join {$db}.tdvs_tabsum t2 on t1.fregcode = t2.fregcode 
                         and t1.fqpcode = t2.fqpcode
                        and m.fqpcode = t2.fqpcode and t2.fvalno = '2'
                       	 and t2.fstatus = 'FINAL'
                        where if(ifnull(FDEVSTATUS,'F') = 'T',round(ABS(t1.fsysmarks-t2.fsysmarks)) >= round(((m.fsmaxmarks/100)*dg.FDEVIATION)),round(ABS(t1.fsysmarks-t2.fsysmarks)) > round(((m.fsmaxmarks/100)*dg.FDEVIATION)))";
						$result1 = mysqli_query($conn, $sql1);
			}

			$sql1 = "insert ignore into {$db}.tdvs_tabsum (fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE)
			select fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE from {$db}.tdvs_deviation";
			$result1 = mysqli_query($conn, $sql1);

			

		}
	}
	echo "success";	
?>