|
ZenCart_Documentation
1.5.0
http://www.collinsharper.com
|
00001 <?php 00010 require('includes/application_top.php'); 00011 00012 $action = (isset($_GET['action']) ? $_GET['action'] : ''); 00013 00014 if (zen_not_null($action)) { 00015 switch ($action) { 00016 case 'insert': 00017 $countries_name = zen_db_prepare_input($_POST['countries_name']); 00018 $countries_iso_code_2 = zen_db_prepare_input($_POST['countries_iso_code_2']); 00019 $countries_iso_code_3 = zen_db_prepare_input($_POST['countries_iso_code_3']); 00020 $address_format_id = zen_db_prepare_input($_POST['address_format_id']); 00021 00022 $db->Execute("insert into " . TABLE_COUNTRIES . " 00023 (countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id) 00024 values ('" . zen_db_input($countries_name) . "', 00025 '" . zen_db_input($countries_iso_code_2) . "', 00026 '" . zen_db_input($countries_iso_code_3) . "', 00027 '" . (int)$address_format_id . "')"); 00028 00029 zen_redirect(zen_href_link(FILENAME_COUNTRIES)); 00030 break; 00031 case 'save': 00032 $countries_id = zen_db_prepare_input($_GET['cID']); 00033 $countries_name = zen_db_prepare_input($_POST['countries_name']); 00034 $countries_iso_code_2 = zen_db_prepare_input($_POST['countries_iso_code_2']); 00035 $countries_iso_code_3 = zen_db_prepare_input($_POST['countries_iso_code_3']); 00036 $address_format_id = zen_db_prepare_input($_POST['address_format_id']); 00037 00038 $db->Execute("update " . TABLE_COUNTRIES . " 00039 set countries_name = '" . zen_db_input($countries_name) . "', 00040 countries_iso_code_2 = '" . zen_db_input($countries_iso_code_2) . "', 00041 countries_iso_code_3 = '" . zen_db_input($countries_iso_code_3) . "', 00042 address_format_id = '" . (int)$address_format_id . "' 00043 where countries_id = '" . (int)$countries_id . "'"); 00044 00045 zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries_id)); 00046 break; 00047 case 'deleteconfirm': 00048 // demo active test 00049 if (zen_admin_demo()) { 00050 $_GET['action']= ''; 00051 $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); 00052 zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'])); 00053 } 00054 $countries_id = zen_db_prepare_input($_POST['cID']); 00055 $sql = "select entry_country_id from " . TABLE_ADDRESS_BOOK . " where entry_country_id = :countryID: LIMIT 1"; 00056 $sql = $db->bindVars($sql, ':countryID:', $countries_id, 'integer'); 00057 $result = $db->Execute($sql); 00058 if ($result->recordCount() == 0) { 00059 $db->Execute("delete from " . TABLE_COUNTRIES . " 00060 where countries_id = '" . (int)$countries_id . "'"); 00061 } else { 00062 $messageStack->add_session(ERROR_COUNTRY_IN_USE, 'error'); 00063 } 00064 00065 zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'])); 00066 break; 00067 } 00068 } 00069 ?> 00070 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 00071 <html <?php echo HTML_PARAMS; ?>> 00072 <head> 00073 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 00074 <title><?php echo TITLE; ?></title> 00075 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 00076 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS"> 00077 <script language="javascript" src="includes/menu.js"></script> 00078 <script language="javascript" src="includes/general.js"></script> 00079 <script type="text/javascript"> 00080 <!-- 00081 function init() 00082 { 00083 cssjsmenu('navbar'); 00084 if (document.getElementById) 00085 { 00086 var kill = document.getElementById('hoverJS'); 00087 kill.disabled = true; 00088 } 00089 } 00090 // --> 00091 </script> 00092 </head> 00093 <body onload="init()"> 00094 <!-- header //--> 00095 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 00096 <!-- header_eof //--> 00097 00098 <!-- body //--> 00099 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 00100 <tr> 00101 <!-- body_text //--> 00102 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 00103 <tr> 00104 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 00105 <tr> 00106 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 00107 <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 00108 </tr> 00109 </table></td> 00110 </tr> 00111 <tr> 00112 <td class="smallText" align="center" width="350" valign="top"><?php echo ISO_COUNTRY_CODES_LINK; ?></td> 00113 </tr> 00114 <tr> 00115 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 00116 <tr> 00117 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 00118 <tr class="dataTableHeadingRow"> 00119 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td> 00120 <td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_COUNTRY_CODES; ?></td> 00121 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 00122 </tr> 00123 <?php 00124 $countries_query_raw = "select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id from " . TABLE_COUNTRIES . " order by countries_name"; 00125 $countries_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $countries_query_raw, $countries_query_numrows); 00126 $countries = $db->Execute($countries_query_raw); 00127 while (!$countries->EOF) { 00128 if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $countries->fields['countries_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { 00129 $cInfo = new objectInfo($countries->fields); 00130 } 00131 00132 if (isset($cInfo) && is_object($cInfo) && ($countries->fields['countries_id'] == $cInfo->countries_id)) { 00133 echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=edit') . '\'">' . "\n"; 00134 } else { 00135 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries->fields['countries_id']) . '\'">' . "\n"; 00136 } 00137 ?> 00138 <td class="dataTableContent"><?php echo $countries->fields['countries_name']; ?></td> 00139 <td class="dataTableContent" align="center" width="40"><?php echo $countries->fields['countries_iso_code_2']; ?></td> 00140 <td class="dataTableContent" align="center" width="40"><?php echo $countries->fields['countries_iso_code_3']; ?></td> 00141 <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($countries->fields['countries_id'] == $cInfo->countries_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries->fields['countries_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 00142 </tr> 00143 <?php 00144 $countries->MoveNext(); 00145 } 00146 ?> 00147 <tr> 00148 <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 00149 <tr> 00150 <td class="smallText" valign="top"><?php echo $countries_split->display_count($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?></td> 00151 <td class="smallText" align="right"><?php echo $countries_split->display_links($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td> 00152 </tr> 00153 <?php 00154 if (empty($action)) { 00155 ?> 00156 <tr> 00157 <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=new') . '">' . zen_image_button('button_new_country.gif', IMAGE_NEW_COUNTRY) . '</a>'; ?></td> 00158 </tr> 00159 <?php 00160 } 00161 ?> 00162 </table></td> 00163 </tr> 00164 </table></td> 00165 <?php 00166 $heading = array(); 00167 $contents = array(); 00168 00169 switch ($action) { 00170 case 'new': 00171 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_COUNTRY . '</b>'); 00172 00173 $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=insert')); 00174 $contents[] = array('text' => TEXT_INFO_INSERT_INTRO); 00175 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_input_field('countries_name')); 00176 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . zen_draw_input_field('countries_iso_code_2')); 00177 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . zen_draw_input_field('countries_iso_code_3')); 00178 $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . zen_draw_pull_down_menu('address_format_id', zen_get_address_formats())); 00179 $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 00180 break; 00181 case 'edit': 00182 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_COUNTRY . '</b>'); 00183 00184 $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=save')); 00185 $contents[] = array('text' => TEXT_INFO_EDIT_INTRO); 00186 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_input_field('countries_name', htmlspecialchars($cInfo->countries_name, ENT_COMPAT, CHARSET, TRUE))); 00187 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . zen_draw_input_field('countries_iso_code_2', $cInfo->countries_iso_code_2)); 00188 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . zen_draw_input_field('countries_iso_code_3', $cInfo->countries_iso_code_3)); 00189 $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . zen_draw_pull_down_menu('address_format_id', zen_get_address_formats(), $cInfo->address_format_id)); 00190 $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 00191 break; 00192 case 'delete': 00193 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_COUNTRY . '</b>'); 00194 00195 $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=deleteconfirm') . zen_draw_hidden_field('cID', $cInfo->countries_id)); 00196 $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); 00197 $contents[] = array('text' => '<br><b>' . $cInfo->countries_name . '</b>'); 00198 $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_UPDATE) . ' <a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 00199 break; 00200 default: 00201 if (is_object($cInfo)) { 00202 $heading[] = array('text' => '<b>' . $cInfo->countries_name . '</b>'); 00203 00204 $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>'); 00205 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . $cInfo->countries_name); 00206 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . ' ' . $cInfo->countries_iso_code_2); 00207 $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . ' ' . $cInfo->countries_iso_code_3); 00208 $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . ' ' . $cInfo->address_format_id); 00209 } 00210 break; 00211 } 00212 00213 if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { 00214 echo ' <td width="25%" valign="top">' . "\n"; 00215 00216 $box = new box; 00217 echo $box->infoBox($heading, $contents); 00218 00219 echo ' </td>' . "\n"; 00220 } 00221 ?> 00222 </tr> 00223 </table></td> 00224 </tr> 00225 </table></td> 00226 <!-- body_text_eof //--> 00227 </tr> 00228 </table> 00229 <!-- body_eof //--> 00230 00231 <!-- footer //--> 00232 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 00233 <!-- footer_eof //--> 00234 <br> 00235 </body> 00236 </html> 00237 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>