Ticket #926: changeset_9971.diff

File changeset_9971.diff, 9.4 KB (added by Ronald Parcinski, 9 years ago)
  • trunk/admin/includes/classes/categories.php

     
    11<?php
    22/* --------------------------------------------------------------
    3   $Id: categories.php 5376 2013-08-12 16:09:06Z web28 $
     3  $Id$
    44
    55   modified eCommerce Shopsoftware
     
    13251325        unset($sql_data_array['specials_last_modified']);
    13261326        xtc_db_perform(TABLE_SPECIALS, $sql_data_array);
     1327        $products_data['specials_id'] = xtc_db_insert_id();
    13271328      } else {
    13281329        unset($sql_data_array['specials_date_added']);
     
    13351336      xtc_db_query("DELETE FROM " . TABLE_SPECIALS . " WHERE specials_id = '" . xtc_db_input($products_data['specials_id']) . "'");
    13361337    }
     1338   
     1339    return $products_data['specials_id'];
    13371340  }
    13381341 
  • trunk/admin/specials.php

     
    11<?php
    22  /* --------------------------------------------------------------
    3    $Id: specials.php 4937 2013-06-17 09:19:54Z Tomcraft $
     3   $Id$
    44
    55   modified eCommerce Shopsoftware
     
    1818
    1919  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
    2128  $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();
    2330 
    2431  //display per page
     
    3845      case 'insert':
    3946      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);
    8948        xtc_redirect(xtc_href_link(FILENAME_SPECIALS, 'page=' . $page_id . '&sID=' . $specials_id));
    9049        break;
     
    13089          $form_action = 'insert';
    13190          $expires_date = '';
    132           if ( ($action == 'edit') && isset($sID) ) {
     91          if ($action == 'edit' && isset($sID)) {
    13392            $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,
    13794                                                  p.products_model,
    13895                                                  p.products_price,
     
    143100                                                  s.expires_date,
    144101                                                  pd.products_name
    145                                              FROM " . TABLE_PRODUCTS . " p,
    146                                                   " . TABLE_PRODUCTS_DESCRIPTION . " pd,
    147                                                   " . TABLE_SPECIALS . " s
    148                                             WHERE p.products_id = pd.products_id
    149                                               AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
    150                                               AND p.products_id = s.products_id
    151                                               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 ."'");
    152109            $product = xtc_db_fetch_array($product_query);
    153110            $sInfo = new objectInfo($product);
     
    169126            // (when creating a new product on special)
    170127            $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");
    176132            while ($specials = xtc_db_fetch_array($specials_query)) {
    177133              $specials_array[] = $specials['products_id'];
     
    199155            echo xtc_draw_hidden_field('specials_id', $sID);               
    200156          }
     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);
    201160          ?>
    202161         
     
    246205           '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_UPDATE . '"/>'). '&nbsp;&nbsp;&nbsp;<a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_SPECIALS, 'page=' . $page_id . '&sID=' . $sID) . '">' . BUTTON_CANCEL . '</a>'; ?>
    247206          </div>
    248          </form>
     207        </form>
    249208      </td>                   
    250209        <?php
     
    268227                </tr>
    269228                <?php
    270                 $specials_query_raw = "-- /admin/specials.php
    271                                        SELECT p.products_id,
     229                $specials_query_raw = "SELECT p.products_id,
    272230                                              p.products_model,
    273231                                              p.products_quantity,