<?php
$b = settings('gift_registry_page');
$seo_pageTitle = seo_str($site->pageTitle($b['gift_registry_page']));
if($url['pid'] == $b['gift_registry_page'])
{
//mark item as purchased
if(isset($_POST['purchased']))
{
$purchased = (int)$_POST['purchased'];
$mysql->update("purchased", "y", "fs_gift_registry_items", "ID = $purchased LIMIT 1");
header("Location: /{$b['gift_registry_page']}/$seo_pageTitle");
exit;
}
//show items
$mainhtml .= '<table width="100%" border="0" cellspacing="0" cellpadding="2" id="basket"><tr align="left"><th>Item</th><th>Action</th></tr>';
$query = $mysql->query("ID,name,link,purchased", "fs_gift_registry_items", "1 ORDER BY name ASC");
while($data = $mysql->get_array($query))
{
$link = (!empty($data['link'])) ? '<br /><small><a href="'.$data['link'].'" target="_blank">More info &gt;&gt;</a></small>' : '';
$button = ($data['purchased'] == 'y') ? '<input type="button" name="d'.$data['ID'].'" id="d'.$data['ID'].'" value="Already purchased" disabled="disabled" />' : '<form id="purcashed'.$data['ID'].'" name="purcashed'.$data['ID'].'" method="post" action=""><input type="submit" name="p'.$data['ID'].'" id="p'.$data['ID'].'" value="Mark it as purchased" /><input type="hidden" name="purchased" id="pur'.$data['ID'].'" value="'.$data['ID'].'" /></form>';
$mainhtml .= '<tr valign="top">
<td width="70%">'.stripslashes($data['name']).$link.'</td>
<td>'.$button.'</td>
</tr>';
}
$mainhtml .= '</table>';
//css
$head = '<link rel="stylesheet" type="text/css" href="/inc/shop/src/shop.css" />';
if(!strstr($mainhtml, 'shop.css'))
{
$mainhtml = str_replace("</head>", $head.'</head>', $mainhtml);
}
//end
}
?>