<?php
/*
  $Id: branding.php,v 1.7 2003/02/02 19:45:42 wilt Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
          $languages = tep_get_languages();

switch ($HTTP_GET_VARS['action']) {
  case 'status':
//die();
    $branding_query=tep_db_query("select branding_status from " . TABLE_BRANDING_LANGUAGES . " where branding_id='".$HTTP_GET_VARS['info']."'");
    $branding_status=tep_db_fetch_array($branding_query);
    $new_branding_status=1;
    if ($branding_status['branding_status']=='1') {
	$new_branding_status=0;
	}
//die($new_branding_status);
    $branding_update=tep_db_query("update " . TABLE_BRANDING_LANGUAGES . " set branding_status=".$new_branding_status." where branding_id='".$HTTP_GET_VARS['info']."'");
    header('Location: ' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action')) . 'info=' . $HTTP_POST_VARS['branding_id'], 'NONSSL')); tep_exit();
  break;
  default:
}
?>  
<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="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?php
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
        </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
switch ($action) {
  case 'edit':
  $branding_query = tep_db_query("select * from " . TABLE_BRANDING_LANGUAGES . " where branding_id = '" . $HTTP_GET_VARS['cID'] . "'");
  $branding = tep_db_fetch_array($branding_query);
?>
      <form method="post" action="<? echo tep_href_link(FILENAME_BRANDING, 'action=post&cID=' . $HTTP_GET_VARS['cID']); ?>">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
          Defining : <?php echo $branding['branding_name']; ?> on page <?php echo $branding['branding_page']; ?>
          </tr>
          <tr><td>&nbsp;</td></tr>
<?php
    for ($i=0; $i<sizeof($languages); $i++) {
      $branding_language_query = tep_db_query("select text from " . TABLE_BRANDING_LANGUAGES_TEXT . " where branding_id = '" . $HTTP_GET_VARS['cID'] . "' and languages_id = '" . $languages[$i]['id'] . "'");
      $branding_language = tep_db_fetch_array($branding_language_query);
?>
          <tr>
            <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_textarea_field('define_field[' . $languages[$i]['id'] . ']','','60','3', $branding_language['text']); ?></td>
          </tr>
          <tr><td>&nbsp;</td></tr>

<?php
    }
?>
        <tr>
        <td class="main" align="left"><?php echo tep_image_submit('button_submit.gif', IMAGE_SUBMIT) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_BRANDING) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
        </tr>
        </form>
        </table></td>
<?php
  break;
  default:
?>
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE; ?>&nbsp;</td>
            <td align="right">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_TITLE; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_PAGE; ?>&nbsp;</td>
                 <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_STATUS; ?>&nbsp;</td>
                 <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php

    $branding_query_raw = "select branding_id, branding_page, branding_name, branding_status from  " . TABLE_BRANDING_LANGUAGES . " order by branding_name asc";
    $branding_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $branding_query_raw, $branding_query_numrows);
    $branding_query=tep_db_query($branding_query_raw);
    $rows = 0;
    while ($branding_result = tep_db_fetch_array($branding_query)) {
      $rows++;
	if (((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $branding_result['branding_id'])) && (!$brInfo)) {
      $brInfo = new objectInfo($branding_result);
      }

      if ( (is_object($brInfo)) && ($branding_result['branding_id'] == $brInfo->branding_id) ) {
?>
          <tr class="dataTableRowSelected" onmouseover="this.style.cursor='hand'" onclick="document.location.href='<?php echo tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=edit&cID=' . $brInfo->branding_id, 'NONSSL'); ?>'">
<?php
      } else {
?>
          <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='<?php echo tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'info=' . $branding_result['branding_id'], 'NONSSL'); ?>'">
<?php
      }
?>
                <td class="dataTableContent" align="center">&nbsp;<?php echo $branding_result['branding_id']; ?>&nbsp;</td>
                <td class="dataTableContent">&nbsp;<?php echo $branding_result['branding_name']; ?>&nbsp;</td>
                <td class="dataTableContent">&nbsp;<?php echo $branding_result['branding_page']; ?>&nbsp;</td>

                <td class="dataTableContent" align="center">&nbsp;
			<?php
			 if ($branding_result['branding_status']==1) {
				echo '<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=status&info=' . $branding_result['branding_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', _ALT_REOPEN) . '</a>';
				} else {
				echo '<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=status&info=' . $branding_result['branding_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', _ALT_CLOSE) . '</a>';
				}
			?>
			&nbsp;</td>
<?php
      if ($branding_result['branding_id'] == $brInfo->branding_id) {
?>
                <td class="smallText" align="center">&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); ?>&nbsp;</td>
<?php
      } else {
?>
                <td class="smallText" align="center">&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('info', 'action', 'x', 'y')) . 'info=' . $branding_result['branding_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; ?>&nbsp;</td>
<?php
      }
?>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smalltext" valign="top">&nbsp;<?php echo $branding_split->display_count($branding_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ENTRIES); ?>&nbsp;&nbsp;</td>
                    <td class="smalltext" align="right">&nbsp;<?php echo $branding_split->display_links($branding_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>&nbsp;<? echo '<br><br>&nbsp;<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action', 'info')) . 'action=new', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_insert.gif', IMAGE_NEW_LANGUAGE) . '</a>&nbsp;';?></td>
			</tr>
                </table></td>
              </tr>
            </table></td>
<?php
  }
  $heading=array();
  $contents=array();
  
  $heading[] = array('align' => 'left', 'text' => '&nbsp;<b>' . $brInfo->branding_name . '</b>&nbsp;');
  if ($HTTP_GET_VARS['action'] != 'edit') {
  if ($HTTP_GET_VARS['action'] == 'confirm') {
    $form = '<form action="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action')) . 'action=deleteconfirm', 'NONSSL') . '" method="post"><input type="hidden" name="cID" value="' . $brInfo->branding_id . '">'  ."\n";
    $contents[] = array('text' => $form);
    $contents[] = array('align' => 'left', 'text' => TEXT_DELETE_INTRO . '<br>&nbsp;<b>' . $poInfo->name . '</b><br>&nbsp;');
    $contents[] = array('align' => 'center', 'text' => tep_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . tep_href_link(FILENAME_POLLS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  } else {
    $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=edit&cID=' . $brInfo->branding_id, 'NONSSL') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>&nbsp;<a href="' . tep_href_link(FILENAME_BRANDING, tep_get_all_get_params(array('action', 'info', 'x', 'y')) . 'action=confirm&info=' . $brInfo->branding_id, 'NONSSL') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
  }

if ($form) $contents[] = array('text' => '</form>');

    echo '            <td width="25%" valign="top">' . "\n";
$box = new box;
echo $box->infoBox($heading, $contents);
    echo '            </td>' . "\n";
}
?>           
          </tr>
        </table></td>
      </tr>
<?php
?>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
