<?php
ini_set('display_errors','1');
error_reporting(E_ALL);
session_start();
include ('start.php');
#include ("include/auth_chk.inc.php");
require ('functions/base.functions.php');
#require ('functions/users.inc.php');
include ('classes/global.class.php');
#include ('classes/groups.class.php');
#include ("include/auth_chk.inc.php");
set_lang($_SESSION['lang']);
$login_type = new users();
if ($_SESSION['permissions']['admin'] !== "1"){
Header("Location: timesheet.php");
exit();
}
if(isset($_POST['user_index']) && isset($_POST['edit_user'])){
$query = new Users;
if(isset($_POST['ldap'])){ $ldap='Y';}else{$ldap='N';}
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->updateUser($_POST['user_index'],$_POST['login'],$_POST['real_name'],$_POST['group'],$status,$_POST['email'],$ldap,$_POST['password']);
Header("Location: users_setup.php");
exit();
}
if(isset($_POST['login']) && isset($_POST['add_user'])){
$query = new Users;
if(isset($_POST['ldap'])){ $ldap='Y';}else{$ldap='N';}
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->addUser($_POST['login'],$_POST['real_name'],$_POST['group'],$status,$_POST['email'],$ldap,$_POST['password'],$_POST['start']);
Header("Location: users_setup.php");
exit();
}
?><!-- Headers -->
<!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" xml:lang="en-us">
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
<link rel="stylesheet" href="js/addons/pager/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/themes/blue/style.css" type="text/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/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript">
$(document).ready(function()Â {Â
    $("#tablesorter")Â
    .tablesorter({widthFixed: true, widgets: ['zebra']})Â
    .tablesorterPager({container: $(".pager")});Â
});Â
</script>
<script type="text/javascript">
$(document).ready(function()Â {Â
$('.add_user_button').live('click',function(){
if ( $('.add_user').css('display') == 'block' ) $('.add_user').css({'display':'none'})
else $('.add_user').css({'display':'block'})
})
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('.button').live('click',function(){
var id = $(this).attr('id');
if($("."+id).is(":visible")){
$("."+id).hide();
}else{
$("."+id).show();
}
return(false); // disable normal anchor behavior
});
});
</script>
<title>Users Settings</title>
</head>
<body>
<?php
include ('include/menu.settings.inc.html');
$users=new Users;
$group=new Groups;
foreach($users->getUsersArray() as $id=>$value){
?>
<div class="<?php echo $id;?>" style=" width:40%;height: 300px;top: 20px; border: 1px solid black; left:30%;position:absolute; z-index:22;background: #F0F0F6;display:none;">
<div style="position:absolute; z-index:20;width:22px;height: 22px;top: -10px;right:-10px;"><a href="#" id="<?php echo $id;?>" class="button"><img style="border:0px;"src="images/button_cancel.png"></a></div>
<center><p>РедакÑиÑование даннÑÑ
:</p></center>
<form method='POST' action=''>
<table style='margin: 10px;'>
<tbody>
<tr><td style='width:30%;'>ÐмÑ</td><td><input type='text' name='real_name' maxlength="64" size='40' value="<?php echo $value['real_name']; ?>"></input></td></tr>
<tr><td>Ðогин</td><td><input type='text' name='login' maxlength="64" size='40' value='<?php echo $value['user_name'];?>'></input></td></tr>
<tr><td>ÐаÑолÑ</td><td><input type='password' name='password' maxlength="64" size='40'></input></td></tr>
<tr><td>Ldap</td><td>
<?php
if ($value['ldap'] == 'Y'){
echo "<input type='checkbox' name='ldap' value='Y' checked>";
}elseif($value['ldap'] == 'N'){
echo "<input type='checkbox' value='Y' name='ldap'>";
}
?>
</input></td></tr>
<tr><td>ÐÑÑппа</td><td><select name='group'>
<option selected value="<?php echo $value['group'];?>"><?php echo $group->getGroupName($value['group']);?></option>';
<?php
$groups=new Groups();
foreach ($groups->getGroupsArray('active') as $num=>$data){
if ($num != $value['group']){
echo '<option value="'.$num.'">'.$data['group_name'].'</option>';
}
}
?>
</select></td></tr>
<tr><td>СÑаÑÑÑ</td><td>
<?php
if ($value['status'] == 'Y'){
echo "<input type='checkbox' name='status' value='Y' checked>";
}elseif($value['status'] == 'N'){
echo "<input type='checkbox' name='status' value='Y'>";
}
?>
</input></td></tr>
<tr><td>Email</td><td><input type='text' name='email' maxlength="128" size='40' value='<?php echo $value['email'];?>'></input><td></td></tr>
</tbody>
</table>
<input type="hidden" name='user_index' value="<?php echo $id; ?>">
<center> <input type="submit" name='edit_user' value="ÐÐ" ></input></center>
</form>
</div>
<?php
}
?>
<div>
<table class="tablesorter" cellspacing="1" id="tablesorter" style="width:80%;">
<thead>
<tr>
<th>ÐмÑ</th>
<th>Ðогин</th>
<th>Ldap</th>
<th>ÐÑÑппа</th>
<th>СÑаÑÑÑ</th>
<th>Email</th>
<th>Start</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ÐмÑ</th>
<th>Ðогин</th>
<th>Ldap</th>
<th>ÐÑÑппа</th>
<th>СÑаÑÑÑ</th>
<th>Email</th>
<th>Start</th>
<th>Action</th>
</tr>
</tfoot>
<tbody>
<?php
#$users=new Users;
#$group=new Groups;
foreach($users->getUsersArray('active') as $id=>$value){
?>
<tr>
<td><?php echo $value['real_name'];?></td>
<td><?php echo $value['user_name'];?></td>
<td><?php echo $value['ldap'];?></td>
<td><?php echo $group->getGroupName($value['group']);?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['email'];?></td>
<td><?php echo $value['start'];?></td>
<td><a href="#" id="<?php echo $id;?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
</tr>
<?php
}
foreach($users->getUsersArray('nope') as $id=>$value){
?>
<tr>
<td><?php echo $value['real_name'];?></td>
<td><?php echo $value['user_name'];?></td>
<td><?php echo $value['ldap'];?></td>
<td><?php echo $group->getGroupName($value['group']);?></td>
<td><?php echo $value['status'];?></td>
<td><?php echo $value['email'];?></td>
<td><?php echo $value['start'];?></td>
<td><a href="#" id="<?php echo $id;?>" class="button"><img style="border: 0px;" src="images/edit.png"></img></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div id="pager" class="pager">
<form>
<img src="js/addons/pager/icons/first.png" class="first"/>
<img src="js/addons/pager/icons/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="js/addons/pager/icons/next.png" class="next"/>
<img src="js/addons/pager/icons/last.png" class="last"/>
<select class="pagesize">
<option selected="selected" value="20">20</option>
<option value="40">40</option>
</select>
</form>
</div>
</div>
<!-- Button 'New User' -->
<div class="" style=" width:50px;height: 50px;top: 50px; border: 0px; right:200px;position:absolute; z-index:10;">
<a href="#" id="add_user" class="add_user_button"><img style="border: 0px;" src="images/add_user_48.png"></a>
</div>
<!-- New User Windows -->
<div class="add_user" style=" width:40%;height: 300px;top: 20px; border: 1px solid black; left:30%;position:absolute; z-index:22;background: #F0F0F6;display:none;">
<div style="position:absolute; z-index:20;width:22px;height: 22px;top: -10px;right:-10px;"><a href="#" class="add_user_button"><img style="border:0px;"src="images/button_cancel.png"></a></div>
<center><p>ÐовÑй ÐолÑзоваÑелÑ:</p></center>
<form method='POST' action=''>
<table style='margin: 10px;'>
<tbody>
<tr><td style='width:30%;'>ÐмÑ</td><td><input type='text' name='real_name' maxlength="64" size='40'></input></td></tr>
<tr><td>Ðогин</td><td><input type='text' name='login' maxlength="64" size='40' ></input></td></tr>
<tr><td>ÐаÑолÑ</td><td><input type='password' name='password' maxlength="64" size='40'></input></td></tr>
<tr><td>Ldap</td><td><input type='checkbox' value='Y' name='ldap'></input></td></tr>
<tr><td>ÐÑÑппа</td><td><select name='group'>
<?php
foreach ($groups->getGroupsArray('active') as $num=>$data){
echo '<option selected value="'.$num.'">'.$data['group_name'].'</option>';
}
?>
</select></td></tr>
<tr><td>СÑаÑÑÑ</td><td><input type='checkbox' name='status' value='Y' checked></input></td></tr>
<tr><td>Email</td><td><input type='text' name='email' maxlength="128" size='40'></input><td></td></tr>
</tbody>
</table>
<input type="hidden" name='start' value="<?php echo date('Y-m-j'); ?>">
<center> <input type="submit" name='add_user' value="ÐÐ" ></input></center>
</form>
</div>