[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> orders_status.php (source)

   1  <?php
   2  /*

   3  $Id: orders_status.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14  
  15    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  16  
  17    if (tep_not_null($action)) {
  18      switch ($action) {
  19        case 'insert':
  20        case 'save':
  21          if (isset($HTTP_GET_VARS['oID'])) $orders_status_id = tep_db_prepare_input($HTTP_GET_VARS['oID']);
  22  
  23          $languages = tep_get_languages();
  24          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  25            $orders_status_name_array = $HTTP_POST_VARS['orders_status_name'];
  26            $language_id = $languages[$i]['id'];
  27  
  28            $sql_data_array = array('orders_status_name' => tep_db_prepare_input($orders_status_name_array[$language_id]),
  29                                    'public_flag' => ((isset($HTTP_POST_VARS['public_flag']) && ($HTTP_POST_VARS['public_flag'] == '1')) ? '1' : '0'),
  30                                    'downloads_flag' => ((isset($HTTP_POST_VARS['downloads_flag']) && ($HTTP_POST_VARS['downloads_flag'] == '1')) ? '1' : '0'));
  31  
  32            if ($action == 'insert') {
  33              if (empty($orders_status_id)) {
  34                $next_id_query = tep_db_query("select max(orders_status_id) as orders_status_id from " . TABLE_ORDERS_STATUS . "");
  35                $next_id = tep_db_fetch_array($next_id_query);
  36                $orders_status_id = $next_id['orders_status_id'] + 1;
  37              }
  38  
  39              $insert_sql_data = array('orders_status_id' => $orders_status_id,
  40                                       'language_id' => $language_id);
  41  
  42              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  43  
  44              tep_db_perform(TABLE_ORDERS_STATUS, $sql_data_array);
  45            } elseif ($action == 'save') {
  46              tep_db_perform(TABLE_ORDERS_STATUS, $sql_data_array, 'update', "orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");
  47            }
  48          }
  49  
  50          if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
  51            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($orders_status_id) . "' where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
  52          }
  53  
  54          tep_redirect(tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $orders_status_id));
  55          break;
  56        case 'deleteconfirm':
  57          $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
  58  
  59          $orders_status_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
  60          $orders_status = tep_db_fetch_array($orders_status_query);
  61  
  62          if ($orders_status['configuration_value'] == $oID) {
  63            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
  64          }
  65  
  66          tep_db_query("delete from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . tep_db_input($oID) . "'");
  67  
  68          tep_redirect(tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page']));
  69          break;
  70        case 'delete':
  71          $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
  72  
  73          $status_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS . " where orders_status = '" . (int)$oID . "'");
  74          $status = tep_db_fetch_array($status_query);
  75  
  76          $remove_status = true;
  77          if ($oID == DEFAULT_ORDERS_STATUS_ID) {
  78            $remove_status = false;
  79            $messageStack->add(ERROR_REMOVE_DEFAULT_ORDER_STATUS, 'error');
  80          } elseif ($status['count'] > 0) {
  81            $remove_status = false;
  82            $messageStack->add(ERROR_STATUS_USED_IN_ORDERS, 'error');
  83          } else {
  84            $history_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_status_id = '" . (int)$oID . "'");
  85            $history = tep_db_fetch_array($history_query);
  86            if ($history['count'] > 0) {
  87              $remove_status = false;
  88              $messageStack->add(ERROR_STATUS_USED_IN_HISTORY, 'error');
  89            }
  90          }
  91          break;
  92      }
  93    }
  94  ?>
  95  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  96  <html <?php echo HTML_PARAMS; ?>>
  97  <head>
  98  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  99  <title><?php echo TITLE; ?></title>
 100  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 101  <script language="javascript" src="includes/general.js"></script>
 102  </head>
 103  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
 104  <!-- header //-->
 105  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 106  <!-- header_eof //-->
 107  
 108  <!-- body //-->
 109  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 110    <tr>
 111      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 112  <!-- left_navigation //-->
 113  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 114  <!-- left_navigation_eof //-->
 115      </table></td>
 116  <!-- body_text //-->
 117      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 118        <tr>
 119          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 120            <tr>
 121              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 122              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 123            </tr>
 124          </table></td>
 125        </tr>
 126        <tr>
 127          <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 128            <tr>
 129              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 130                <tr class="dataTableHeadingRow">
 131                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ORDERS_STATUS; ?></td>
 132                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PUBLIC_STATUS; ?></td>
 133                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DOWNLOADS_STATUS; ?></td>
 134                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 135                </tr>
 136  <?php
 137    $orders_status_query_raw = "select * from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id";
 138    $orders_status_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_status_query_raw, $orders_status_query_numrows);
 139    $orders_status_query = tep_db_query($orders_status_query_raw);
 140    while ($orders_status = tep_db_fetch_array($orders_status_query)) {
 141      if ((!isset($HTTP_GET_VARS['oID']) || (isset($HTTP_GET_VARS['oID']) && ($HTTP_GET_VARS['oID'] == $orders_status['orders_status_id']))) && !isset($oInfo) && (substr($action, 0, 3) != 'new')) {
 142        $oInfo = new objectInfo($orders_status);
 143      }
 144  
 145      if (isset($oInfo) && is_object($oInfo) && ($orders_status['orders_status_id'] == $oInfo->orders_status_id)) {
 146        echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id . '&action=edit') . '\'">' . "\n";
 147      } else {
 148        echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $orders_status['orders_status_id']) . '\'">' . "\n";
 149      }
 150  
 151      if (DEFAULT_ORDERS_STATUS_ID == $orders_status['orders_status_id']) {
 152        echo '                <td class="dataTableContent"><b>' . $orders_status['orders_status_name'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
 153      } else {
 154        echo '                <td class="dataTableContent">' . $orders_status['orders_status_name'] . '</td>' . "\n";
 155      }
 156  ?>
 157                  <td class="dataTableContent" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'icons/' . (($orders_status['public_flag'] == '1') ? 'tick.gif' : 'cross.gif')); ?></td>
 158                  <td class="dataTableContent" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'icons/' . (($orders_status['downloads_flag'] == '1') ? 'tick.gif' : 'cross.gif')); ?></td>
 159                  <td class="dataTableContent" align="right"><?php if (isset($oInfo) && is_object($oInfo) && ($orders_status['orders_status_id'] == $oInfo->orders_status_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $orders_status['orders_status_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 160                </tr>
 161  <?php
 162    }
 163  ?>
 164                <tr>
 165                  <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 166                    <tr>
 167                      <td class="smallText" valign="top"><?php echo $orders_status_split->display_count($orders_status_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS_STATUS); ?></td>
 168                      <td class="smallText" align="right"><?php echo $orders_status_split->display_links($orders_status_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
 169                    </tr>
 170  <?php
 171    if (empty($action)) {
 172  ?>
 173                    <tr>
 174                      <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
 175                    </tr>
 176  <?php
 177    }
 178  ?>
 179                  </table></td>
 180                </tr>
 181              </table></td>
 182  <?php
 183    $heading = array();
 184    $contents = array();
 185  
 186    switch ($action) {
 187      case 'new':
 188        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_ORDERS_STATUS . '</b>');
 189  
 190        $contents = array('form' => tep_draw_form('status', FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&action=insert'));
 191        $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
 192  
 193        $orders_status_inputs_string = '';
 194        $languages = tep_get_languages();
 195        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 196          $orders_status_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('orders_status_name[' . $languages[$i]['id'] . ']');
 197        }
 198  
 199        $contents[] = array('text' => '<br>' . TEXT_INFO_ORDERS_STATUS_NAME . $orders_status_inputs_string);
 200        $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('public_flag', '1') . ' ' . TEXT_SET_PUBLIC_STATUS);
 201        $contents[] = array('text' => tep_draw_checkbox_field('downloads_flag', '1') . ' ' . TEXT_SET_DOWNLOADS_STATUS);
 202        $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
 203        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 204        break;
 205      case 'edit':
 206        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_ORDERS_STATUS . '</b>');
 207  
 208        $contents = array('form' => tep_draw_form('status', FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id  . '&action=save'));
 209        $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
 210  
 211        $orders_status_inputs_string = '';
 212        $languages = tep_get_languages();
 213        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 214          $orders_status_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('orders_status_name[' . $languages[$i]['id'] . ']', tep_get_orders_status_name($oInfo->orders_status_id, $languages[$i]['id']));
 215        }
 216  
 217        $contents[] = array('text' => '<br>' . TEXT_INFO_ORDERS_STATUS_NAME . $orders_status_inputs_string);
 218        $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('public_flag', '1', $oInfo->public_flag) . ' ' . TEXT_SET_PUBLIC_STATUS);
 219        $contents[] = array('text' => tep_draw_checkbox_field('downloads_flag', '1', $oInfo->downloads_flag) . ' ' . TEXT_SET_DOWNLOADS_STATUS);
 220        if (DEFAULT_ORDERS_STATUS_ID != $oInfo->orders_status_id) $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
 221        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 222        break;
 223      case 'delete':
 224        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_ORDERS_STATUS . '</b>');
 225  
 226        $contents = array('form' => tep_draw_form('status', FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id  . '&action=deleteconfirm'));
 227        $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
 228        $contents[] = array('text' => '<br><b>' . $oInfo->orders_status_name . '</b>');
 229        if ($remove_status) $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 230        break;
 231      default:
 232        if (isset($oInfo) && is_object($oInfo)) {
 233          $heading[] = array('text' => '<b>' . $oInfo->orders_status_name . '</b>');
 234  
 235          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_STATUS, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $oInfo->orders_status_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
 236  
 237          $orders_status_inputs_string = '';
 238          $languages = tep_get_languages();
 239          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 240            $orders_status_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_get_orders_status_name($oInfo->orders_status_id, $languages[$i]['id']);
 241          }
 242  
 243          $contents[] = array('text' => $orders_status_inputs_string);
 244        }
 245        break;
 246    }
 247  
 248    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
 249      echo '            <td width="25%" valign="top">' . "\n";
 250  
 251      $box = new box;
 252      echo $box->infoBox($heading, $contents);
 253  
 254      echo '            </td>' . "\n";
 255    }
 256  ?>
 257            </tr>
 258          </table></td>
 259        </tr>
 260      </table></td>
 261  <!-- body_text_eof //-->
 262    </tr>
 263  </table>
 264  <!-- body_eof //-->
 265  
 266  <!-- footer //-->
 267  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 268  <!-- footer_eof //-->
 269  <br>
 270  </body>
 271  </html>
 272  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7