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


Current Path : /var/www/misc/public_html/oums_old/phpscript/
Upload File :
Current File : /var/www/misc/public_html/oums_old/phpscript/home_note.php

<?php
	include("sys_connect.php");
	include("sys_mainphp.php");
	include("sys_session.php");	
	
	//birthday 
	$date1=date('m-d');
	if($type_id=='ADMIN')
	{
		$mysql="select * from masempl where right(femplbday,5)= '$date1' order by femplname";
	}
	elseif($type_id=='CHIEF')
	{
		$mysql="select * from masempl where right(femplbday,5)= '$date1' order by femplname";
	}
	elseif($type_id=='SUPER')
	{
		$mysql="select * from masempl where right(femplbday,5)= '$date1' order by femplname";
	}
	else
	{
		$mysql="select * from masempl where fdeptcode='$dept_id' and right(femplbday,5)= '$date1' order by femplname";
	}				
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	$mybday=mysqli_num_rows($myres);						
									
	//Movement 
	$strt_date=date('Y-m-d',strtotime("yesterday"));
	$mysql="select * from staffmove where left(fstrtdate,10) > '$strt_date' order by fstrtdate desc";
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	$mymove=mysqli_num_rows($myres);					

	//Task status
	$mysql="select * from taskreminder where ftaskasto='$empl_id' and ftaskstat='PENDING' and fdeleted<>'T' order by ftaskdate";
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	$mytask = mysqli_num_rows($myres);					

	//work status
	$mywork=0;	
	$strt_date = date('Y-m-01');
	$work_days = date('d');
	for ($i= 0; $i < $work_days; $i++) 
	{
		$work_date = date('Y-m-d',strtotime("+$i day", strtotime($strt_date)));
		$mysql = "select * from workentry where femplcode='$empl_id' and left(fworkdate,10)='$work_date'";
		$myres = mysqli_query($mycon,$mysql);
		$mycnt = mysqli_num_rows($myres);								
		if($mycnt==0)
		{
			$mywork++;
		}								
	}

	//attendance
	if($type_id=='ADMIN')
	{
		$mysql="select * from masdept where ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}
	elseif($type_id=='CHIEF')
	{
		$mysql="select * from masdept where fdepthead='$empl_id' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}
	elseif($type_id=='SUPER')
	{
		$mysql="select * from masdept where fdeptcode='$dept_id' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}
	else
	{
		$mysql="select * from masdept where fdeptcode='$dept_id' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}				
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	$myattn=0;
	while($row = mysqli_fetch_assoc($myres))
	{
		$dept_code= $row['fdeptcode']; 						
		$date1 = date('Y-m-01');
		$tdate = date('d');
		for ($i= 0; $i < $tdate; $i++) 
		{
			$date2 = date('Y-m-d',strtotime("+$i day", strtotime($date1)));
			$mysql1 = "select fdeptcode, count(*) as fattnentr from attendance where fdeptcode='$dept_code' and left(fattndate,10)='$date2'";
			$myres1 = mysqli_query($mycon,$mysql1);
			while($row1 = mysqli_fetch_assoc($myres1))
			{
				$attn_entr= $row1['fattnentr']; 
				if($attn_entr==0)
				{
					$myattn=$myattn+1;
				}
			}						
		}
	}											

	//salary 
	if($type_id=='ADMIN')
	{
		$mysql="select * from masdept where ifnull(fsalrcomp,'F')<>'F' and ifnull(fdeptstat,'')<>'F'order by fdeptname";
	}
	elseif($type_id=='CHIEF')
	{
		$mysql="select * from masdept where fdeptcode='$dept_id' and ifnull(fsalrcomp,'F')<>'F' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}
	elseif($type_id=='SUPER')
	{
		$mysql="select * from masdept where fdeptcode='$dept_id'  and ifnull(fsalrcomp,'F')<>'F' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}
	else
	{
		$mysql="select * from masdept where fdeptcode='' and ifnull(fsalrcomp,'F')<>'F' and ifnull(fdeptstat,'')<>'F' order by fdeptname";
	}				
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	$mysalr=0;
	while($row = mysqli_fetch_assoc($myres))
	{
		$dept_code= $row['fdeptcode']; 						
		$mnth1 = date('Y-m',strtotime("first day of last month"));
		$mysql1="select fdeptcode,count(*) as salcount from salary where fsalrmnth='$mnth1' and fdeptcode='$dept_code' order by fdeptcode";		
		$myres1 = mysqli_query($mycon,$mysql1);
		while($row1 = mysqli_fetch_assoc($myres1))
		{
			if($row1['salcount']==0)		
			{
				$dept_name=substr($row['fdeptname'],0,60);
				$mnth1=date('M-Y',strtotime($mnth1));
				$mysalr=$mysalr+1;
			}
		}						
	}

	//expenses	
	$myexpn = 0;
	if($type_id=='CHIEF')
	{
		$mysql ="select fdeptcode,femplcode,";
		$mysql.="sum(case when facnttype='receipt' then fexpnamnt end) as totl_recp, ";
		$mysql.="sum(case when facnttype='payment' then fexpnamnt end) as totl_payt from expenses ";
		$mysql.="where femplcode in (select femplcode from masempl where fdeptcode='$dept_id' and femplstat='T') ";
		$mysql.="group by fdeptcode,femplcode";
	}
	else
	{
		$mysql ="select fdeptcode,femplcode,";
		$mysql.="sum(case when facnttype='receipt' then fexpnamnt end) as totl_recp, ";
		$mysql.="sum(case when facnttype='payment' then fexpnamnt end) as totl_payt from expenses ";		
		$mysql.="where femplcode='$empl_id' group by fdeptcode,femplcode";		
	}
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	while($row = mysqli_fetch_assoc($myres))
	{
		$curr_date = date('d-M-Y');	
		$totl_baln = $row['totl_recp']-$row['totl_payt'];
		$totl_baln = number_format((float)$totl_baln,2,'.','');								
		$empl_name=get_empl_name($row['femplcode']);
		
		$mysql1="select fexpndate from expenses where femplcode='$row[femplcode]' order by fexpndate desc limit 1";
		$myres1 = mysqli_query($mycon,$mysql1);
		while($row1 = mysqli_fetch_assoc($myres1))
		{
			$curr_date = date('d-M-Y');	
			$expn_date = date('d-M-Y',strtotime($row1['fexpndate']));
		}				
		$myexpn = $myexpn + 1;
	}

	if($type_id=='ADMIN')
	{
		$mysql="select fdeptcode,sum(case when facnttype='receipt' then fexpnamnt end) as totl_recp, sum(case when facnttype='payment' then fexpnamnt end) as totl_payt from expenses group by fdeptcode";
	}
	elseif($type_id=='CHIEF')
	{
		$mysql="select fdeptcode,sum(case when facnttype='receipt' then fexpnamnt end) as totl_recp, sum(case when facnttype='payment' then fexpnamnt end) as totl_payt from expenses where fdeptcode='$dept_id' group by fdeptcode";
	}
	$myres = mysqli_query($mycon,$mysql) or die(mysqli_error($mycon));
	while($row = mysqli_fetch_assoc($myres))
	{
		$curr_date = date('d-M-Y');	
		$totl_baln = $row['totl_recp']-$row['totl_payt'];
		$totl_baln = number_format((float)$totl_baln,2,'.','');								
		$myexpn = $myexpn + 1;
	}
	
	//appraisals
	$myappr = 0;
													
	echo json_encode(array("bday"=>$mybday, "move"=>$mymove, "task"=>$mytask, "work"=>$mywork, "attn"=>$myattn, "salr"=>$mysalr, "appr"=>$myappr, "expn"=>$myexpn));	
?>