[TEP-COMMIT] [CVS admin] update to the template structure

anonymous-OfajU3CKLf1/[email protected] 22 Jul 2004 23:32:00 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
Commit in admin/admin on MAIN

weight_classes.php +172 -247 1.1 -> 1.2

templates/pages/weight_classes.php +237 added 1.1

+409 -247

1 added + 1 modified, total 2 files

update to the template structure

----------

admin /admin

weight_classes.php 1.1 -> 1.2

diff -u -r1.1 -r1.2
--- weight_classes.php 2004/04/15 16:06:39 1.1
+++ weight_classes.php 2004/07/22 23:31:58 1.2
@@ -12,285 +12,210 @@

require('includes/application_top.php');

- $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

+ $selected_box = 'localization';

- if (tep_not_null($action)) {

+ $action = (isset($_GET['action']) ? $_GET['action'] : '');
+
+ if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
+ $_GET['page'] = 1;
+ }
+
+ if (!empty($action)) {

switch ($action) {

- case 'insert':

case 'save':

- if (isset($HTTP_GET_VARS['wcID'])) $weight_class_id = tep_db_prepare_input($HTTP_GET_VARS['wcID']);
-
- $classes_title_array = $HTTP_POST_VARS['weight_class_title'];
- $classes_key_array = $HTTP_POST_VARS['weight_class_key'];

$languages = tep_get_languages();

- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- $language_id = $languages[$i]['id'];
-
- $sql_data_array = array('weight_class_title' => tep_db_prepare_input($classes_title_array[$language_id]),
- 'weight_class_key' => tep_db_prepare_input($classes_key_array[$language_id]));

- if ($action == 'insert') {
- if (empty($weight_class_id)) {
- $next_id_query = tep_db_query("select max(weight_class_id) as weight_class_id from " . TABLE_WEIGHT_CLASS);
- $next_id = tep_db_fetch_array($next_id_query);
- $weight_class_id = $next_id['weight_class_id'] + 1;
- }

+ if (isset($_GET['wcID']) && is_numeric($_GET['wcID'])) {
+ $weight_class_id = $_GET['wcID'];
+ } else {
+ $Qwc = $osC_Database->query('select max(weight_class_id) as weight_class_id from :table_weight_classes');
+ $Qwc->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qwc->execute();

- $insert_sql_data = array('weight_class_id' => $weight_class_id,
- 'language_id' => $language_id);

+ $weight_class_id = ($Qwc->valueInt('weight_class_id') + 1);
+ }

- $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

+ $error = false;

- tep_db_perform(TABLE_WEIGHT_CLASS, $sql_data_array);
- } elseif ($action == 'save') {
- tep_db_perform(TABLE_WEIGHT_CLASS, $sql_data_array, 'update', "weight_class_id = '" . (int)$weight_class_id . "' and language_id = '" . (int)$language_id . "'");

+ $osC_Database->startTransaction();

- $weight_class_rules_array = $HTTP_POST_VARS['weight_class_rules'];

+ foreach ($languages as $l_entry) {
+ if (isset($_GET['wcID']) && is_numeric($_GET['wcID'])) {
+ $Qwc = $osC_Database->query('update :table_weight_classes set weight_class_key = :weight_class_key, weight_class_title = :weight_class_title where weight_class_id = :weight_class_id and language_id = :language_id');
+ } else {
+ $Qwc = $osC_Database->query('insert into :table_weight_classes (weight_class_id, language_id, weight_class_key, weight_class_title) values (:weight_class_id, :language_id, :weight_class_key, :weight_class_title)');
+ }
+ $Qwc->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qwc->bindInt(':weight_class_id', $weight_class_id);
+ $Qwc->bindInt(':language_id', $l_entry['id']);
+ $Qwc->bindValue(':weight_class_key', $_POST['weight_class_key'][$l_entry['id']]);
+ $Qwc->bindValue(':weight_class_title', $_POST['weight_class_title'][$l_entry['id']]);
+ $Qwc->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }
+ }

- foreach ($weight_class_rules_array as $weight_class_to_id => $weight_class_rule) {
- $sql_data_array = array('weight_class_rule' => tep_db_prepare_input($weight_class_rule));
- tep_db_perform(TABLE_WEIGHT_CLASS_RULES, $sql_data_array, 'update', "weight_class_from_id = '" . (int)$weight_class_id . "' and weight_class_to_id = '" . $weight_class_to_id . "'");

+ if ($error === false) {
+ if (isset($_GET['wcID']) && is_numeric($_GET['wcID'])) {
+ $Qrules = $osC_Database->query('select weight_class_to_id from :table_weight_classes_rules where weight_class_from_id = :weight_class_from_id and weight_class_to_id != :weight_class_to_id');
+ $Qrules->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qrules->bindInt(':weight_class_from_id', $weight_class_id);
+ $Qrules->bindInt(':weight_class_to_id', $weight_class_id);
+ $Qrules->execute();
+
+ while ($Qrules->next()) {
+ $Qrule = $osC_Database->query('update :table_weight_classes_rules set weight_class_rule = :weight_class_rule where weight_class_from_id = :weight_class_from_id and weight_class_to_id = :weight_class_to_id');
+ $Qrule->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qrule->bindValue(':weight_class_rule', $_POST['weight_class_rules'][$Qrules->valueInt('weight_class_to_id')]);
+ $Qrule->bindInt(':weight_class_from_id', $weight_class_id);
+ $Qrule->bindInt(':weight_class_to_id', $Qrules->valueInt('weight_class_to_id'));
+ $Qrule->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }

}

-

+ } else {
+ $Qclasses = $osC_Database->query('select weight_class_id from :table_weight_classes where weight_class_id != :weight_class_id and language_id = :language_id');
+ $Qclasses->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qclasses->bindInt(':weight_class_id', $weight_class_id);
+ $Qclasses->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qclasses->execute();
+
+ while ($Qclasses->next()) {
+ $Qdefault = $osC_Database->query('insert into :table_weight_classes_rules (weight_class_from_id, weight_class_to_id, weight_class_rule) values (:weight_class_from_id, :weight_class_to_id, :weight_class_rule)');
+ $Qdefault->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qdefault->bindInt(':weight_class_from_id', $Qclasses->valueInt('weight_class_id'));
+ $Qdefault->bindInt(':weight_class_to_id', $weight_class_id);
+ $Qdefault->bindValue(':weight_class_rule', '1');
+ $Qdefault->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }
+
+ if ($error === false) {
+ $Qnew = $osC_Database->query('insert into :table_weight_classes_rules (weight_class_from_id, weight_class_to_id, weight_class_rule) values (:weight_class_from_id, :weight_class_to_id, :weight_class_rule)');
+ $Qnew->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qnew->bindInt(':weight_class_from_id', $weight_class_id);
+ $Qnew->bindInt(':weight_class_to_id', $Qclasses->valueInt('weight_class_id'));
+ $Qnew->bindValue(':weight_class_rule', $_POST['weight_class_rules'][$Qclasses->valueInt('weight_class_id')]);
+ $Qnew->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }
+ }
+ }

}
}

- if ($action == 'insert') {
- $classes_query = tep_db_query("select weight_class_id, language_id from " . TABLE_WEIGHT_CLASS . " where weight_class_id != '" . (int)$weight_class_id . "' and language_id = '" . (int)$languages_id . "'");
- while ($classes = tep_db_fetch_array($classes_query)) {
- $sql_data_array = array('weight_class_from_id' => tep_db_prepare_input($weight_class_id),
- 'weight_class_to_id' => tep_db_prepare_input($classes['weight_class_id']),
- 'weight_class_rule' => 1);
- tep_db_perform(TABLE_WEIGHT_CLASS_RULES, $sql_data_array);
-
- $sql_data_array = array('weight_class_from_id' => tep_db_prepare_input($classes['weight_class_id']),
- 'weight_class_to_id' => tep_db_prepare_input($weight_class_id),
- 'weight_class_rule' => 1);
- tep_db_perform(TABLE_WEIGHT_CLASS_RULES, $sql_data_array);
- }

+ if ($error === false) {
+ if (isset($_POST['default']) && ($_POST['default'] == 'on') && (SHIPPING_WEIGHT_UNIT != $weight_class_id)) {
+ $Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
+ $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
+ $Qupdate->bindInt(':configuration_value', $weight_class_id);
+ $Qupdate->bindValue(':configuration_key', 'SHIPPING_WEIGHT_UNIT');
+ $Qupdate->execute();
+
+ if ($osC_Database->isError() === false) {
+ $clear_cache = ($Qupdate->affectedRows() ? true : false);
+ } else {
+ $error = true;
+ }
+ }

}

- if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
- tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($weight_class_id) . "' where configuration_key = 'SHIPPING_WEIGHT_UNIT'");
- }

+ if ($error === false) {
+ $osC_Database->commitTransaction();
+
+ if (isset($_POST['default']) && ($_POST['default'] == 'on') && (SHIPPING_WEIGHT_UNIT != $weight_class_id)) {
+ if ($clear_cache === true) {
+ $osC_Cache->clear('configuration');
+ }
+ }

- osC_Cache::clear('weight-classes');
- osC_Cache::clear('weight-rules');

+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+ } else {
+ $osC_Database->rollbackTransaction();

- tep_redirect(tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $weight_class_id));

+ $messageStack->add_session(ERROR_DB_ROWS_NOT_UPDATED, 'error');
+ }
+
+ tep_redirect(tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $weight_class_id));

break;
case 'deleteconfirm':

- $wcID = tep_db_prepare_input($HTTP_GET_VARS['wcID']);
-
- tep_db_query("delete from " . TABLE_WEIGHT_CLASS . " where weight_class_id = '" . tep_db_input($wcID) . "'");
- tep_db_query("delete from " . TABLE_WEIGHT_CLASS_RULES . " where weight_class_from_id = '" . tep_db_input($wcID) . "' or weight_class_to_id = '" . tep_db_input($wcID) . "'");

+ if (isset($_GET['wcID']) && is_numeric($_GET['wcID'])) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products where products_weight_class = :products_weight_class');
+ $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcheck->bindInt(':products_weight_class', $_GET['wcID']);
+ $Qcheck->execute();
+
+ if ( (SHIPPING_WEIGHT_UNIT == $_GET['wcID']) || ($Qcheck->valueInt('total') > 0) ) {
+ if (SHIPPING_WEIGHT_UNIT == $_GET['wcID']) {
+ $messageStack->add_session(TEXT_INFO_DELETE_PROHIBITED, 'warning');
+ }

- osC_Cache::clear('weight-classes');
- osC_Cache::clear('weight-rules');

+ if ($Qcheck->valueInt('total') > 0) {
+ $messageStack->add_session(sprintf(TEXT_INFO_DELETE_PROHIBITED_PRODUCTS, $Qcheck->valueInt('total')), 'warning');
+ }

- tep_redirect(tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page']));
- break;
- case 'delete':
- $wcID = tep_db_prepare_input($HTTP_GET_VARS['wcID']);

+ tep_redirect(tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $_GET['wcID']));
+ } else {
+ $error = false;
+
+ $osC_Database->startTransaction();
+
+ $Qrules = $osC_Database->query('delete from :table_weight_classes_rules where weight_class_from_id = :weight_class_from_id or weight_class_to_id = :weight_class_to_id');
+ $Qrules->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qrules->bindInt(':weight_class_from_id', $_GET['wcID']);
+ $Qrules->bindInt(':weight_class_to_id', $_GET['wcID']);
+ $Qrules->execute();

- $remove_status = true;
- if ($wcID == SHIPPING_WEIGHT_UNIT) {
- $remove_status = false;
- $messageStack->add(ERROR_REMOVE_DEFAULT_WEIGHT_CLASS, 'error');
- }
- break;
- case 'update_rules':
- $wcID = tep_db_prepare_input($HTTP_GET_VARS['wcID']);

+ if ($osC_Database->isError()) {
+ $error = true;
+ }

+ if ($error === false) {
+ $Qclasses = $osC_Database->query('delete from :table_weight_classes where weight_class_id = :weight_class_id');
+ $Qclasses->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qclasses->bindInt(':weight_class_id', $_GET['wcID']);
+ $Qclasses->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ }
+ }

- 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="includes/stylesheet.css">
-<script language="javascript" src="includes/general.js"></script>
-</head>
-<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
-<!-- 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="2">
- <tr>
- <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
- <tr>
- <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
- <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td valign="top"><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"><?php echo TABLE_HEADING_WEIGHT_CLASSES_TITLE; ?></td>
- <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_WEIGHT_CLASSES_UNIT; ?></td>
- <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
- </tr>
-<?php
- $classes_query_raw = "select weight_class_id, weight_class_key, weight_class_title, language_id from " . TABLE_WEIGHT_CLASS . " where language_id = '" . (int)$languages_id . "' order by weight_class_title";
- $classes_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $classes_query_raw, $classes_query_numrows);
- $classes_query = tep_db_query($classes_query_raw);
- while ($classes = tep_db_fetch_array($classes_query)) {
- if ((!isset($HTTP_GET_VARS['wcID']) || (isset($HTTP_GET_VARS['wcID']) && ($HTTP_GET_VARS['wcID'] == $classes['weight_class_id']))) && !isset($wcInfo) && (substr($action, 0, 3) != 'new')) {
- $wcInfo = new objectInfo($classes);
- }

+ if ($error === false) {
+ $osC_Database->commitTransaction();

- if (isset($wcInfo) && is_object($wcInfo) && ($classes['weight_class_id'] == $wcInfo->weight_class_id)) {
- echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=edit') . '\'">' . "\n";
- } else {
- echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $classes['weight_class_id']) . '\'">' . "\n";
- }

+ $osC_Cache->clear('weight-classes');
+ $osC_Cache->clear('weight-rules');

- if (SHIPPING_WEIGHT_UNIT == $classes['weight_class_id']) {
- echo ' <td class="dataTableContent"><b>' . $classes['weight_class_title'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
- } else {
- echo ' <td class="dataTableContent">' . $classes['weight_class_title'] . '</td>' . "\n";
- }
-?>
- <td class="dataTableContent"><?php echo $classes['weight_class_key']; ?></td>
- <td class="dataTableContent" align="right"><?php if (isset($wcInfo) && is_object($wcInfo) && ($classes['weight_class_id'] == $wcInfo->weight_class_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&oID=' . $classes['weight_class_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_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 $classes_split->display_count($classes_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_WEIGHT_CLASSES); ?></td>
- <td class="smallText" align="right"><?php echo $classes_split->display_links($classes_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
- </tr>
-<?php
- if (empty($action)) {
-?>
- <tr>
- <td colspan="3" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
- </tr>
-<?php
- }
-?>
- </table></td>
- </tr>
- </table></td>
-<?php
- $heading = array();
- $contents = array();
-
- switch ($action) {
- case 'new':
- $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_WEIGHT_CLASS . '</b>');
-
- $contents = array('form' => tep_draw_form('status', FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&action=insert'));
- $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
-
- $classes_inputs_string = '';
- $languages = tep_get_languages();
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- $classes_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('weight_class_title[' . $languages[$i]['id'] . ']') . tep_draw_input_field('weight_class_key[' . $languages[$i]['id'] . ']', $wcInfo->weight_class_key, 'size="4"');
- }
-
- $contents[] = array('text' => '<br>' . TEXT_INFO_WEIGHT_CLASS_TITLE . $classes_inputs_string);
- $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
- $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
- break;
- case 'edit':
- $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_WEIGHT_CLASS . '</b>');
-
- $contents = array('form' => tep_draw_form('edit', FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=save'));
- $contents[] = array('text' => TEXT_INFO_EDIT_INTRO . '</b>');
-
- $classes_inputs_string = '';
- $languages = tep_get_languages();
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- $classes_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('weight_class_title[' . $languages[$i]['id'] . ']', tep_get_weight_class_title($wcInfo->weight_class_id, $languages[$i]['id'])) . tep_draw_input_field('weight_class_key[' . $languages[$i]['id'] . ']', tep_get_weight_class_key($wcInfo->weight_class_id, $languages[$i]['id']), 'size="4"');
- }
-
- $contents[] = array('text' => '<br><b>' . TEXT_INFO_WEIGHT_CLASS_TITLE . '</b>' . $classes_inputs_string);
-
- $contents[] = array('text' => '<br><b>' . TEXT_INFO_HEADING_EDIT_WEIGHT_RULES . '</b>');
- $contents[] = array('form' => tep_draw_form('edit_rules', FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=update_rules'));
-
- $weight_rules_string = '<table border="0" cellspacing="0" cellpadding="2">';
- $rules_query = tep_db_query("select r.weight_class_to_id, r.weight_class_rule, c.weight_class_title from " . TABLE_WEIGHT_CLASS_RULES . " r, " . TABLE_WEIGHT_CLASS . " c where r.weight_class_from_id = '" . $wcInfo->weight_class_id . "' and r.weight_class_to_id != '" . $wcInfo->weight_class_id . "' and r.weight_class_to_id = c.weight_class_id and c.language_id = '" . (int)$languages_id . "' order by c.weight_class_title");
- while ($rules = tep_db_fetch_array($rules_query)) {
- $weight_rules_string .= '<tr><td class="dataTableContent">' . $rules['weight_class_title'] . ':</td><td class="dataTableContent">' . tep_draw_input_field('weight_class_rules[' . $rules['weight_class_to_id'] . ']', $rules['weight_class_rule'], 'size="10"') . '</td></tr>';
- }
-
- $weight_rules_string .= '</table>';
-
- $contents[] = array('text' => $weight_rules_string);
-
- if (SHIPPING_WEIGHT_UNIT != $wcInfo->weight_class_id) $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' <b>' . TEXT_SET_DEFAULT . '</b>');
-
- $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
- break;
- case 'delete':
- $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_WEIGHT_CLASS . '</b>');
-
- $contents = array('form' => tep_draw_form('status', FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=deleteconfirm'));
- $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
- $contents[] = array('text' => '<br><b>' . $wcInfo->weight_class_title . '</b>');
- if ($remove_status) $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
- break;
- default:
- if (isset($wcInfo) && is_object($wcInfo)) {
- $heading[] = array('text' => '<b>' . $wcInfo->weight_class_title . '</b>');

+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+ } else {
+ $osC_Database->rollbackTransaction();

- $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $HTTP_GET_VARS['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');

+ $messageStack->add_session(ERROR_DB_ROWS_NOT_UPDATED, 'error');
+ }

- $classes_inputs_string = '';
- $languages = tep_get_languages();
- for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
- $classes_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_get_weight_class_title($wcInfo->weight_class_id, $languages[$i]['id']);

+ tep_redirect(tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page']));
+ }

}

-
- $contents[] = array('text' => $classes_inputs_string);
- }
- break;

+ break;
+ }

}

- if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
- echo ' <td width="25%" valign="top">' . "\n";

+ $page_contents = 'weight_classes.php';

- $box = new box;
- echo $box->infoBox($heading, $contents);

+ require('templates/default.php');

- echo ' </td>' . "\n";
- }

+ require('includes/application_bottom.php');

?>

- </tr>
- </table></td>
- </tr>
- </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'); ?>

----------

admin /admin /templates /pages

weight_classes.php added at 1.1

diff -N weight_classes.php
--- /dev/null Fri Jul 23 01:31:57 2004
+++ /tmp/cvsAAAHcayDg Fri Jul 23 01:31:58 2004
@@ -0,0 +1,237 @@

+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+?>
+
+<h1><?php echo HEADING_TITLE; ?></h1>
+
+<div id="infoBox_wcDefault" <?php if (!empty($action)) { echo 'style="display: none;"'; } ?>>
+ <table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">
+ <thead>
+ <tr>
+ <th><?php echo TABLE_HEADING_WEIGHT_CLASSES_TITLE; ?></th>
+ <th><?php echo TABLE_HEADING_WEIGHT_CLASSES_UNIT; ?></th>
+ <th><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</th>
+ </tr>
+ </thead>
+ <tbody>
+<?php
+ $Qclasses = $osC_Database->query('select weight_class_id, weight_class_key, weight_class_title from :table_weight_classes where language_id = :language_id order by weight_class_title');
+ $Qclasses->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qclasses->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qclasses->setBatchLimit($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS);
+ $Qclasses->execute();
+
+ while ($Qclasses->next()) {
+ if (!isset($wcInfo) && (!isset($_GET['wcID']) || (isset($_GET['wcID']) && ($_GET['wcID'] == $Qclasses->valueInt('weight_class_id'))))) {
+ $wcInfo = new objectInfo($Qclasses->toArray());
+ }
+
+ if (isset($wcInfo) && ($Qclasses->valueInt('weight_class_id') == $wcInfo->weight_class_id)) {
+ echo ' <tr class="selected">' . "\n";
+ } else {
+ echo ' <tr onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" onClick="document.location.href=\'' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $Qclasses->valueInt('weight_class_id')) . '\';">' . "\n";
+ }
+
+ if (SHIPPING_WEIGHT_UNIT == $Qclasses->valueInt('weight_class_id')) {
+ echo ' <td><b>' . $Qclasses->value('weight_class_title') . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
+ } else {
+ echo ' <td>' . $Qclasses->value('weight_class_title') . '</td>' . "\n";
+ }
+?>
+ <td><?php echo $Qclasses->value('weight_class_key'); ?></td>
+ <td align="right">
+<?php
+ if (isset($wcInfo) && ($Qclasses->valueInt('weight_class_id') == $wcInfo->weight_class_id)) {
+ echo '<a href="#" onClick="toggleInfoBox(\'wcEdit\');">' . tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . '</a>&nbsp;' .
+ '<a href="#" onClick="toggleInfoBox(\'wcDelete\');">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ } else {
+ echo '<a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $Qclasses->valueInt('weight_class_id') . '&action=wcEdit') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . '</a>&nbsp;' .
+ '<a href="' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $Qclasses->valueInt('weight_class_id') . '&action=wcDelete') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ }
+?>
+ </td>
+ </tr>
+<?php
+ }
+?>
+ </tbody>
+ </table>
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td class="smallText"><?php echo $Qclasses->displayBatchLinksTotal(TEXT_DISPLAY_NUMBER_OF_WEIGHT_CLASSES); ?></td>
+ <td class="smallText" align="right"><?php echo $Qclasses->displayBatchLinksPullDown(); ?></td>
+ </tr>
+ </table>
+
+ <p align="right"><?php echo '<input type="button" value="' . IMAGE_INSERT . '" onClick="toggleInfoBox(\'wcNew\');" class="infoBoxButton">'; ?></p>
+</div>
+
+<div id="infoBox_wcNew" <?php if ($action != 'wcNew') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/new.png', IMAGE_INSERT, '16', '16') . ' ' . TEXT_INFO_HEADING_NEW_WEIGHT_CLASS; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('wcNew', FILENAME_WEIGHT_CLASSES, 'action=save'); ?>
+
+ <p><?php echo TEXT_INFO_INSERT_INTRO; ?></p>
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_INFO_WEIGHT_CLASS_TITLE . '</b>'; ?></td>
+ <td class="smallText" width="60%">
+<?php
+ $languages = tep_get_languages();
+ foreach ($languages as $l_entry) {
+ echo tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . '&nbsp;' . osc_draw_input_field('weight_class_title[' . $l_entry['id'] . ']') . osc_draw_input_field('weight_class_key[' . $l_entry['id'] . ']', '', 'size="4"') . '<br>';
+ }
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_INFO_HEADING_EDIT_WEIGHT_RULES . '</b>'; ?></td>
+ <td class="smallText" width="60%">
+ <table border="0" cellspacing="0" cellpadding="2">
+<?php
+ $Qrules = $osC_Database->query('select weight_class_id, weight_class_title from :table_weight_classes where language_id = :language_id order by weight_class_title');
+ $Qrules->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qrules->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qrules->execute();
+
+ while ($Qrules->next()) {
+ echo ' <tr>' . "\n" .
+ ' <td class="dataTableContent">' . $Qrules->value('weight_class_title') . ':</td>' . "\n" .
+ ' <td class="dataTableContent">' . osc_draw_input_field('weight_class_rules[' . $Qrules->valueInt('weight_class_id') . ']') . '</td>' . "\n" .
+ ' </tr>' . "\n";
+ }
+?>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_SET_DEFAULT . '</b>'; ?></td>
+ <td class="smallText" width="60%"><?php echo osc_draw_checkbox_field('default'); ?></td>
+ </tr>
+ </table>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_SAVE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'wcDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<?php
+ if (isset($wcInfo)) {
+?>
+
+<div id="infoBox_wcEdit" <?php if ($action != 'wcEdit') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . ' ' . $wcInfo->weight_class_title; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('wcEdit', FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=save'); ?>
+
+ <p><?php echo TEXT_INFO_EDIT_INTRO; ?></p>
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_INFO_WEIGHT_CLASS_TITLE . '</b>'; ?></td>
+ <td class="smallText" width="60%">
+<?php
+ $Qwc = $osC_Database->query('select language_id, weight_class_key, weight_class_title from :table_weight_classes where weight_class_id = :weight_class_id');
+ $Qwc->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qwc->bindInt(':weight_class_id', $wcInfo->weight_class_id);
+ $Qwc->execute();
+
+ $class_name = array();
+ while ($Qwc->next()) {
+ $class_name[$Qwc->valueInt('language_id')] = array('key' => $Qwc->value('weight_class_key'),
+ 'title' => $Qwc->value('weight_class_title'));
+ }
+
+ $languages = tep_get_languages();
+ foreach ($languages as $l_entry) {
+ echo tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . '&nbsp;' . osc_draw_input_field('weight_class_title[' . $l_entry['id'] . ']', $class_name[$l_entry['id']]['title']) . osc_draw_input_field('weight_class_key[' . $l_entry['id'] . ']', $class_name[$l_entry['id']]['key'], 'size="4"') . '<br>';
+ }
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_INFO_HEADING_EDIT_WEIGHT_RULES . '</b>'; ?></td>
+ <td class="smallText" width="60%">
+ <table border="0" cellspacing="0" cellpadding="2">
+<?php
+ $Qrules = $osC_Database->query('select r.weight_class_to_id, r.weight_class_rule, c.weight_class_title from :table_weight_classes_rules r, :table_weight_classes c where r.weight_class_from_id = :weight_class_from_id and r.weight_class_to_id != :weight_class_to_id and r.weight_class_to_id = c.weight_class_id and c.language_id = :language_id order by c.weight_class_title');
+ $Qrules->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
+ $Qrules->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
+ $Qrules->bindInt(':weight_class_from_id', $wcInfo->weight_class_id);
+ $Qrules->bindInt(':weight_class_to_id', $wcInfo->weight_class_id);
+ $Qrules->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qrules->execute();
+
+ while ($Qrules->next()) {
+ echo ' <tr>' . "\n" .
+ ' <td class="dataTableContent">' . $Qrules->value('weight_class_title') . ':</td>' . "\n" .
+ ' <td class="dataTableContent">' . osc_draw_input_field('weight_class_rules[' . $Qrules->valueInt('weight_class_to_id') . ']', $Qrules->value('weight_class_rule')) . '</td>' . "\n" .
+ ' </tr>' . "\n";
+ }
+?>
+ </table>
+ </td>
+ </tr>
+<?php
+ if (SHIPPING_WEIGHT_UNIT != $wcInfo->weight_class_id) {
+?>
+ <tr>
+ <td class="smallText" width="40%"><?php echo '<b>' . TEXT_SET_DEFAULT . '</b>'; ?></td>
+ <td class="smallText" width="60%"><?php echo osc_draw_checkbox_field('default'); ?></td>
+ </tr>
+<?php
+ }
+?>
+ </table>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_SAVE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'wcDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<div id="infoBox_wcDelete" <?php if ($action != 'wcDelete') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . ' ' . $wcInfo->weight_class_title; ?></div>
+ <div class="infoBoxContent">
+<?php
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products where products_weight_class = :products_weight_class');
+ $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcheck->bindInt(':products_weight_class', $wcInfo->weight_class_id);
+ $Qcheck->execute();
+
+ if ( (SHIPPING_WEIGHT_UNIT == $wcInfo->weight_class_id) || ($Qcheck->valueInt('total') > 0) ) {
+ if (SHIPPING_WEIGHT_UNIT == $wcInfo->weight_class_id) {
+ echo '<p><b>' . TEXT_INFO_DELETE_PROHIBITED . '</b></p>' . "\n";
+ }
+
+ if ($Qcheck->valueInt('total') > 0) {
+ echo ' <p><b>' . sprintf(TEXT_INFO_DELETE_PROHIBITED_PRODUCTS, $Qcheck->valueInt('total')) . '</b></p>' . "\n";
+ }
+
+ echo ' <p align="center"><input type="button" value="' . IMAGE_BACK . '" onClick="toggleInfoBox(\'wcDefault\');" class="operationButton"></p>' . "\n";
+ } else {
+?>
+ <p><?php echo TEXT_INFO_DELETE_INTRO; ?></p>
+ <p><b><?php echo $wcInfo->weight_class_title; ?></b></p>
+ <p align="center"><?php echo '<input type="button" value="' . IMAGE_DELETE . '" class="operationButton" onClick="document.location.href=\'' . tep_href_link(FILENAME_WEIGHT_CLASSES, 'page=' . $_GET['page'] . '&wcID=' . $wcInfo->weight_class_id . '&action=deleteconfirm') . '\';"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'wcDefault\');" class="operationButton">'; ?></p>
+<?php
+ }
+?>
+ </div>
+</div>
+
+<?php
+ }
+?>

CVSspam 0.2.8

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click