}
 $orders_id = substr($orders_id, 0, -1) . ")";
 // Set the Sales to Temp State (it may happen that an order happend while billing)
 $sql = "UPDATE " . TABLE_AFFILIATE_SALES . " \n        set affiliate_billing_status=99 \n          where affiliate_id='" . $affiliate_payment['affiliate_id'] . "' \n          and affiliate_orders_id in " . $orders_id . " \n        ";
 xtc_db_query($sql);
 // Get Sum of payment (Could have changed since last selects);
 $sql = "\n        SELECT sum(affiliate_payment) as affiliate_payment\n          FROM " . TABLE_AFFILIATE_SALES . " \n          WHERE affiliate_id='" . $affiliate_payment['affiliate_id'] . "' and  affiliate_billing_status=99 \n        ";
 $affiliate_billing_query = xtc_db_query($sql);
 $affiliate_billing = xtc_db_fetch_array($affiliate_billing_query);
 // Get affiliate Informations
 $sql = "\n        SELECT a.*, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id \n          from " . TABLE_AFFILIATE . " a \n          left join " . TABLE_ZONES . " z on (a.affiliate_zone_id  = z.zone_id) \n          left join " . TABLE_COUNTRIES . " c on (a.affiliate_country_id = c.countries_id)\n          WHERE affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' \n        ";
 $affiliate_query = xtc_db_query($sql);
 $affiliate = xtc_db_fetch_array($affiliate_query);
 // Get need tax informations for the affiliate
 $affiliate_tax_rate = xtc_get_affiliate_tax_rate(AFFILIATE_TAX_ID, $affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id']);
 $affiliate_tax = xtc_round($affiliate_billing['affiliate_payment'] * $affiliate_tax_rate / 100, 2);
 // Netto-Provision
 $affiliate_payment_total = $affiliate_billing['affiliate_payment'];
 // Bill the order
 $affiliate['affiliate_state'] = xtc_get_zone_code($affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id'], $affiliate['affiliate_state']);
 $sql_data_array = array('affiliate_id' => $affiliate_payment['affiliate_id'], 'affiliate_payment' => $affiliate_billing['affiliate_payment'] - $affiliate_tax, 'affiliate_payment_tax' => $affiliate_tax, 'affiliate_payment_total' => $affiliate_payment_total, 'affiliate_payment_date' => 'now()', 'affiliate_payment_status' => '0', 'affiliate_firstname' => $affiliate['affiliate_firstname'], 'affiliate_lastname' => $affiliate['affiliate_lastname'], 'affiliate_street_address' => $affiliate['affiliate_street_address'], 'affiliate_suburb' => $affiliate['affiliate_suburb'], 'affiliate_city' => $affiliate['affiliate_city'], 'affiliate_country' => $affiliate['countries_name'], 'affiliate_postcode' => $affiliate['affiliate_postcode'], 'affiliate_company' => $affiliate['affiliate_company'], 'affiliate_state' => $affiliate['affiliate_state'], 'affiliate_address_format_id' => $affiliate['address_format_id']);
 xtc_db_perform(TABLE_AFFILIATE_PAYMENT, $sql_data_array);
 $insert_id = xtc_db_insert_id();
 // Set the Sales to Final State
 xtc_db_query("update " . TABLE_AFFILIATE_SALES . " set affiliate_payment_id = '" . $insert_id . "', affiliate_billing_status = 1, affiliate_payment_date = now() where affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' and affiliate_billing_status = 99");
 // Notify Affiliate
 if (AFFILIATE_NOTIFY_AFTER_BILLING == 'true') {
     $check_status_query = xtc_db_query("select af.affiliate_email_address, ap.affiliate_lastname, ap.affiliate_firstname, ap.affiliate_payment_status, ap.affiliate_payment_date, ap.affiliate_payment_date from " . TABLE_AFFILIATE_PAYMENT . " ap, " . TABLE_AFFILIATE . " af where affiliate_payment_id  = '" . $insert_id . "' and af.affiliate_id = ap.affiliate_id ");
     $check_status = xtc_db_fetch_array($check_status_query);
     $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_AFFILIATE_PAYMENT_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . xtc_catalog_href_link(FILENAME_CATALOG_AFFILIATE_PAYMENT_INFO, 'payment_id=' . $insert_id, 'SSL') . "\n" . EMAIL_TEXT_PAYMENT_BILLED . ' ' . xtc_date_long($check_status['affiliate_payment_date']) . "\n\n" . EMAIL_TEXT_NEW_PAYMENT;
     xtc_php_mail(AFFILIATE_EMAIL_ADDRESS, EMAIL_SUPPORT_NAME, $check_status['affiliate_email_address'], $check_status['affiliate_firstname'] . ' ' . $check_status['affiliate_lastname'], '', EMAIL_SUPPORT_REPLY_ADDRESS, EMAIL_SUPPORT_REPLY_ADDRESS_NAME, '', '', EMAIL_TEXT_SUBJECT, nl2br($email), $email);
function showSpecialsBox()
{
    global $pInfo;
    //web28 - 2010-07-27 - show products_price
    // include localized categories specials strings
    require_once DIR_FS_LANGUAGES . $_SESSION['language'] . '/admin/categories_specials.php';
    //BOF web28 - 2010-07-27 - show products_price
    if (PRICE_IS_BRUTTO == 'true') {
        $products_price_sp = xtc_round($pInfo->products_price * ((100 + xtc_get_tax_rate($pInfo->products_tax_class_id)) / 100), PRICE_PRECISION);
        $products_price_netto_sp = TEXT_NETTO . '<strong>' . $pInfo->products_price * (xtc_get_tax_rate($sInfo->products_tax_class_id) + 100) / 100 . '</strong>  ';
    } else {
        $products_price_sp = xtc_round($pInfo->products_price, PRICE_PRECISION);
        $products_price_netto_sp = '';
    }
    //EOF web28 - 2010-07-27 - show products_price
    // if editing an existing product
    if (isset($_GET['pID'])) {
        $specials_query = "SELECT p.products_tax_class_id,\n                                p.products_id,\n                                p.products_price,\n                                pd.products_name,\n                                s.specials_id,\n                                s.specials_quantity,\n                                s.specials_new_products_price,\n                                s.specials_date_added,\n                                s.specials_last_modified,\n                                s.expires_date,\n                                s.status\n                           FROM " . TABLE_PRODUCTS . " p,\n                                " . TABLE_PRODUCTS_DESCRIPTION . " pd,\n                                " . TABLE_SPECIALS . " s\n                          WHERE p.products_id = pd.products_id\n                            AND pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n                            AND p.products_id = s.products_id\n                            AND s.products_id = '" . (int) $_GET['pID'] . "'";
        //DokuMan - 2011-11-8 - added missing s.status from SP1b
        $specials_query = xtDBquery($specials_query);
        // if there exists already a special for this product
        if (xtc_db_num_rows($specials_query, true) > 0) {
            $special = xtc_db_fetch_array($specials_query, true);
            $sInfo = new objectInfo($special);
        }
    }
    $price = $sInfo->products_price;
    $new_price = $sInfo->specials_new_products_price;
    $new_price_netto = '';
    //web28 - 2010-07-27 - show special_price netto
    if (PRICE_IS_BRUTTO == 'true') {
        $price_netto = xtc_round($price, PRICE_PRECISION);
        if ($price > 0) {
            $new_price_netto = TEXT_NETTO . '<strong>' . xtc_round($new_price, PRICE_PRECISION) . '</strong>';
            //web28 - 2010-07-27 - show special_price netto
        }
        $price = $price * (xtc_get_tax_rate($sInfo->products_tax_class_id) + 100) / 100;
        $new_price = $new_price * (xtc_get_tax_rate($sInfo->products_tax_class_id) + 100) / 100;
    }
    $price = xtc_round($price, PRICE_PRECISION);
    $new_price = xtc_round($new_price, PRICE_PRECISION);
    // build the expires date in the format YYYY-MM-DD
    if (isset($_GET['pID']) and xtc_db_num_rows($specials_query, true) > 0 and $sInfo->expires_date != 0) {
        $expires_date = substr($sInfo->expires_date, 0, 4) . "-" . substr($sInfo->expires_date, 5, 2) . "-" . substr($sInfo->expires_date, 8, 2);
    } else {
        $expires_date = "";
    }
    if ($sInfo->status == 1) {
        $status = 'checked="checked"';
    } else {
        $status = '';
    }
    // tell the storing script if to update existing special,
    // or to insert a new one
    echo xtc_draw_hidden_field('specials_action', isset($_GET['pID']) && xtc_db_num_rows($specials_query, true) > 0 ? "update" : "insert");
    echo xtc_draw_hidden_field('tax_rate', xtc_get_tax_rate($pInfo->products_tax_class_id));
    //web28 - 2010-07-27 - add hidden field
    echo xtc_draw_hidden_field('products_price_hidden', $pInfo->products_price);
    //web28 - 2010-07-27 - FIX wrong specials price
    if (isset($_GET['pID']) and xtc_db_num_rows($specials_query, true) > 0) {
        echo xtc_draw_hidden_field('specials_id', $sInfo->specials_id);
    }
    ?>

<script type="text/javascript">
  var specialExpires = new ctlSpiffyCalendarBox("specialExpires", "new_product", "specials_expires","btnDate2","<?php 
    echo $expires_date;
    ?>
",2);
</script>
<script language="JavaScript" type="text/JavaScript">
  function showSpecial() {
    //alert(document.getElementById("special").style.display);
  if (document.getElementById("special").style.display =="none" || document.getElementById("special").style.display =="") {
    document.getElementById("special").style.display="block";
    document.getElementById('butSpecial').innerHTML= '<a href="JavaScript:showSpecial()" class="btn btn-default">&laquo; Sonderangebot</a>';
  } else {
    document.getElementById("special").style.display="none";
    document.getElementById('butSpecial').innerHTML= '<a href="JavaScript:showSpecial()" class="btn btn-default">Sonderangebot &raquo;</a>';
    }
  }
</script>
<style type='text/css'>#special{display: none;}</style>
<noscript>
<style type="text/css">#special{display: block;}</style>
</noscript>
  <div id="special">
    <div style="padding: 8px 0px 3px 5px;">
          <div class="main">
            <strong><?php 
    echo SPECIALS_TITLE;
    ?>
</strong>
          </div>
    </div>
    <div class='col-xs-12' style="width: 100%; border: 1px solid; border-color: #aaaaaa; padding:5px; background-color: #f3f3f3;">   
            <?php 
    if (!isset($_GET['pID'])) {
        ?>
            <div class="col-xs-12 col-sm-9 col-md-5 col-lg-5">
              <div class="main col-xs-12 col-sm-4"><?php 
        echo TEXT_SPECIALS_NO_PID;
        ?>
</div>             
            </div>
            <div class='clearfix' ></div>
            <?php 
    } else {
        ?>
            <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5 ">
              <div class="main col-xs-12 col-sm-4"><?php 
        echo TEXT_PRODUCTS_PRICE;
        ?>
</div>
              <div class="main col-xs-12 col-sm-4"><?php 
        echo $products_price_sp;
        echo $products_price_netto_sp;
        ?>
</div>
            </div>   
            <div class='clearfix' ></div>
            <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5">
              <div class="main col-xs-12 col-sm-4" >
                <?php 
        echo TEXT_SPECIALS_SPECIAL_PRICE;
        ?>
              </div>
              <div class="main col-xs-12 col-sm-4" >
                <?php 
        echo xtc_draw_input_field('specials_price', $new_price, 'style="width: 135px"') . '&nbsp;&nbsp;&nbsp;' . $new_price_netto;
        ?>
              </div>
              <div class="main col-xs-12 col-sm-4" >
                <?php 
        if (isset($_GET['pID']) and xtc_db_num_rows($specials_query, true) > 0) {
            ?>
                <input type="checkbox" name="specials_delete" value="true" id="input_specials_delete"  onclick="if(this.checked==true)return confirm('<?php 
            echo TEXT_INFO_DELETE_INTRO;
            ?>
');"style="vertical-align:middle;"/><label for="input_specials_delete">&nbsp;<?php 
            echo TEXT_INFO_HEADING_DELETE_SPECIALS;
            ?>
</label>
                <?php 
        }
        ?>
              </div>
            </div>
            <div class='clearfix' ></div>
            <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5">
              <div class="main col-xs-12 col-sm-4">
                <?php 
        echo TEXT_SPECIALS_SPECIAL_QUANTITY;
        ?>
&nbsp;
              </div>
              <div class="main col-xs-12 col-sm-4">
                <?php 
        echo xtc_draw_input_field('specials_quantity', $sInfo->specials_quantity, 'style="width: 135px"');
        ?>
              </div>
            </div>
            <div class='clearfix' ></div>
            <?php 
        if (isset($_GET['pID']) and xtc_db_num_rows($specials_query, true) > 0) {
            ?>
              <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5">
                <div class="main col-xs-12 col-sm-4"><?php 
            echo TEXT_INFO_DATE_ADDED;
            ?>
</div>
                <div class="main col-xs-12 col-sm-4"><?php 
            echo xtc_date_short($sInfo->specials_date_added);
            ?>
</div>
                <div class="main col-xs-12 col-sm-4">&nbsp;</div>
              </div>
            <div class='clearfix' ></div>
              <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5">
                <div class="main col-xs-12 col-sm-4"><?php 
            echo TEXT_INFO_LAST_MODIFIED;
            ?>
</div>
                <div class="main col-xs-12 col-sm-4"><?php 
            echo xtc_date_short($sInfo->specials_last_modified);
            ?>
</div>
                <div class="main col-xs-12 col-sm-4">&nbsp;</div>
              </div>
            <div class='clearfix' ></div>
            <?php 
        }
        ?>
            <div class="col-xs-12 col-xs-12 col-sm-9 col-md-5 col-lg-5"> 
              <div class="main col-xs-12 col-sm-4">
                <?php 
        echo TEXT_SPECIALS_EXPIRES_DATE;
        ?>
              </div>
              <div class="main col-xs-12 col-sm-4">
                <script type="text/javascript">specialExpires.writeControl(); specialExpires.dateFormat="yyyy-MM-dd";</script>
                <noscript>
                <?php 
        echo xtc_draw_input_field('specials_expires', $expires_date, 'style="width: 135px"');
        ?>
                </noscript>
              </div>
              <div class="main col-xs-12 col-sm-4">
                <?php 
        if (isset($_GET['pID']) and xtc_db_num_rows($specials_query, true) > 0) {
            ?>
                <input type="checkbox" name="specials_status" value="1" id="input_specials_status"  style="vertical-align:middle;" <?php 
            echo $status;
            ?>
/><label for="input_specials_status">&nbsp;<?php 
            echo TEXT_EDIT_STATUS;
            ?>
</label>
                <?php 
        }
        ?>
              </div>
            </div>
            <div class='clearfix' ></div>
            <div class="col-xs-12">
              <div class="main" style="padding:3px; background: #D8D8D8;">
                <?php 
        echo TEXT_SPECIALS_PRICE_TIP;
        ?>
              </div>
            </div>
            <?php 
    }
    ?>
    </div>
  </div>
<?php 
}
Пример #3
0
/**
 * xtc_calculate_tax()
 *
 * @param mixed $price
 * @param mixed $tax
 * @return
 */
function xtc_calculate_tax($price, $tax)
{
    global $currencies;
    return xtc_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
         }
         //Informations
         $contents[] = array('align' => 'center', 'text' => '<div style="padding-top: 5px; font-weight: bold; width: 90%; border-top: 1px solid Black; margin-top: 5px;">' . TEXT_INFORMATIONS . '</div>');
         $contents[] = array('text' => '<div style="padding-left: 30px;">' . TEXT_DATE_ADDED . ' ' . xtc_date_short($pInfo->products_date_added) . '</div>');
         if (xtc_not_null($pInfo->products_last_modified)) {
             $contents[] = array('text' => '<div style="padding-left: 30px;">' . TEXT_LAST_MODIFIED . '&nbsp;' . xtc_date_short($pInfo->products_last_modified) . '</div>');
         }
         if (date('Y-m-d') < $pInfo->products_date_available) {
             $contents[] = array('text' => '<div style="padding-left: 30px;">' . TEXT_DATE_AVAILABLE . ' ' . xtc_date_short($pInfo->products_date_available) . '</div>');
         }
         // START IN-SOLUTION Berechung des Bruttopreises
         $price = $pInfo->products_price;
         $price = xtc_round($price, PRICE_PRECISION);
         $price_string = '' . TEXT_PRODUCTS_PRICE_INFO . '&nbsp;' . $currencies->format($price);
         if (PRICE_IS_BRUTTO == 'true' && ($_GET['read'] == 'only' || $action != 'new_product_preview')) {
             $price_netto = xtc_round($price, PRICE_PRECISION);
             $tax_query = xtc_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . $pInfo->products_tax_class_id . "' ");
             $tax = xtc_db_fetch_array($tax_query);
             $price = $price * ($tax[tax_rate] + 100) / 100;
             $price_string = '' . TEXT_PRODUCTS_PRICE_INFO . '&nbsp;' . $currencies->format($price) . '<br/>' . TXT_NETTO . $currencies->format($price_netto);
         }
         $contents[] = array('text' => '<div style="padding-left: 30px;">' . $price_string . '</div><div style="padding-left: 30px;">' . TEXT_PRODUCTS_DISCOUNT_ALLOWED_INFO . '&nbsp;' . $pInfo->products_discount_allowed . ' %</div><div style="padding-left: 30px;">' . TEXT_PRODUCTS_QUANTITY_INFO . '&nbsp;' . $pInfo->products_quantity . '</div>');
         // END IN-SOLUTION
         //$contents[] = array('text' => '<br />' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br />' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity);
         $contents[] = array('text' => '<div style="padding-left: 30px; padding-bottom: 10px;">' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '</div>');
         $contents[] = array('text' => '<div style="padding-left: 30px; padding-bottom: 10px;">' . TEXT_PRODUCT_LINKED_TO . '<br />' . xtc_output_generated_category_path($pInfo->products_id, 'product') . '</div>');
         $contents[] = array('align' => 'center', 'text' => '<div style="padding: 10px;">' . xtc_product_thumb_image($pInfo->products_image, $pInfo->products_name) . '</div><div style="padding-bottom: 10px;">' . $pInfo->products_image . '</div>');
     }
 } else {
     // create category/product info
     $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>');
 $products_query_raw = "SELECT\n                                   p.products_id,\n                                   p.products_model,\n                                   p.products_ean,\n                                   p.products_quantity,\n                                   p.products_image,\n                                   p.products_price,\n                                   p.products_discount_allowed,\n                                   p.products_tax_class_id,\n                                   p.products_date_available,\n                                   p.products_status,\n                                   pd.products_name                                         \n                              FROM " . TABLE_PRODUCTS . " p,\n                                   " . TABLE_PRODUCTS_DESCRIPTION . " pd\n                             WHERE p.products_id = pd.products_id\n                               AND pd.language_id = '" . $_SESSION['languages_id'] . "'\n                               AND (pd.products_name LIKE ('%" . $_GET['search'] . "%') OR \n                                    p.products_model LIKE ('%" . $_GET['search'] . "%') OR \n                                    p.products_ean LIKE ('%" . $_GET['search'] . "%')\n                                   )\n                          ORDER BY pd.products_name";
 $products_split = new splitPageResults($_GET['page'], MAX_DISPLAY_PRODUCTS_SEARCH_RESULTS, $products_query_raw, $products_query_numrows);
 $products_query = xtc_db_query($products_query_raw);
 while ($products = xtc_db_fetch_array($products_query)) {
     ?>
   <tr class="dataTableRow">
     <?php 
     if ($products['products_status'] == '1') {
         $products_status = xtc_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10);
     } else {
         $products_status = xtc_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
     }
     $products_tax_rate = xtc_get_tax_rate($products['products_tax_class_id']);
     // calculate brutto price for display
     if (PRICE_IS_BRUTTO == 'true') {
         $products_price = xtc_round($products['products_price'] * ((100 + $products_tax_rate) / 100), PRICE_PRECISION);
         $products_price = $currencies->format($products_price);
         $products_price_netto = $currencies->format($products['products_price']);
     } else {
         $products_price = $currencies->format($products['products_price']);
         $products_price_netto = '';
     }
     echo xtc_draw_form('product_ins', FILENAME_ORDERS_EDIT, 'action=product_ins', 'post');
     //BOF - web28 - 2011-01-16 - FIX missing sessions id
     //echo xtc_draw_hidden_field(xtc_session_name(), xtc_session_id());
     //EOF - web28 - 2011-01-16 - FIX missing sessions id
     echo xtc_draw_hidden_field('cID', $_POST['cID']);
     echo xtc_draw_hidden_field('oID', $_GET['oID']);
     echo xtc_draw_hidden_field('products_id', $products['products_id']);
     ?>
       <td class="dataTableContent">&nbsp;<?php 
Пример #6
0
              </tr>
<?php 
    $specials_query_raw = "select p.products_id, pd.products_name,p.products_tax_class_id, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $_SESSION['languages_id'] . "' and p.products_id = s.products_id order by pd.products_name";
    $specials_split = new splitPageResults($_GET['page'], '20', $specials_query_raw, $specials_query_numrows);
    $specials_query = xtc_db_query($specials_query_raw);
    while ($specials = xtc_db_fetch_array($specials_query)) {
        $price = $specials['products_price'];
        $new_price = $specials['specials_new_products_price'];
        if (PRICE_IS_BRUTTO == 'true') {
            $price_netto = xtc_round($price, PRICE_PRECISION);
            $new_price_netto = xtc_round($new_price, PRICE_PRECISION);
            $price = $price * (xtc_get_tax_rate($specials['products_tax_class_id']) + 100) / 100;
            $new_price = $new_price * (xtc_get_tax_rate($specials['products_tax_class_id']) + 100) / 100;
        }
        $specials['products_price'] = xtc_round($price, PRICE_PRECISION);
        $specials['specials_new_products_price'] = xtc_round($new_price, PRICE_PRECISION);
        if ((!$_GET['sID'] || $_GET['sID'] == $specials['specials_id']) && !$sInfo) {
            $products_query = xtc_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . $specials['products_id'] . "'");
            $products = xtc_db_fetch_array($products_query);
            $sInfo_array = xtc_array_merge($specials, $products);
            $sInfo = new objectInfo($sInfo_array);
            $sInfo->specials_new_products_price = $specials['specials_new_products_price'];
            $sInfo->products_price = $specials['products_price'];
        }
        if (is_object($sInfo) && $specials['specials_id'] == $sInfo->specials_id) {
            echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'pointer\'" onclick="document.location.href=\'' . xtc_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
        } else {
            echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'pointer\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . xtc_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials['specials_id']) . '\'">' . "\n";
        }
        ?>
                <td  class="dataTableContent"><?php 
        while ($staffel_values = xtc_db_fetch_array($staffel_query)) {
            // load data into array
            ?>
          <div class='col-xs-12'>
            <div class='col-sm-6 col-xs-12 main'><?php 
            echo $staffel_values['quantity'];
            ?>
</div>            
            <div class='col-sm-6 col-xs-12 main'>
              <?php 
            if (PRICE_IS_BRUTTO == 'true') {
                $tax_query = xtc_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . $pInfo->products_tax_class_id . "' ");
                $tax = xtc_db_fetch_array($tax_query);
                $products_price = xtc_round($staffel_values['personal_offer'] * ((100 + $tax['tax_rate']) / 100), PRICE_PRECISION);
            } else {
                $products_price = xtc_round($staffel_values['personal_offer'], PRICE_PRECISION);
            }
            echo $products_price;
            if (PRICE_IS_BRUTTO == 'true') {
                echo ' <br />' . TEXT_NETTO . '<strong>' . $xtPrice->xtcFormat($staffel_values['personal_offer'], false) . '</strong>  ';
            }
            ?>
            </div>
            <div align="left" style="padding-left:5px;"><a class="btn btn-default" onclick="W4B_graduated_prices_edit_removerow(this);" href="<?php 
            echo xtc_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&function=delete&quantity=' . $staffel_values['quantity'] . '&statusID=' . $group_data[$col]['STATUS_ID'] . '&action=new_product&pID=' . $_GET['pID']);
            ?>
"><?php 
            echo BUTTON_DELETE;
            ?>
</a></div>
          </div>          
    ?>
    <tr class="dataTableRow">
      <?php 
    echo xtc_draw_form('product_option_ins', FILENAME_ORDERS_EDIT, 'action=product_option_ins', 'post');
    //BOF - web28 - 2011-01-16 - FIX missing sessions id
    echo xtc_draw_hidden_field(xtc_session_name(), xtc_session_id());
    //EOF - web28 - 2011-01-16 - FIX missing sessions id
    echo xtc_draw_hidden_field('oID', (int) $_GET['oID']);
    echo xtc_draw_hidden_field('opID', (int) $_GET['opID']);
    echo xtc_draw_hidden_field('pID', (int) $_GET['pID']);
    echo xtc_draw_hidden_field('aID', (int) $products['products_attributes_id']);
    $brutto = PRICE_IS_BRUTTO;
    if ($brutto == 'true') {
        $options_values_price = xtc_round($products['options_values_price'] * (1 + $_GET['pTX'] / 100), PRICE_PRECISION);
    } else {
        $options_values_price = xtc_round($products['options_values_price'], PRICE_PRECISION);
    }
    ?>
        <td class="dataTableContent"><?php 
    echo $products['products_attributes_id'];
    ?>
</td>
        <td class="dataTableContent"><?php 
    echo xtc_oe_get_options_name($products['options_id']);
    ?>
</td>
        <td class="dataTableContent"><?php 
    echo xtc_oe_get_options_values_name($products['options_values_id']);
    ?>
</td>
        <td class="dataTableContent">
// download function end
xtc_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $_POST['current_product_id'] . "'");
// Simple, yet effective.. loop through the selected Option Values.. find the proper price & prefix.. insert.. yadda yadda yadda.
for ($i = 0; $i < sizeof($_POST['optionValues']); $i++) {
    $query = "SELECT * \n                FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " \n               WHERE products_options_values_id = '" . $_POST['optionValues'][$i] . "'";
    $result = xtc_db_query($query);
    $matches = xtc_db_num_rows($result);
    while ($line = xtc_db_fetch_array($result)) {
        $optionsID = $line['products_options_id'];
    }
    $cv_id = $_POST['optionValues'][$i];
    $value_price = $_POST[$cv_id . '_price'];
    if (PRICE_IS_BRUTTO == 'true') {
        $value_price = $value_price / (xtc_get_tax_rate(xtc_get_tax_class_id($_POST['current_product_id'])) + 100) * 100;
    }
    $value_price = xtc_round($value_price, PRICE_PRECISION);
    //default values
    $sql_data_array = array('products_id' => $_POST['current_product_id'], 'options_id' => $optionsID, 'options_values_id' => $_POST['optionValues'][$i], 'options_values_price' => $value_price, 'price_prefix' => $_POST[$cv_id . '_prefix'], 'attributes_model' => xtc_db_prepare_input($_POST[$cv_id . '_model']), 'attributes_stock' => $_POST[$cv_id . '_stock'], 'options_values_weight' => $_POST[$cv_id . '_weight'], 'weight_prefix' => $_POST[$cv_id . '_weight_prefix'], 'sortorder' => $_POST[$cv_id . '_sortorder']);
    //additional values
    $add_data_array = array('attributes_ean' => xtc_db_prepare_input($_POST[$cv_id . '_ean']));
    $sql_data_array = xtc_array_merge($sql_data_array, $add_data_array);
    xtc_db_perform(TABLE_PRODUCTS_ATTRIBUTES, $sql_data_array);
    $products_attributes_id = xtc_db_insert_id();
    if ($_POST[$cv_id . '_download_file'] != '') {
        $value_download_file = $_POST[$cv_id . '_download_file'];
        $value_download_expire = $_POST[$cv_id . '_download_expire'];
        $value_download_count = $_POST[$cv_id . '_download_count'];
        $sql_data_array = array('products_attributes_id' => $products_attributes_id, 'products_attributes_filename' => xtc_db_prepare_input($value_download_file), 'products_attributes_maxdays' => $value_download_expire, 'products_attributes_maxcount' => $value_download_count);
        xtc_db_perform(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, $sql_data_array);
    }
}
 } else {
     $attribute_value_price_calculate = xtc_round(isset($attr_array['options_values_price']) ? $attr_array['options_values_price'] : 0, PRICE_PRECISION);
 }
 echo '<td style="width:35px;" class="main" align="left">' . PHP_EOL;
 echo '<div class="col-xs-3">';
 echo '   <select name="' . $current_value_id . '_prefix">' . PHP_EOL;
 echo '     <option value="+"' . (isset($attr_array['posCheck']) ? $attr_array['posCheck'] : '') . '>+</option>' . PHP_EOL;
 echo '     <option value="-"' . (isset($attr_array['negCheck']) ? $attr_array['negCheck'] : '') . '>-</option>' . PHP_EOL;
 echo '    </select>' . PHP_EOL;
 echo '</div>';
 echo '<div class="col-xs-9">';
 echo '<input type="text" name="' . $current_value_id . '_price" value="' . $attribute_value_price_calculate . '" size="10">' . PHP_EOL;
 echo '</div>';
 // brutto Admin
 if (PRICE_IS_BRUTTO == 'true') {
     echo '<span style="font-size:11px">' . TEXT_NETTO . '<strong>' . $xtPrice->xtcFormat(xtc_round(isset($attr_array['options_values_price']) ? $attr_array['options_values_price'] : 0, PRICE_PRECISION), true) . '</strong></span>  ' . PHP_EOL;
 }
 echo '</td>' . PHP_EOL;
 echo '</tr>' . PHP_EOL;
 // Download function start
 if (strtoupper($current_product_option_name) == 'DOWNLOADS') {
     echo '<tr class="hidden-lg hidden-md">' . PHP_EOL;
     echo '<td class="main" colspan="' . $colspan . '" style="white-space: nowrap; background: #ccc; padding: 4px;">' . xtc_draw_pull_down_menu($current_value_id . '_download_file', xtc_getDownloads(), isset($attr_dl_array['products_attributes_filename']) ? $attr_dl_array['products_attributes_filename'] : '', '') . PHP_EOL;
     echo '&nbsp;&nbsp;&nbsp;' . DL_COUNT . ' <input type="text" name="' . $current_value_id . '_download_count" value="' . (isset($attr_dl_array['products_attributes_maxcount']) ? $attr_dl_array['products_attributes_maxcount'] : '') . '" size="6">' . PHP_EOL;
     echo '&nbsp;&nbsp;&nbsp;' . DL_EXPIRE . ' <input type="text" name="' . $current_value_id . '_download_expire" value="' . (isset($attr_dl_array['products_attributes_maxdays']) ? $attr_dl_array['products_attributes_maxdays'] : '') . '" size="6"></td>' . PHP_EOL;
     echo '</tr>' . PHP_EOL;
 }
 // Download function end
 echo '<tr class="' . $rowClass . ' hidden-lg hidden-md">' . PHP_EOL;
 #hidden-lg hidden-md
 echo '<td colspan="2" class="main" style="width:150px"><hr></td>' . PHP_EOL;
$smarty->assign('LINK_TRANSACTIONS', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_3) . '\')">');
$smarty->assign('LINK_CONVERSION', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_4) . '\')">');
$smarty->assign('LINK_AMOUNT', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_5) . '\')">');
$smarty->assign('LINK_AVERAGE', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_6) . '\')">');
$smarty->assign('LINK_COMISSION_RATE', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_7) . '\')">');
$smarty->assign('LINK_COMISSION', '<a href="javascript:popupWindow(\'' . xtc_href_link(FILENAME_AFFILIATE_HELP_8) . '\')">');
if (AFFILATE_USE_TIER == 'true') {
    $smarty->assign('AFFILIATE_USE_TIER', 'true');
    for ($tier_number = 0; $tier_number <= AFFILIATE_TIER_LEVELS; $tier_number++) {
        if (is_null($affiliate_percent_tier[$tier_number - 1])) {
            $affiliate_percent_tier[$tier_number - 1] = $affiliate_percent;
        }
        $affiliate_percent_tier_table .= '<tr>';
        $affiliate_percent_tier_table .= '<td width="15%" class="boxtext"><a href=' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_level=' . $tier_number . '&a_period=' . $a_period, 'SSL') . '>' . TEXT_COMMISSION_LEVEL_TIER . $tier_number . '</a></td>';
        $affiliate_percent_tier_table .= '<td width="15%" align="right" class="boxtext"><a href=' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_level=' . $tier_number . '&a_period=' . $a_period, 'SSL') . '>' . TEXT_COMMISSION_RATE_TIER . '</a></td>';
        $affiliate_percent_tier_table .= '<td width="5%" class="boxtext">' . xtc_round($affiliate_percent_tier[$tier_number - 1], 2) . '%' . '</td>';
        $affiliate_percent_tier_table .= '<td width="15%" align="right" class="boxtext"><a href=' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_level=' . $tier_number . '&a_period=' . $a_period, 'SSL') . '>' . TEXT_COMMISSION_TIER_COUNT . '</a></td>';
        $affiliate_percent_tier_table .= '<td width="5%" class="boxtext">' . ($affiliate_sales[$tier_number]['count'] > 0 ? $affiliate_sales[$tier_number]['count'] : '0') . '</td>';
        $affiliate_percent_tier_table .= '<td width="15%" align="right" class="boxtext"><a href=' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_level=' . $tier_number . '&a_period=' . $a_period, 'SSL') . '>' . TEXT_COMMISSION_TIER_TOTAL . '</a></td>';
        $affiliate_percent_tier_table .= '<td width="5%" class="boxtext">' . $xtPrice->xtcFormat($affiliate_sales[$tier_number]['total'], true) . '</td>';
        $affiliate_percent_tier_table .= '<td width="20%" align="right" class="boxtext"><a href=' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_level=' . $tier_number . '&a_period=' . $a_period, 'SSL') . '>' . TEXT_COMMISSION_TIER . '</a></td>';
        $affiliate_percent_tier_table .= '<td width="5%" class="boxtext">' . $xtPrice->xtcFormat($affiliate_sales[$tier_number]['payment'], true) . '</td>';
        $affiliate_percent_tier_table .= '</tr>';
    }
    $smarty->assign('affiliate_percent_tier_table', $affiliate_percent_tier_table);
}
$smarty->assign('LINK_BANNER', '<a href="' . xtc_href_link(FILENAME_AFFILIATE_BANNERS) . '">' . xtc_image_button('button_affiliate_banners.gif', IMAGE_BANNERS) . '</a>');
$smarty->assign('LINK_CLICKS', '<a href="' . xtc_href_link(FILENAME_AFFILIATE_CLICKS, '', 'SSL') . '">' . xtc_image_button('button_affiliate_clickthroughs.gif', IMAGE_CLICKTHROUGHS) . '</a>');
$smarty->assign('LINK_SALES', '<a href="' . xtc_href_link(FILENAME_AFFILIATE_SALES, 'a_period=' . $a_period, 'SSL') . '">' . xtc_image_button('button_affiliate_sales.gif', IMAGE_SALES) . '</a>');
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
Пример #12
0
 function insert_product($products_data, $dest_category_id, $link, $action = 'insert')
 {
     $products_id = xtc_db_prepare_input($products_data['products_id']);
     $products_date_available = xtc_db_prepare_input($products_data['products_date_available']);
     $products_date_available = date('Y-m-d') < $products_date_available ? $products_date_available : 'null';
     $products_status = xtc_db_prepare_input($products_data['products_status']);
     if ($products_data['products_startpage'] == 1) {
         $this->link_product($products_data['products_id'], 0);
         //$products_status = 1;    //web28 2012-10-30 - don't set status active
     } else {
         $this->set_product_remove_startpage_sql($products_data['products_id'], 0);
         //Dokuman - 2009-11-12 - BUGFIX #0000351: When products disable display on startpage, should update table products_to_categories
     }
     if (PRICE_IS_BRUTTO == 'true' && $products_data['products_price']) {
         $products_data['products_price'] = round($products_data['products_price'] / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100, PRICE_PRECISION);
     }
     $customers_statuses_array = xtc_get_customers_statuses();
     $permission = array();
     for ($i = 0, $n = sizeof($customers_statuses_array); $i < $n; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission[$customers_statuses_array[$i]['id']] = 0;
         }
     }
     if (isset($products_data['groups'])) {
         foreach ($products_data['groups'] as $dummy => $b) {
             $permission[$b] = 1;
         }
     }
     // build array
     if ($permission['all'] == 1) {
         $permission = array();
         end($customers_statuses_array);
         for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
             if (isset($customers_statuses_array[$i]['id'])) {
                 $permission[$customers_statuses_array[$i]['id']] = 1;
             }
         }
     }
     $permission_array = array();
     // set pointer to last key
     end($customers_statuses_array);
     for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission_array = array_merge($permission_array, array('group_permission_' . $customers_statuses_array[$i]['id'] => $permission[$customers_statuses_array[$i]['id']]));
         }
     }
     $sql_data_array = array('products_quantity' => xtc_db_prepare_input($products_data['products_quantity']), 'products_model' => xtc_db_prepare_input($products_data['products_model']), 'products_ean' => xtc_db_prepare_input($products_data['products_ean']), 'products_price' => xtc_db_prepare_input($products_data['products_price']), 'products_sort' => xtc_db_prepare_input($products_data['products_sort']), 'products_shippingtime' => xtc_db_prepare_input($products_data['shipping_status']), 'products_discount_allowed' => xtc_db_prepare_input($products_data['products_discount_allowed']), 'products_date_available' => $products_date_available, 'products_weight' => xtc_db_prepare_input($products_data['products_weight']), 'products_status' => $products_status, 'products_startpage' => xtc_db_prepare_input($products_data['products_startpage']), 'products_startpage_sort' => xtc_db_prepare_input($products_data['products_startpage_sort']), 'products_tax_class_id' => xtc_db_prepare_input($products_data['products_tax_class_id']), 'product_template' => xtc_db_prepare_input($products_data['info_template']), 'options_template' => xtc_db_prepare_input($products_data['options_template']), 'manufacturers_id' => xtc_db_prepare_input($products_data['manufacturers_id']), 'products_fsk18' => xtc_db_prepare_input($products_data['fsk18']), 'products_vpe_value' => xtc_db_prepare_input($products_data['products_vpe_value']), 'products_vpe_status' => xtc_db_prepare_input($products_data['products_vpe_status']), 'products_vpe' => xtc_db_prepare_input($products_data['products_vpe']), 'wholesaler_id' => xtc_db_prepare_input($products_data['wholesaler_id']), 'wholesaler_reorder' => xtc_db_prepare_input($products_data['wholesaler_reorder']));
     if (trim(ADD_PRODUCTS_FIELDS) != '') {
         $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_FIELDS, $products_data));
     }
     //echo print_r($sql_data_array); EXIT;
     $sql_data_array = array_merge($sql_data_array, $permission_array);
     //get the next ai-value from table products if no products_id is set
     if (!$products_id || $products_id == '') {
         $new_pid_query = xtc_db_query("SHOW TABLE STATUS LIKE '" . TABLE_PRODUCTS . "'");
         $new_pid_query_values = xtc_db_fetch_array($new_pid_query);
         $products_id = $new_pid_query_values['Auto_increment'];
     }
     //prepare products_image filename
     $accepted_products_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_products_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     if ($products_image = xtc_try_upload('products_image', DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_products_image_files_extensions, $accepted_products_image_files_mime_types)) {
         $pname_arr = explode('.', $products_image->filename);
         $nsuffix = array_pop($pname_arr);
         $products_image_name = $products_id . '_0.' . $nsuffix;
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['products_previous_image_0'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['products_previous_image_0']);
         }
         //workaround if there are v2 images mixed with v3
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_image->filename . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] == 0) {
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         } else {
             copy(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         }
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_image_name);
         require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
         require DIR_WS_INCLUDES . 'product_info_images.php';
         require DIR_WS_INCLUDES . 'product_popup_images.php';
         // set file rights
         $this->set_products_images_file_rights($products_image_name);
     } else {
         // save, when wo no upload an image
         $mo_img = array('image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
         if ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
             if ($products_data['del_mo_pic']) {
                 foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                     if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                         xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                     }
                     break;
                 }
             }
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
         } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
         }
         $products_image_name = $products_data['products_previous_image_0'];
     }
     //are we asked to delete some pics?
     if ($products_data['del_pic'] != '') {
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['del_pic'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['del_pic']);
         }
         xtc_db_query("UPDATE " . TABLE_PRODUCTS . "\n                         SET products_image = NULL\n                       WHERE products_id    = '" . xtc_db_input($products_id) . "'");
     }
     if ($products_data['del_mo_pic'] != '') {
         foreach ($products_data['del_mo_pic'] as $dummy => $val) {
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $val . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($val);
             }
             xtc_db_query("DELETE FROM " . TABLE_PRODUCTS_IMAGES . "\n                                     WHERE products_id = '" . xtc_db_input($products_id) . "'\n                                       AND image_name  = '" . $val . "'");
         }
     }
     //MO_PICS
     $accepted_mo_pics_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_mo_pics_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     for ($img = 0; $img < MO_PICS; $img++) {
         if ($pIMG = xtc_try_upload('mo_pics_' . $img, DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_mo_pics_image_files_extensions, $accepted_mo_pics_image_files_mime_types)) {
             $pname_arr = explode('.', $pIMG->filename);
             $nsuffix = array_pop($pname_arr);
             $products_image_name = $products_id . '_' . ($img + 1) . '.' . $nsuffix;
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $products_data['products_previous_image_' . ($img + 1)] . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($products_data['products_previous_image_' . ($img + 1)]);
             }
             @xtc_del_image_file($products_image_name);
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $pIMG->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $products_image_name);
             //get data & write to table
             // $mo_img = array ('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img +1), 'image_name' => xtc_db_prepare_input($products_image_name));
             $mo_img = array('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img + 1), 'image_name' => xtc_db_prepare_input($products_image_name), 'image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
             if ($action == 'insert') {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             } elseif ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
                 if ($products_data['del_mo_pic']) {
                     foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                         if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                         }
                         break;
                     }
                 }
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
             } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             }
             //image processing
             require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
             require DIR_WS_INCLUDES . 'product_info_images.php';
             require DIR_WS_INCLUDES . 'product_popup_images.php';
             //set file rights
             $this->set_products_images_file_rights($products_image_name);
         }
     }
     if (is_array($products_data['image_title'])) {
         foreach ($products_data['image_title'] as $it_image_nr => $it_image_title) {
             $mo_img = array('image_title' => xtc_db_prepare_input($it_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($it_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (is_array($products_data['image_alt'])) {
         foreach ($products_data['image_alt'] as $ia_image_nr => $ia_image_title) {
             $mo_img = array('image_alt' => xtc_db_prepare_input($ia_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($ia_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (isset($products_data['products_image']) && xtc_not_null($products_data['products_image']) && $products_data['products_image'] != 'none') {
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_data['products_image']);
     }
     if ($action == 'insert') {
         $insert_sql_data = array('products_date_added' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array);
         $products_id = xtc_db_insert_id();
         xtc_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                              SET products_id   = '" . $products_id . "',\n                              categories_id = '" . $dest_category_id . "'");
         // web28 - 2012-03-11 - link product to startpage
         /* not longer needed
            if ($products_data['products_startpage'] == 1 ) {
              xtc_db_query("INSERT INTO ".TABLE_PRODUCTS_TO_CATEGORIES."
                                    SET products_id   = '".$products_id."',
                                        categories_id = '0'");
            }
            */
     } elseif ($action == 'update') {
         $update_sql_data = array('products_last_modified' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $update_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\'');
     }
     //Included specials
     if (file_exists("includes/modules/categories_specials.php")) {
         require_once "includes/modules/categories_specials.php";
         saveSpecialsData($products_id);
     }
     $languages = xtc_get_languages();
     // Here we go, lets write Group prices into db
     // start
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $personal_price = xtc_db_prepare_input($products_data['products_price_' . $group_data[$col]['STATUS_ID']]);
             if ($personal_price == '' || $personal_price == '0.0000') {
                 $personal_price = '0.00';
             } else {
                 if (PRICE_IS_BRUTTO == 'true') {
                     $personal_price = $personal_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
                 }
                 $personal_price = xtc_round($personal_price, PRICE_PRECISION);
             }
             if ($action == 'insert') {
                 xtc_db_query("DELETE FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                              WHERE products_id = '" . $products_id . "'\n                                AND quantity    = '1'");
                 $insert_array = array();
                 $insert_array = array('personal_offer' => $personal_price, 'quantity' => '1', 'products_id' => $products_id);
                 xtc_db_perform("personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'], $insert_array);
             } else {
                 xtc_db_query("UPDATE personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                         SET personal_offer = '" . $personal_price . "'\n                                       WHERE products_id = '" . $products_id . "'\n                                         AND quantity    = '1'");
             }
         }
     }
     // end
     // ok, lets check write new staffelpreis into db (if there is one)
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $quantity = xtc_db_prepare_input($products_data['products_quantity_staffel_' . $group_data[$col]['STATUS_ID']]);
             $staffelpreis = xtc_db_prepare_input($products_data['products_price_staffel_' . $group_data[$col]['STATUS_ID']]);
             if (PRICE_IS_BRUTTO == 'true') {
                 $staffelpreis = $staffelpreis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
             }
             $staffelpreis = xtc_round($staffelpreis, PRICE_PRECISION);
             if ($staffelpreis != '' && $quantity != '') {
                 // ok, lets check entered data to get rid of user faults
                 if ($quantity <= 1) {
                     $quantity = 2;
                 }
                 $check_query = xtc_db_query("SELECT quantity\n                                                           FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                          WHERE products_id = '" . $products_id . "'\n                                                            AND quantity    = '" . $quantity . "'");
                 // dont insert if same qty!
                 if (xtc_db_num_rows($check_query) < 1) {
                     xtc_db_query("INSERT INTO personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                   SET price_id       = '',\n                                                       products_id    = '" . $products_id . "',\n                                                       quantity       = '" . $quantity . "',\n                                                       personal_offer = '" . $staffelpreis . "'");
                 }
             }
         }
     }
     foreach ($languages as $lang) {
         $language_id = $lang['id'];
         $sql_data_array = array('products_name' => xtc_db_prepare_input($products_data['products_name'][$language_id]), 'products_description' => xtc_db_prepare_input($products_data['products_description_' . $language_id]), 'products_short_description' => xtc_db_prepare_input($products_data['products_short_description_' . $language_id]), 'products_keywords' => xtc_db_prepare_input($products_data['products_keywords'][$language_id]), 'products_url' => xtc_db_prepare_input($products_data['products_url'][$language_id]), 'products_meta_title' => xtc_db_prepare_input($products_data['products_meta_title'][$language_id]), 'products_meta_description' => xtc_db_prepare_input($products_data['products_meta_description'][$language_id]), 'products_meta_keywords' => xtc_db_prepare_input($products_data['products_meta_keywords'][$language_id]));
         if (trim(ADD_PRODUCTS_DESCRIPTION_FIELDS)) {
             $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_DESCRIPTION_FIELDS, $products_data, $language_id));
         }
         if ($action == 'insert') {
             $insert_sql_data = array('products_id' => $products_id, 'language_id' => $language_id);
             $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
         } elseif ($action == 'update') {
             //BOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             $product_query = xtc_db_query("SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . "\n                                               WHERE language_id = '" . $lang['id'] . "'\n                                                 AND products_id = '" . $products_id . "'");
             if (xtc_db_num_rows($product_query) == 0) {
                 xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, array('products_id' => $products_id, 'language_id' => $lang['id']));
             }
             //EOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\' and language_id = \'' . $language_id . '\'');
         }
     }
     //redirect by update button
     if (isset($products_data['prod_update'])) {
         xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&action=new_product&pID=' . $products_id . $this->page_parameter));
     }
     xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, xtc_get_path($dest_categories_id) . '&pID=' . $products_id . $this->page_parameter));
     //web28 2012-04-14 new redirect
 }
$affiliate = xtc_db_fetch_array($affiliate_query);
$affiliate_percent = 0;
$affiliate_percent = $affiliate['affiliate_commission_percent'];
if ($affiliate_percent < AFFILIATE_PERCENT) {
    $affiliate_percent = AFFILIATE_PERCENT;
}
$affiliate_clickthroughs_raw = "select count(*) as count from " . TABLE_AFFILIATE_CLICKTHROUGHS . " where affiliate_id = '" . $_GET['acID'] . "'";
$affiliate_clickthroughs_query = xtc_db_query($affiliate_clickthroughs_raw);
$affiliate_clickthroughs = xtc_db_fetch_array($affiliate_clickthroughs_query);
$affiliate_clickthroughs = $affiliate_clickthroughs['count'];
$affiliate_sales_raw = "\n    select count(*) as count, sum(affiliate_value) as total, sum(affiliate_payment) as payment from " . TABLE_AFFILIATE_SALES . " a \n    left join " . TABLE_ORDERS . " o on (a.affiliate_orders_id=o.orders_id) \n    where a.affiliate_id = '" . $_GET['acID'] . "' and o.orders_status >= " . AFFILIATE_PAYMENT_ORDER_MIN_STATUS . "\n    ";
$affiliate_sales_query = xtc_db_query($affiliate_sales_raw);
$affiliate_sales = xtc_db_fetch_array($affiliate_sales_query);
$affiliate_transactions = $affiliate_sales['count'];
if ($affiliate_clickthroughs > 0) {
    $affiliate_conversions = xtc_round($affiliate_transactions / $affiliate_clickthroughs * 100, 2) . "%";
} else {
    $affiliate_conversions = "n/a";
}
if ($affiliate_sales['total'] > 0) {
    $affiliate_average = $affiliate_sales['total'] / $affiliate_sales['count'];
} else {
    $affiliate_average = 0;
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
echo HTML_PARAMS;
?>
>
<head>
echo '<a href="javascript:popupWindow(\'' . (HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_HELP_6) . '\')">' . TEXT_SUMMARY_HELP . '</a>';
?>
</td>
                  <td width="15%" class="dataTableContent"><?php 
echo $currencies->display_price($affiliate_average, '');
?>
</td>
                </tr>
                <tr>
                  <td width="35%" align="right" class="dataTableContent"><?php 
echo TEXT_COMMISSION_RATE;
echo '<a href="javascript:popupWindow(\'' . (HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_HELP_7) . '\')">' . TEXT_SUMMARY_HELP . '</a>';
?>
</td>
                  <td width="15%" class="dataTableContent"><?php 
echo xtc_round(AFFILIATE_PERCENT, 2) . ' %';
?>
</td>
                  <td width="35%" align="right" class="dataTableContent"><b><?php 
echo TEXT_COMMISSION;
echo '<a href="javascript:popupWindow(\'' . (HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE_HELP_8) . '\')">' . TEXT_SUMMARY_HELP . '</a>';
?>
</b></td>
                  <td width="15%" class="dataTableContent"><b><?php 
echo $currencies->display_price($affiliate_commission, '');
?>
</b></td>
                </tr>
                <tr>
                  <td colspan="4"><?php 
echo xtc_draw_separator();
function W4B_graduated_prices_save()
{
    $products_data = $_POST;
    $group_data = array();
    $products_id = (int) $_GET['pID'];
    $i = 0;
    $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
    while ($group_values = xtc_db_fetch_array($group_query)) {
        // load data into array
        $i++;
        $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
    }
    for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
        if ($group_data[$col]['STATUS_ID'] != '') {
            $quantity = xtc_db_prepare_input($products_data['products_quantity_staffel_' . $group_data[$col]['STATUS_ID']]);
            $staffelpreis = xtc_db_prepare_input($products_data['products_price_staffel_' . $group_data[$col]['STATUS_ID']]);
            if (PRICE_IS_BRUTTO == 'true') {
                $staffelpreis = $staffelpreis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
            }
            $staffelpreis = xtc_round($staffelpreis, PRICE_PRECISION);
            if ($staffelpreis != '' && $quantity != '') {
                // ok, lets check entered data to get rid of user faults
                if ($quantity <= 1) {
                    $quantity = 2;
                }
                $check_query = xtc_db_query("SELECT quantity\n                                                           FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                          WHERE products_id = '" . $products_id . "'\n                                                            AND quantity    = '" . $quantity . "'");
                // dont insert if same qty!
                if (xtc_db_num_rows($check_query) < 1) {
                    xtc_db_query("INSERT INTO personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                   SET price_id       = '',\n                                                       products_id    = '" . $products_id . "',\n                                                       quantity       = '" . $quantity . "',\n                                                       personal_offer = '" . $staffelpreis . "'");
                }
            }
        }
    }
    header("HTTP/1.0 204 No Content");
    die;
}