<?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();
}
#add group action
if(isset($_POST['add_group']) && isset($_POST['group_name'])){
$query = new Groups;
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->addGroup($_POST['group_name'],$_POST['owner_id'],$status,$_POST['note']);
Header("Location: groups.php");
exit();
}
#update group action
if(isset($_POST['edit_group']) && isset($_POST['gid'])){
$query = new Groups;
if(isset($_POST['status'])){ $status='Y';}else{$status='N';}
$query->updateGroup($_POST['gid'],$_POST['group_name'],$_POST['owner_id'],$status,$_POST['note']);
Header("Location: groups.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(){
$('.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>
<script type="text/javascript">
$(document).ready(function()Â {Â
$('.add_group_button').live('click',function(){
if ( $('.add_group').css('display') == 'block' ) $('.add_group').css({'display':'none'})
else $('.add_group').css({'display':'block'})
})
});
</script>
<title>Group Settings</title>
</head>
<body>
<?php
include ('include/menu.settings.inc.html');
?>
<?php
$groups = new Groups;
$users = new Users;
foreach ($groups->getGroupsArray() as $id=>$data){
?>
<script type="text/javascript">
$(document).ready(function()Â {Â
$('.<?php echo $id; ?>_key').live('click',function(){
if ( $('.<?php echo $id; ?>').css('display') == 'block' ) $('.<?php echo $id; ?>').css({'display':'none'})
else $('.<?php echo $id; ?>').css({'display':'block'})
})
});
</script>
<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%;'><?php echo gettext('group name');?></td><td><input type='text' name='group_name' maxlength="64" size='40' value="<?php echo $data['group_name']; ?>"></input></td></tr>
<tr><td><?php echo gettext('status');?></td><td>
<?php
if ($data['status'] == 'Y'){
echo "<input type='checkbox' name='status' value='Y' checked>";
}elseif($data['status'] == 'N'){
echo "<input type='checkbox' value='Y' name='status'>";
}
?>
</input></td></tr>
<tr><td><?php echo gettext('owner');?></td><td><select name='owner_id'>
<option selected value="<?php echo $data['owner_id'];?>"><?php echo $users->getRealName($data['owner_id']);?></option>
<?php
foreach ($users->getUsersbyType('dm') as $uid=>$value){
if ($uid != $data['owner_id'] && $value['status'] != 'N'){
echo '<option value="'.$uid.'">'.$value['real_name'].'</option>';
}
}
?>
</select></td></tr>
<tr><td><?php echo gettext('description');?></td><td><textarea rows="4" cols="40" name='note'><?php echo $value['note'];?></textarea></td></tr>
</tbody>
</table>
<input type="hidden" name='gid' value="<?php echo $id; ?>">
<center> <input type="submit" name='edit_group' value="ÐÐ" ></input></center>
</form>
</div>
<?php
}
?>
<table class="tablesorter" cellspacing="1" id="tablesorter" style="width:80%;">
<thead>
<tr>
<th style="width:20%;"><?php echo gettext('group name');?></th>
<th style="width:5%;"><?php echo gettext('status');?></th>
<th style="width:25%;"><?php echo gettext('group owner');?></th>
<th style="width:45%;"><?php echo gettext('description');?></th>
<th style="width:5%;"><?php echo gettext('action');?></th>
</tr>
</thead>
<tfoot>
<tr>
<th style="width:20%;"><?php echo gettext('group name');?></th>
<th style="width:5%;"><?php echo gettext('status');?></th>
<th style="width:25%;"><?php echo gettext('group owner');?></th>
<th style="width:45%;"><?php echo gettext('description');?></th>
<th style="width:5%;"><?php echo gettext('action');?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($groups->getGroupsArray() as $id=>$data){
if ($data['status'] == 'Y') {
echo '<tr>';
echo '<td>'.$data['group_name'].'</td>';
echo '<td>'.$data['status'].'</td>';
echo '<td>'.$users->getRealName($data['owner_id']).'</td>';
echo '<td>'.$data['note'].'</td>';
echo '<td><a href="#" class="'.$id.'_key"><img style="border: 0px;" src="images/edit.png"></a></td>';
echo '</tr>';
}
}
foreach ($groups->getGroupsArray() as $id=>$data){
if ($data['status'] == 'N') {
echo '<tr>';
echo '<td>'.$data['group_name'].'</td>';
echo '<td>'.$data['status'].'</td>';
echo '<td>'.$users->getRealName($data['owner_id']).'</td>';
echo '<td>'.$data['note'].'</td>';
echo '<td><a href="#" id="'.$id.'" class="button"><img style="border: 0px;" src="images/edit.png"></a></td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
<div id="pager" class="pager">
<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>
<option value="60">60</option>
</select>
</div>
<!-- Button 'New GROUP' -->
<div class="" style=" width:50px;height: 50px;top: 50px; border: 0px; right:80px;position:absolute; z-index:10;">
<a href="#" id="add_group" class="add_group_button"><img style="border: 0px;" src="images/add_user_48.png"></a>
</div>
<div class="add_group" 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_group_button"><img style="border:0px;"src="images/button_cancel.png"></a></div>
<center><p><?php echo gettext('add group');?></p></center>
<form method='POST' action=''>
<table style='margin: 10px;'>
<tbody>
<tr><td style='width:30%;'><?php echo gettext('group name');?></td><td><input type='text' name='group_name' maxlength="64" size='40'></input></td></tr>
<tr><td><?php echo gettext('status');?></td><td>
<input type='checkbox' name='status' value='Y' checked>
</input></td></tr>
<tr><td><?php echo gettext('owner');?></td><td><select name='owner_id'>
<?php
#$groups=new Groups();
foreach ($users->getUsersbyType('dm') as $uid=>$value){
if ($value['status'] != 'N'){
echo '<option value="'.$uid.'">'.$value['real_name'].'</option>';
}
}
?>
</select></td></tr>
<tr><td><?php echo gettext('description');?></td><td><textarea rows="4" cols="40" name='note'></textarea></td></tr>
</tbody>
</table>
<center> <input type="submit" name='add_group' value="ÐÐ" ></input></center>
</form>
</div>
<?php
include ('end.php');
?>