| 1 | <?php
|
|---|
| 2 | /* --------------------------------------------------------------
|
|---|
| 3 | $Id: cross_sell_groups.php 1231 2005-09-21 13:05:36Z mz $
|
|---|
| 4 |
|
|---|
| 5 | XT-Commerce - community made shopping
|
|---|
| 6 | http://www.xt-commerce.com
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 2003 XT-Commerce
|
|---|
| 9 | --------------------------------------------------------------
|
|---|
| 10 | based on:
|
|---|
| 11 | (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
|
|---|
| 12 | (c) 2002-2003 osCommerce(orders_status.php,v 1.19 2003/02/06); www.oscommerce.com
|
|---|
| 13 | (c) 2003 nextcommerce (orders_status.php,v 1.9 2003/08/18); www.nextcommerce.org
|
|---|
| 14 |
|
|---|
| 15 | Released under the GNU General Public License
|
|---|
| 16 | --------------------------------------------------------------*/
|
|---|
| 17 |
|
|---|
| 18 | require('includes/application_top.php');
|
|---|
| 19 |
|
|---|
| 20 | $action = (isset($_GET['action']) ? $_GET['action'] : '');
|
|---|
| 21 |
|
|---|
| 22 | if (xtc_not_null($action)) {
|
|---|
| 23 | switch ($action) {
|
|---|
| 24 | case 'insert':
|
|---|
| 25 | case 'save':
|
|---|
| 26 | if (isset($_GET['oID'])) $cross_sell_id = xtc_db_prepare_input($_GET['oID']);
|
|---|
| 27 |
|
|---|
| 28 | $languages = xtc_get_languages();
|
|---|
| 29 | for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
|
|---|
| 30 | $cross_sell_name_array = $_POST['cross_sell_group_name'];
|
|---|
| 31 | $language_id = $languages[$i]['id'];
|
|---|
| 32 |
|
|---|
| 33 | $sql_data_array = array('groupname' => xtc_db_prepare_input($cross_sell_name_array[$language_id]),
|
|---|
| 34 | 'xsell_sort_order' => (int)$_POST['xsell_sort_order']
|
|---|
| 35 | );
|
|---|
| 36 |
|
|---|
| 37 | if ($action == 'insert') {
|
|---|
| 38 | if (!xtc_not_null($cross_sell_id)) {
|
|---|
| 39 | $next_id_query = xtc_db_query("select max(products_xsell_grp_name_id) as products_xsell_grp_name_id from " . TABLE_PRODUCTS_XSELL_GROUPS . "");
|
|---|
| 40 | $next_id = xtc_db_fetch_array($next_id_query);
|
|---|
| 41 | $cross_sell_id = $next_id['products_xsell_grp_name_id'] + 1;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | $insert_sql_data = array('products_xsell_grp_name_id' => $cross_sell_id,
|
|---|
| 45 | 'language_id' => $language_id);
|
|---|
| 46 | $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
|
|---|
| 47 | xtc_db_perform(TABLE_PRODUCTS_XSELL_GROUPS, $sql_data_array);
|
|---|
| 48 | } elseif ($action == 'save') {
|
|---|
| 49 | $cross_sell_query = xtc_db_query("SELECT *
|
|---|
| 50 | FROM ".TABLE_PRODUCTS_XSELL_GROUPS."
|
|---|
| 51 | WHERE language_id = '".(int)$language_id."'
|
|---|
| 52 | AND products_xsell_grp_name_id = '".xtc_db_input($cross_sell_id)."'");
|
|---|
| 53 |
|
|---|
| 54 | if (xtc_db_num_rows($cross_sell_query) == 0) {
|
|---|
| 55 | xtc_db_perform(TABLE_PRODUCTS_XSELL_GROUPS, array ('products_xsell_grp_name_id' => (int)$cross_sell_id, 'language_id' => (int)$language_id));
|
|---|
| 56 | }
|
|---|
| 57 | xtc_db_perform(TABLE_PRODUCTS_XSELL_GROUPS, $sql_data_array, 'update', "products_xsell_grp_name_id = '" . (int)$cross_sell_id . "' and language_id = '" . (int)$language_id . "'");
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | xtc_redirect(xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $cross_sell_id));
|
|---|
| 63 | break;
|
|---|
| 64 |
|
|---|
| 65 | case 'deleteconfirm':
|
|---|
| 66 | $oID = xtc_db_prepare_input($_GET['oID']);
|
|---|
| 67 |
|
|---|
| 68 | xtc_db_query("DELETE FROM " . TABLE_PRODUCTS_XSELL_GROUPS . " WHERE products_xsell_grp_name_id = '" . xtc_db_input($oID) . "'");
|
|---|
| 69 |
|
|---|
| 70 | xtc_redirect(xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page']));
|
|---|
| 71 | break;
|
|---|
| 72 |
|
|---|
| 73 | case 'delete':
|
|---|
| 74 | $oID = xtc_db_prepare_input($_GET['oID']);
|
|---|
| 75 |
|
|---|
| 76 | $cross_sell_query = xtc_db_query("SELECT count(*) as count from " . TABLE_PRODUCTS_XSELL . " WHERE products_xsell_grp_name_id = '" . xtc_db_input($oID) . "'");
|
|---|
| 77 | $status = xtc_db_fetch_array($cross_sell_query);
|
|---|
| 78 |
|
|---|
| 79 | $remove_status = true;
|
|---|
| 80 | if ($status['count'] > 0) {
|
|---|
| 81 | $remove_status = false;
|
|---|
| 82 | $messageStack->add(ERROR_STATUS_USED_IN_CROSS_SELLS, 'error');
|
|---|
| 83 | }
|
|---|
| 84 | break;
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 | require (DIR_WS_INCLUDES.'head.php');
|
|---|
| 88 | ?>
|
|---|
| 89 | <script type="text/javascript" src="includes/general.js"></script>
|
|---|
| 90 | </head>
|
|---|
| 91 | <body>
|
|---|
| 92 | <!-- header //-->
|
|---|
| 93 | <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
|
|---|
| 94 | <!-- header_eof //-->
|
|---|
| 95 | <!-- body //-->
|
|---|
| 96 | <table class="tableBody">
|
|---|
| 97 | <tr>
|
|---|
| 98 | <?php //left_navigation
|
|---|
| 99 | if (USE_ADMIN_TOP_MENU == 'false') {
|
|---|
| 100 | echo '<td class="columnLeft2">'.PHP_EOL;
|
|---|
| 101 | echo '<!-- left_navigation //-->'.PHP_EOL;
|
|---|
| 102 | require_once(DIR_WS_INCLUDES . 'column_left.php');
|
|---|
| 103 | echo '<!-- left_navigation eof //-->'.PHP_EOL;
|
|---|
| 104 | echo '</td>'.PHP_EOL;
|
|---|
| 105 | }
|
|---|
| 106 | ?>
|
|---|
| 107 | <!-- body_text //-->
|
|---|
| 108 | <td class="boxCenter">
|
|---|
| 109 | <div class="pageHeadingImage"><?php echo xtc_image(DIR_WS_ICONS.'heading/icon_configuration.png'); ?></div>
|
|---|
| 110 | <div class="pageHeading"><?php echo HEADING_TITLE; ?></div>
|
|---|
| 111 | <div class="main pdg2 flt-l">Configuration</div>
|
|---|
| 112 | <table class="tableCenter">
|
|---|
| 113 | <tr>
|
|---|
| 114 | <td class="boxCenterLeft">
|
|---|
| 115 | <table class="tableBoxCenter collapse">
|
|---|
| 116 | <tr class="dataTableHeadingRow">
|
|---|
| 117 | <td class="dataTableHeadingContent" style="width:1%;"><?php echo 'ID' ?></td>
|
|---|
| 118 | <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_XSELL_GROUP_NAME; ?></td>
|
|---|
| 119 | <td class="dataTableHeadingContent txta-r" style="width:5%;"><?php echo TEXT_DEFAULT_SORT_ORDER_TITLE; ?> </td>
|
|---|
| 120 | <td class="dataTableHeadingContent txta-r" style="width:1%;"><?php echo TABLE_HEADING_ACTION; ?> </td>
|
|---|
| 121 | </tr>
|
|---|
| 122 | <?php
|
|---|
| 123 | $cross_sell_query_raw = "SELECT *
|
|---|
| 124 | FROM " . TABLE_PRODUCTS_XSELL_GROUPS . "
|
|---|
| 125 | WHERE language_id = '" . (int)$_SESSION['languages_id'] . "'
|
|---|
| 126 | ORDER BY xsell_sort_order, products_xsell_grp_name_id";
|
|---|
| 127 | $cross_sell_split = new splitPageResults($_GET['page'], '20', $cross_sell_query_raw, $cross_sell_query_numrows);
|
|---|
| 128 | $cross_sell_query = xtc_db_query($cross_sell_query_raw);
|
|---|
| 129 | while ($cross_sell = xtc_db_fetch_array($cross_sell_query)) {
|
|---|
| 130 | if ((!isset($_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $cross_sell['products_xsell_grp_name_id']))) && !isset($oInfo) && (substr($action, 0, 3) != 'new')) {
|
|---|
| 131 | $oInfo = new objectInfo($cross_sell);
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | if (isset($oInfo) && is_object($oInfo) && ($cross_sell['products_xsell_grp_name_id'] == $oInfo->products_xsell_grp_name_id) ) {
|
|---|
| 135 | echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'pointer\'" onclick="document.location.href=\'' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id . '&action=edit') . '\'">' . "\n";
|
|---|
| 136 | } else {
|
|---|
| 137 | echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'pointer\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $cross_sell['products_xsell_grp_name_id']) . '\'">' . "\n";
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | echo '<td class="dataTableContent txta-l">' . $cross_sell['products_xsell_grp_name_id'] . '</td>' . "\n";
|
|---|
| 141 | echo '<td class="dataTableContent txta-l">' . $cross_sell['groupname'] . '</td>' . "\n";
|
|---|
| 142 |
|
|---|
| 143 | ?>
|
|---|
| 144 | <td class="dataTableContent txta-r"><?php echo $cross_sell['xsell_sort_order']; ?></td>
|
|---|
| 145 | <td class="dataTableContent txta-r"><?php if (isset($oInfo) && is_object($oInfo) && ($cross_sell['products_xsell_grp_name_id'] == $oInfo->products_xsell_grp_name_id) ) { echo xtc_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ICON_ARROW_RIGHT); } else { echo '<a href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $cross_sell['products_xsell_grp_name_id']) . '">' . xtc_image(DIR_WS_IMAGES . 'icon_arrow_grey.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
|
|---|
| 146 | </tr>
|
|---|
| 147 | <?php
|
|---|
| 148 | }
|
|---|
| 149 | ?>
|
|---|
| 150 | </table>
|
|---|
| 151 | <div class="smallText pdg2 flt-l"><?php echo $cross_sell_split->display_count($cross_sell_query_numrows, '20', $_GET['page'], TEXT_DISPLAY_NUMBER_OF_XSELL_GROUP); ?></div>
|
|---|
| 152 | <div class="smallText pdg2 flt-r"><?php echo $cross_sell_split->display_links($cross_sell_query_numrows, '20', MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></div>
|
|---|
| 153 |
|
|---|
| 154 | <?php
|
|---|
| 155 | if (empty($action)) {
|
|---|
| 156 | ?>
|
|---|
| 157 | <div class="clear"></div>
|
|---|
| 158 | <div class="pdg2 flt-r smallText"><?php echo '<a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&action=new') . '">' . BUTTON_INSERT . '</a>'; ?></div>
|
|---|
| 159 |
|
|---|
| 160 | <?php
|
|---|
| 161 | }
|
|---|
| 162 | ?>
|
|---|
| 163 |
|
|---|
| 164 | </td>
|
|---|
| 165 | <?php
|
|---|
| 166 | $heading = array();
|
|---|
| 167 | $contents = array();
|
|---|
| 168 | switch ($action) {
|
|---|
| 169 | case 'new':
|
|---|
| 170 | $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_XSELL_GROUP . '</b>');
|
|---|
| 171 | $contents = array('form' => xtc_draw_form('status', FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&action=insert'));
|
|---|
| 172 | $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
|
|---|
| 173 |
|
|---|
| 174 | $cross_sell_inputs_string = '';
|
|---|
| 175 | $languages = xtc_get_languages();
|
|---|
| 176 | for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
|
|---|
| 177 | $cross_sell_inputs_string .= '<br />' . xtc_image(DIR_WS_LANGUAGES.$languages[$i]['directory'].'/admin/images/'.$languages[$i]['image']) . ' ' . xtc_draw_input_field('cross_sell_group_name[' . $languages[$i]['id'] . ']');
|
|---|
| 178 | }
|
|---|
| 179 | $contents[] = array('text' => '<br />' . TEXT_INFO_XSELL_GROUP_NAME . $cross_sell_inputs_string);
|
|---|
| 180 | $contents[] = array('text' => '<br />' . TEXT_DEFAULT_SORT_ORDER_TITLE . '<br />' . xtc_draw_input_field('xsell_sort_order', ''));
|
|---|
| 181 | $contents[] = array('text' => '<br />' . xtc_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
|
|---|
| 182 | $contents[] = array('align' => 'center', 'text' => '<br /><input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_INSERT . '"/> <a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page']) . '">' . BUTTON_CANCEL . '</a>');
|
|---|
| 183 | break;
|
|---|
| 184 |
|
|---|
| 185 | case 'edit':
|
|---|
| 186 | $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_XSELL_GROUP . '</b>');
|
|---|
| 187 |
|
|---|
| 188 | $contents = array('form' => xtc_draw_form('status', FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id . '&action=save'));
|
|---|
| 189 | $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
|
|---|
| 190 |
|
|---|
| 191 | $cross_sell_inputs_string = '';
|
|---|
| 192 | $languages = xtc_get_languages();
|
|---|
| 193 | for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
|
|---|
| 194 | $cross_sell_inputs_string .= '<br />' . xtc_image(DIR_WS_LANGUAGES.$languages[$i]['directory'].'/admin/images/'.$languages[$i]['image']) . ' ' . xtc_draw_input_field('cross_sell_group_name[' . $languages[$i]['id'] . ']', xtc_get_cross_sell_name($oInfo->products_xsell_grp_name_id, $languages[$i]['id']));
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | $contents[] = array('text' => '<br />' . TEXT_INFO_XSELL_GROUP_NAME . $cross_sell_inputs_string);
|
|---|
| 198 | $contents[] = array('text' => '<br />' . TEXT_DEFAULT_SORT_ORDER_TITLE . '<br />' . xtc_draw_input_field('xsell_sort_order', $oInfo->xsell_sort_order));
|
|---|
| 199 | $contents[] = array('align' => 'center', 'text' => '<br /><input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_UPDATE . '"/> <a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id) . '">' . BUTTON_CANCEL . '</a>');
|
|---|
| 200 | break;
|
|---|
| 201 |
|
|---|
| 202 | case 'delete':
|
|---|
| 203 | $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_XSELL_GROUP . '</b>');
|
|---|
| 204 | $contents = array('form' => xtc_draw_form('status', FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id . '&action=deleteconfirm'));
|
|---|
| 205 | $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
|
|---|
| 206 | $contents[] = array('text' => '<br /><b>' . $oInfo->groupname . '</b>');
|
|---|
| 207 | if ($remove_status) $contents[] = array('align' => 'center', 'text' => '<br /><input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_DELETE . '"/> <a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id) . '">' . BUTTON_CANCEL . '</a>');
|
|---|
| 208 | break;
|
|---|
| 209 |
|
|---|
| 210 | default:
|
|---|
| 211 | if (isset($oInfo) && is_object($oInfo)) {
|
|---|
| 212 | $heading[] = array('text' => '<b>' . $oInfo->groupname . '</b>');
|
|---|
| 213 |
|
|---|
| 214 | $contents[] = array('align' => 'center', 'text' => '<a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id . '&action=edit') . '">' . BUTTON_EDIT . '</a> <a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_XSELL_GROUPS, 'page=' . $_GET['page'] . '&oID=' . $oInfo->products_xsell_grp_name_id . '&action=delete') . '">' . BUTTON_DELETE . '</a>');
|
|---|
| 215 |
|
|---|
| 216 | $cross_sell_inputs_string = '';
|
|---|
| 217 | $languages = xtc_get_languages();
|
|---|
| 218 | for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
|
|---|
| 219 | $cross_sell_inputs_string .= '<br />' . xtc_image(DIR_WS_LANGUAGES.$languages[$i]['directory'].'/admin/images/'.$languages[$i]['image']) . ' ' . xtc_get_cross_sell_name($oInfo->products_xsell_grp_name_id, $languages[$i]['id']);
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | $contents[] = array('text' => $cross_sell_inputs_string);
|
|---|
| 223 | }
|
|---|
| 224 | break;
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | if ( (xtc_not_null($heading)) && (xtc_not_null($contents)) ) {
|
|---|
| 228 | echo ' <td class="boxRight">' . "\n";
|
|---|
| 229 | $box = new box;
|
|---|
| 230 | echo $box->infoBox($heading, $contents);
|
|---|
| 231 | echo ' </td>' . "\n";
|
|---|
| 232 | }
|
|---|
| 233 | ?>
|
|---|
| 234 | </tr>
|
|---|
| 235 | </table>
|
|---|
| 236 | </td>
|
|---|
| 237 | <!-- body_text_eof //-->
|
|---|
| 238 | </tr>
|
|---|
| 239 | </table>
|
|---|
| 240 | <!-- body_eof //-->
|
|---|
| 241 | <!-- footer //-->
|
|---|
| 242 | <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
|
|---|
| 243 | <!-- footer_eof //-->
|
|---|
| 244 | <br />
|
|---|
| 245 | </body>
|
|---|
| 246 | </html>
|
|---|
| 247 | <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
|
|---|