shopping list converted

This commit is contained in:
Ryan Walberg 2012-11-15 23:51:03 +00:00
parent a275c640d8
commit 6a38fab536
2 changed files with 114 additions and 85 deletions

View file

@ -26,31 +26,6 @@ else {
$userid = $_SESSION["userid"];
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Gift Registry - My Shopping List</title>
<script language="JavaScript" type="text/javascript">
function printPage() {
window.print();
}
</script>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body>
<?php
if ($OPT["show_helptext"]) {
?>
<p class="helptext">
This is a list of all items you have <strong>reserved</strong>. Once you've bought or decided not to buy an item, remember to return to the recipient's gift lists and mark it accordingly.
</p>
<?php
}
?>
<p class="pagetitle">Gift Registry - My Shopping List</p>
<?php
if (empty($_GET["sort"]))
$sort = "source";
else
@ -83,64 +58,30 @@ $query = "SELECT description, source, price, i.comment, a.quantity, a.quantity *
"INNER JOIN {$OPT["table_prefix"]}ranks r ON r.ranking = i.ranking " .
"INNER JOIN {$OPT["table_prefix"]}allocs a ON a.userid = $userid AND a.itemid = i.itemid AND bought = 0 " .
"ORDER BY $sortby";
$shoplist = mysql_query($query) or die("Could not query $query: " . mysql_error());
$rs = mysql_query($query) or die("Could not query $query: " . mysql_error());
$shoplist = array();
$totalprice = 0;
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
$totalprice += $row["total"];
if ($row["quantity"] == 1) {
$row["price"] = formatPrice($row["price"]);
}
else {
$row["price"] = $row["quantity"] . " @ " . formatPrice($row["price"]) . " = " . formatPrice($row["total"]);
}
$shoplist[] = $row;
}
$itemcount = mysql_num_rows($rs);
mysql_free_result($rs);
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty-3.1.12/libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
$smarty->assign('shoplist', $shoplist);
$smarty->assign('totalprice', formatPrice($totalprice));
$smarty->assign('itemcount', $itemcount);
$smarty->assign('userid', $userid);
$smarty->assign('isadmin', $_SESSION["admin"]);
$smarty->assign('opt', $OPT);
$smarty->display('shoplist.tpl');
?>
<p>
<table class="partbox" width="100%" cellspacing="0">
<tr class="partboxtitle">
<td colspan="5" align="center">My Shopping List</td>
</tr>
<tr>
<th class="colheader"><a href="shoplist.php?sort=recipient">Recipient</a></th>
<th class="colheader"><a href="shoplist.php?sort=description">Description</a></th>
<th class="colheader"><a href="shoplist.php?sort=ranking">Ranking</a></th>
<th class="colheader"><a href="shoplist.php?sort=source">Source</a></th>
<th class="rcolheader"><a href="shoplist.php?sort=price">Price</a></th>
</tr>
<?php
$i = 0;
$totalprice = 0;
while ($row = mysql_fetch_array($shoplist,MYSQL_ASSOC)) {
$totalprice += $row["total"];
?>
<tr class="<?php echo (!($i++ % 2)) ? "evenrow" : "oddrow" ?>">
<td nowrap><?php echo $row["fullname"]; ?></td>
<td><?php echo $row["description"]; ?></td>
<td><?php echo $row["rendered"]; ?></td>
<td><?php echo $row["source"]; ?></td>
<td align="right">
<?php
if ($row["quantity"] == 1)
echo formatPrice($row["price"]);
else
echo $row["quantity"] . " @ " . formatPrice($row["price"]) . " = " . formatPrice($row["total"]);
?>
</td>
</tr>
<?php
if ($row["comment"] != "") {
?>
<tr class="<?php echo (($i % 2) ? "evenrow" : "oddrow"); ?>">
<td>&nbsp;</td>
<td colspan="3">
<i><?php echo str_replace("\r\n","<br />",$row["comment"]); ?></i>
</td>
<td>&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
</p>
<p>
<?php echo mysql_num_rows($shoplist) . " item(s), {$OPT["currency_symbol"]}$totalprice total."; ?>
</p>
<?php
mysql_free_result($shoplist);
?>
<p>
<a onClick="printPage()" href="#">Send to printer</a>&nbsp;/&nbsp;<a href="index.php">Back to main</a>
</p>
</body>
</html>

View file

@ -0,0 +1,88 @@
{*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gift Registry - My Shopping List</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<script language="JavaScript" type="text/javascript">
function printPage() {
window.print();
}
</script>
</head>
<body>
{include file='navbar.tpl' isadmin=$isadmin}
<div class="container" style="padding-top: 60px;">
{if $opt.show_helptext}
<div class="row">
<div class="span12">
<div class="alert alert-info">
This is a list of all items you have <strong>reserved</strong>. Once you've bought or decided not to buy an item, remember to return to the recipient's gift lists and mark it accordingly.
</div>
</div>
</div>
{/if}
<div class="row">
<div class="span12">
<div class="well">
<h1>My Shopping List</h1>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th><a href="shoplist.php?sort=recipient">Recipient</a></th>
<th><a href="shoplist.php?sort=description">Description</a></th>
<th><a href="shoplist.php?sort=ranking">Ranking</a></th>
<th><a href="shoplist.php?sort=source">Source</a></th>
<th><a href="shoplist.php?sort=price">Price</a></th>
</tr>
</thead>
<tbody>
{foreach from=$shoplist item=row}
<tr>
<td>{$row.fullname|escape:'htmlall'}</td>
<td>{$row.description|escape:'htmlall'}</td>
<td>{$row.rendered}</td>
<td>{$row.source}</td>
<td>{$row.price}</td>
</tr>
{/foreach}
</tbody>
</table>
<h5>{$itemcount} item(s), {$totalprice} total.</h5>
</div>
</div>
</div>
<div class="row">
<div class="span6">
<div class="well">
<a onClick="printPage()" href="#">Send to printer</a>
</div>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>