Files
HotLunches/view_guides.php
2026-10-19 15:22:52 -07:00

123 lines
3.5 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-HOW-TO-GUIDES');
//
// Get set of guides
//
$query = "SELECT category,title,description,uploaded_date,file_name,h.record_num " .
"FROM how_to_guides AS h, how_to_guide_categories as hc " .
"WHERE h.category_num = hc.record_num " .
"ORDER BY hc.sequence,h.sequence,title";
$results = db_query($query);
$numGuides = db_num_rows($results);
$uploaddir = "how-to-guides";
?>
<script>
$(document).ready(function() {
$(".how-to-doc-row").hide();
$(".how-to-title-row").click(function(e) {
var cclass = $(this).attr('cat');
if ($(this).hasClass("row-open")) {
$("."+cclass).hide();
$(this).removeClass("row-open");
}
else {
// $(".how-to-doc-row").hide();
$("."+cclass).show();
$(this).addClass("row-open");
}
});
$("#show-all").click(function(e) {
e.preventDefault();
$(".how-to-doc-row").show();
$(".how-to-title-row").each(function(e) {
$(this).addClass("row-open");
});
});
$("#hide-all").click(function(e) {
e.preventDefault();
$(".how-to-doc-row").hide();
$(".how-to-title-row").each(function(e) {
$(this).removeClass("row-open");
});
});
});
</script>
<br>
<table width='<?php echo($default_data_width) ?>' class='content-table'>
<tr>
<td align='left' colspan='3'>
<b><a href='' id='show-all'>[Show All Guides]</a></b>
<b><a href='' id='hide-all'>[Hide All Guides]</a></b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>--- <?php echo($numGuides) ?> <?php displayLanguageText('TEXT-GUIDES'); ?> ---</b>
</td>
</tr>
<?php
$prev_category = "";
$count = 0;
$view_icon = "<img src='images/icons/filesearch24.png' alt='View Guide' border='0'>";
while ($entry = db_fetch_array($results)) {
extract($entry);
$bgclass = "data-even";
if ($count % 2) $bgclass = "data-odd";
$count++;
if ($category != $prev_category) {
$prev_category = $category;
$cclass = str_replace(' ','_',$category);
$cclass = str_replace(',','',$cclass);
$cclass = str_replace('.','',$cclass);
?>
<tr height='3'>
<td align='center' colspan='3'> </td>
</tr>
<tr class='how-to-title-row' cat='<?php echo($cclass) ?>'>
<td colspan='3' align='left' class='subheading'>&nbsp;&nbsp;+&nbsp;&nbsp;<?php echo($category) ?></td>
</tr>
<?php
}
$file_date = date("Y-m-d",filectime("$uploaddir/$file_name"));
?>
<tr class='how-to-doc-row <?php echo($cclass) ?>'>
<td align='left' class='<?php echo($bgclass) ?>'>
<b><a href='view-guide.php?dnum=<?php echo($record_num) ?>'><?php echo($title) ?></a></b>
<?php if (strlen($description)) echo("<br>\n" . $description . "\n"); ?>
</td>
<td width='80' align='left' valign='top' class='<?php echo($bgclass) ?>'><?php echo($file_date) ?></td>
<td width='50' align='center' valign='top' class='<?php echo($bgclass) ?>'><a href='view-guide.php?dnum=<?php echo($record_num) ?>'><?php echo($view_icon) ?></a></td>
</tr>
<?php
}
?>
<tr height='3'>
<td align='center' colspan='3'> </td>
</tr>
</table>
<br>
<?php
endTemplate();
?>