PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/zones.php

http://daocart.googlecode.com/
PHP | 232 lines | 193 code | 17 blank | 22 comment | 28 complexity | 96370200d22183054de3a39266132016 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, BSD-3-Clause
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // |zen-cart Open Source E-commerce |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2003 The zen-cart developers |
  7. // | |
  8. // | http://www.zen-cart.com/index.php |
  9. // | |
  10. // | Portions Copyright (c) 2003 osCommerce |
  11. // +----------------------------------------------------------------------+
  12. // | This source file is subject to version 2.0 of the GPL license, |
  13. // | that is bundled with this package in the file LICENSE, and is |
  14. // | available through the world-wide-web at the following url: |
  15. // | http://www.zen-cart.com/license/2_0.txt. |
  16. // | If you did not receive a copy of the zen-cart license and are unable |
  17. // | to obtain it through the world-wide-web, please send a note to |
  18. // | license@zen-cart.com so we can mail you a copy immediately. |
  19. // +----------------------------------------------------------------------+
  20. // $Id: zones.php 1969 2005-09-13 06:57:21Z drbyte $
  21. //
  22. require('includes/application_top.php');
  23. $action = (isset($_GET['action']) ? $_GET['action'] : '');
  24. if (zen_not_null($action)) {
  25. switch ($action) {
  26. case 'insert':
  27. $zone_country_id = zen_db_prepare_input($_POST['zone_country_id']);
  28. $zone_code = zen_db_prepare_input($_POST['zone_code']);
  29. $zone_name = zen_db_prepare_input($_POST['zone_name']);
  30. $db->Execute("insert into " . TABLE_ZONES . "
  31. (zone_country_id, zone_code, zone_name)
  32. values ('" . (int)$zone_country_id . "',
  33. '" . zen_db_input($zone_code) . "',
  34. '" . zen_db_input($zone_name) . "')");
  35. zen_redirect(zen_href_link(FILENAME_ZONES));
  36. break;
  37. case 'save':
  38. $zone_id = zen_db_prepare_input($_GET['cID']);
  39. $zone_country_id = zen_db_prepare_input($_POST['zone_country_id']);
  40. $zone_code = zen_db_prepare_input($_POST['zone_code']);
  41. $zone_name = zen_db_prepare_input($_POST['zone_name']);
  42. $db->Execute("update " . TABLE_ZONES . "
  43. set zone_country_id = '" . (int)$zone_country_id . "',
  44. zone_code = '" . zen_db_input($zone_code) . "',
  45. zone_name = '" . zen_db_input($zone_name) . "'
  46. where zone_id = '" . (int)$zone_id . "'");
  47. zen_redirect(zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $zone_id));
  48. break;
  49. case 'deleteconfirm':
  50. // demo active test
  51. if (zen_admin_demo()) {
  52. $_GET['action']= '';
  53. $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  54. zen_redirect(zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page']));
  55. }
  56. $zone_id = zen_db_prepare_input($_GET['cID']);
  57. $db->Execute("delete from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");
  58. zen_redirect(zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page']));
  59. break;
  60. }
  61. }
  62. ?>
  63. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  64. <html <?php echo HTML_PARAMS; ?>>
  65. <head>
  66. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  67. <title><?php echo TITLE; ?></title>
  68. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  69. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  70. <script language="javascript" src="includes/menu.js"></script>
  71. <script language="javascript" src="includes/general.js"></script>
  72. <script type="text/javascript">
  73. <!--
  74. function init()
  75. {
  76. cssjsmenu('navbar');
  77. if (document.getElementById)
  78. {
  79. var kill = document.getElementById('hoverJS');
  80. kill.disabled = true;
  81. }
  82. }
  83. // -->
  84. </script>
  85. </head>
  86. <body onload="init()">
  87. <!-- header //-->
  88. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  89. <!-- header_eof //-->
  90. <!-- body //-->
  91. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  92. <tr>
  93. <!-- body_text //-->
  94. <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  95. <tr>
  96. <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  97. <tr>
  98. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  99. <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  100. </tr>
  101. </table></td>
  102. </tr>
  103. <tr>
  104. <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  105. <tr>
  106. <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  107. <tr class="dataTableHeadingRow">
  108. <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td>
  109. <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ZONE_NAME; ?></td>
  110. <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ZONE_CODE; ?></td>
  111. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  112. </tr>
  113. <?php
  114. $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";
  115. $zones_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $zones_query_raw, $zones_query_numrows);
  116. $zones = $db->Execute($zones_query_raw);
  117. while (!$zones->EOF) {
  118. if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $zones->fields['zone_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
  119. $cInfo = new objectInfo($zones->fields);
  120. }
  121. if (isset($cInfo) && is_object($cInfo) && ($zones->fields['zone_id'] == $cInfo->zone_id)) {
  122. echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=edit') . '\'">' . "\n";
  123. } else {
  124. echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $zones->fields['zone_id']) . '\'">' . "\n";
  125. }
  126. ?>
  127. <td class="dataTableContent"><?php echo $zones->fields['countries_name']; ?></td>
  128. <td class="dataTableContent"><?php echo $zones->fields['zone_name']; ?></td>
  129. <td class="dataTableContent" align="center"><?php echo $zones->fields['zone_code']; ?></td>
  130. <td class="dataTableContent" align="right">
  131. <?php if (isset($cInfo) && is_object($cInfo) && ($zones->fields['zone_id'] == $cInfo->zone_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $zones->fields['zone_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
  132. &nbsp;</td>
  133. </tr>
  134. <?php
  135. $zones->MoveNext();
  136. }
  137. ?>
  138. <tr>
  139. <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  140. <tr>
  141. <td class="smallText" valign="top"><?php echo $zones_split->display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ZONES); ?></td>
  142. <td class="smallText" align="right"><?php echo $zones_split->display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
  143. </tr>
  144. <?php
  145. if (empty($action)) {
  146. ?>
  147. <tr>
  148. <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&action=new') . '">' . zen_image_button('button_new_zone.gif', IMAGE_NEW_ZONE) . '</a>'; ?></td>
  149. </tr>
  150. <?php
  151. }
  152. ?>
  153. </table></td>
  154. </tr>
  155. </table></td>
  156. <?php
  157. $heading = array();
  158. $contents = array();
  159. switch ($action) {
  160. case 'new':
  161. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_ZONE . '</b>');
  162. $contents = array('form' => zen_draw_form('zones', FILENAME_ZONES, 'page=' . $_GET['page'] . '&action=insert'));
  163. $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
  164. $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . zen_draw_input_field('zone_name'));
  165. $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_CODE . '<br>' . zen_draw_input_field('zone_code'));
  166. $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_pull_down_menu('zone_country_id', zen_get_countries()));
  167. $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  168. break;
  169. case 'edit':
  170. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_ZONE . '</b>');
  171. $contents = array('form' => zen_draw_form('zones', FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=save'));
  172. $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
  173. $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . zen_draw_input_field('zone_name', $cInfo->zone_name));
  174. $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_CODE . '<br>' . zen_draw_input_field('zone_code', $cInfo->zone_code));
  175. $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_pull_down_menu('zone_country_id', zen_get_countries(), $cInfo->countries_id));
  176. $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  177. break;
  178. case 'delete':
  179. $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_ZONE . '</b>');
  180. $contents = array('form' => zen_draw_form('zones', FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=deleteconfirm'));
  181. $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  182. $contents[] = array('text' => '<br><b>' . $cInfo->zone_name . '</b>');
  183. $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  184. break;
  185. default:
  186. if (isset($cInfo) && is_object($cInfo)) {
  187. $heading[] = array('text' => '<b>' . $cInfo->zone_name . '</b>');
  188. $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_ZONES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->zone_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
  189. $contents[] = array('text' => '<br>' . TEXT_INFO_ZONES_NAME . '<br>' . $cInfo->zone_name . ' (' . $cInfo->zone_code . ')');
  190. $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . ' ' . $cInfo->countries_name);
  191. }
  192. break;
  193. }
  194. if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  195. echo ' <td width="25%" valign="top">' . "\n";
  196. $box = new box;
  197. echo $box->infoBox($heading, $contents);
  198. echo ' </td>' . "\n";
  199. }
  200. ?>
  201. </tr>
  202. </table></td>
  203. </tr>
  204. </table></td>
  205. <!-- body_text_eof //-->
  206. </tr>
  207. </table>
  208. <!-- body_eof //-->
  209. <!-- footer //-->
  210. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  211. <!-- footer_eof //-->
  212. <br>
  213. </body>
  214. </html>
  215. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>