reworked admin_user again

This commit is contained in:
Jan-Philipp Litza 2012-12-27 17:32:14 +01:00
parent b01ab50367
commit 3af1d09d61
7 changed files with 60 additions and 97 deletions

View File

@ -281,93 +281,65 @@ function admin_user() {
if (!isset ($_GET["OrderBy"])) if (!isset ($_GET["OrderBy"]))
$_GET["OrderBy"] = "Nick"; $_GET["OrderBy"] = "Nick";
$SQL = "SELECT * FROM `User` ORDER BY `" . sql_escape($_GET["OrderBy"]) . "` ASC"; $SQL = "SELECT * FROM `User` ORDER BY `" . sql_escape($_GET["OrderBy"]) . "` ASC";
$Erg = sql_query($SQL); $angels = sql_select($SQL);
// anzahl zeilen // anzahl zeilen
$Zeilen = mysql_num_rows($Erg); $Zeilen = count($angels);
$html .= "Anzahl Engel: $Zeilen<br /><br />\n"; $html .= "Anzahl Engel: $Zeilen<br /><br />\n";
$html .= '<table width="100%" class="border" cellpadding="2" cellspacing="1"> <thead>
<tr class="contenttopic">
<th>
<a href="' . page_link_to("admin_user") . '&OrderBy=Nick">Nick</a>
</th>
<th><a href="' . page_link_to("admin_user") . '&OrderBy=Vorname">Vorname</a> <a href="' . page_link_to("admin_user") . '&OrderBy=Name">Name</a></th>
<th><a href="' . page_link_to("admin_user") . '&OrderBy=DECT">DECT</a></th>
<th><a href="' . page_link_to("admin_user") . '&OrderBy=Alter">Alter</a></th>
<th><a href="' . page_link_to("admin_user") . '&OrderBy=email">E-Mail</a></th>
<th class="rotate"><div><a href="' . page_link_to("admin_user") . '&OrderBy=Gekommen">Gekommen</a></div></th>
<th class="rotate"><div><a href="' . page_link_to("admin_user") . '&OrderBy=Aktiv">Aktiv</a></div></th>
<th class="rotate"><div><a href="' . page_link_to("admin_user") . '&OrderBy=Tshirt">T-Shirt</a></div></th>
<th class="rotate"><div><a href="' . page_link_to("admin_user") . '&OrderBy=Size">Gr&ouml;&szlig;e</a></div></th>
<th><a href="' . page_link_to("admin_user") . '&OrderBy=lastLogIn">Last login</a></th>
<th>Edit</th>
</tr></thead>';
$Gekommen = 0;
$Active = 0;
$Tshirt = 0;
for ($n = 0; $n < $Zeilen; $n++) { function prepare_angel_table($angel) {
$title = ""; global $privileges;
$user_groups = sql_select("SELECT * FROM `UserGroups` JOIN `Groups` ON (`Groups`.`UID` = `UserGroups`.`group_id`) WHERE `UserGroups`.`uid`=" . sql_escape(mysql_result($Erg, $n, "UID")) . " ORDER BY `Groups`.`Name`"); $groups = sql_select_single_col("SELECT `Name` FROM `UserGroups` JOIN `Groups` ON (`Groups`.`UID` = `UserGroups`.`group_id`) WHERE `UserGroups`.`uid`=" . sql_escape($angel["UID"]) . " ORDER BY `Groups`.`Name`");
$groups = array (); $popup = '<div class="hidden">Groups: ' . implode(', ', $groups);
foreach ($user_groups as $user_group) { if (strlen($angel["Telefon"]) > 0)
$groups[] = $user_group['Name']; $popup .= "<br>Tel: " . $angel["Telefon"];
if (strlen($angel["Handy"]) > 0)
$popup .= "<br>Handy: " . $angel["Handy"];
if (strlen($angel["DECT"]) > 0)
$popup .= "<br>DECT: " . $angel["DECT"];
if (strlen($angel["Hometown"]) > 0)
$popup .= "<br>Hometown: " . $angel["Hometown"];
if (strlen($angel["CreateDate"]) > 0)
$popup .= "<br>Registered: " . $angel["CreateDate"];
if (strlen($angel["Art"]) > 0)
$popup .= "<br>Type: " . $angel["Art"];
if (strlen($angel["ICQ"]) > 0)
$popup .= "<br>ICQ: " . $angel["ICQ"];
if (strlen($angel["jabber"]) > 0)
$popup .= "<br>Jabber: " . $angel["jabber"];
return array(
'Nick' => in_array('user_shifts_admin', $privileges)? '<a href="' . page_link_to("user_myshifts") . '&amp;id=' . $angel["UID"] . '">' . htmlspecialchars($angel["Nick"]) . '</a>' : htmlspecialchars($angel['Nick']),
'Name' => htmlspecialchars($angel['Vorname'] . ' ' . $angel['Name']),
'DECT' => htmlspecialchars($angel['DECT']),
'Alter' => htmlspecialchars($angel['Alter']),
'email' => '<a href="mailto:' . htmlspecialchars($angel['email']) . '">' . htmlspecialchars($angel['email']) . '</a>' . $popup,
'Gekommen' => '<img src="pic/icons/' . ($angel['Gekommen'] == 1? 'tick' : 'cross') . '.png" alt="' . $angel['Gekommen'] . '">',
'Aktiv' => '<img src="pic/icons/' . ($angel['Aktiv'] == 1? 'tick' : 'cross') . '.png" alt="' . $angel['Aktiv'] . '">',
'Tshirt' => '<img src="pic/icons/' . ($angel['Tshirt'] == 1? 'tick' : 'cross') . '.png" alt="' . $angel['Tshirt'] . '">',
'Size' => $angel['Size'],
'lastLogIn' => date('d.m.&\n\b\s\p;H:i', $angel['lastLogIn']),
'edit' => '<a href="' . page_link_to("admin_user") . '&amp;id=' . $angel["UID"] . '"><img src="pic/icons/pencil.png" alt="' . Get_Text('Edit') . '" title="' . Get_Text('Edit') . '"></a>',
);
} }
$title .= 'Groups: ' . join(", ", $groups) . "<br />"; $angels = array_map('prepare_angel_table', $angels);
if (strlen(mysql_result($Erg, $n, "Telefon")) > 0) $Gekommen = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1");
$title .= "Tel: " . mysql_result($Erg, $n, "Telefon") . "<br />"; $Active = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1");
if (strlen(mysql_result($Erg, $n, "Handy")) > 0) $Tshirt = sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1");
$title .= "Handy: " . mysql_result($Erg, $n, "Handy") . "<br />"; $angels[] = array('Nick' => '<strong>Summe</strong>', 'Gekommen' => $Gekommen, 'Aktiv' => $Active, 'Tshirt' => $Tshirt);
if (strlen(mysql_result($Erg, $n, "DECT")) > 0) $html .= table(array(
$title .= "DECT: <a href=\"./dect.php?custum=" . mysql_result($Erg, $n, "DECT") . "\">" . 'Nick' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=Nick">Nick</a>',
mysql_result($Erg, $n, "DECT") . "</a><br />"; 'Name' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=Vorname">Vorname</a> <a href="' . page_link_to("admin_user") . '&amp;OrderBy=Name">Name</a>',
if (strlen(mysql_result($Erg, $n, "Hometown")) > 0) 'DECT' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=DECT">DECT</a>',
$title .= "Hometown: " . mysql_result($Erg, $n, "Hometown") . "<br />"; 'Alter' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=Alter">Alter</a>',
if (strlen(mysql_result($Erg, $n, "CreateDate")) > 0) 'email' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=email">E-Mail</a>',
$title .= "Registered: " . mysql_result($Erg, $n, "CreateDate") . "<br />"; 'Gekommen' => '<div class="rotate"><a href="' . page_link_to("admin_user") . '&amp;OrderBy=Gekommen">Gekommen</a></div>',
if (strlen(mysql_result($Erg, $n, "Art")) > 0) 'Aktiv' => '<div class="rotate"><a href="' . page_link_to("admin_user") . '&amp;OrderBy=Aktiv">Aktiv</a></div>',
$title .= "Type: " . mysql_result($Erg, $n, "Art") . "<br />"; 'Tshirt' => '<div class="rotate"><a href="' . page_link_to("admin_user") . '&amp;OrderBy=Tshirt">T-Shirt</a></div>',
if (strlen(mysql_result($Erg, $n, "ICQ")) > 0) 'Size' => '<div class="rotate"><a href="' . page_link_to("admin_user") . '&amp;OrderBy=Size">Gr&ouml;&szlig;e</a></div>',
$title .= "ICQ: " . mysql_result($Erg, $n, "ICQ") . "<br />"; 'lastLogIn' => '<a href="' . page_link_to("admin_user") . '&amp;OrderBy=lastLogIn">Last login</a>',
if (strlen(mysql_result($Erg, $n, "jabber")) > 0) 'edit' => ''),
$title .= "jabber: " . mysql_result($Erg, $n, "jabber") . "<br />"; $angels);
$html .= "<tr class=\"content\">\n";
if (in_array("user_shifts_admin", $privileges))
$html .= "\t<td><a href=\"" . page_link_to("user_myshifts") . "&id=" . mysql_result($Erg, $n, "UID") . "\">" . mysql_result($Erg, $n, "Nick") . "</a></td>\n";
else
$html .= "\t<td>" . mysql_result($Erg, $n, "Nick") . "</td>\n";
$html .= "\t<td>" . mysql_result($Erg, $n, "Vorname") . " " . mysql_result($Erg, $n, "Name") . "</td>\n";
$html .= "\t<td>" . mysql_result($Erg, $n, "DECT") . "</td>\n";
$html .= "\t<td>" . mysql_result($Erg, $n, "Alter") . "</td>\n";
$html .= "\t<td>";
if (strlen(mysql_result($Erg, $n, "email")) > 0)
$html .= "<a href=\"mailto:" . mysql_result($Erg, $n, "email") . "\">" .
mysql_result($Erg, $n, "email") . "</a>";
$html .= '<div class="hidden">' . $title . '</div>';
$html .= "</td>\n";
$Gekommen += mysql_result($Erg, $n, "Gekommen");
$html .= "\t<td class=\"" . (mysql_result($Erg, $n, "Gekommen") == 1? 'true' : 'false') . "\">" . mysql_result($Erg, $n, "Gekommen") . "</td>\n";
$Active += mysql_result($Erg, $n, "Aktiv");
$html .= "\t<td class=\"" . (mysql_result($Erg, $n, "Aktiv") == 1? 'true' : 'false') . "\">" . mysql_result($Erg, $n, "Aktiv") . "</td>\n";
$Tshirt += mysql_result($Erg, $n, "Tshirt");
$html .= "\t<td class=\"" . (mysql_result($Erg, $n, "Tshirt") == 1? 'true' : 'false') . "\">" . mysql_result($Erg, $n, "Tshirt") . "</td>\n";
$html .= "\t<td>" . mysql_result($Erg, $n, "Size") . "</td>\n";
$last_login = mysql_result($Erg, $n, "lastLogIn");
if($last_login == 0)
$html .= "<td>never</td>";
else
$html .= "<td>" . date('d.m.&\n\b\s\p;H:i', $last_login) . "</td>";
$html .= "\t<td>" . '<a href="' . page_link_to("admin_user") . '&id=' . mysql_result($Erg, $n, "UID") . '">Edit</a>' .
"</td>\n";
$html .= "</tr>\n";
}
$html .= "<tr>" .
"<th>Summe</th><th></th><th></th><th></th><th></th>" .
"<th>$Gekommen</th><th>$Active</th><th>$Tshirt</th><th></th><th></th><th></th></tr>\n";
$html .= "\t</table>\n";
// Ende Userliste
} }
return $html; return $html;
} }

View File

@ -33,8 +33,11 @@ function sql_select($query) {
function sql_select_single_col($query) { function sql_select_single_col($query) {
$result = sql_select($query); $result = sql_select($query);
return array_map('array_pop', $result); return array_map('array_shift', $result);
}
function sql_select_single_cell($query) {
return array_shift(array_shift(sql_select($query)));
} }
// Execute a query // Execute a query

View File

@ -147,7 +147,7 @@ function table($columns, $rows, $data = true) {
$html .= '<table' . ($data ? ' class="data"' : '') . '>'; $html .= '<table' . ($data ? ' class="data"' : '') . '>';
$html .= '<thead><tr>'; $html .= '<thead><tr>';
foreach ($columns as $key => $column) foreach ($columns as $key => $column)
$html .= '<th>' . $column . '</th>'; $html .= '<th class="' . $key . '">' . $column . '</th>';
$html .= '</tr></thead>'; $html .= '</tr></thead>';
$html .= '<tbody>'; $html .= '<tbody>';
foreach ($rows as $row) { foreach ($rows as $row) {

View File

@ -152,24 +152,12 @@ td, th {
border: 1px solid #888; border: 1px solid #888;
} }
td.true, td.false { th.Gekommen {
color: transparent;
}
td.true {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLvZPZLkNhFIV75zjvYm7VGFNCqoZUJ+roKUUpjRuqp61Wq0NKDMelGGqOxBSUIBKXWtWGZxAvobr8lWjChRgSF//dv9be+9trCwAI/vIE/26gXmviW5bqnb8yUK028qZjPfoPWEj4Ku5HBspgAz941IXZeze8N1bottSo8BTZviVWrEh546EO03EXpuJOdG63otJbjBKHkEp/Ml6yNYYzpuezWL4s5VMtT8acCMQcb5XL3eJE8VgBlR7BeMGW9Z4yT9y1CeyucuhdTGDxfftaBO7G4L+zg91UocxVmCiy51NpiP3n2treUPujL8xhOjYOzZYsQWANyRYlU4Y9Br6oHd5bDh0bCpSOixJiWx71YY09J5pM/WEbzFcDmHvwwBu2wnikg+lEj4mwBe5bC5h1OUqcwpdC60dxegRmR06TyjCF9G9z+qM2uCJmuMJmaNZaUrCSIi6X+jJIBBYtW5Cge7cd7sgoHDfDaAvKQGAlRZYc6ltJlMxX03UzlaRlBdQrzSCwksLRbOpHUSb7pcsnxCCwngvM2Rm/ugUCi84fycr4l2t8Bb6iqTxSCgNIAAAAAElFTkSuQmCC') no-repeat center center;
}
td.false {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIhSURBVDjLlZPrThNRFIWJicmJz6BWiYbIkYDEG0JbBiitDQgm0PuFXqSAtKXtpE2hNuoPTXwSnwtExd6w0pl2OtPlrphKLSXhx07OZM769qy19wwAGLhM1ddC184+d18QMzoq3lfsD3LZ7Y3XbE5DL6Atzuyilc5Ciyd7IHVfgNcDYTQ2tvDr5crn6uLSvX+Av2Lk36FFpSVENDe3OxDZu8apO5rROJDLo30+Nlvj5RnTlVNAKs1aCVFr7b4BPn6Cls21AWgEQlz2+Dl1h7IdA+i97A/geP65WhbmrnZZ0GIJpr6OqZqYAd5/gJpKox4Mg7pD2YoC2b0/54rJQuJZdm6Izcgma4TW1WZ0h+y8BfbyJMwBmSxkjw+VObNanp5h/adwGhaTXF4NWbLj9gEONyCmUZmd10pGgf1/vwcgOT3tUQE0DdicwIod2EmSbwsKE1P8QoDkcHPJ5YESjgBJkYQpIEZ2KEB51Y6y3ojvY+P8XEDN7uKS0w0ltA7QGCWHCxSWWpwyaCeLy0BkA7UXyyg8fIzDoWHeBaDN4tQdSvAVdU1Aok+nsNTipIEVnkywo/FHatVkBoIhnFisOBoZxcGtQd4B0GYJNZsDSiAEadUBCkstPtN3Avs2Msa+Dt9XfxoFSNYF/Bh9gP0bOqHLAm2WUF1YQskwrVFYPWkf3h1iXwbvqGfFPSGW9Eah8HSS9fuZDnS32f71m8KFY7xs/QZyu6TH2+2+FAAAAABJRU5ErkJggg==') no-repeat center center;
}
.rotate {
/* this is a hack because the height of the row isn't adjusted automatically */ /* this is a hack because the height of the row isn't adjusted automatically */
height: 6em; height: 6em;
} }
.rotate div { div.rotate {
transform: rotate(270deg); transform: rotate(270deg);
width: 1ex; width: 1ex;
margin: 0 auto -2px; margin: 0 auto -2px;

BIN
public/pic/icons/cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

BIN
public/pic/icons/pencil.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

BIN
public/pic/icons/tick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B