<?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 'insert':
        $name = go_db_producing_input($_POST['name']);
        $code = go_db_producing_input($_POST['code']);
        $picture = go_db_producing_input($_POST['picture']);
        $directory = go_db_producing_input($_POST['directory']);
        $sort_order = go_db_producing_input($_POST['sort_order']);
        go_db_query("insert into " . DB_TBL_LANGUAGES . " (name, code, picture, directory, sort_order) values ('" . go_db_input($name) . "', '" . go_db_input($code) . "', '" . go_db_input($picture) . "', '" . go_db_input($directory) . "', '" . go_db_input($sort_order) . "')");
        $insert_id = go_db_insert_id(); 
        $categories_query = go_db_query("select c.categories_id, cd.categories_name from ((" . DB_TBL_CATEGORIES . " c) left join " . DB_TBL_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id) where cd.language_id = '" . (int)$languages_id . "'");
        while ($categories = go_db_fetch_array($categories_query)) {
          go_db_query("insert into " . DB_TBL_CATEGORIES_DESCRIPTION . " (categories_id, language_id, categories_name) values ('" . (int)$categories['categories_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($categories['categories_name']) . "')");
        } 
        $items_query = go_db_query("select p.items_id, pd.items_name, pd.items_description, pd.items_url from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_ITEMS_DESCRIPTION . " pd on p.items_id = pd.items_id) where pd.language_id = '" . (int)$languages_id . "'");
        while ($items = go_db_fetch_array($items_query)) {
          go_db_query("insert into " . DB_TBL_ITEMS_DESCRIPTION . " (items_id, language_id, items_name, items_description, items_url) values ('" . (int)$items['items_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($items['items_name']) . "', '" . go_db_input($items['items_description']) . "', '" . go_db_input($items['items_url']) . "')");
        } 
        $items_options_query = go_db_query("select items_options_id, items_options_name from " . DB_TBL_ITEMS_OPTIONS . " where language_id = '" . (int)$languages_id . "'");
        while ($items_options = go_db_fetch_array($items_options_query)) {
          go_db_query("insert into " . DB_TBL_ITEMS_OPTIONS . " (items_options_id, language_id, items_options_name) values ('" . (int)$items_options['items_options_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($items_options['items_options_name']) . "')");
        } 
        $items_options_values_query = go_db_query("select items_options_values_id, items_options_values_name from " . DB_TBL_ITEMS_OPTIONS_VALUES . " where language_id = '" . (int)$languages_id . "'");
        while ($items_options_values = go_db_fetch_array($items_options_values_query)) {
          go_db_query("insert into " . DB_TBL_ITEMS_OPTIONS_VALUES . " (items_options_values_id, language_id, items_options_values_name) values ('" . (int)$items_options_values['items_options_values_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($items_options_values['items_options_values_name']) . "')");
        } 
        $producers_query = go_db_query("select m.producers_id, mi.producers_url from ((" . DB_TBL_PRODUCERS . " m) left join " . DB_TBL_PRODUCERS_INFO . " mi on m.producers_id = mi.producers_id) where mi.languages_id = '" . (int)$languages_id . "'");
        while ($producers = go_db_fetch_array($producers_query)) {
          go_db_query("insert into " . DB_TBL_PRODUCERS_INFO . " (producers_id, languages_id, producers_url) values ('" . $producers['producers_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($producers['producers_url']) . "')");
        } 
        $orders_status_query = go_db_query("select orders_status_id, orders_status_name from " . DB_TBL_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
        while ($orders_status = go_db_fetch_array($orders_status_query)) {
          go_db_query("insert into " . DB_TBL_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . (int)$orders_status['orders_status_id'] . "', '" . (int)$insert_id . "', '" . go_db_input($orders_status['orders_status_name']) . "')");
        }
        if (isset($_POST['default']) && ($_POST['default'] == 'on')) {
          go_db_query("update " . DB_TBL_SET_IT_UP . " set set_it_up_value = '" . go_db_input($code) . "' where set_it_up_key = 'DEFAULT_LANGUAGE'");
        }
        go_forward(go_href_link(NAME_OF_FILE_LANGUAGES, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'lID=' . $insert_id));
        break;
      case 'save':
        $lID = go_db_producing_input($_GET['lID']);
        $name = go_db_producing_input($_POST['name']);
        $code = go_db_producing_input($_POST['code']);
        $picture = go_db_producing_input($_POST['picture']);
        $directory = go_db_producing_input($_POST['directory']);
        $sort_order = go_db_producing_input($_POST['sort_order']);
        go_db_query("update " . DB_TBL_LANGUAGES . " set name = '" . go_db_input($name) . "', code = '" . go_db_input($code) . "', picture = '" . go_db_input($picture) . "', directory = '" . go_db_input($directory) . "', sort_order = '" . go_db_input($sort_order) . "' where languages_id = '" . (int)$lID . "'");
        if ($_POST['default'] == 'on') {
          go_db_query("update " . DB_TBL_SET_IT_UP . " set set_it_up_value = '" . go_db_input($code) . "' where set_it_up_key = 'DEFAULT_LANGUAGE'");
        }
        go_forward(go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $_GET['lID']));
        break;
      case 'deleteconfirm':
        $lID = go_db_producing_input($_GET['lID']);
        $lng_query = go_db_query("select languages_id from " . DB_TBL_LANGUAGES . " where code = '" . DEFAULT_CURRENCY . "'");
        $lng = go_db_fetch_array($lng_query);
        if ($lng['languages_id'] == $lID) {
          go_db_query("update " . DB_TBL_SET_IT_UP . " set set_it_up_value = '' where set_it_up_key = 'DEFAULT_CURRENCY'");
        }
        go_db_query("delete from " . DB_TBL_CATEGORIES_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_ITEMS_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_ITEMS_OPTIONS . " where language_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_ITEMS_OPTIONS_VALUES . " where language_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_PRODUCERS_INFO . " where languages_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_ORDERS_STATUS . " where language_id = '" . (int)$lID . "'");
        go_db_query("delete from " . DB_TBL_LANGUAGES . " where languages_id = '" . (int)$lID . "'");
        go_forward(go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page']));
        break;
      case 'delete':
        $lID = go_db_producing_input($_GET['lID']);
        $lng_query = go_db_query("select code from " . DB_TBL_LANGUAGES . " where languages_id = '" . (int)$lID . "'");
        $lng = go_db_fetch_array($lng_query);
        $remove_language = true;
        if ($lng['code'] == DEFAULT_LANGUAGE) {
          $remove_language = false;
          $messageStack->add(ERROR_REMOVE_DEFAULT_LANGUAGE, 'error');
        }
        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>
      <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_LANGUAGE_NAME; ?></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_LANGUAGE_CODE; ?></td>
                <td class="tbUPDataInside" align="right"><?php echo DB_TBL_ABOVE_ACTION; ?>&nbsp;</td>
              </tr>
<?php
  $languages_query_raw = "select languages_id, name, code, picture, directory, sort_order from " . DB_TBL_LANGUAGES . " order by sort_order";
  $languages_split = new splitPageResults($_GET['page'], MAX_SHOW_SEARCH_RESULTS, $languages_query_raw, $languages_query_numrows);
  $languages_query = go_db_query($languages_query_raw);
  while ($languages = go_db_fetch_array($languages_query)) {
    if ((!isset($_GET['lID']) || (isset($_GET['lID']) && ($_GET['lID'] == $languages['languages_id']))) && !isset($lInfo) && (substr($action, 0, 3) != 'new')) {
      $lInfo = new objectInfo($languages);
    }
    if (isset($lInfo) && is_object($lInfo) && ($languages['languages_id'] == $lInfo->languages_id) ) {
      echo '                  <tr id="defaultSelected" class="tbCountDataSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=change') . '\'">' . "\n";
    } else {
      echo '                  <tr class="tbCountData" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $languages['languages_id']) . '\'">' . "\n";
    }
    if (DEFAULT_LANGUAGE == $languages['code']) {
      echo '                <td class="TbInsideData"><b>' . $languages['name'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
    } else {
      echo '                <td class="TbInsideData">' . $languages['name'] . '</td>' . "\n";
    }
?>
                <td class="TbInsideData"><?php echo $languages['code']; ?></td>
                <td class="TbInsideData" align="right"><?php if (isset($lInfo) && is_object($lInfo) && ($languages['languages_id'] == $lInfo->languages_id)) { echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif'); } else { echo '<a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $languages['languages_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_info.gif', PICTURE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
  }
?>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $languages_split->display_count($languages_query_numrows, MAX_SHOW_SEARCH_RESULTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_LANGUAGES); ?></td>
                    <td class="smallText" align="right"><?php echo $languages_split->display_links($languages_query_numrows, MAX_SHOW_SEARCH_RESULTS, MAX_SHOW_PAGE_LINKS, $_GET['page']); ?></td>
                  </tr>
<?php
  if (empty($action)) {
?>
                  <tr>
                    <td align="right" colspan="2"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=new') . '">' . go_picture_button('button_new_language.gif', PICTURE_NEW_LANGUAGE) . '</a>'; ?></td>
                  </tr>
<?php
  }
?>
                </table></td>
              </tr>
            </table></td>
<?php
  $heading = array();
  $contents = array();
  switch ($action) {
    case 'new':
      $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_NEW_LANGUAGE . '</b>');
      $contents = array('form' => go_fetch_form('languages', NAME_OF_FILE_LANGUAGES, 'action=insert'));
      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . go_fetch_inputfeld('name'));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_CODE . '<br>' . go_fetch_inputfeld('code'));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_PICTURE . '<br>' . go_fetch_inputfeld('picture', 'icon.gif'));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . go_fetch_inputfeld('directory'));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br>' . go_fetch_inputfeld('sort_order'));
      $contents[] = array('text' => '<br>' . go_fetch_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
      $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_insert.gif', PICTURE_INSERT) . ' <a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $_GET['lID']) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
      break;
    case 'change':
      $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_CHANGE_LANGUAGE . '</b>');
      $contents = array('form' => go_fetch_form('languages', NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=save'));
      $contents[] = array('text' => TEXT_INFO_CHANGE_INTRO);
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . go_fetch_inputfeld('name', $lInfo->name));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_CODE . '<br>' . go_fetch_inputfeld('code', $lInfo->code));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_PICTURE . '<br>' . go_fetch_inputfeld('picture', $lInfo->picture));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . go_fetch_inputfeld('directory', $lInfo->directory));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br>' . go_fetch_inputfeld('sort_order', $lInfo->sort_order));
      if (DEFAULT_LANGUAGE != $lInfo->code) $contents[] = array('text' => '<br>' . go_fetch_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
      $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_update.gif', PICTURE_UPDATE) . ' <a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
      break;
    case 'delete':
      $heading[] = array('text' => '<b>' . TEXT_INFO_ABOVE_DELETE_LANGUAGE . '</b>');
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<br><b>' . $lInfo->name . '</b>');
      $contents[] = array('align' => 'center', 'text' => '<br>' . (($remove_language) ? '<a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=deleteconfirm') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a>' : '') . ' <a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
      break;
    default:
      if (is_object($lInfo)) {
        $heading[] = array('text' => '<b>' . $lInfo->name . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=change') . '">' . go_picture_button('button_change.gif', PICTURE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=delete') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_DEFINE_LANGUAGE, 'lngdir=' . $lInfo->directory) . '">' . go_picture_button('button_details.gif', PICTURE_DETAILS) . '</a>');
        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . ' ' . $lInfo->name);
        $contents[] = array('text' => TEXT_INFO_LANGUAGE_CODE . ' ' . $lInfo->code);
        $contents[] = array('text' => '<br>' . go_picture(FOLDER_RELATIV_CATALOG_LANGUAGES . $lInfo->directory . '/picture/' . $lInfo->picture, $lInfo->name));
        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . FOLDER_RELATIV_CATALOG_LANGUAGES . '<b>' . $lInfo->directory . '</b>');
        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . ' ' . $lInfo->sort_order);
      }
      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>
    </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'); ?>
