Skip to content

Commit

Permalink
bootstrap defaultpage() function
Browse files Browse the repository at this point in the history
  • Loading branch information
stwalkerster committed Dec 4, 2013
1 parent 8e1d337 commit dce304b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 21 deletions.
41 changes: 20 additions & 21 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,29 +462,28 @@ function getdevs() {
}

function defaultpage() {
global $tsSQLlink, $toolserver_database, $skin, $tsurl, $availableRequestStates, $defaultRequestStateKey;
@mysql_select_db( $toolserver_database, $tsSQLlink) or sqlerror(mysql_error,"Could not select db");
$html = '<h1>Create an account!</h1>';

global $availableRequestStates, $defaultRequestStateKey;

$requestSectionData = array();
// list requests in each section
foreach($availableRequestStates as $k => $v) {
$html .= "<h2>".$v['header']."</h2>";
$html .= listrequests($k, TRUE, FALSE);
}
foreach($availableRequestStates as $k => $v)
{
$requestSectionData[$v['header']] = listrequests($k, TRUE, FALSE);
}

global $smarty;

$html .= "<h2>Last 5 Closed requests</h2><span id=\"closed\"></span>\n";
$query = "SELECT pend_id, pend_name, pend_checksum FROM acc_pend JOIN acc_log ON pend_id = log_pend WHERE log_action LIKE 'Closed%' ORDER BY log_time DESC LIMIT 5;";
$result = mysql_query($query, $tsSQLlink);
if (!$result)
sqlerror("Query failed: $query ERROR: " . mysql_error(),"Database query error.");
$html .= "<ol>\n";
$currentrow = 0;
while ( list( $pend_id, $pend_name, $pend_checksum ) = mysql_fetch_row( $result ) ) {
$out = '<li>';
$out .= "<a class=\"btn btn-small btn-info\" href=\"$tsurl/acc.php?action=zoom&amp;id=" . $pend_id . "\">Zoom</a><a class=\"btn btn-warning btn-small\" href=\"$tsurl/acc.php?action=defer&amp;id=" . $pend_id . "&amp;sum=" . $pend_checksum . "&amp;target=$defaultRequestStateKey\">Reset</a> <a href=\"http://en.wikipedia.org/wiki/User:" . $pend_name . "\">" . _utf8_decode($pend_name) . "</a></li>";
$html .= $out;
}
$html .= "</ol>\n";
$query = "SELECT pend_id, pend_name, pend_checksum, log_time FROM acc_pend JOIN acc_log ON pend_id = log_pend WHERE log_action LIKE 'Closed%' ORDER BY log_time DESC LIMIT 5;";
$database = gGetDb();
$statement = $database->prepare($query);
$statement->execute();

$last5result = $statement->fetchAll(PDO::FETCH_ASSOC);

$smarty->assign("lastFive", $last5result);
$smarty->assign("requestSectionData", $requestSectionData);
$html = $smarty->fetch("mainpage/mainpage.tpl");

return $html;
}

Expand Down
45 changes: 45 additions & 0 deletions templates/mainpage/mainpage.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div class="row-fluid">
<div class="page-header">
<h1>Create an account!</h1>
</div>
</div>

<div class="row-fluid">
{foreach from=$requestSectionData key="header" item="section"}
<div>
<h2>{$header}</h2>
{$section}
</div>
{/foreach}
</div>

<hr />

<div class="row-fluid">
<h2>Last 5 Closed requests</h2>
<table class="table table-condensed table-striped" style="width:auto;">
<thead>
<th>ID</th>
<th>Name</th>
<th>{* zoom *}</th>
</thead>
{foreach from=$lastFive item="req"}
<tr>
<th>{$req.pend_id}</th>
<td>
{$req.pend_name|escape}
</td>
<td>
<a href="{$tsurl}/acc.php?action=zoom&amp;id={$req.pend_id|escape:'url'}" class="btn btn-info">
<i class="icon-white icon-search"></i>&nbsp;Zoom
</a>
</td>
<td>
<a href="{$tsurl}/acc.php?action=defer&amp;id={$req.pend_id|escape:'url'}&amp;sum={$req.pend_checksum|escape:'url'}&amp;target=Open" class="btn btn-warning">
<i class="icon-white icon-refresh"></i>&nbsp;Reset
</a>
</td>
</tr>
{/foreach}
</table>
</div>

0 comments on commit dce304b

Please sign in to comment.