Ticket #926: changeset_9971.diff
| File changeset_9971.diff, 9.4 KB (added by , 9 years ago) |
|---|
-
trunk/admin/includes/classes/categories.php
1 1 <?php 2 2 /* -------------------------------------------------------------- 3 $Id : categories.php 5376 2013-08-12 16:09:06Z web28$3 $Id$ 4 4 5 5 modified eCommerce Shopsoftware … … 1325 1325 unset($sql_data_array['specials_last_modified']); 1326 1326 xtc_db_perform(TABLE_SPECIALS, $sql_data_array); 1327 $products_data['specials_id'] = xtc_db_insert_id(); 1327 1328 } else { 1328 1329 unset($sql_data_array['specials_date_added']); … … 1335 1336 xtc_db_query("DELETE FROM " . TABLE_SPECIALS . " WHERE specials_id = '" . xtc_db_input($products_data['specials_id']) . "'"); 1336 1337 } 1338 1339 return $products_data['specials_id']; 1337 1340 } 1338 1341 -
trunk/admin/specials.php
1 1 <?php 2 2 /* -------------------------------------------------------------- 3 $Id : specials.php 4937 2013-06-17 09:19:54Z Tomcraft$3 $Id$ 4 4 5 5 modified eCommerce Shopsoftware … … 18 18 19 19 require('includes/application_top.php'); 20 require(DIR_FS_CATALOG.DIR_WS_CLASSES . 'xtcPrice.php'); 20 21 // include needed functions 22 require_once (DIR_FS_INC.'xtc_get_tax_rate.inc.php'); 23 24 // include needed classes 25 require_once (DIR_WS_CLASSES.'categories.php'); 26 require_once (DIR_FS_CATALOG.DIR_WS_CLASSES . 'xtcPrice.php'); 27 21 28 $xtPrice = new xtcPrice(DEFAULT_CURRENCY,$_SESSION['customers_status']['customers_status_id']); 22 require_once(DIR_FS_INC .'xtc_get_tax_rate.inc.php');29 $catfunc = new categories(); 23 30 24 31 //display per page … … 38 45 case 'insert': 39 46 case 'update': 40 if (PRICE_IS_BRUTTO=='true' && substr($_POST['specials_price'], -1) != '%'){ 41 $sql = "-- /admin/specials.php 42 SELECT tr.tax_rate 43 FROM " . TABLE_TAX_RATES . " tr, 44 " . TABLE_PRODUCTS . " p 45 WHERE tr.tax_class_id = p. products_tax_class_id 46 AND p.products_id = '". (int)$_POST['products_id'] . "' 47 "; 48 49 $tax_query = xtc_db_query($sql); 50 $tax = xtc_db_fetch_array($tax_query); 51 $_POST['specials_price'] = ($_POST['specials_price']/($tax['tax_rate']+100)*100); 52 } 53 if (substr($_POST['specials_price'], -1) == '%') { 54 $new_special_insert_query = xtc_db_query("-- /admin/specials.php 55 SELECT products_id, 56 products_tax_class_id, 57 products_price 58 FROM " . TABLE_PRODUCTS . " 59 WHERE products_id = '" . (int)$_POST['products_id'] . "'"); 60 $new_special_insert = xtc_db_fetch_array($new_special_insert_query); 61 $_POST['products_price'] = $new_special_insert['products_price']; 62 $_POST['specials_price'] = ($_POST['products_price'] - (($_POST['specials_price'] / 100) * $_POST['products_price'])); 63 } 64 65 $expires_date = isset($_POST['specials_expires']) && !empty($_POST['specials_expires']) ? date('Y-m-d', strtotime($_POST['specials_expires'])).' 23:59:59' : ''; 66 $start_date = isset($_POST['specials_start']) && !empty($_POST['specials_start']) ? date('Y-m-d', strtotime($_POST['specials_start'])).' 00:00:00' : ''; 67 68 $sql_data_array = array('products_id' => (int)$_POST['products_id'], 69 'specials_quantity' => (int)$_POST['specials_quantity'], 70 'specials_new_products_price' => xtc_db_prepare_input($_POST['specials_price']), 71 'specials_date_added' => 'now()', 72 'specials_last_modified' => 'now()', 73 'start_date' => xtc_db_prepare_input($start_date), 74 'expires_date' => xtc_db_prepare_input($expires_date), 75 'status' => '1' 76 ); 77 78 if ($action == 'insert') { 79 unset($sql_data_array['specials_last_modified']); 80 xtc_db_perform(TABLE_SPECIALS, $sql_data_array); 81 $specials_id = xtc_db_insert_id(); 82 } else { 83 unset($sql_data_array['specials_date_added']); 84 unset($sql_data_array['status']); 85 $specials_id = (int)$_POST['specials_id']; 86 xtc_db_perform(TABLE_SPECIALS, $sql_data_array, 'update', "specials_id = '".$specials_id."'"); 87 } 88 47 $specials_id = $catfunc->saveSpecialsData($_POST); 89 48 xtc_redirect(xtc_href_link(FILENAME_SPECIALS, 'page=' . $page_id . '&sID=' . $specials_id)); 90 49 break; … … 130 89 $form_action = 'insert'; 131 90 $expires_date = ''; 132 if ( ($action == 'edit') && isset($sID)) {91 if ($action == 'edit' && isset($sID)) { 133 92 $form_action = 'update'; 134 $product_query = xtc_db_query("-- /admin/specials.php 135 SELECT 136 p.products_id, 93 $product_query = xtc_db_query("SELECT p.products_id, 137 94 p.products_model, 138 95 p.products_price, … … 143 100 s.expires_date, 144 101 pd.products_name 145 FROM " . TABLE_PRODUCTS . " p ,146 " . TABLE_PRODUCTS_DESCRIPTION . " pd,147 " . TABLE_SPECIALS . " s148 WHERE p.products_id = pd.products_id149 AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "'150 ANDp.products_id = s.products_id151 AND s.specials_id = '" . $sID ."'");102 FROM " . TABLE_PRODUCTS . " p 103 JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd 104 ON p.products_id = pd.products_id 105 AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 106 JOIN " . TABLE_SPECIALS . " s 107 ON p.products_id = s.products_id 108 AND s.specials_id = '" . $sID ."'"); 152 109 $product = xtc_db_fetch_array($product_query); 153 110 $sInfo = new objectInfo($product); … … 169 126 // (when creating a new product on special) 170 127 $specials_array = array(); 171 $specials_query = xtc_db_query("-- /admin/specials.php 172 SELECT p.products_id 173 FROM " . TABLE_PRODUCTS . " p, 174 " . TABLE_SPECIALS . " s 175 WHERE s.products_id = p.products_id"); 128 $specials_query = xtc_db_query("SELECT p.products_id 129 FROM " . TABLE_PRODUCTS . " p 130 JOIN " . TABLE_SPECIALS . " s 131 ON s.products_id = p.products_id"); 176 132 while ($specials = xtc_db_fetch_array($specials_query)) { 177 133 $specials_array[] = $specials['products_id']; … … 199 155 echo xtc_draw_hidden_field('specials_id', $sID); 200 156 } 157 echo xtc_draw_hidden_field('tax_rate', xtc_get_tax_rate($sInfo->products_tax_class_id)); 158 echo xtc_draw_hidden_field('products_price_hidden', $sInfo->products_price); 159 echo xtc_draw_hidden_field('specials_action', $form_action); 201 160 ?> 202 161 … … 246 205 '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_UPDATE . '"/>'). ' <a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_SPECIALS, 'page=' . $page_id . '&sID=' . $sID) . '">' . BUTTON_CANCEL . '</a>'; ?> 247 206 </div> 248 </form>207 </form> 249 208 </td> 250 209 <?php … … 268 227 </tr> 269 228 <?php 270 $specials_query_raw = "-- /admin/specials.php 271 SELECT p.products_id, 229 $specials_query_raw = "SELECT p.products_id, 272 230 p.products_model, 273 231 p.products_quantity,
