<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
  require('load_this/load_bigware_11.php');
  $action = (isset($_GET['action']) ? $_GET['action'] : '');
  if (go_not_null($action)) {
    switch ($action) {
      case 'update':
        $reviews_id = go_db_producing_input($_GET['rID']);
        $reviews_rating = go_db_producing_input($_POST['reviews_rating']);
        $reviews_text = go_db_producing_input($_POST['reviews_text']);
        go_db_query("update " . DB_TBL_REVIEWS . " set reviews_rating = '" . go_db_input($reviews_rating) . "', last_modified = now() where reviews_id = '" . (int)$reviews_id . "'");
        go_db_query("update " . DB_TBL_REVIERELATIV_DESCRIPTION . " set reviews_text = '" . go_db_input($reviews_text) . "' where reviews_id = '" . (int)$reviews_id . "'");
        go_forward(go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $reviews_id));
        break;
      case 'deleteconfirm':
        $reviews_id = go_db_producing_input($_GET['rID']);
        go_db_query("delete from " . DB_TBL_REVIEWS . " where reviews_id = '" . (int)$reviews_id . "'");
        go_db_query("delete from " . DB_TBL_REVIERELATIV_DESCRIPTION . " where reviews_id = '" . (int)$reviews_id . "'");
        go_forward(go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page']));
        break;
    }
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="load_this/style.css">
<script language="javascript" src="load_this/menu.js"></script>
<script language="javascript" src="load_this/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo FRAME_WIDTH; ?>" valign="top">
<!-- left_navigation //-->
<!-- left_navigation_eof //-->
</td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
            <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('tranparentes.gif', ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
<?php
  if ($action == 'change') {
    $rID = go_db_producing_input($_GET['rID']);
    $reviews_query = go_db_query("select r.reviews_id, r.items_id, r.attendees_name, r.date_added, r.last_modified, r.reviews_read, rd.reviews_text, r.reviews_rating from " . DB_TBL_REVIEWS . " r, " . DB_TBL_REVIERELATIV_DESCRIPTION . " rd where r.reviews_id = '" . (int)$rID . "' and r.reviews_id = rd.reviews_id");
    $reviews = go_db_fetch_array($reviews_query);
    $items_query = go_db_query("select items_picture from " . DB_TBL_ITEMS . " where items_id = '" . (int)$reviews['items_id'] . "'");
    $items = go_db_fetch_array($items_query);
    $items_name_query = go_db_query("select items_name from " . DB_TBL_ITEMS_DESCRIPTION . " where items_id = '" . (int)$reviews['items_id'] . "' and language_id = '" . (int)$languages_id . "'");
    $items_name = go_db_fetch_array($items_name_query);
    $rInfo_array = array_merge($reviews, $items, $items_name);
    $rInfo = new objectInfo($rInfo_array);
?>
      <tr><?php echo go_fetch_form('review', NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $_GET['rID'] . '&action=preview'); ?>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="main" valign="top"><b><?php echo TYPE_IN_ITEM; ?></b> <?php echo $rInfo->items_name; ?><br><b><?php echo TYPE_IN_FROM; ?></b> <?php echo $rInfo->attendees_name; ?><br><br><b><?php echo TYPE_IN_DATE; ?></b> <?php echo go_date_short($rInfo->date_added); ?></td>
            <td class="main" align="right" valign="top"><?php echo go_picture(HTTP_CATALOG_SERVER . FOLDER_RELATIV_CATALOG_PICTURES . $rInfo->items_picture, $rInfo->items_name, SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT, 'hspace="5" vspace="5"'); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="main" valign="top"><b><?php echo TYPE_IN_REVIEW; ?></b><br><br><?php echo go_fetch_textarea_field('reviews_text', 'soft', '60', '15', $rInfo->reviews_text); ?></td>
          </tr>
          <tr>
            <td class="smallText" align="right"><?php echo TYPE_IN_REVIEW_TEXT; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo TYPE_IN_RATING; ?></b>&nbsp;<?php echo TEXT_BAD; ?>&nbsp;<?php for ($i=1; $i<=5; $i++) echo go_fetch_radio_field('reviews_rating', $i, '', $rInfo->reviews_rating) . '&nbsp;'; echo TEXT_GOOD; ?></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="main"><?php echo go_fetch_hidden_field('reviews_id', $rInfo->reviews_id) . go_fetch_hidden_field('items_id', $rInfo->items_id) . go_fetch_hidden_field('attendees_name', $rInfo->attendees_name) . go_fetch_hidden_field('items_name', $rInfo->items_name) . go_fetch_hidden_field('items_picture', $rInfo->items_picture) . go_fetch_hidden_field('date_added', $rInfo->date_added) . go_picture_submit('button_preview.gif', PICTURE_PREVIEW) . ' <a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $_GET['rID']) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>'; ?></td>
      </form></tr>
<?php
  } elseif ($action == 'preview') {
    if (go_not_null($_POST)) {
      $rInfo = new objectInfo($_POST);
    } else {
      $rID = go_db_producing_input($_GET['rID']);
      $reviews_query = go_db_query("select r.reviews_id, r.items_id, r.attendees_name, r.date_added, r.last_modified, r.reviews_read, rd.reviews_text, r.reviews_rating from " . DB_TBL_REVIEWS . " r, " . DB_TBL_REVIERELATIV_DESCRIPTION . " rd where r.reviews_id = '" . (int)$rID . "' and r.reviews_id = rd.reviews_id");
      $reviews = go_db_fetch_array($reviews_query);
      $items_query = go_db_query("select items_picture from " . DB_TBL_ITEMS . " where items_id = '" . (int)$reviews['items_id'] . "'");
      $items = go_db_fetch_array($items_query);
      $items_name_query = go_db_query("select items_name from " . DB_TBL_ITEMS_DESCRIPTION . " where items_id = '" . (int)$reviews['items_id'] . "' and language_id = '" . (int)$languages_id . "'");
      $items_name = go_db_fetch_array($items_name_query);
      $rInfo_array = array_merge($reviews, $items, $items_name);
      $rInfo = new objectInfo($rInfo_array);
    }
?>
      <tr><?php echo go_fetch_form('update', NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $_GET['rID'] . '&action=update', 'post', 'enctype="multipart/form-data"'); ?>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="main" valign="top"><b><?php echo TYPE_IN_ITEM; ?></b> <?php echo $rInfo->items_name; ?><br><b><?php echo TYPE_IN_FROM; ?></b> <?php echo $rInfo->attendees_name; ?><br><br><b><?php echo TYPE_IN_DATE; ?></b> <?php echo go_date_short($rInfo->date_added); ?></td>
            <td class="main" align="right" valign="top"><?php echo go_picture(HTTP_CATALOG_SERVER . FOLDER_RELATIV_CATALOG_PICTURES . $rInfo->items_picture, $rInfo->items_name, SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT, 'hspace="5" vspace="5"'); ?></td>
          </tr>
        </table>
      </tr>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top" class="main"><b><?php echo TYPE_IN_REVIEW; ?></b><br><br><?php echo nl2br(go_db_output(go_break_string($rInfo->reviews_text, 15))); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo TYPE_IN_RATING; ?></b>&nbsp;<?php echo go_picture(FOLDER_RELATIV_CATALOG_PICTURES . 'stars_' . $rInfo->reviews_rating . '.gif', sprintf(TEXT_OF_5_STARS, $rInfo->reviews_rating)); ?>&nbsp;<small>[<?php echo sprintf(TEXT_OF_5_STARS, $rInfo->reviews_rating); ?>]</small></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
<?php
    if (go_not_null($_POST)) {
 reset($_POST);
      while(list($key, $value) = each($_POST)) echo go_fetch_hidden_field($key, $value);
?>
      <tr>
        <td align="right" class="smallText"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=change') . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a> ' . go_picture_submit('button_update.gif', PICTURE_UPDATE) . ' <a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>'; ?></td>
      </form></tr>
<?php
    } else {
      if (isset($_GET['origin'])) {
        $back_url = $_GET['origin'];
        $back_url_parameter = '';
      } else {
        $back_url = NAME_OF_FILE_REVIEWS;
        $back_url_parameter = 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id;
      }
?>
      <tr>
        <td align="right"><?php echo '<a href="' . go_href_link($back_url, $back_url_parameter, 'NONSSL') . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a>'; ?></td>
      </tr>
<?php
    }
  } else {
?>
      <tr>
        <td><table cellpadding="5" border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" cellpadding="5" cellspacing="1" style="border-collapse: collapse" width="100%" id="AutoNumber1">
              <tr class="tbUPCountData">
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_ITEMS; ?></td>
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_RATING; ?></td>
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_DATE_ADDED; ?></td>
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_ACTION; ?>&nbsp;</td>
              </tr>
<?php
    $reviews_query_raw = "select reviews_id, items_id, date_added, last_modified, reviews_rating from " . DB_TBL_REVIEWS . " order by date_added DESC";
    $reviews_split = new splitPageResults($_GET['page'], MAX_SHOW_SEARCH_RESULTS, $reviews_query_raw, $reviews_query_numrows);
    $reviews_query = go_db_query($reviews_query_raw);
    while ($reviews = go_db_fetch_array($reviews_query)) {
      if ((!isset($_GET['rID']) || (isset($_GET['rID']) && ($_GET['rID'] == $reviews['reviews_id']))) && !isset($rInfo)) {
        $reviews_text_query = go_db_query("select r.reviews_read, r.attendees_name, length(rd.reviews_text) as reviews_text_size from " . DB_TBL_REVIEWS . " r, " . DB_TBL_REVIERELATIV_DESCRIPTION . " rd where r.reviews_id = '" . (int)$reviews['reviews_id'] . "' and r.reviews_id = rd.reviews_id");
        $reviews_text = go_db_fetch_array($reviews_text_query);
        $items_picture_query = go_db_query("select items_picture from " . DB_TBL_ITEMS . " where items_id = '" . (int)$reviews['items_id'] . "'");
        $items_picture = go_db_fetch_array($items_picture_query);
        $items_name_query = go_db_query("select items_name from " . DB_TBL_ITEMS_DESCRIPTION . " where items_id = '" . (int)$reviews['items_id'] . "' and language_id = '" . (int)$languages_id . "'");
        $items_name = go_db_fetch_array($items_name_query);
        $reviews_average_query = go_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . DB_TBL_REVIEWS . " where items_id = '" . (int)$reviews['items_id'] . "'");
        $reviews_average = go_db_fetch_array($reviews_average_query);
        $review_info = array_merge($reviews_text, $reviews_average, $items_name);
        $rInfo_array = array_merge($reviews, $review_info, $items_picture);
        $rInfo = new objectInfo($rInfo_array);
      }
      if (isset($rInfo) && is_object($rInfo) && ($reviews['reviews_id'] == $rInfo->reviews_id) ) {
        echo '              <tr id="defaultSelected" class="tbCountDataSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=preview') . '\'">' . "\n";
      } else {
        echo '              <tr class="tbCountData" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $reviews['reviews_id']) . '\'">' . "\n";
      }
?>
                <td class="TbInsideData"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $reviews['reviews_id'] . '&action=preview') . '">' . go_picture(FOLDER_RELATIV_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;' . go_get_values_from_items_description($reviews['items_id'], '', 'items_name'); ?></td>  <!--Fred-->
                <td class="TbInsideData" align="right"><?php echo go_picture(HTTP_CATALOG_SERVER . FOLDER_RELATIV_CATALOG_PICTURES . 'stars_' . $reviews['reviews_rating'] . '.gif'); ?></td>
                <td class="TbInsideData" align="right"><?php echo go_date_short($reviews['date_added']); ?></td>
                <td class="TbInsideData" align="right"><?php if ( (is_object($rInfo)) && ($reviews['reviews_id'] == $rInfo->reviews_id) ) { echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif'); } else { echo '<a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $reviews['reviews_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_info.gif', PICTURE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $reviews_split->display_count($reviews_query_numrows, MAX_SHOW_SEARCH_RESULTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_REVIEWS); ?></td>
                    <td class="smallText" align="right"><?php echo $reviews_split->display_links($reviews_query_numrows, MAX_SHOW_SEARCH_RESULTS, MAX_SHOW_PAGE_LINKS, $_GET['page']); ?></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
<?php
    $heading = array();
    $contents = array();
    switch ($action) {
      case 'delete':
        $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_REVIEW . '</b>');
        $contents = array('form' => go_fetch_form('reviews', NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=deleteconfirm'));
        $contents[] = array('text' => TEXT_INFO_DELETE_REVIEW_INTRO);
        $contents[] = array('text' => '<br><b>' . $rInfo->items_name . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_delete.gif', PICTURE_DELETE) . ' <a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
        break;
      default:
      if (isset($rInfo) && is_object($rInfo)) {
        $heading[] = array('text' => '<b>' . $rInfo->items_name . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=change') . '">' . go_picture_button('button_change.gif', PICTURE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_REVIEWS, 'page=' . $_GET['page'] . '&rID=' . $rInfo->reviews_id . '&action=delete') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a>');
        $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . go_date_short($rInfo->date_added));
        if (go_not_null($rInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . go_date_short($rInfo->last_modified));
        $contents[] = array('text' => '<br>' . go_info_picture($rInfo->items_picture, $rInfo->items_name, SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT));
        $contents[] = array('text' => '<br>' . TEXT_INFO_REVIEW_AUTHOR . ' ' . $rInfo->attendees_name);
        $contents[] = array('text' => TEXT_INFO_REVIEW_RATING . ' ' . go_picture(HTTP_CATALOG_SERVER . FOLDER_RELATIV_CATALOG_PICTURES . 'stars_' . $rInfo->reviews_rating . '.gif'));
        $contents[] = array('text' => TEXT_INFO_REVIEW_READ . ' ' . $rInfo->reviews_read);
        $contents[] = array('text' => '<br>' . TEXT_INFO_REVIEW_SIZE . ' ' . $rInfo->reviews_text_size . ' bytes');
        $contents[] = array('text' => '<br>' . TEXT_INFO_ITEMS_AVERAGE_RATING . ' ' . number_format($rInfo->average_rating, 2) . '%');
      }
        break;
    }
    if ( (go_not_null($heading)) && (go_not_null($contents)) ) {
      echo '            <td width="25%" valign="top"><br>' . "\n";
      $frame = new frame;
      echo $frame->infoBox($heading, $contents);
      echo '            </td>' . "\n";
    }
?>
          </tr>
        </table></td>
      </tr>
<?php
  }
?>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>
