Location: PHPKode > projects > Opensheet > opensheet/users_projects.php
<?php



ini_set('display_errors','1');
error_reporting(E_ALL);
session_start();
include ('start.php');
require ('functions/base.functions.php');
include ('classes/global.class.php');


	set_lang($_SESSION['lang']);
	$login_type = new users();
		if ($_SESSION['permissions']['admin'] !== "1"){
		Header("Location: timesheet.php");
					exit();

		}
		
if(isset($_POST['users']) && isset($_POST['pid'])){
$pid = $_POST['pid'];	
$users = new Users;
$projectHours = new Projects();
$uids = $users->getUsersArray('active');
$uidtemp = $_POST['users'];
$uidToStay = array();
	foreach($uidtemp as $num=>$uid){
		$uidInproject[$uid]=array('status'=>'Y');
	}

	foreach($uids as $uid=>$data){
		if(isset($uidInproject[$uid])){
				$to_base[$uid]= array('status' => 'Y');
			}else{
				$hours = $projectHours->getPrjUsrSummMonth($pid,$uid,date('Y'),date('m') );
				if(is_null($hours[$pid]['summ']) || $hours[$pid]['summ'] == NULL || $hours[$pid]['summ'] == 0){
					$to_base[$uid]= array('status' => 'N');
					}	else {	
					$uidToStay[$uid] = array('have_hours'=>'Y'); 
				}
			
			}
		}
		
	foreach($to_base as $uid=>$value){
		
		$users->updateProjectStatus($uid,$pid,$value['status']);
	} 	
	$send = serialize($uidToStay);
	Header("Location: users_projects.php?pid=$pid&data=$send");
	exit();
}

if(isset($_POST['project_id']) && isset($_POST['flush_hours_per_user'])){
	$pid = $_POST['project_id'];
	$year = date('Y');
	$month = date('m');
	$days = date('t');
	$days++;
	$users = $_POST['users'];
	$query = new Timesheet;
	$array = array();
	
	
	foreach($users as $uid=>$action) {
			for($day=1;$day<$days;$day++){
				$array['projects'][$pid][$day]= "";
				
			}
		$query->setHours($uid,$array,$year,$month);
	}
	

 	
 		Header("Location: users_projects.php?pid=$pid");
					exit();
}




?><!-- Headers -->
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link   rel="stylesheet" type="text/css" href="css/multiselect.common.css"  />
<link   rel="stylesheet" type="text/css" href="css/ui.multiselect.css" />
<link   rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
<link   type="text/css" rel="stylesheet" href="css/south-street/jquery-ui-1.7.1.custom.css" />
<link   rel="stylesheet" type="text/css" href="css/green/style.css"  media="print, projection, screen" />

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="js/ui.multiselect.js"></script>
<script type="text/javascript" src="js/plugins/localisation/jquery.localisation-min.js"></script>

<script type="text/javascript">


$(function(){
		$('.show_error_close').live('click',function(){ 
			 if ( $('.show_error').css('display') == 'block' )  $('.show_error').css({'display':'none'}) 
			 else $('.show_error').css({'display':'block'})
		})
});	
</script>

<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->
<script type="text/javascript">
$(function(){
	$.localise('ui-multiselect', {/*language: 'en',*/ path: 'js/locale/'});
	$(".multiselect").multiselect();

});
</script>


<title>Users in Projects</title>


</head>
<body>
<?php
include ('include/menu.settings.inc.html');
#get project id
$pid = $_GET['pid'];
$send =  $_GET['data'];
$send = unserialize(stripslashes($send)); #Get error while we try to remove users with hours in a base

#print_r(unserialize(stripslashes($send)));
#$data = unserialize($send);

#print_r($data);

$users =  new Users;
$usersListActive = $users->getProjectUsers($pid);
asort($usersListActive);
#print_r($users->getProjectUsers($pid));
?>
<form action="" method="POST">
      <select id="users" class="multiselect" multiple="multiple" name="users[]">
<?php 
foreach ($usersListActive as $num=>$data){
}
		foreach ($usersListActive as $num=>$data){
			echo '<option value="'.$data['user_id'].'" selected="selected">'.$data['real_name'].'</option>';
			$projectUids[$data['user_id']]= array('status'=>'Y');
			}

	foreach ($users->getUsersArray('active') as $uid=>$value){
			if(!isset($projectUids[$uid])) {	echo '<option value="'.$uid.'">'.$value['real_name'].'</option>';}
	}




$project = new Projects;
$project_vars = $project->getProjectVars($pid);
?>
</select>
      <br/>
      <input type="hidden" value="<?php echo $pid;?>" name="pid"/>
     <center> <input type="submit" value="<?php echo gettext('GO');?>"/></center>
    </form>


<!-- Project desc -->
<div class="project" style=" width:200px;height: 450px;top: 50px; border: 1px solid black; right:50px;position:absolute; z-index:22;background: #F0F0F6;">
<center><p><?php echo gettext('project');?>:</p></center>

<table style='margin: 10px;'>
<tbody>

<tr><td style='width:30%;'><?php echo $project_vars['proj_name'];?></td></tr>
<tr><td style='width:30%;'><br></td></tr>
<tr><td style='width:30%;'><?php echo gettext('Index');?>:</td></tr>
<tr><td style='width:30%;'><?php echo $project_vars['proj_index'];?></td></tr>
<tr><td style='width:30%;'><br></td></tr>
<tr><td style='width:30%;'><?php echo gettext('type');?>:</td></tr>
<tr><td style='width:30%;'><?php echo $project_vars['proj_type'];?></td></tr>
<tr><td style='width:30%;'><br></td></tr>
<tr><td style='width:30%;'><?php echo gettext('owner');?>:</td></tr>
<tr><td style='width:30%;'><?php echo $users->getRealName($project_vars['owner_id']);?></td></tr>
<tr><td style='width:30%;'><br></td></tr>
<tr><td style='width:30%;'><?php echo gettext('start');?>:</td></tr>
<tr><td style='width:30%;'><?php echo $project_vars['start'];?></td></tr>
<tr><td style='width:30%;'><br></td></tr>
<tr><td style='width:30%;'><?php echo gettext('note');?>:</td></tr>
<tr><td style='width:30%;'><?php echo $project_vars['note'];?></td></tr>
</tbody>
</table>

</div>

<!-- Error Message -->
<?php 
if (isset($send) && $send != NULL){
?>
<div class="show_error" style=" width:30%;height: 450px;top: 70px; border: 1px solid black; right:35%;position:absolute; z-index:122;background: #F0F0F6;display: block;">
<div style="position:absolute; z-index:123;width:22px;height: 22px;top: -10px;right:-10px;"><a href="#"  class="show_error_close"><img style="border:0px;"src="images/button_cancel.png"></a></div>

<center><p><?php echo gettext('show_error_while_removing_user_from_project');?>:</p></center>
<p><?php echo gettext('To keep our base You need to choose:');?>:</p>
<p><?php echo gettext('1: Keep this user in this project,press Cancel button');?>:</p>
<p><?php echo gettext('2: Flush user this months hours');?>:</p>


<form method='POST' action=''>
<table style='margin: 10px;width:100%;'>
<tbody>
<?php foreach($send as $uid=>$trash){ ?>

<tr><td style='width:80%;'><?php echo $users->getRealName($uid);?></td>
<td><input type='checkbox' name='users[<?php echo $uid;?>]' value='Y' checked></input></td>

</tr>
<?php } ?>
</tbody></table>
<input type='hidden' name='project_id' value='<?php echo $pid;?>'>
<center> <input type="submit" name='flush_hours_per_user' value="Flush" ></input></center>
</form>


</div>
<?php }   ?>

</body>
</html>
Return current item: Opensheet