<?php require_once('../Connections/oprmConn.php'); 



if($_REQUEST['from']==1) {



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf1 = "update weby_profiles set hr_rate = '$_REQUEST[hr_rate]' where user_id = '$_REQUEST[user]'";



$getProf1 = mysql_query($query_getProf1, $oprmConn) or die(mysql_error());



}







if($_REQUEST['from']==3) {



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf1 = "update weby_users_projects set status = 'D' where user_id = '$_REQUEST[user]' and project_id = '$_REQUEST[pid]'"; 



$getProf1 = mysql_query($query_getProf1, $oprmConn) or die(mysql_error());







$q = "SELECT DISTINCT a.full_name, b.project_name, c.email_address



FROM weby_profiles a, weby_users c, weby_projects b, weby_users_projects d



WHERE d.project_id = b.projetc_id



AND c.user_id = d.user_id



AND a.user_id = c.user_id and c.user_id = '$_REQUEST[user]' and d.project_id = '$_REQUEST[pid]'";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = $q;



$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());



$row_getProj = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);







// send email to new user along with registration details.



	$user_email = $row_getProj['email_address'];



    $headers = 'MIME-Version: 1.0' . "\r\n";



       $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



       $headers .= "From: SS WEB TECHNOLOGIES<mailsendinfo@SS WEB TECHNOLOGIES>" . "\r\n" ;



	$subject = "SS WEB TECHNOLOGIES- Project Assignation Removed.";



	$body = "Hi $row_getProj[full_name],<br>This is to inform you that your below assignation to the project has been removed by the admin. <br>



	==================================================================<br>



	Project Name: $row_getProj[project_name]<br>



	==================================================================<br>



	If you have any queries, please contact admin.



	<br>



	Thanks,<br>



	SS WEB TECHNOLOGIES";



	mail($user_email, $subject, $body, $headers);







$l = "resources-view.php?user_id=$_REQUEST[user]&msg=Project removed successfully";





}











if($_REQUEST['from']==2) {

mysql_select_db($database_oprmConn, $oprmConn);

// $query_updateleaves = "update weby_users set total_leaves = '{$_REQUEST[total_leaves]}', performance_notes = '{$_REQUEST[performance_notes]}' where user_id = '{$_REQUEST[user]}'";
$query_updateleaves = "UPDATE weby_users SET total_leaves = '$_REQUEST[total_leaves]' WHERE user_id = '$_REQUEST[user]'";
$updateleaves = mysql_query($query_updateleaves, $oprmConn) or die(mysql_error());

$query_weeklyhours = "UPDATE weby_users SET weekly_hrs = '$_REQUEST[weekly_hrs]' WHERE user_id = '$_REQUEST[user]'";
$weeklyhours= mysql_query($query_weeklyhours, $oprmConn) or die(mysql_error());

$query_updatenotes = "UPDATE weby_users SET performance_notes = '$_REQUEST[performance_notes]' WHERE user_id = '$_REQUEST[user]'";
$updatenotes = mysql_query($query_updatenotes, $oprmConn) or die(mysql_error());

$query_updateOLDADDRESS = "UPDATE weby_profiles SET old_address = '$_REQUEST[old_address]' WHERE user_id = '$_REQUEST[user]'";
$updateOLDADDRESS = mysql_query($query_updateOLDADDRESS, $oprmConn) or die(mysql_error());

// $query_updateperformance_notes = "update weby_profiles set performance_notes = '$_REQUEST[performance_notes]' where user_id = '$_REQUEST[user]'";

// $updateperformance_notes = mysql_query($query_updateperformance_notes, $oprmConn) or die(mysql_error());
$msg = 'User activity Updated.';

$q = "select * FROM weby_users where user_id = '$_REQUEST[user]' and status = '$_REQUEST[status]'";

mysql_select_db($database_oprmConn, $oprmConn);

$query_getProj = $q;

$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());

$row_getProj = mysql_fetch_assoc($getProj);

$totalRows_getProj = mysql_num_rows($getProj);

mysql_select_db($database_oprmConn, $oprmConn);

$query_getserial = "select * FROM weby_users where user_id = '$_REQUEST[user]'";

$getserial = mysql_query($query_getserial, $oprmConn) or die(mysql_error());

$row_getserial = mysql_fetch_assoc($getserial);

if($row_getserial['employee_id'] == ''){

mysql_select_db($database_oprmConn, $oprmConn);

$query_getserialno = "select max(employee_id) as empid FROM weby_users";

$getserialno = mysql_query($query_getserialno, $oprmConn) or die(mysql_error());

$row_getserialno = mysql_fetch_assoc($getserialno);

$empid = $row_getserialno['empid'];

$employeeid = $empid+1;

}else{ $employeeid = $row_getserial['employee_id']; }

if($totalRows_getProj < 1) {



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf1 = "update weby_users set status = '$_REQUEST[status]', employee_id = '$employeeid' where user_id = '$_REQUEST[user]'";



$getProf1 = mysql_query($query_getProf1, $oprmConn) or die(mysql_error());







$q = "SELECT DISTINCT a.full_name, c.email_address



FROM weby_profiles a, weby_users c



WHERE a.user_id = c.user_id and c.user_id = '$_REQUEST[user]'";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = $q;



$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());



$row_getProj = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);







// send email to new user along with registration details.



	$user_email = $row_getProj['email_address'];



    $headers = 'MIME-Version: 1.0' . "\r\n";



       $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



       $headers .= "From: SS WEB TECHNOLOGIES<mailsendinfo@SS WEB TECHNOLOGIES>" . "\r\n" ;



	   $s = "InActive";



	   if($_REQUEST['status']=="A")



	   $s = "Active";



	   if($_REQUEST['status']=="P")



	   $s = "Pending";



	   if($_REQUEST['status']=="D")



	   $s = "Deleted";



	   



	$subject = "SS WEB TECHNOLOGIES- Accouunt Status Changed to $s .";



	$body = "Hi $row_getProj[full_name],<br>This is to inform you that your Account status has been changed to below status. <br>



	==================================================================<br>



	Resource Name: $row_getProj[full_name]<br>



	Status: $s<br>



	==================================================================<br>



	If you have any queries, please contact admin.



	<br>



	Thanks,<br>



	SS WEB TECHNOLOGIES";



	mail($user_email, $subject, $body, $headers);

$msg = "User activity Updated";

}







if($_REQUEST['project_name']>0) {



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf = "SELECT  * FROM weby_users_projects WHERE user_id = '$_REQUEST[user]' AND project_id = '$_REQUEST[project_name]' and status = 'A'";



$getProf = mysql_query($query_getProf, $oprmConn) or die(mysql_error());



$row_getProf = mysql_fetch_assoc($getProf);



$totalRows_getProf = mysql_num_rows($getProf);







if($totalRows_getProf < 1) {



$q = "INSERT INTO weby_users_projects (`user_proj_id`, `project_id`, `user_id`, `status`, `created_by`, `created_date`, `updated_by`, `updated_date`) VALUES ('NULL', '$_REQUEST[project_name]', '$_REQUEST[user]', 'A', '$_SESSION[user_id]', '$_REQUEST[date]', '$_SESSION[user]', CURRENT_TIMESTAMP)";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf11 = $q;



$getProf11 = mysql_query($query_getProf11, $oprmConn) or die(mysql_error());







$q = "SELECT DISTINCT a.full_name, b.project_name, c.email_address



FROM weby_profiles a, weby_users c, weby_projects b



WHERE b.projetc_id = '$_REQUEST[project_name]'



AND a.user_id = c.user_id and c.user_id = '$_REQUEST[user]'";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = $q;



$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());



$row_getProj = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);







// send email to new user along with registration details.



	$user_email = $row_getProj['email_address'];



    $headers = 'MIME-Version: 1.0' . "\r\n";



       $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



       $headers .= "From: SS WEB TECHNOLOGIES<mailsendinfo@SS WEB TECHNOLOGIES>" . "\r\n" ;



	$subject = "SS WEB TECHNOLOGIES- Project Assignation Added.";



	$body = "Hi $row_getProj[full_name],<br>This is to inform you that your below assignation to the project has been activated by the admin. <br>



	==================================================================<br>



	Project Name: $row_getProj[project_name]<br>



	==================================================================<br>



	If you have any queries, please contact admin.



	<br>



	Thanks,<br>



	SS WEB TECHNOLOGIES";



	mail($user_email, $subject, $body, $headers);

$msg = "New Project added successfully";

}







}

if($msg==""){	$msg = "Current changes are already exist";} else { $msg = $msg;}if($_REQUEST['status']=='D'){	$l = "resources-list.php?msg=User deleted successfully";} else {	$l = "resources-view.php?user_id=$_REQUEST[user]&msg=$msg";}

}

















if($_REQUEST['from']==4) {



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProf11 = "update weby_timesheets set status = '$_REQUEST[status]' where timesheet_id = '$_REQUEST[tid]'";



$getProf11 = mysql_query($query_getProf11, $oprmConn) or die(mysql_error());







mysql_select_db($database_oprmConn, $oprmConn);



$q = "SELECT weby_profiles.full_name,weby_timesheets.created_date, weby_timesheets.timesheet_id, weby_timesheets.project_id, weby_timesheets.total_hrs, weby_timesheets.hr_rate, weby_timesheets.total_amount, weby_timesheets.status, weby_timesheetstatus.status_label, weby_projects.project_name, weby_users.email_address FROM weby_timesheets, weby_profiles, weby_projects , weby_users, weby_timesheetstatus WHERE weby_timesheets.timesheet_id = '$_REQUEST[tid]' and weby_timesheets.user_id = weby_profiles.user_id and weby_users.user_id = weby_profiles.user_id AND weby_profiles.user_id =weby_timesheets.user_id AND weby_projects.projetc_id = weby_timesheets.project_id and weby_timesheetstatus.status_key = weby_timesheets.status";



mysql_select_db($database_oprmConn, $oprmConn);



$query_getProj = $q;



$getProj = mysql_query($query_getProj, $oprmConn) or die(mysql_error());



$row_getTime = mysql_fetch_assoc($getProj);



$totalRows_getProj = mysql_num_rows($getProj);







 $s = $row_getTime['status_label'];



 $d = date('d/m/Y', strtotime($row_getTime['created_date']));







// send email to new user along with registration details.



	$user_email = $row_getTime['email_address'];

	

    $headers = 'MIME-Version: 1.0' . "\r\n";



       $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



       $headers .= "From:  $SERVER_EMAIL" . "\r\n" ;



	$subject = "SS WEB TECHNOLOGIES- Time sheet status changed to $s.";



	$body = "Hi $row_getTime[full_name],<br><br>This is to inform you that your timesheet id $row_getTime[timesheet_id] dated $d total hours $row_getTime[total_hrs] of project $row_getTime[project_name] has been $s by the admin.<br>





<br>



	If you have any queries, please contact admin.



	<br>



	Thanks,<br>



	SS WEB TECHNOLOGIES";



	mail($user_email, $subject, $body, $headers);



	



$l = "index.php?msg=Timesheet Status Uploaded";



}



header("Location: $l");







?>







<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">



<head>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<title>Untitled Document</title>



</head>







<body>



</body>



</html>



