<?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');
  require(FOLDER_RELATIV_CLASSES . 'class_bigware_1.php');
  $currencies = new currencies();
  $action = (isset($_GET['action']) ? $_GET['action'] : '');  
  if ( preg_match("/(insert|update|setflag)/i", $action) ) include_once('load_this/load_bigware_14.php');
 
  if (go_not_null($action)) {
    switch ($action) { 
    	
      case 'setflag':
        if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
          if (isset($_GET['bigID'])) {
            go_set_item_status((int)$_GET['bigID'], $_GET['flag']);
          }
          if (USE_CACHE == 'true') {
            go_reset_cache_block('categories');
            go_reset_cache_block('also_purchased');
          }
        }
        go_forward(go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'bigPfad=' . $_GET['bigPfad'] . '&bigID=' . (int)$_GET['bigID']));
        break;
		case 'setflag_cat':
        		if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') )
			{
	      		if (isset($_GET['bigID']))
				{
            		go_set_categories_status((int)$_GET['bigID'], $_GET['flag']);
    				}
          		if (USE_CACHE == 'true')
				{
            			go_reset_cache_block('categories');
            			go_reset_cache_block('also_purchased');
          			}
        		}
			go_forward(go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'bigPfad=' . $_GET['bigPfad'] . '&bigID=' . (int)$_GET['bigID']));
			break;    	
    case 'delete_item_confirm':
        if (isset($_POST['items_id']) && isset($_POST['item_categories']) && is_array($_POST['item_categories'])) {
          $item_id = go_db_producing_input($_POST['items_id']);
          $item_categories = $_POST['item_categories'];
          for ($i=0, $n=sizeof($item_categories); $i<$n; $i++) {
            go_db_query("delete from " . DB_TBL_ITEMS_TO_CATEGORIES . " where items_id = '" . (int)$item_id . "' and categories_id = '" . (int)$item_categories[$i] . "'");
          } 
		  go_db_query("delete from " . DB_TBL_ITEMS_GROUPS . " where items_id = '" . go_db_input($item_id) . "' "); 
          $item_categories_query = go_db_query("select count(*) as total from " . DB_TBL_ITEMS_TO_CATEGORIES . " where items_id = '" . (int)$item_id . "'");
          $item_categories = go_db_fetch_array($item_categories_query);
          if ($item_categories['total'] == '0') {
            go_remove_item($item_id);
          }
        }
        if (USE_CACHE == 'true') {
          go_reset_cache_block('categories');
          go_reset_cache_block('also_purchased');
        }
        go_forward(go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'bigPfad=' . $bigPfad));
    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/general.js"></script>
<script language="javascript" src="load_this/menu.js"></script>
<script language="javascript" src="tiny_mce/tiny_mce.js"></script>
<script language="javascript" src="tiny_mce/tiny_mce_init.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
function ow(seite)
  {
	w1 = window.open(seite, 'LEAF', 'toolbar=no,status=no,width=700,height=300,directories=no,scrollbars=yes,location=no,resize=yes,menubar=no');
  	w1.focus();
}
//-->
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2" align="center">
  <tr>
    <!--td width="<?php echo FRAME_WIDTH; ?>" valign="top"></td-->
<!-- body_text //-->
    <td width="100%" valign="top">

    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><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', 1, ABOVE_PICTURE_HEIGHT); ?></td>
            <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td class="smallText" align="right">
<?php
    echo go_fetch_form('search', NAME_OF_FILE_ALL_ITEMS_LIST, '', 'get');
    echo ABOVE_TITLE_SEARCH . ' ' . go_fetch_inputfeld('search');
    echo '</form>';
?>
                </td>
              </tr>
              <tr>
                <td class="smallText" align="right">

                </td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="5">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="5">
              <tr class="tbUPCountData">
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_CATEGORIES_ITEMS; ?></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_ART_Number; ?></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_ANZAHL; ?></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_GEWICHT; ?></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_SYN; ?></td>
                <td class="tbUPDataInside" align="center"><?php echo DB_TBL_ABOVE_STATUS; ?></td>
<?php
                	
		  if ( $action == 'delete_item' ){ 
?>   
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_ACTION; ?>&nbsp;</td>
<?php               	 
		   }      
?>                
                
              </tr>
<?php
    $categories_count = 0;
    $rows = 0;
    if (isset($_GET['search'])) {
      $search = go_db_producing_input($_GET['search']); 
        $categories_query = go_db_query("select c.categories_id, cd.categories_name,cd.categories_desc, c.categories_picture, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status from " . DB_TBL_CATEGORIES . " c, " . DB_TBL_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . go_db_input($search) . "%' order by c.sort_order, cd.categories_name");
    } else { 
      $categories_query = go_db_query("select c.categories_id, cd.categories_name, cd.categories_desc, c.categories_picture, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status from " . DB_TBL_CATEGORIES . " c, " . DB_TBL_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
		}


    $items_count = 0;
    if (isset($_GET['search'])) {   
      $items_query = go_db_query("select p.items_ship_price, p.items_ship_price_two, p.syn, p.items_id, p.items_model, p.items_weight, pd.items_name, pd.items_name2, pd.bezeichnung1, pd.inhalt1, pd.bezeichnung2, pd.inhalt2, pd.bezeichnung3, pd.inhalt3, pd.bezeichnung4, pd.inhalt4, pd.bezeichnung5, pd.inhalt5, pd.bezeichnung6, pd.inhalt6, p.items_quantity, p.items_picture, p.items_bpicture, p.items_3picture, p.items_4picture, p.items_5picture, p.items_price,p.items_price_option, p.items_price_uvp, p.items_date_added, p.items_last_modified, p.items_date_available, p.items_date_available_end, p.items_status, p2c.categories_id from " . DB_TBL_ITEMS . " p, " . DB_TBL_ITEMS_DESCRIPTION . " pd, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c where p.items_id = pd.items_id and pd.language_id = '" . (int)$languages_id . "' and p.items_id = p2c.items_id and ( p.items_model like '%" . go_db_input($search) . "%' or pd.items_name like '%" . go_db_input($search) . "%') order by pd.items_name");
    
    } else {  
      $items_query = go_db_query("select p.items_ship_price, p.items_ship_price_two, p.syn, p.items_id, p.items_model, p.items_weight, pd.items_name, pd.items_name2, pd.bezeichnung1, pd.inhalt1, pd.bezeichnung2, pd.inhalt2, pd.bezeichnung3, pd.inhalt3, pd.bezeichnung4, pd.inhalt4, pd.bezeichnung5, pd.inhalt5, pd.bezeichnung6, pd.inhalt6, p.items_quantity, p.items_picture, p.items_bpicture, p.items_3picture, p.items_4picture, p.items_5picture, p.items_price,p.items_price_option, p.items_price_uvp, p.items_date_added, p.items_last_modified, p.items_date_available, p.items_date_available_end, p.items_status from " . DB_TBL_ITEMS . " p, " . DB_TBL_ITEMS_DESCRIPTION . " pd, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c where p.items_id = pd.items_id and pd.language_id = '" . (int)$languages_id . "' and p.items_id = p2c.items_id order by pd.items_name"); 
		}
    while ($items = go_db_fetch_array($items_query)) {
      $items_count++;
      $rows++; 
      if (isset($_GET['search'])) $bigPfad = $items['categories_id'];
      if ( (!isset($_GET['bigID']) && !isset($_GET['bigID']) || (isset($_GET['bigID']) && ($_GET['bigID'] == $items['items_id']))) && !isset($pInfo) && !isset($bigwareInfo) && (substr($action, 0, 3) != 'new')) { 
        $reviews_query = go_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . DB_TBL_REVIEWS . " where items_id = '" . (int)$items['items_id'] . "'");
        $reviews = go_db_fetch_array($reviews_query);
        $pInfo_array = array_merge($items, $reviews);
        $pInfo = new objectInfo($pInfo_array);
      }
//      if (isset($pInfo) && is_object($pInfo) && ($items['items_id'] == $pInfo->items_id) ) {
//        echo '              <tr id="defaultSelected" class="tbCountDataSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $items['items_id'] . '&action=new_item') . '\'">' . "\n";
//      } else {
        echo '              <tr class="tbCountData" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $items['items_id'] . '&action=new_item') . '\'">' . "\n";
//      }
?>

                <td class="TbInsideData">&nbsp;<?php echo '<a href="' . go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'bigPfad=' . $bigPfad . '&bigID=' . $items['items_id'] . '&action=delete_item') . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'papierkorb.gif', 'delete') . '</a>&nbsp;' . $items['items_name']; ?></td>
                <td class="TbInsideData">&nbsp;<?php echo $items['items_model']; ?></td>
                <td class="TbInsideData">&nbsp;<?php echo $items['items_quantity']; ?></td>
                <td class="TbInsideData">&nbsp;<?php echo $items['items_weight']; ?></td>
                <td class="TbInsideData">&nbsp;<?php echo $items['syn']; ?></td>
                <td class="TbInsideData" align="center">&nbsp;
                <?php
      if ($items['items_status'] == '1') {
        echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green.gif', PICTURE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'action=setflag&flag=0&bigID=' . $items['items_id'] . '&bigPfad=' . $bigPfad) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red_light.gif', PICTURE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
      } else {
        echo '<a href="' . go_href_link(NAME_OF_FILE_ALL_ITEMS_LIST, 'action=setflag&flag=1&bigID=' . $items['items_id'] . '&bigPfad=' . $bigPfad) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green_light.gif', PICTURE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red.gif', PICTURE_ICON_STATUS_RED, 10, 10);
      }
?>
</td>
 <?php
                	
		  if ( $action == 'delete_item' ){ 
?>   
		                <td class="TbInsideData" align="right">&nbsp;      	
<?php                	
		                	 if (isset($pInfo) && is_object($pInfo) && ($items['items_id'] == $pInfo->items_id)) { 
		                	 		echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif', ''); 
		                	 	} 
		                	 	else { 
		                	 		echo '<a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, 'bigPfad=' . $bigPfad . '&bigID=' . $items['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_info.gif', PICTURE_ICON_INFO) . '</a>'; 
		                	 	} 
?> 
		                	 &nbsp;</td>  
<?php               	 
		   }      
?>
              </tr>
<?php
    }
    $bigPfad_back = '';
    if (sizeof($bigPfad_array) > 0) {
      for ($i=0, $n=sizeof($bigPfad_array)-1; $i<$n; $i++) {
        if (empty($bigPfad_back)) {
          $bigPfad_back .= $bigPfad_array[$i];
        } else {
          $bigPfad_back .= '_' . $bigPfad_array[$i];
        }
      }
    }
    $bigPfad_back = (go_not_null($bigPfad_back)) ? 'bigPfad=' . $bigPfad_back . '&' : '';
?>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText"><?php echo TEXT_CATEGORIES . '&nbsp;' . $categories_count . '<br>' . TEXT_ITEMS . '&nbsp;' . $items_count; ?></td>
                    <?php if ($bigPfad == "") { ?>
                    <td align="right" class="smallText"><?php if (sizeof($bigPfad_array) > 0) echo '<a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, $bigPfad_back . 'bigID=' . $current_category_id) . '">' . go_picture_button('button_back.gif', PICTURE_BACK); ?></a></td>
                    
		    <?php } else{ ?>
                    <td align="right" class="smallText"><?php if (sizeof($bigPfad_array) > 0) echo '<a href="' . go_href_link(NAME_OF_FILE_CATEGORIES, $bigPfad_back . 'bigID=' . $current_category_id) . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a>&nbsp;'; ?>&nbsp;</td>
                    <?php } ?>
                  </tr>
                </table></td>
              </tr>
            </table></td>
<?php
if ( $action == 'delete_item' ){
	require('all_items_list_boxes.php'); 
}
?>
          </tr>
        </table></td>
      </tr>
    </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'); ?>
