<?php include("admin_globals.php"); ?>
<style>
table { border-collapse:collapse; width:100%;} 
th {text-align:center;  }
#revtable { margin-bottom:60px;   }



.revitems { text-align:center; font-size:10px;  }
.revtext { font-size:10px;}
.emptrev { height:16px; background-color:#FFF; }
</style>

<? 


if (isset ($_GET['apprev'])){ $idtoapp=$_GET['apprev']; mysql_query("UPDATE reviews_store SET approved='1' WHERE i='$idtoapp'"); }
if (isset ($_GET['deapr'])){ $idtodeapp=$_GET['deapr']; mysql_query("UPDATE reviews_store SET approved='0' WHERE i='$idtodeapp'"); }
if (isset ($_GET['delrev'])){ $idtocancel=$_GET['delrev']; mysql_query("DELETE FROM reviews_store WHERE i='$idtocancel'");}

if (isset ($_GET['MENUapprev'])){ $idtoapp=$_GET['MENUapprev']; mysql_query("UPDATE reviews_menu SET approved='1' WHERE i='$idtoapp'"); }
if (isset ($_GET['MENUdeapr'])){ $idtodeapp=$_GET['MENUdeapr']; mysql_query("UPDATE reviews_menu SET approved='0' WHERE i='$idtodeapp'"); }
if (isset ($_GET['MENUdelrev'])){   $idtocancel=$_GET['MENUdelrev']; mysql_query("DELETE FROM reviews_menu WHERE i='$idtocancel'");}

if (isset ($_GET['PRODapprev'])){ $idtoapp=$_GET['PRODapprev']; mysql_query("UPDATE reviews_product SET approved='1' WHERE i='$idtoapp'"); }
if (isset ($_GET['PRODdeapr'])){ $idtodeapp=$_GET['PRODdeapr']; mysql_query("UPDATE reviews_product SET approved='0' WHERE i='$idtodeapp'"); }
if (isset ($_GET['PRODdelrev'])){   $idtocancel=$_GET['PRODdelrev']; mysql_query("DELETE FROM reviews_product WHERE i='$idtocancel'");}



$qreviews="select * from reviews_store ORDER by timestamp DESC";
   $rreviews=mysql_query($qreviews);
        ?>
       <h3>COMPANY/STORE REVIEWS</h3>
       <div id='revtable'>
        <table>
        <tr>
        <th></th>
        <th></th>
        <th>Rating</th>
        <th>Email</th>
        <th>Date</th>
        </tr>
         <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>
        <? 
		while($nt2=mysql_fetch_array($rreviews)){
			?> <tr>
               <td rowspan="2" width="10" class="revitems" ><a href="index.php?admin-page=2&delrev=<? echo $nt2[i];?>"><img src="../images/cancel.gif"></a></td>
               <td rowspan="2" width="30" class="revitems" >
               <? if ($nt2[approved]==0) { ?>
               <a href="index.php?admin-page=2&apprev=<? echo $nt2[i];?>"><img src="../images/check.png" height="12" ></a>
               <? } else { ?><a href="index.php?admin-page=2&deapr=<? echo $nt2[i];?>"><img src="../images/star.png" height="16" ></a><? } ?>
               </td>
               <td  class="revitems"><? echo $nt2[rating]; ?></td>
			   <td  class="revitems"><a href="mailto:<? echo $nt2[email]; ?>"><? echo $nt2[email]; ?></td>
			   <td  class="revitems"  style="width:200px;"><? echo $nt2[dateposted]; ?></td>
               </tr>
               <tr><td class="revtext" colspan="5" >REVIEW: <? echo $nt2[review]; ?></td></tr>
               <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>
        <? }

        ?></table>
        </div>

<?
if($restaurant_pkg=='1'){
	$qreviews="select * from reviews_menu ORDER by timestamp DESC";
   $rreviews=mysql_query($qreviews);
        ?>
       <h3>MENU REVIEWS</h3>
       <div id='revprodtable'>
        <table>
        <tr>
        <th></th>
        <th></th>
        <th>Product</th>
        <th>Rating</th>
        <th>Email</th>
        <th>Date</th>
        </tr>
         <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>

        <? 
		while($nt2=mysql_fetch_array($rreviews)){
			$findmenu=mysql_query("SELECT itemName from menuItem  WHERE itemkey=$nt2[itemKey] ");
			//echo $nt2[itemKey];
			if(mysql_num_rows($findmenu)>0){
            $itemName=mysql_result($findmenu,0,'itemName');
			}
			?> <tr>
               <td rowspan="2" class="revitems" ><a href="index.php?admin-page=2&MENUdelrev=<? echo $nt2[i];?>"><img src="../images/cancel.gif"></a></td>
               <td rowspan="2" width="30" class="revitems" >
               <? if ($nt2[approved]==0) { ?>
               <a href="index.php?admin-page=2&MENUapprev=<? echo $nt2[i];?>"><img  src="../images/check.png" height="12" ></a>
               <? } else { ?><a href="index.php?admin-page=2&MENUdeapr=<? echo $nt2[i];?>"><img src="../images/star.png" height="16" ></a> <? } ?>
               </td>
               <td  class="revitems"><b><? echo $itemName; ?></b></td>
               <td  class="revitems"><? echo $nt2[rating]; ?></td>
			   <td  class="revitems"><a href="mailto:<? echo $nt2[email]; ?>"><? echo $nt2[email]; ?></a></td>
			   <td  class="revitems"  style="width:200px;"><? echo $nt2[dateposted]; ?></td>
               </tr>
               <tr><td class="revtext" colspan="5" >REVIEW: <? echo $nt2[review]; ?></td></tr>
               <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>
        <? } ?>
        </table>
        </div>
<?php } ?>        
        
        
        
        
        <?
if($ecommerce_pkg=='1'){
	$qreviews="select * from reviews_product ORDER by timestamp DESC";
   $rreviews=mysql_query($qreviews);
        ?>
       <h3>PRODUCT REVIEWS</h3>
       <div id='revprodtable'>
        <table>
        <tr>
        <th></th>
        <th></th>
        <th>Product</th>
        <th>Rating</th>
        <th>Email</th>
        <th>Date</th>
        </tr>
         <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>

        <? 
		while($nt2=mysql_fetch_array($rreviews)){
			$findprod=mysql_query("SELECT itemName from products  WHERE itemkey=$nt2[itemKey] ");
            $itemName=mysql_result($findprod,0,'itemName');
			?> <tr>
               <td rowspan="2" class="revitems" ><a href="index.php?admin-page=2&PRODdelrev=<? echo $nt2[i];?>"><img  src="/images/cancel.gif"></a></td>
               <td rowspan="2" width="30" class="revitems" >
               <? if ($nt2[approved]==0) { ?>
               <a href="index.php?admin-page=2&PRODapprev=<? echo $nt2[i];?>"><img  src="/images/check.png" height="12" ></a>
               <? } else { ?><a href="index.php?admin-page=2&PRODdeapr=<? echo $nt2[i];?>"><img  src="/images/star.png" height="16" ></a> <? } ?>
               </td>
               <td  class="revitems"><b><? echo $itemName; ?></b></td>
               <td  class="revitems"><? echo $nt2[rating]; ?></td>
			   <td  class="revitems"><a href="mailto:<? echo $nt2[email]; ?>"><? echo $nt2[email]; ?></a></td>
			   <td  class="revitems"  style="width:200px;"><? echo $nt2[dateposted]; ?></td>
               </tr>
               <tr><td class="revtext" colspan="5" >REVIEW: <? echo $nt2[review]; ?></td></tr>
               <tr><td class="emptrev" colspan="6" ><hr size="1"></td></tr>
        <? } ?>
        </table>
        </div></div>
		
<?php } ?>


<div style="clear: both;">&nbsp;</div>
			  <div style="text-align:center;"><?php echo $bottom_links; ?></div>