function __construct(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows)
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     // # scrub any white space found in incoming queries!
     if ($sql_query) {
         $sql_query = preg_replace("/\\s+/", " ", $sql_query);
     }
     //error_log(print_r($sql_query,1));
     $pos_to = strlen($sql_query);
     $pos_from = strripos($sql_query, ' from', 0);
     $pos_order_by = strripos($sql_query, ' order by', $pos_from);
     if ($pos_order_by < $pos_to && $pos_order_by != false) {
         $pos_to = $pos_order_by;
     }
     $pos_limit = strripos($sql_query, ' limit', $pos_from);
     if ($pos_limit < $pos_to && $pos_limit != false) {
         $pos_to = $pos_limit;
     }
     $pos_procedure = strripos($sql_query, ' procedure', $pos_from);
     if ($pos_procedure < $pos_to && $pos_procedure != false) {
         $pos_to = $pos_procedure;
     }
     $offset = $max_rows_per_page * ($current_page_number - 1);
     $sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
     $reviews_count_query = tep_db_query("select 0 " . substr($sql_query, $pos_from, $pos_to - $pos_from));
     //$reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = (int) tep_db_num_rows($reviews_count_query);
     $this->current_page_number = $current_page_number;
     $this->max_rows_per_page = $max_rows_per_page;
     $this->query_num_rows = $query_num_rows;
 }
 function remove()
 {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
     tep_db_query("alter table " . TABLE_CUSTOMERS . " drop `customers_guest`");
     tep_db_query("alter table " . TABLE_ORDERS . " drop `customers_guest`");
     tep_db_query("alter table " . TABLE_ADDRESS_BOOK . " drop `customers_guest`");
 }
Example #3
0
function tep_get_configuration_key_value($lookup)
{
    $configuration_query_raw = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'");
    $configuration_query = tep_db_fetch_array($configuration_query_raw);
    $lookup_value = $configuration_query['configuration_value'];
    return $lookup_value;
}
Example #4
0
function tep_update_whos_online()
{
    global $customer_id;
    if (tep_session_is_registered('customer_id')) {
        $wo_customer_id = $customer_id;
        $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $customer_id . "'");
        $customer = tep_db_fetch_array($customer_query);
        $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
    } else {
        $wo_customer_id = '';
        $wo_full_name = 'Guest';
    }
    $wo_session_id = tep_session_id();
    $wo_ip_address = getenv('REMOTE_ADDR');
    $wo_last_page_url = getenv('REQUEST_URI');
    $current_time = time();
    $xx_mins_ago = $current_time - 900;
    // remove entries that have expired
    tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
    $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
    $stored_customer = tep_db_fetch_array($stored_customer_query);
    if ($stored_customer['count'] > 0) {
        tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int) $wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'");
    } else {
        tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . (int) $wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "')");
    }
}
Example #5
0
 function query($order_id)
 {
     global $languages_id;
     $order_query = tep_db_query("select o.*, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS . " s where o.orders_id = '" . (int) $order_id . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int) $languages_id . "'");
     $order = tep_db_fetch_array($order_query);
     $totals_query = tep_db_query("select title, text, class from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "' order by sort_order");
     while ($totals = tep_db_fetch_array($totals_query)) {
         $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class']);
     }
     $this->info = array('total' => null, 'currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'status' => $order['orders_status_name'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified']);
     foreach ($this->totals as $t) {
         if ($t['class'] == 'ot_total') {
             $this->info['total'] = $t['text'];
             break;
         }
     }
     $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']);
     $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']);
     $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']);
     $index = 0;
     $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $order_id . "'");
     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
         $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']);
         $subindex = 0;
         $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'");
         if (tep_db_num_rows($attributes_query)) {
             while ($attributes = tep_db_fetch_array($attributes_query)) {
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']);
                 $subindex++;
             }
         }
         $index++;
     }
 }
function generateDesignsId($month)
{
    //    $dateObj = DateTime::createFromFormat('!m', $month);
    //    $month_name = $dateObj->format('F');
    $month_name = date('F', mktime(0, 0, 0, $month, 10));
    echo "<h3>{$month_name}</h3>";
    $query = "SELECT designs_id, status_time FROM designs_status_history";
    $query .= " WHERE status=9 AND YEAR(FROM_UNIXTIME(status_time)) = '2014' AND MONTH(FROM_UNIXTIME(status_time)) = '{$month}'";
    $result = tep_db_query($query);
    $c = array();
    $c['no'] = 'No.';
    $c['id'] = 'Designs ID';
    $c['date'] = 'Finalized Date';
    $table_des[] = $c;
    while ($row = tep_db_fetch_array($result)) {
        $no++;
        $date = date('d-m-Y', $row['status_time']);
        $c = array();
        $c['no'] = $no;
        $c['id'] = $row['designs_id'];
        $c['date'] = $date;
        $table_des[] = $c;
    }
    $table = tep_draw_table('main_center', $table_des, true);
    echo $table;
}
 /**
  * Fetches the product and adds it as an article to the klarna class. No need to return any data.
  * Articles need to be set for fraud purpose, incorrect article means no_risk invoice. Hereby klarna will not take any risks.
  *
  * @param mixed $mProductId The product identified. Either int or string. Adapted according shop functionality
  * @param Klarna $oKlarna The Klarna class object. Used to set any articles
  * @return void
  */
 protected function fetchProduct($mProductId)
 {
     global $currencies, $currency;
     include DIR_WS_CLASSES . 'language.php';
     $lng = new language();
     if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
         $lng->set_language($HTTP_GET_VARS['language']);
     } else {
         $lng->get_browser_language();
     }
     $language = $lng->language['directory'];
     $languages_id = $lng->language['id'];
     $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int) $mProductId . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "'");
     $aProduct_info = tep_db_fetch_array($product_info_query);
     $sArtNo = MODULE_PAYMENT_KLARNA_ARTNO == 'id' || MODULE_PAYMENT_KLARNA_ARTNO == '' ? $aProduct_info['id'] : $aProduct_info['name'];
     $iTax = tep_get_tax_rate($aProduct_info['products_tax_class_id']);
     if (DISPLAY_PRICE_WITH_TAX == 'true') {
         $iPrice_with_tax = $currencies->get_value($currency) * $aProduct_info['products_price'];
     } else {
         $iPrice_with_tax = $currencies->get_value($currency) * $aProduct_info['products_price'] * ($iTax / 100 + 1);
     }
     // Add goods
     $this->oKlarna->addArticle(1, $sArtNo, $aProduct_info['products_name'], $iPrice_with_tax, $iTax, 0, KlarnaFlags::INC_VAT);
     $this->iSum += $iPrice_with_tax;
 }
    function getSetField()
    {
        global $languages_id;
        $statuses_array = array();
        $flags_query = tep_db_query("describe orders_status public_flag");
        if (tep_db_num_rows($flags_query) == 1) {
            $statuses_query = tep_db_query("select orders_status_id, orders_status_name from orders_status where language_id = '" . (int) $languages_id . "' and public_flag = '0' order by orders_status_name");
        } else {
            $statuses_query = tep_db_query("select orders_status_id, orders_status_name from orders_status where language_id = '" . (int) $languages_id . "' order by orders_status_name");
        }
        while ($statuses = tep_db_fetch_array($statuses_query)) {
            $statuses_array[] = array('id' => $statuses['orders_status_id'], 'text' => $statuses['orders_status_name']);
        }
        $input = tep_draw_pull_down_menu('transactions_order_status_id', $statuses_array, OSCOM_APP_PAYPAL_TRANSACTIONS_ORDER_STATUS_ID, 'id="inputTransactionsOrderStatusId"');
        $result = <<<EOT
<div>
  <p>
    <label for="inputTransactionsOrderStatusId">{$this->title}</label>

    {$this->description}
  </p>

  <div>
    {$input}
  </div>
</div>
EOT;
        return $result;
    }
 function getConfig($cfg)
 {
     global $db;
     $config = tep_db_query("SELECT configuration_value FROM configuration WHERE configuration_key='{$cfg}'");
     $config = mysql_fetch_assoc($config);
     return $config["configuration_value"];
 }
function setProductDescription2($products_id, $focus = null)
{
    use_class('element');
    $q = tep_db_query("SELECT * FROM products_description2 WHERE products_id={$products_id}");
    $pd2 = tep_db_fetch_array($q);
    $elements_used = $this->retrieveElementsUsed($products_id);
    if (!is_null($focus) && !is_array($focus)) {
        $focus = explode(',', $focus);
    }
    $need_tobe_filled_c = is_null($focus) || in_array('c', $focus) && ($pd2['clasp_type'] == '' || $pd2['clasp_type'] == 0) ? true : false;
    $need_tobe_filled_s = is_null($focus) || in_array('s', $focus) && ($pd2['setting_type'] == '' || $pd2['setting_type'] == 0) ? true : false;
    if ($need_tobe_filled_c || $need_tobe_filled_s) {
        $sda = array();
        foreach ($elements_used as $eid) {
            $el = new element($eid);
            if ($need_tobe_filled_c && !isset($sda['clasp_type']) && $sda['clasp_type'] == '') {
                $sda['clasp_type'] = $el->attributes['clasp']['id'];
            }
            if ($need_tobe_filled_s && !isset($sda['setting_type']) && $sda['setting_type'] == '') {
                $sda['setting_type'] = $el->attributes['setting']['id'];
            }
        }
        if (count($sda) > 0) {
            if (tep_db_num_rows($q) > 0) {
                tep_db_perform('products_description2', $sda, 'update', "products_id={$products_id}");
            } else {
                $sda['products_id'] = $products_id;
                tep_db_perform('products_description2', $sda);
            }
        }
    }
}
 private function get_subcategories($parent_id)
 {
     if (tep_has_category_subcategories($parent_id)) {
         global $languages_id;
         $categories_data = array();
         // Retrieve the data on the subcategories
         $categories_query_raw = "\n\t\t\t\tselect\n\t\t\t\t  c.categories_id,\n\t\t\t\t  c.parent_id,\n\t\t\t\t  cd.categories_name\n\t\t\t\tfrom " . TABLE_CATEGORIES_DESCRIPTION . " cd\n\t\t\t\t  join " . TABLE_CATEGORIES . " c\n\t\t\t\t\ton (c.categories_id = cd.categories_id)\n\t\t\t\twhere\n\t\t\t\t  c.parent_id = '" . (int) $parent_id . "'\n\t\t\t\t  and cd.language_id = '" . (int) $languages_id . "'\n\t\t\t\torder by\n\t\t\t\t  c.sort_order,\n\t\t\t\t  cd.categories_name\n\t\t\t  ";
         //print 'Categories Query: ' . $categories_query_raw . '<br />';
         $categories_query = tep_db_query($categories_query_raw);
         // Load the subcategory data into an array
         $index = 0;
         while ($categories = tep_db_fetch_array($categories_query)) {
             $categories_id = (int) $categories['categories_id'];
             $path_string = $this->get_category_path($categories_id);
             if ($categories_id != 0) {
                 $categories_data[$index] = array('id' => $categories_id, 'name' => $categories['categories_name'], 'parent_id' => $categories['parent_id'], 'path' => $path_string);
                 // If the category has subcats, add them to the array
                 if (tep_has_category_subcategories($categories_id)) {
                     $categories_data[$index]['subcat'] = $this->get_subcategories($categories_id);
                 } else {
                     $categories_data[$index]['subcat'] = false;
                 }
             }
             // if( $categories_id
             $index++;
         }
         //while ($categories
         return $categories_data;
     } else {
         return false;
     }
 }
function datasCountByStatus()
{
    global $tabs, $filter_type, $filter_owner, $filter_team, $filter_teamcat;
    //    if($filter_type=='0') {
    //        $filter = ($filter_team<=0) ? '' : "WHERE i.department=$filter_team ";
    //        if($filter_teamcat!='0') $filter .= (($filter!='') ? ' AND' : ' WHERE')." i.category='$filter_teamcat' ";
    //    } else {
    //        $filter = "WHERE i.owner=$filter_owner";
    //    }
    $statuscount = array();
    $q = "SELECT category, COUNT(id_promoboxes) AS total_datas";
    $q .= " FROM promoboxes GROUP BY category";
    $r = tep_db_query($q);
    foreach ($tabs as $skey => $sval) {
        $statuscount[$skey] = '0';
    }
    while ($row = tep_db_fetch_array($r)) {
        $statuscount[$row['category']] = $row['total_datas'];
    }
    $dcArray = array();
    foreach ($statuscount as $status => $dc) {
        $dcArray[] = $status . '|' . $dc;
    }
    return implode('|||', $dcArray);
}
Example #13
0
 function query($order_id)
 {
     $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'");
     $order = tep_db_fetch_array($order_query);
     $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "' order by sort_order");
     while ($totals = tep_db_fetch_array($totals_query)) {
         $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text'], 'class' => $totals['class'], 'value' => $totals['value'], 'sort_order' => $totals['sort_order'], 'orders_total_id' => $totals['orders_total_id']);
     }
     $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'shipping_tax' => $order['shipping_tax'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified']);
     $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']);
     $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']);
     $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']);
     $countryid = tep_get_country_id($this->delivery["country"]);
     $zoneid = tep_get_zone_id($countryid, $this->delivery["state"]);
     $index = 0;
     $orders_products_query = tep_db_query("\n     SELECT \n\t op.orders_products_id, \n\t op.products_name, \n\t op.products_model, \n\t op.products_price,\n\t op.products_tax, \n\t op.products_quantity, \n\t op.final_price, \n\t p.products_tax_class_id,\n\t p.products_weight\n  FROM " . TABLE_ORDERS_PRODUCTS . " op\n  LEFT JOIN " . TABLE_PRODUCTS . " p\n    ON op.products_id = p.products_id\n WHERE orders_id = '" . (int) $order_id . "'");
     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
         $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'tax_description' => tep_get_tax_description($orders_products['products_tax_class_id'], $countryid, $zoneid), 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price'], 'weight' => $orders_products['products_weight'], 'orders_products_id' => $orders_products['orders_products_id']);
         $subindex = 0;
         $attributes_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'");
         if (tep_db_num_rows($attributes_query)) {
             while ($attributes = tep_db_fetch_array($attributes_query)) {
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price'], 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);
                 $subindex++;
             }
         }
         $index++;
     }
 }
function processXMLFile($xml_file)
{
    global $timestamp, $logger;
    $xmlt = new xml_tools();
    $xml = $xmlt->loadFile($xml_file);
    $order_date = $timestamp;
    $segments_id = (int) $xml->LOCAL_INFO->SEGMENT_ID;
    $group_name = (string) $xml->LOCAL_INFO->GROUP_NAME;
    $refill_orders = $xml->REFILL_ORDERS->ORDER;
    $counter = 0;
    foreach ($refill_orders as $ro) {
        $products_id = (int) $ro->PRODUCTS_ID;
        $articles_id = (int) $ro->ARTICLES_ID;
        $products_ean = $ro->PRODUCTS_EAN;
        $quantity = (int) $ro->QUANTITY;
        $trans_type = (string) (strtoupper($ro->TRANS_TYPE) == 'NULL' ? '' : $ro->TRANS_TYPE);
        $trans_id = (int) $ro->TRANS_ID;
        //CREATE DEPOT ORDERS
        $q_check = "SELECT depot_orders_id FROM depot_orders " . " WHERE segments_id = {$segments_id}" . " AND trans_type = '' AND trans_id = {$trans_id}";
        $r_check = tep_db_query($q_check);
        //ONLY CREATE ORDER WHICH NOT IMPORTED
        if (tep_db_num_rows($r_check) == 0) {
            $class_do = new depot_orders();
            $class_do->newOrder($segments_id, $products_id, $articles_id, $products_ean, $quantity, $order_date, $trans_type, $trans_id, $group_name);
            $counter++;
        }
    }
    $logger->write("{$counter} orders imported");
    unlink($xml_file);
    $logger->write("xml deleted");
    return $counter;
}
Example #15
0
 function calculate_price($products_price, $products_tax, $quantity = 1, $rate = "", $pid = "")
 {
     global $currency;
     if (is_numeric($pid)) {
         $dbres = tep_db_query("select categories_id from products_to_categories where products_id='" . $pid . "'");
         $row = tep_db_fetch_array($dbres);
         $cat_id = (int) $row['categories_id'];
         if ($cat_id == 23) {
             return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
         }
     }
     if ($rate == "") {
         $rate = get_price_rate($_SESSION['customer_id']);
     }
     if (get_price_group_name($_SESSION['customer_id']) == "Interior Designer") {
         $dbres = tep_db_query("select dn_price from products where products_id='{$pid}'");
         $row = tep_db_fetch_array($dbres);
         if ((double) $row['dn_price'] > 0) {
             $products_price = $row['dn_price'];
             $rate = "100";
         }
     }
     return ceil(tep_add_tax($products_price * $rate / 100, $products_tax)) * $quantity;
     //      return tep_round(tep_add_tax(($products_price*$rate)/100, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
 }
Example #16
0
function tep_update_htpasswd_file()
{
    $shops = array();
    $shops_query = tep_db_query("select shops_id, shops_htpasswd_file from " . TABLE_SHOPS . " where shops_htpasswd_file <> ''");
    while ($shops_array = tep_db_fetch_array($shops_query)) {
        $shops[$shops_array['shops_id']] = $shops_array['shops_htpasswd_file'];
    }
    $passwords = array();
    $users_query = tep_db_query("select u.users_id, u.users_password, ug.users_groups_shops from " . TABLE_USERS . " u, " . TABLE_USERS_GROUPS . " ug where u.users_status = '1' and u.users_groups_id = ug.users_groups_id");
    while ($users = tep_db_fetch_array($users_query)) {
        $available_shops = array();
        if (empty($users['users_groups_shops'])) {
            $available_shops = array_keys($shops);
        } else {
            $available_shops = explode(',', $users['users_groups_shops']);
        }
        reset($shops);
        while (list($shop_id, $shops_htpasswd_file) = each($shops)) {
            if (in_array($shop_id, $available_shops)) {
                $passwords[$shops_htpasswd_file] .= $users['users_id'] . ':' . $users['users_password'] . "\r\n";
            }
        }
    }
    reset($passwords);
    while (list($shops_htpasswd_file, $passwords_string) = each($passwords)) {
        if ($fp = fopen($shops_htpasswd_file, "w")) {
            fwrite($fp, $passwords_string);
            fclose($fp);
        }
    }
}
function build_cds_list_menu($startid = 0, $ulstyle = '')
{
    global $languages_id;
    if ($ulstyle != '') {
        $ulstyle = ' id="' . $ulstyle . '"';
    }
    $cds_menu = '';
    //loop through category id to find all subcategories and pages
    $cds_pages_query = tep_db_query("SELECT c.categories_id as 'ID', \r\n                                                  cd.categories_name as 'Name',\r\n                                                  c.categories_parent_id as 'ParentID',\r\n                                                  c.category_append_cdpath as 'Append',\r\n                                                  c.categories_url_override as 'URL',\r\n                                                  c.categories_url_override_target as 'Target',\r\n                                                  c.pages_group_access as 'Group', 'c' as 'type',\r\n                                                  c.categories_sort_order as 'Sort'\r\n                                          FROM pages_categories c \r\n                                          LEFT JOIN pages_categories_description cd \r\n                                          ON c.categories_id = cd.categories_id \r\n                                          WHERE c.categories_parent_id = '" . $startid . "' \r\n                                          AND c.categories_status = '1'\r\n                                          AND c.categories_in_menu = '1'\r\n                                          AND cd.language_id = '" . (int) $languages_id . "'\r\n                                          UNION\r\n                                          SELECT p.pages_id as 'ID', \r\n                                                  pd.pages_menu_name as 'Name',\r\n                                                  p2c.categories_id as 'ParentID',\r\n                                                  p.pages_append_cdpath as 'Append',\r\n                                                  p.pages_url as 'URL',\r\n                                                  p.pages_url_target as 'Target',\r\n                                                  p.pages_group_access as 'Group', 'p' as 'type',\r\n                                                  p.pages_sort_order as 'Sort'\r\n                                            FROM pages p, \r\n                                                  pages_description  pd, \r\n                                                  pages_to_categories p2c \r\n                                            WHERE p.pages_id = pd.pages_id \r\n                                                AND pd.language_id ='" . (int) $languages_id . "'\r\n                                                AND p.pages_id = p2c.pages_id \r\n                                                AND p.pages_status = '1'\r\n                                                AND pd.pages_menu_name <> ''\r\n                                                AND p.pages_in_menu = '1'\r\n                                                AND p2c.categories_id ='" . $startid . "'\r\n                                            ORDER BY Sort ");
    $rows_count = tep_db_num_rows($cds_pages_query);
    if ($rows_count > 0) {
        $cds_menu .= "\n" . '     <ul' . $ulstyle . '>' . "\n";
        $ulstyle = '';
        while ($cds_pages_data = tep_db_fetch_array($cds_pages_query)) {
            $cds_menu .= '         <li>' . cds_build_menu_url($cds_pages_data['ID'], $cds_pages_data['Name'], $cds_pages_data['type'], $cds_pages_data['URL'], $cds_pages_data['Append'], $cds_pages_data['Target']);
            if ($cds_pages_data['type'] == 'c' && $cds_pages_data['URL'] == '') {
                //we found a subcategory, loop, loop, loop.......
                $cds_menu .= build_cds_list_menu($cds_pages_data['ID']);
            }
            $cds_menu .= '</li>' . "\n";
        }
        $cds_menu .= '     </ul>' . "\n";
    }
    return $cds_menu;
}
 function loadProduct($product_id, $products_price, $products_tax_class_id, $qtyBlocks = 1, $price_breaks_array = NULL, $min_order_qty = 1)
 {
     // Collect required data (show for retail only)
     // in a preview read=only no data for the price break available
     if (!tep_not_null($price_breaks_array)) {
         $price_breaks_array = array();
         $price_breaks_query = tep_db_query("select products_price, products_qty from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . (int) $product_id . "' and customers_group_id = '0' order by products_qty");
         while ($price_break = tep_db_fetch_array($price_breaks_query)) {
             $price_breaks_array[] = $price_break;
         }
     }
     //Assign members
     $this->thePrice = $products_price;
     $this->taxClass = $products_tax_class_id;
     $this->qtyBlocks = $qtyBlocks < 1 ? 1 : $qtyBlocks;
     $this->price_breaks = $price_breaks_array;
     $this->products_min_order_qty = $min_order_qty < 1 ? 1 : $min_order_qty;
     //Custom
     $this->hasQuantityPrice = false;
     $this->hiPrice = $this->thePrice;
     $this->lowPrice = $this->thePrice;
     if (count($this->price_breaks) > 0) {
         $this->hasQuantityPrice = true;
         foreach ($this->price_breaks as $price_break) {
             $this->hiPrice = max($this->hiPrice, $price_break['products_price']);
             $this->lowPrice = min($this->lowPrice, $price_break['products_price']);
         }
     }
 }
Example #19
0
 function _draw_stocked_attributes()
 {
     global $languages_id;
     $out = '';
     $attributes = $this->_build_attributes_array(true, false);
     if (sizeof($attributes) <= 1) {
         return parent::_draw_stocked_attributes();
     }
     // Check stock
     $s = sizeof($attributes[0]['ovals']);
     for ($a = 0; $a < $s; $a++) {
         $attribute_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int) $this->products_id . "' AND products_stock_attributes REGEXP '(^|,)" . (int) $attributes[0]['oid'] . "-" . (int) $attributes[0]['ovals'][$a]['id'] . "(,|\$)' AND products_stock_quantity > 0");
         $out_of_stock = tep_db_num_rows($attribute_stock_query) == 0;
         if ($out_of_stock) {
             unset($attributes[0]['ovals'][$a]);
         }
     }
     // Draw first option dropdown with all values
     $out .= '<tr><td align="right" class=main><b>' . $attributes[0]['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id[' . $attributes[0]['oid'] . ']', array_merge(array(array('id' => 0, 'text' => 'First select ' . $attributes[0]['oname'])), $attributes[0]['ovals']), $attributes[0]['default'], "onchange=\"i" . $attributes[0]['oid'] . "(this.form);\"") . "</td></tr>\n";
     // Draw second to next to last option dropdowns - no values, with onchange
     for ($o = 1; $o < sizeof($attributes) - 1; $o++) {
         $out .= '<tr><td align="right" class=main><b>' . $attributes[$o]['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id[' . $attributes[$o]['oid'] . ']', array(array('id' => 0, 'text' => 'Next select ' . $attributes[$o]['oname'])), '', "onchange=\"i" . $attributes[$o]['oid'] . "(this.form);\"") . "</td></tr>\n";
     }
     // Draw last option dropdown - no values, no onchange
     $out .= '<tr><td align="right" class=main><b>' . $attributes[$o]['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id[' . $attributes[$o]['oid'] . ']', array(array('id' => 0, 'text' => 'Next select ' . $attributes[$o]['oname'])), '') . "</td></tr>\n";
     $out .= $this->_draw_dropdown_sequence_js($attributes);
     return $out;
 }
function affiliate_insert($sql_data_array, $affiliate_parent = 0)
{
    // LOCK TABLES
    tep_db_query("LOCK TABLES " . TABLE_AFFILIATE . " WRITE");
    if ($affiliate_parent > 0) {
        $affiliate_root_query = tep_db_query("select affiliate_root, affiliate_rgt, affiliate_lft�from  " . TABLE_AFFILIATE . " where affiliate_id = '" . $affiliate_parent . "' ");
        // Check if we have a parent affiliate
        if ($affiliate_root_array = tep_db_fetch_array($affiliate_root_query)) {
            tep_db_query("update " . TABLE_AFFILIATE . " SET affiliate_lft = affiliate_lft + 2 WHERE affiliate_root  =  '" . $affiliate_root_array['affiliate_root'] . "' and  affiliate_lft > " . $affiliate_root_array['affiliate_rgt'] . "  AND affiliate_rgt >= " . $affiliate_root_array['affiliate_rgt'] . " ");
            tep_db_query("update " . TABLE_AFFILIATE . " SET affiliate_rgt = affiliate_rgt + 2 WHERE affiliate_root  =  '" . $affiliate_root_array['affiliate_root'] . "' and  affiliate_rgt >= " . $affiliate_root_array['affiliate_rgt'] . "  ");
            $sql_data_array['affiliate_root'] = $affiliate_root_array['affiliate_root'];
            $sql_data_array['affiliate_lft'] = $affiliate_root_array['affiliate_rgt'];
            $sql_data_array['affiliate_rgt'] = $affiliate_root_array['affiliate_rgt'] + 1;
            tep_db_perform(TABLE_AFFILIATE, $sql_data_array);
            $affiliate_id = tep_db_insert_id();
        }
        // no parent -> new root
    } else {
        $sql_data_array['affiliate_lft'] = '1';
        $sql_data_array['affiliate_rgt'] = '2';
        tep_db_perform(TABLE_AFFILIATE, $sql_data_array);
        $affiliate_id = tep_db_insert_id();
        tep_db_query("update " . TABLE_AFFILIATE . " set affiliate_root = '" . $affiliate_id . "' where affiliate_id = '" . $affiliate_id . "' ");
    }
    // UNLOCK TABLES
    tep_db_query("UNLOCK TABLES");
    return $affiliate_id;
}
 function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows, $link = 'db_link')
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     /*$pos_to = strlen($sql_query);
           $pos_from = strpos($sql_query, ' from', 0);
     
           $pos_group_by = strpos($sql_query, ' group by', $pos_from);
           if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by;
     
           $pos_having = strpos($sql_query, ' having', $pos_from);
           if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having;
     
           $pos_order_by = strpos($sql_query, ' order by', $pos_from);
           if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by;*/
     $count_query = preg_replace("/SELECT(.*?)FROM/si", "SELECT count(*) AS total FROM", $sql_query);
     $count_query = preg_replace("/HAVING.*\$/si", "", $count_query);
     $count_query = preg_replace("/ORDER BY.*\$/si", "", $count_query);
     $reviews_count_query = tep_db_query($count_query, $link);
     $reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = $reviews_count['total'];
     $num_pages = ceil($query_num_rows / $max_rows_per_page);
     if ($current_page_number > $num_pages) {
         $current_page_number = $num_pages;
     }
     $offset = $max_rows_per_page * ($current_page_number - 1);
     $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
 }
 function tep_get_tax_title_class_id($tax_class_title)
 {
     $classes_query = tep_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'");
     $tax_class_array = tep_db_fetch_array($classes_query);
     $tax_class_id = $tax_class_array['tax_class_id'];
     return $tax_class_id;
 }
Example #23
0
function tep_values_name($values_id)
{
    global $languages_id;
    $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int) $values_id . "' and language_id = '" . (int) $languages_id . "'");
    $values_values = tep_db_fetch_array($values);
    return $values_values['products_options_values_name'];
}
Example #24
0
 function query($order_id)
 {
     // PWA BOF
     // added customers_dummy_account
     $order_query = tep_db_query("select customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, customers_dummy_account, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, delivery_date, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'");
     // PWA EOF
     $order = tep_db_fetch_array($order_query);
     $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "' order by sort_order");
     while ($totals = tep_db_fetch_array($totals_query)) {
         $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']);
     }
     $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified'], 'delivery_date' => $order['delivery_date']);
     $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address'], 'is_dummy_account' => $order['customers_dummy_account']);
     // PWA EOF
     $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']);
     $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']);
     $index = 0;
     $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_code, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $order_id . "'");
     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
         $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'code' => $orders_products['products_code'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']);
         $subindex = 0;
         $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'");
         if (tep_db_num_rows($attributes_query)) {
             while ($attributes = tep_db_fetch_array($attributes_query)) {
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']);
                 $subindex++;
             }
         }
         $index++;
     }
 }
 /**
  * Call CONFIRMATION_DELIVER and updates order and item data
  */
 public static function deliverAction()
 {
     $post = Globals::getPost();
     $orderId = Globals::getPostEntry('order_number');
     $order = new order($orderId);
     $transactionId = Db::getRatepayOrderDataEntry($orderId, 'transaction_id');
     $transactionShortId = Db::getRatepayOrderDataEntry($orderId, 'transaction_short_id');
     $subType = Data::isFullDeliver(self::getDeliverPostData($post), $orderId) ? 'full-deliver' : 'partial-deliver';
     $data = array('HeadInfo' => RequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, $subType), 'BasketInfo' => RequestMapper::getBasketInfoModel($order, $orderId, self::getDeliverPostData($post)));
     $payment = Loader::getRatepayPayment($order->info['payment_method']);
     $requestService = new RequestService($payment->sandbox, $data);
     $result = $requestService->callConfirmationDeliver();
     Db::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse());
     if (!array_key_exists('error', $result)) {
         Session::setRpSessionEntry('message_css_class', 'messageStackSuccess');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_DELIVER_SUCCESS);
         Db::shipRpOrder(self::getDeliverPostData($post), $order);
         Db::setRpHistoryEntrys($post, 'CONFIRMATION_DELIVER', $subType);
         $flag = true;
         foreach (Db::getRpItems($orderId) as $item) {
             if ($item['ordered'] != $item['shipped']) {
                 $flag = false;
             }
         }
         if ($flag) {
             $sql = "UPDATE orders SET " . "orders_status = " . (int) 3 . " WHERE " . "orders_id = '" . tep_db_input($orderId) . "'";
             tep_db_query($sql);
         }
     } else {
         Session::setRpSessionEntry('message_css_class', 'messageStackError');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_DELIVER_ERROR);
     }
     tep_redirect(tep_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL'));
 }
Example #26
0
 /**
  * @author Michael Hammelmann <*****@*****.**>
  * @version 1
  * @param $pID products_id
 **/
 function product($pID)
 {
     global $languages_id;
     $product_info_query = tep_db_query("select p.products_distributor_id,p.products_id, pd.products_name, pd.products_description,pd.short_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id,p.products_weight from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $pID . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "'");
     $product_info = tep_db_fetch_array($product_info_query);
     $this->price = $product_info['products_price'];
     $this->tax = tep_get_tax_rate($product_info['products_tax_class_id']);
     $tax_class_query = tep_db_query("select tax_class_title from  " . TABLE_TAX_CLASS . " where tax_class_id=" . $product_info['products_tax_class_id']);
     $tax_class = tep_db_fetch_array($tax_class_query);
     $this->tax_title = $tax_class['tax_class_title'];
     $this->weight = $product_info['products_weight'];
     $this->short_description = $product_info['short_description'];
     $this->name = $product_info['products_name'];
     $this->image = $product_info['products_image'];
     /**
      * added for distributor specific data
     **/
     $distributor_path_query = tep_db_query("select * from " . TABLE_DISTRIBUTORS . " where distributor_id=" . $product_info['products_distributor_id']);
     $distributor_path = tep_db_fetch_array($distributor_path_query);
     $this->pdf_path = $distributor_path['pdf_prefix'];
     $this->image_path = $distributor_path['image_prefix'];
     if ($this->image_path == '') {
         $this->image_path = DIR_WS_IMAGES;
     }
     if ($this->image == '') {
         $this->image = 'empty.jpg';
         $this->image_path = DIR_WS_IMAGES;
     }
 }
 function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows)
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     $pos_to = strlen($sql_query);
     $pos_from = strpos($sql_query, ' from', 0);
     $pos_group_by = strpos($sql_query, ' group by', $pos_from);
     if ($pos_group_by < $pos_to && $pos_group_by != false) {
         $pos_to = $pos_group_by;
     }
     $pos_having = strpos($sql_query, ' having', $pos_from);
     if ($pos_having < $pos_to && $pos_having != false) {
         $pos_to = $pos_having;
     }
     $pos_order_by = strpos($sql_query, ' order by', $pos_from);
     if ($pos_order_by < $pos_to && $pos_order_by != false) {
         $pos_to = $pos_order_by;
     }
     $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, $pos_to - $pos_from));
     $reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = $reviews_count['total'];
     $num_pages = ceil($query_num_rows / $max_rows_per_page);
     if ($current_page_number > $num_pages) {
         $current_page_number = $num_pages;
     }
     $offset = $max_rows_per_page * ($current_page_number - 1);
     $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
 }
 function _draw_stocked_attributes()
 {
     global $languages_id;
     $out = '';
     $attributes = $this->_build_attributes_array(true, false);
     if (sizeof($attributes) > 0) {
         for ($o = 0; $o < sizeof($attributes); $o++) {
             $s = sizeof($attributes[$o]['ovals']);
             for ($a = 0; $a < $s; $a++) {
                 $attribute_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int) $this->products_id . "' AND products_stock_attributes REGEXP '(^|,)" . (int) $attributes[$o]['oid'] . "-" . (int) $attributes[$o]['ovals'][$a]['id'] . "(,|\$)' AND products_stock_quantity > 0");
                 $out_of_stock = tep_db_num_rows($attribute_stock_query) == 0;
                 if ($out_of_stock && $this->show_out_of_stock == 'True') {
                     switch ($this->mark_out_of_stock) {
                         case 'Left':
                             $attributes[$o]['ovals'][$a]['text'] = TEXT_OUT_OF_STOCK . ' - ' . $attributes[$o]['ovals'][$a]['text'];
                             break;
                         case 'Right':
                             $attributes[$o]['ovals'][$a]['text'] .= ' - ' . TEXT_OUT_OF_STOCK;
                             break;
                     }
                 } elseif ($out_of_stock && $this->show_out_of_stock != 'True') {
                     unset($attributes[$o]['ovals'][$a]);
                 }
             }
             $out .= '<tr><td align="right" class="main"><b>' . $attributes[$o]['oname'] . ':</b></td><td class="main" align="left">' . tep_draw_pull_down_menu('id[' . $attributes[$o]['oid'] . ']', array_values($attributes[$o]['ovals']), $attributes[$o]['default'], 'onchange="stkmsg(this.form);"') . '</td></tr>';
         }
         $out .= $this->_draw_out_of_stock_message_js($attributes);
         return $out;
     }
 }
Example #29
0
 function form_make($engine, $id_field, $date_field, $i)
 {
     $html = '<div class="createhead">' . constant("CREATE_" . strtoupper($engine) . "_" . $i) . '</div>';
     $engine != "customers" ? $dateclause = ", MIN(UNIX_TIMESTAMP({$date_field})) as date_min, MAX(UNIX_TIMESTAMP({$date_field})) as date_max" : ($dateclause = "");
     $sql = "SELECT COUNT(*), MIN({$id_field}), MAX({$id_field})" . $dateclause . " FROM " . constant("TABLE_" . strtoupper($engine)) . $this->where;
     $result = tep_db_query($sql);
     if ($myrow = tep_db_fetch_array($result)) {
         $date_min = date('M j, Y g:i a', $myrow["date_min"]);
         $date_max = date('M j, Y g:i a', $myrow["date_max"]);
         $html .= '<span class="createlabel">' . CREATE_TOTAL . ":</span> " . $myrow["COUNT(*)"] . "<br />";
         if ($myrow["COUNT(*)"] >= 1) {
             $html .= '<span class="createlabel">' . CREATE_NUM_S . ":</span> " . $myrow["MIN({$id_field})"];
             $myrow["COUNT(*)"] > 1 ? $html .= " " . CREATE_TO . " " . $myrow["MAX({$id_field})"] . "<br />" : ($html .= "<br />");
             if ($engine != "customers") {
                 $html .= '<span class="createlabel">' . CREATE_DATE_S . ":</span> " . $date_min;
                 $myrow["COUNT(*)"] > 1 ? $html .= " " . CREATE_TO . " " . $date_max . "<br />" : ($html .= "<br />");
             }
             $html .= '<form action=' . $_SERVER[PHP_SELF] . ' method="post" name="' . $engine . $i . '">';
             $html .= '<input name="engine" type="hidden" value="' . $engine . '" />';
             $html .= '<input name="whereclause" type="hidden" value="' . $this->where . '" />';
             $html .= '<input name="qbimported" type="hidden" value="' . $i . '" />';
             $html .= '<input name="stage" type="hidden" value="process" />';
             $html .= '<input name="submit" type="submit" value="' . CREATE_BUTTON . '" />';
             $html .= '</form>';
             $html .= '<br /><br />';
         } else {
             $html .= '<br />';
         }
     }
     $this->form = $html;
 }
Example #30
0
function sbs_get_countries($countries_id = '', $with_iso_codes = false)
{
    $countries_array = array();
    if (tep_not_null($countries_id)) {
        if ($with_iso_codes == true) {
            // Ajax Country-state selector
            //$countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name");
            $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int) $countries_id . "' and active = 1 order by countries_name");
            $countries_values = tep_db_fetch_array($countries);
            $countries_array = array('countries_name' => $countries_values['countries_name'], 'countries_iso_code_2' => $countries_values['countries_iso_code_2'], 'countries_iso_code_3' => $countries_values['countries_iso_code_3']);
        } else {
            $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int) $countries_id . "'");
            $countries_values = tep_db_fetch_array($countries);
            $countries_array = array('countries_name' => $countries_values['countries_name']);
        }
    } else {
        // Ajax Country-state selector
        //$countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");
        $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " where active = 1 order by countries_name");
        while ($countries_values = tep_db_fetch_array($countries)) {
            $countries_array[] = array('countries_id' => $countries_values['countries_id'], 'countries_name' => $countries_values['countries_name']);
        }
    }
    return $countries_array;
}