Show single group and there users almost done

This commit is contained in:
Quitta 2013-07-15 21:18:51 +02:00
parent 3553cc6cac
commit f0da13a60e
7 changed files with 150 additions and 5 deletions

View file

@ -8,6 +8,17 @@ class Support_Group{
////////////////////////////////////////////Functions////////////////////////////////////////////////////
//return all groups
public static function getGroup($id) {
$dbl = new DBLayer("lib");
$statement = $dbl->execute("SELECT * FROM support_group WHERE SGroupId = :id", array('id' => $id));
$row = $statement->fetch();
$instanceGroup = new self();
$instanceGroup->set($row);
return $instanceGroup;
}
//return all groups
public static function getGroups() {
$dbl = new DBLayer("lib");

View file

@ -31,6 +31,8 @@ t_send = "Send reply"
[show_queue]
[show_sgroup]
[sgroup_list]
group_success = "The group has been created!"
group_name_taken = "The groupname was already used!"

View file

@ -31,6 +31,8 @@ t_send = "Envoyer la reponse"
[show_queue]
[show_sgroup]
[sgroup_list]
group_success = "le group est cree!"
group_name_taken = "le nom pour le group est deja utilise!"

View file

@ -1,13 +1,11 @@
<?php
function sgroup_list(){
//if logged in & queue id is given
//if logged in
if(WebUsers::isLoggedIn()){
if( WebUsers::isAdmin()){
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName","getTag"), Array("sGroupId","name","tag"));
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";

View file

@ -0,0 +1,36 @@
<?php
function show_sgroup(){
//if logged in
if(WebUsers::isLoggedIn()){
if( WebUsers::isAdmin()){
if( isset($_GET['id'])){
$id = filter_var($_GET['id'],FILTER_SANITIZE_STRING);
$group = Support_Group::getGroup($id);
$result['groupsname'] = $group->getName();
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName","getTag"), Array("sGroupId","name","tag"));
return $result;
}else{
//ERROR: No page specified!
$_SESSION['error_code'] = "404";
header("Location: index.php?page=error");
exit;
}
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}

View file

@ -34,7 +34,6 @@
</div>
<input type="hidden" name="function" value="add_sgroup">
<input type="hidden" name="target_id" value="{$target_id}">
<div class="control-group">
<label class="control-label"></label>
@ -92,7 +91,7 @@
{foreach from=$grouplist item=group}
<tr>
<td>{$group.sGroupId}</td>
<td><a href ="index.php?page=show_group&id={$group.sGroupId}">{$group.name}</a></td>
<td><a href ="index.php?page=show_sgroup&id={$group.sGroupId}">{$group.name}</a></td>
<td class="center"><span class="label label-important" >{$group.tag}</span></td>
<td class="center"><a class="btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Delete</a></td>
</tr>

View file

@ -0,0 +1,97 @@
{block name=content}
<div class="row-fluid sortable ui-sortable">
<div class="box span12">
<div class="box-header well" data-original-title="">
<h2><i class="icon-plus-sign"></i> Add User</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<div class="row-fluid">
<form id="addSGroup" class="form-vertical" method="post" action="index.php">
<legend>Add a user to the group '{$groupsname}'</legend>
<div class="control-group" style="display: inline-block; ">
<label class="control-label">username</label>
<div class="controls">
<div class="input-prepend">
<input type="text" maxlength="15" id="Name" name="Name">
</div>
</div>
</div>
<input type="hidden" name="function" value="add_user_to_sgroup">
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button type="submit" class="btn btn-primary" >Add</button>
</div>
</div>
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
<div class="alert alert-success">
{$group_success}
</div>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"}
<div class="alert alert-warning">
{$group_name_taken}
</div>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"}
<div class="alert alert-warning">
{$group_tag_taken}
</div>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"}
<div class="alert alert-warning">
{$group_size_error}
</div>
{/if}
</form>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
<div class="row-fluid sortable ui-sortable">
<div class="box span12">
<div class="box-header well" data-original-title="">
<h2><i class="icon-list"></i>{$groupsname} List</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<div class="row-fluid">
<legend>All support groups</legend>
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{foreach from=$grouplist item=group}
<tr>
<td>{$group.sGroupId}</td>
<td><a href ="index.php?page=show_group&id={$group.sGroupId}">{$group.name}</a></td>
<td class="center"><span class="label label-important" >{$group.tag}</span></td>
<td class="center"><a class="btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Delete</a></td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}