home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / pc / contents / ecommerce / software / osCommerce.exe / oscommerce-2.2ms2 / catalog / admin / zones.php < prev   
PHP Script  |  2003-06-29  |  11KB  |  199 lines

  1. <?php
  2. /*
  3.   $Id: zones.php,v 1.23 2003/06/29 22:50:52 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2002 osCommerce
  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.         $zone_country_id = tep_db_prepare_input($HTTP_POST_VARS['zone_country_id']);
  21.         $zone_code = tep_db_prepare_input($HTTP_POST_VARS['zone_code']);
  22.         $zone_name = tep_db_prepare_input($HTTP_POST_VARS['zone_name']);
  23.  
  24.         tep_db_query("insert into " . TABLE_ZONES . " (zone_country_id, zone_code, zone_name) values ('" . (int)$zone_country_id . "', '" . tep_db_input($zone_code) . "', '" . tep_db_input($zone_name) . "')");
  25.  
  26.         tep_redirect(tep_href_link(FILENAME_ZONES));
  27.         break;
  28.       case 'save':
  29.         $zone_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  30.         $zone_country_id = tep_db_prepare_input($HTTP_POST_VARS['zone_country_id']);
  31.         $zone_code = tep_db_prepare_input($HTTP_POST_VARS['zone_code']);
  32.         $zone_name = tep_db_prepare_input($HTTP_POST_VARS['zone_name']);
  33.  
  34.         tep_db_query("update " . TABLE_ZONES . " set zone_country_id = '" . (int)$zone_country_id . "', zone_code = '" . tep_db_input($zone_code) . "', zone_name = '" . tep_db_input($zone_name) . "' where zone_id = '" . (int)$zone_id . "'");
  35.  
  36.         tep_redirect(tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $zone_id));
  37.         break;
  38.       case 'deleteconfirm':
  39.         $zone_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  40.  
  41.         tep_db_query("delete from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");
  42.  
  43.         tep_redirect(tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page']));
  44.         break;
  45.     }
  46.   }
  47. ?>
  48. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  49. <html <?php echo HTML_PARAMS; ?>>
  50. <head>
  51. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  52. <title><?php echo TITLE; ?></title>
  53. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  54. <script language="javascript" src="includes/general.js"></script>
  55. </head>
  56. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
  57. <!-- header //-->
  58. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  59. <!-- header_eof //-->
  60.  
  61. <!-- body //-->
  62. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  63.   <tr>
  64.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  65. <!-- left_navigation //-->
  66. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  67. <!-- left_navigation_eof //-->
  68.     </table></td>
  69. <!-- body_text //-->
  70.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  71.       <tr>
  72.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  73.           <tr>
  74.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  75.             <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  76.           </tr>
  77.         </table></td>
  78.       </tr>
  79.       <tr>
  80.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  81.           <tr>
  82.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  83.               <tr class="dataTableHeadingRow">
  84.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td>
  85.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ZONE_NAME; ?></td>
  86.                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ZONE_CODE; ?></td>
  87.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
  88.               </tr>
  89. <?php
  90.   $zones_query_raw = "select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id order by c.countries_name, z.zone_name";
  91.   $zones_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $zones_query_raw, $zones_query_numrows);
  92.   $zones_query = tep_db_query($zones_query_raw);
  93.   while ($zones = tep_db_fetch_array($zones_query)) {
  94.     if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $zones['zone_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
  95.       $cInfo = new objectInfo($zones);
  96.     }
  97.  
  98.     if (isset($cInfo) && is_object($cInfo) && ($zones['zone_id'] == $cInfo->zone_id)) {
  99.       echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id . '&action=edit') . '\'">' . "\n";
  100.     } else {
  101.       echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $zones['zone_id']) . '\'">' . "\n";
  102.     }
  103. ?>
  104.                 <td class="dataTableContent"><?php echo $zones['countries_name']; ?></td>
  105.                 <td class="dataTableContent"><?php echo $zones['zone_name']; ?></td>
  106.                 <td class="dataTableContent" align="center"><?php echo $zones['zone_code']; ?></td>
  107.                 <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($zones['zone_id'] == $cInfo->zone_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $zones['zone_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
  108.               </tr>
  109. <?php
  110.   }
  111. ?>
  112.               <tr>
  113.                 <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  114.                   <tr>
  115.                     <td class="smallText" valign="top"><?php echo $zones_split->display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ZONES); ?></td>
  116.                     <td class="smallText" align="right"><?php echo $zones_split->display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
  117.                   </tr>
  118. <?php
  119.   if (empty($action)) {
  120. ?>
  121.                   <tr>
  122.                     <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new_zone.gif', IMAGE_NEW_ZONE) . '</a>'; ?></td>
  123.                   </tr>
  124. <?php
  125.   }
  126. ?>
  127.                 </table></td>
  128.               </tr>
  129.             </table></td>
  130. <?php
  131.   $heading = array();
  132.   $contents = array();
  133.  
  134.   switch ($action) {
  135.     case 'new':
  136.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_ZONE . '</b>');
  137.  
  138.       $contents = array('form' => tep_draw_form('zones', FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&action=insert'));
  139.       $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
  140.       $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . tep_draw_input_field('zone_name'));
  141.       $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_CODE . '<br>' . tep_draw_input_field('zone_code'));
  142.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries()));
  143.       $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  144.       break;
  145.     case 'edit':
  146.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_ZONE . '</b>');
  147.  
  148.       $contents = array('form' => tep_draw_form('zones', FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id . '&action=save'));
  149.       $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
  150.       $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . tep_draw_input_field('zone_name', $cInfo->zone_name));
  151.       $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_CODE . '<br>' . tep_draw_input_field('zone_code', $cInfo->zone_code));
  152.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(), $cInfo->countries_id));
  153.       $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  154.       break;
  155.     case 'delete':
  156.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_ZONE . '</b>');
  157.  
  158.       $contents = array('form' => tep_draw_form('zones', FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id . '&action=deleteconfirm'));
  159.       $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  160.       $contents[] = array('text' => '<br><b>' . $cInfo->zone_name . '</b>');
  161.       $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  162.       break;
  163.     default:
  164.       if (isset($cInfo) && is_object($cInfo)) {
  165.         $heading[] = array('text' => '<b>' . $cInfo->zone_name . '</b>');
  166.  
  167.         $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ZONES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->zone_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
  168.         $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . $cInfo->zone_name . ' (' . $cInfo->zone_code . ')');
  169.         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . ' ' . $cInfo->countries_name);
  170.       }
  171.       break;
  172.   }
  173.  
  174.   if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
  175.     echo '            <td width="25%" valign="top">' . "\n";
  176.  
  177.     $box = new box;
  178.     echo $box->infoBox($heading, $contents);
  179.  
  180.     echo '            </td>' . "\n";
  181.   }
  182. ?>
  183.           </tr>
  184.         </table></td>
  185.       </tr>
  186.     </table></td>
  187. <!-- body_text_eof //-->
  188.   </tr>
  189. </table>
  190. <!-- body_eof //-->
  191.  
  192. <!-- footer //-->
  193. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  194. <!-- footer_eof //-->
  195. <br>
  196. </body>
  197. </html>
  198. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  199.