Example #1
0
     // # Retrieve current-day product costing from the products table and add to orders products.
     // # important to keep historical pricing / costs for inventory since this can fluctuate with time.
     // # if no cost found in suppliers_products_groups, try the products table for old format
     // # costing from suppliers_products_groups table
     $cost_price_query = tep_db_query("SELECT suppliers_group_price FROM " . TABLE_SUPPLIERS_PRODUCTS_GROUPS . " WHERE products_id = '" . $orders_products['products_id'] . "' AND priority = '0' LIMIT 1");
     $cost_price = tep_db_num_rows($cost_price_query) > 0 ? tep_db_result($cost_price_query, 0) : 0;
     tep_db_free_result($cost_price_query);
     // # costing from products table
     $cost_old_query = tep_db_query("SELECT products_price_myself FROM " . TABLE_PRODUCTS . " WHERE products_id = '" . $orders_products['products_id'] . "'");
     $cost_old = tep_db_num_rows($cost_old_query) > 0 ? tep_db_result($cost_old_query, 0) : 0;
     tep_db_free_result($cost_old_query);
     // # if supplier cost is empty, use old format
     $cost = !empty($cost_price) ? $cost_price : $cost_old;
     // # Retrieve price from products_groups table.
     $pricing_query = tep_db_query("SELECT pg.customers_group_price \n\t\t\t\t\t\t\t\t\t\t   FROM " . TABLE_PRODUCTS_GROUPS . " pg \n\t\t\t\t\t\t\t\t\t\t   LEFT JOIN " . TABLE_CUSTOMERS . " c ON c.customers_group_id = pg.customers_group_id\n\t\t\t\t\t\t\t\t\t\t   LEFT JOIN " . TABLE_ORDERS . " o ON o.customers_id = c.customers_id\n\t\t\t\t\t\t\t\t\t\t   WHERE o.orders_id = '" . $oID . "'\n\t\t\t\t\t\t\t\t\t\t   AND products_id = '" . $orders_products['products_id'] . "'\n\t\t\t\t\t\t\t\t\t\t  ");
     $price = tep_db_num_rows($pricing_query) > 0 ? tep_db_result($pricing_query, 0) : $orders_products['products_price'];
     tep_db_free_result($pricing_query);
     // # populate orders_products_data array
     $order->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => str_replace("'", "'", $orders_products['products_name']), 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => (double) $price, 'cost' => (double) $cost, 'final_price' => $orders_products['final_price'], 'products_id' => $orders_products['products_id'], 'free_shipping' => $orders_products['free_shipping'], 'separate_shipping' => $orders_products['separate_shipping'], 'products_weight' => $orders_products['products_weight'], 'orders_products_id' => $orders_products['orders_products_id'], 'warehouse_id' => $orders_products['warehouse_id']);
     $subindex = 0;
     $attributes_query_string = "select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $oID . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'";
     $attributes_query = tep_db_query($attributes_query_string);
     if (tep_db_num_rows($attributes_query)) {
         while ($attributes = tep_db_fetch_array($attributes_query)) {
             $order->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++;
 }
 // # END while
Example #2
0
 function send($newsletter_id)
 {
     // # routine for selecting and adding appropriate user select into newsletters_queue table of database.
     // # SELECT only retail customers price group who are NOT amazon customers and who ARE subscribed.
     $mail_query = tep_db_query("SELECT * \n\t\t\t\t\t\t\t\t\tFROM (SELECT DISTINCT c.customers_email_address, \n\t\t\t\t\t\t\t\t\t\t\tc.customers_id,\n\t\t\t\t\t\t\t\t\t\t\tc.customers_firstname, \n\t\t\t\t\t\t\t\t\t\t\tc.customers_lastname,\n\t\t\t\t\t\t\t\t\t\t\tc.customers_newsletter\n\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_CUSTOMERS . "  c\n\t\t\t\t\t\t\t\t\t\t\tWHERE c.customers_email_address NOT LIKE '*****@*****.**'\n\t\t\t\t\t\t\t\t\t\t\tAND c.customers_group_id = '0'\n\t\t\t\t\t\t\t\t\t\t\tAND c.customers_newsletter = '1'\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tUNION ALL\n\n\t\t\t\t\t\t\t\t\t\tSELECT DISTINCT s.subscribers_email_address,\n\t\t\t\t\t\t\t\t\t\t\t\ts.customers_id,\n\t\t\t\t\t\t\t\t\t\t\t\ts.subscribers_firstname,\n\t\t\t\t\t\t\t\t\t\t\t\ts.subscribers_lastname,\n\t\t\t\t\t\t\t\t\t\t\t\ts.customers_newsletter\n\t\t\t\t\t\t\t\t\t\tFROM subscribers s\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_CUSTOMERS . " c ON c.customers_email_address = s.subscribers_email_address\n\t\t  \t\t\t\t\t\t\t\tWHERE c.customers_email_address IS NULL\n\t\t  \t\t\t\t\t\t\t\tAND s.customers_newsletter = '1') AS table1\n\t\t\t\t\t\t\t\t\t");
     /*	
     
     		$mail_query = tep_db_query("SELECT customers_id, customers_firstname, customers_lastname, customers_email_address 
     								    FROM " . TABLE_CUSTOMERS . "  c
     									WHERE c.customers_email_address NOT LIKE '*****@*****.**'
     									AND c.customers_group_id = '0'
     									AND c.customers_newsletter = '1'
     								  ");
     */
     $home_domain = str_replace(array('https://', 'http://', 'www.'), '', SITE_DOMAIN);
     $known_domains = array('gmail.com', 'yahoo.com', 'hotmail.com', 'aol.com', $home_domain);
     while ($mail = tep_db_fetch_array($mail_query)) {
         $ok_insert = false;
         preg_match('/@(.*)/', $mail['customers_email_address'], $domain);
         if (in_array($domain[1], $known_domains)) {
             $ok_insert = true;
         } else {
             if (checkdnsrr($domain[1], "MX")) {
                 $ok_insert = true;
             } else {
                 tep_db_query("DELETE FROM subscribers WHERE subscribers_email_address = '" . $mail['customers_email_address'] . "'");
                 $ok_insert = false;
             }
         }
         if ($ok_insert) {
             $known_domains[] = $domain[1];
             // # routine for adding appropriate user select into newsletter_queue table of database.
             tep_db_query("INSERT IGNORE INTO newsletter_queue \n\t\t\t\t\t\t\t  SET newsletters_id = '" . (int) $newsletter_id . "',\n\t\t\t\t\t\t\t  user_id = '" . (!empty($mail['customers_id']) ? $mail['customers_id'] : '0') . "',\n\t\t\t\t\t\t\t  firstname = '" . mysql_real_escape_string($mail['customers_firstname']) . "',\n\t\t\t\t\t\t\t  lastname = '" . mysql_real_escape_string($mail['customers_lastname']) . "',\n\t\t\t\t\t\t\t  email = '" . $mail['customers_email_address'] . "',\n\t\t\t\t\t\t\t  updated = NOW(),\n\t\t\t\t\t\t\t  status = 'pending'\n\t\t\t\t\t\t\t");
         }
     }
     // # Update the newsletter send count after MX validation.
     $newCount = tep_db_result(tep_db_query("SELECT COUNT(0) FROM newsletter_queue WHERE newsletters_id = '" . $newsletter_id . "'"), 0);
     tep_db_query("UPDATE newsletters SET send_count = '" . $newCount . "' WHERE newsletters_id = '" . $newsletter_id . "'");
 }
Example #3
0
 function __construct($status = '', $dateMode = '', $date_from = '', $date_to = '', $channel = '')
 {
     $this->channel = $channel;
     $this->dateMode = $dateMode;
     // # date_from and date_to have to be a unix timestamp. Use mktime !
     // # if set then both have to be valid date_from and date_to
     $this->date_from = !empty($date_from) ? $date_from : date('01/01/Y 00:00:01');
     $this->date_to = !empty($date_to) ? $date_to : date('m/d/Y 23:59:59');
     $this->date_from = new DateTime($this->date_from);
     $this->date_to = new DateTime($this->date_to);
     $this->previous = '';
     $this->next = '';
     $this->status = $status;
     $this->info = array(array());
     // # get date of first sale
     $this->globalStartDate = date("01/01/Y 00:00:01", strtotime(tep_db_result(tep_db_query("SELECT MIN(date_purchased) FROM " . TABLE_ORDERS), 0)));
     // # start our loop value.
     $i = 0;
     if ($this->status === '0' || $this->status > 0) {
         $this->filter_sql = " AND o.orders_status='" . $this->status . "'";
     } elseif ($this->status === 'all') {
         $this->filter_sql = "";
     } else {
         $this->filter_sql = "";
     }
     // # switch through date modes
     switch ($this->dateMode) {
         // # hourly
         case 'H':
             $this->size = 24;
             for ($i = 0; $i < $this->size; $i++) {
                 $this->dates_from[$i] = mktime(0, 0, 0, $this->date_from->format('m'), $this->date_from->format('d'), $this->date_from->format('Y'));
                 $this->dates_to[$i] = new DateTime(date('m/d/Y H:i:s', $this->dates_from[$i]));
                 $this->dates_to[$i] = $this->dates_to[$i]->modify('+ ' . ($i + 1) . ' hours');
                 $this->dates_from[$i] = new DateTime(date('m/d/Y H:i:s', $this->dates_from[$i]));
                 $this->dates_from[$i] = $this->dates_from[$i]->modify('+ ' . $i . ' hours');
                 $this->info[$i]['text'] = $this->dates_from[$i]->format('ga') . ' - ' . $this->dates_to[$i]->format('ga');
                 $this->info[$i]['link'] = 'datemode=H&date_from=' . $this->dates_from[$i]->format('m/d/Y') . '&date_to=' . $this->dates_to[$i]->format('m/d/Y') . (!empty($_GET['channel']) ? '&channel=' . $_GET['channel'] : '');
             }
             $prevStart = date('m/d/Y', $this->date_from->getTimestamp() - $this->date_to->format('d'));
             $prevEnd = date('m/d/Y', $this->date_from->getTimestamp() - $this->date_to->format('d'));
             $nextStart = $this->date_from->modify('+1 day');
             $nextStart = $nextStart->format('m/d/Y');
             $nextEnd = date('m/d/Y', $this->date_from->getTimestamp() + 1);
             if (date('Y', strtotime($prevStart)) >= date('Y', $this->globalStartDate)) {
                 $this->previous = "datemode=" . $this->dateMode . "&date_from=" . $prevStart . "&date_to=" . $prevEnd;
             }
             if (date('Y', strtotime($nextEnd)) <= date('Y')) {
                 $this->next = "datemode=" . $this->dateMode . "&date_from=" . $nextStart . "&date_to=" . $nextEnd;
             }
             break;
             // # daily
         // # daily
         case 'd':
             $this->size = date('t', $this->date_to->getTimestamp());
             for ($i = 0; $i < $this->size; $i++) {
                 $this->dates_from[$i] = mktime(0, 0, 0, $this->date_from->format('m'), $this->date_from->format('01') + $i, $this->date_from->format('Y'));
                 $this->dates_to[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->dates_to[$i] = $this->dates_to[$i]->modify('+ 23 hours');
                 $this->dates_from[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->info[$i]['text'] = $this->dates_from[$i]->format('M j');
                 $this->info[$i]['link'] = 'datemode=H&date_from=' . $this->dates_from[$i]->format('m/d/Y') . '&date_to=' . $this->dates_to[$i]->format('m/d/Y') . (!empty($_GET['channel']) ? '&channel=' . $_GET['channel'] : '');
             }
             $prevStart = date('m/01/Y', $this->date_from->getTimestamp() - $this->date_to->format('t'));
             $prevEnd = date('m/t/Y', $this->date_from->getTimestamp() - $this->date_to->format('t'));
             $nextStart = $this->date_from->modify('+1 month');
             $nextStart = $nextStart->format('m/01/Y');
             $nextEnd = date('m/t/Y', $this->date_from->getTimestamp() + 364);
             if (date('Y', strtotime($prevStart)) >= date('Y', $this->globalStartDate)) {
                 $this->previous = "datemode=" . $this->dateMode . "&date_from=" . $prevStart . "&date_to=" . $prevEnd;
             }
             if (date('Y', strtotime($nextEnd)) <= date('Y')) {
                 $this->next = "datemode=" . $this->dateMode . "&date_from=" . $nextStart . "&date_to=" . $nextEnd;
             }
             break;
             // # weekly
         // # weekly
         case 'w':
             $this->size = ceil($this->date_to->format('t') / 7);
             $tmpMonth = $this->date_from->format('m');
             $tmpYear = $this->date_from->format('Y');
             for ($i = 0; $i < $this->size; $i++) {
                 $this->dates_from[$i] = mktime(0, 0, 0, $this->date_from->format('m'), $this->date_from->format('d') + $i * 7, $this->date_from->format('Y'));
                 $this->dates_to[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->dates_to[$i] = $this->dates_to[$i]->modify('+ 6 days');
                 $this->dates_from[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 if ($this->dates_to[$i]->getTimestamp() + 6 > $this->dates_to[$i]->getTimestamp()) {
                     if ($i == $this->size - 1) {
                         // last
                         $this->dates_to[$i] = $this->dates_to[$i]->modify($this->dates_from[$i]->format('m/t/Y'));
                     }
                 }
                 $this->info[$i]['text'] = $this->dates_from[$i]->format('m/d/Y') . ' - ' . $this->dates_to[$i]->format('m/d/Y');
                 $this->info[$i]['link'] = 'datemode=d&date_from=' . $this->dates_from[$i]->format('m/d/Y') . '&date_to=' . $this->dates_to[$i]->format('m/d/Y') . (!empty($_GET['channel']) ? '&channel=' . $_GET['channel'] : '');
             }
             $prevStart = date('m/01/Y', $this->date_from->getTimestamp() - $this->date_to->format('t'));
             $prevEnd = date('m/t/Y', $this->date_from->getTimestamp() - $this->date_to->format('t'));
             $nextStart = $this->date_from->modify('+1 month');
             $nextStart = $nextStart->format('m/01/Y');
             $nextEnd = date('m/t/Y', $this->date_from->getTimestamp() + 364);
             if (date('Y', strtotime($prevStart)) >= date('Y', $this->globalStartDate)) {
                 $this->previous = "datemode=" . $this->dateMode . "&date_from=" . $prevStart . "&date_to=" . $prevEnd;
             }
             if (date('Y', strtotime($nextEnd)) <= date('Y')) {
                 $this->next = "datemode=" . $this->dateMode . "&date_from=" . $nextStart . "&date_to=" . $nextEnd;
             }
             break;
             // # monthly
         // # monthly
         case 'm':
         case 'default':
             $this->size = 12;
             $tmpMonth = $this->date_from->format('m');
             $tmpYear = $this->date_from->format('Y');
             for ($i = 0; $i < $this->size; $i++) {
                 // # the first of the $tmpMonth + $i
                 $this->dates_from[$i] = mktime(0, 0, 0, $tmpMonth + $i, 1, $tmpYear);
                 // # the last of the $tmpMonth
                 $this->dates_to[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->dates_to[$i] = $this->dates_to[$i]->modify('last day of this month');
                 $this->dates_from[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->info[$i]['text'] = $this->dates_from[$i]->format('M y');
                 $this->info[$i]['link'] = 'datemode=w&date_from=' . $this->dates_from[$i]->format('m/d/Y') . '&date_to=' . $this->dates_to[$i]->format('m/d/Y') . (!empty($_GET['channel']) ? '&channel=' . $_GET['channel'] : '');
             }
             $prevStart = date('01/01/Y', $this->date_from->getTimestamp() - 364);
             $prevEnd = date('12/31/Y', $this->date_from->getTimestamp() - 364);
             $nextStart = $this->date_from->modify('+1 year');
             $nextStart = $nextStart->format('m/d/Y');
             $nextEnd = date('12/31/Y', $this->date_from->getTimestamp() + 364);
             if (date('Y', strtotime($prevStart)) >= date('Y', $this->globalStartDate)) {
                 $this->previous = "datemode=" . $this->dateMode . "&date_from=" . $prevStart . "&date_to=" . $prevEnd;
             }
             if (date('Y', strtotime($nextEnd)) <= date('Y')) {
                 $this->next = "datemode=" . $this->dateMode . "&date_from=" . $nextStart . "&date_to=" . $nextEnd;
             }
             break;
             // # yearly
         // # yearly
         case 'Y':
             $tmpMonth = $this->date_from->format('m');
             $tmpYear = $this->date_from->format('Y');
             $this->size = date('Y', $this->date_to->getTimestamp()) + 1 - date('Y', $this->date_from->getTimestamp());
             for ($i = 0; $i < $this->size; $i++) {
                 // # the first of the $tmpMonth + $i
                 $this->dates_from[$i] = mktime(0, 0, 0, 1, 1, $tmpYear + $i);
                 // # the last of the $tmpMonth
                 $this->dates_to[$i] = new DateTime(date('12/31/Y', $this->dates_from[$i]));
                 $this->dates_to[$i] = $this->dates_to[$i]->modify('last day of this year');
                 $this->dates_from[$i] = new DateTime(date('m/d/Y', $this->dates_from[$i]));
                 $this->info[$i]['text'] = $this->dates_from[$i]->format('Y');
                 $this->info[$i]['link'] = 'datemode=m&date_from=' . $this->dates_from[$i]->format('m/d/Y') . '&date_to=' . $this->dates_to[$i]->format('m/d/Y') . (!empty($_GET['channel']) ? '&channel=' . $_GET['channel'] : '');
             }
             break;
     }
     // # Channel Source
     switch ($this->channel) {
         // # Amazon
         case 'amazon':
             $this->channel = " AND (o.orders_source = 'dbfeed_amazon_us' OR o.orders_source LIKE '%amazon%' OR o.customers_name LIKE 'Amazon%') ";
             break;
             // # eBay
         // # eBay
         case 'ebay':
             $this->channel = " AND o.orders_source LIKE '%ebay%' ";
             break;
             // # E-Mail
         // # E-Mail
         case 'email':
             $this->channel = " AND o.orders_source LIKE 'email%' ";
             break;
             // # Retail sales
         // # Retail sales
         case 'retail':
             $this->channel = " AND o.customers_name NOT LIKE 'Amazon%' AND o.orders_source != 'vendor' AND o.orders_source NOT LIKE '%amazon%' ";
             break;
             // # Vendor sales
         // # Vendor sales
         case 'vendor':
             $this->channel = " AND o.orders_source LIKE 'vendor' ";
             break;
             // # all
         // # all
         case 'default':
             $this->channel = '';
             break;
     }
     // # now execute the main query function below
     $this->query();
 }
Example #4
0
if ($_GET['action'] == 'autoComplete' && !empty($_GET['searchName'])) {
    retrieveCustomerNames(trim($_GET['searchName']));
}
$result = tep_db_query("SELECT code, value FROM " . TABLE_CURRENCIES . " ORDER BY code");
if (tep_db_num_rows($result) > 0) {
    $selectCurrencyBox = "<select name='Currency'><option value='' SELECTED>" . TEXT_SELECT_CURRENCY . "</option>\n";
    while ($db_Row = tep_db_fetch_array($result)) {
        $selectCurrencyBox .= "<option value='" . $db_Row["code"] . " , " . $db_Row["value"] . "'" . ($db_Row["code"] == 'USD' ? ' SELECTED' : '');
        $selectCurrencyBox .= ">" . $db_Row["code"] . "</option>\n";
    }
    $selectCurrencyBox .= "</select>\n";
}
if (isset($_GET['Customer']) && empty($_GET['Customer'])) {
    $ret = getSearchQuery($_GET['searchName']);
    $customers_id_query = tep_db_query("SELECT c.customers_id FROM customers c LEFT JOIN address_book a ON c.customers_default_address_id=a.address_book_id WHERE " . $ret['query'] . " LIMIT 1");
    $customers_id = tep_db_num_rows($customers_id_query) > 0 ? tep_db_result($customers_id_query, 0) : '';
    $_GET['Customer'] = $customers_id;
} else {
    if (!empty($_GET['Customer']) || !empty($_GET['Customer_nr'])) {
        $account_query = tep_db_query("SELECT * FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . $_GET['Customer'] . "'");
        $account = tep_db_fetch_array($account_query);
        $customers_id = $account['customers_id'];
        $address_query = tep_db_query("SELECT * FROM " . TABLE_ADDRESS_BOOK . " WHERE customers_id = '" . $customers_id . "'");
        $address = tep_db_fetch_array($address_query);
        $existing_info_query = tep_db_query("SELECT o.billing_name, \n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_company,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_street_address,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_suburb,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_postcode,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_city,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_state,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.billing_country,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_company,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_street_address,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_suburb,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_postcode,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_city,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_state,\n\t\t\t\t\t\t\t\t\t\t\t\t\to.delivery_country\n\t\t\t\t\t\t\t\t\t\t\t  FROM " . TABLE_ORDERS . " o \n\t\t\t\t\t\t\t\t\t\t\t  WHERE o.customers_id = '" . $customers_id . "'\n\t\t\t\t\t\t\t\t\t\t\t  ORDER BY o.orders_id DESC\n\t\t\t\t\t\t\t\t\t\t\t  LIMIT 1\n\t\t\t\t\t\t\t\t\t\t\t ");
        $existing_info = tep_db_fetch_array($existing_info_query);
    }
}
?>
	
Example #5
0
function tep_db_table_exists($database, $table)
{
    if (empty($database)) {
        $database = DB_DATABASE;
    }
    $tables_query = tep_db_query("show tables in " . $database);
    for ($i = 0, $n = tep_db_num_rows($tables_query); $i < $n; $i++) {
        $tablename = tep_db_result($tables_query, $i, 0);
        if ($tablename == $table) {
            return true;
        }
    }
    return false;
}
Example #6
0
<?php

define('TITLE', 'Order CSV Exporter');
define('FILENAME_EXPORTORDERS', 'exportorders.php');
require 'includes/application_top.php';
//require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_EXPORTORDERS);
define('HEADING_TITLE', 'Export orders to CSV file');
define('INPUT_START', 'From Order #');
define('INPUT_END', 'To Order #');
define('INPUT_VALID', 'Export to CSV');
define('INPUT_DESC', 'Select the order numbers you want to export. Leave both fields empty if you want to export all orders or leave one of the fields empty to export all orders from X or all orders to X.');
if (!empty($_POST)) {
    $start = !empty($_POST['start']) ? (int) $_POST['start'] : tep_db_result(tep_db_query("SELECT orders_id FROM orders ORDER BY orders_id ASC LIMIT 1"), 0);
    $end = !empty($_POST['end']) ? (int) $_POST['end'] : tep_db_result(tep_db_query("SELECT orders_id FROM orders ORDER BY orders_id DESC LIMIT 1"), 0);
    if (empty($start) && empty($end)) {
        $where = " WHERE o.date_purchased >= '" . date('Y-m-d') . "'";
        // # if $start is empty we select all orders up to $end
    } else {
        $rstart = min($start, $end);
        $rend = max($start, $end);
        $where = " WHERE o.orders_id BETWEEN " . (int) $rstart . " AND " . (int) $rend;
    }
    // # export orders from orders table - does not include products.
    if (isset($_POST['export_orders'])) {
        $result = tep_db_query("SELECT o.orders_id AS `Order ID`, \r\n\t\t\t\t\t\t\t\t\t   o.customers_id AS `Customer ID`, \r\n\t\t\t\t\t\t\t\t\t   o.date_purchased AS `Purchase Date`, \r\n\t\t\t\t\t\t\t\t\t   o.customers_name AS `Customer Full Name`,\r\n\t\t\t\t\t\t\t\t\t   c.customers_firstname AS `Customer First Name`,\r\n\t\t\t\t\t\t\t\t\t   c.customers_lastname AS `Customer Last Name`,\r\n\t\t\t\t\t\t\t\t\t   o.cc_owner AS `Name on Card`,\r\n\t\t\t\t\t\t\t\t\t   o.customers_company AS `Customer Company`, \r\n\t\t\t\t\t\t\t\t\t   o.customers_email_address AS `Customer Email Address`,\r\n\t\t\t\t\t\t\t\t\t   o.billing_street_address AS `Billing Address`,\r\n\t\t\t\t\t\t\t\t\t   o.billing_suburb AS `Billing Address2`,\r\n\t\t\t\t\t\t\t\t\t   o.billing_city AS `Billing City`, \r\n\t\t\t\t\t\t\t\t\t   o.billing_state AS `Billing State`, \r\n\t\t\t\t\t\t\t\t\t   o.billing_postcode AS `Billing Postal Code`, \r\n\t\t\t\t\t\t\t\t\t   o.billing_country AS `Billing Country`, \r\n\t\t\t\t\t\t\t\t\t   o.customers_telephone AS `Customer Phone Number`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_name AS `Delivery Name`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_company AS `Delivery Company`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_street_address AS `Delivery Address`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_suburb AS `Delivery Address2`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_city AS `Delivery City`,\r\n\t\t\t\t\t\t\t\t\t   o.delivery_state AS `Delivery State`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_postcode AS `Delivery Postal Code`, \r\n\t\t\t\t\t\t\t\t\t   o.delivery_country AS `Delivery Country`, \r\n\t\t\t\t\t\t\t\t\t   o.cc_type AS `Credit Card Type`, \r\n\t\t\t\t\t\t\t\t\t   o.cc_number AS `Last 4 of Card`, \r\n\t\t\t\t\t\t\t\t\t   o.cc_expires AS `Card Exp. Date`,\r\n\t\t\t\t\t\t\t\t\t   o.comments AS `Order Comments`,\r\n\t\t\t\t\t\t\t\t\t   (SELECT value FROM orders_total WHERE class = 'ot_subtotal' AND orders_id = o.orders_id LIMIT 1) AS `Order Sub-total`,\r\n\t\t\t\t\t\t\t\t\t   (SELECT value FROM orders_total WHERE class = 'ot_tax' AND orders_id = o.orders_id LIMIT 1) AS `Order Tax`,\r\n\t\t\t\t\t\t\t\t\t   (SELECT value FROM orders_total WHERE class = 'ot_shipping' AND orders_id = o.orders_id LIMIT 1) AS `Order Shipping`,\r\n\t\t\t\t\t\t\t\t\t   (SELECT value FROM orders_total WHERE class = 'ot_coupon' AND orders_id = o.orders_id LIMIT 1) AS `Order Coupon`,\r\n\t\t\t\t\t\t\t\t\t   (SELECT value FROM orders_total WHERE class = 'ot_total' AND orders_id = o.orders_id LIMIT 1) AS `Order Total`\r\n\t\t\t\t\t\t\t\tFROM orders o\r\n\t\t\t\t\t\t\t\tLEFT JOIN customers c ON c.customers_id = o.customers_id\r\n\t\t\t\t\t\t\t\t" . $where . "\r\n\t\t\t\t\t\t\t\tAND o.orders_status != 0\r\n\t\t\t\t\t\t\t\tGROUP BY o.orders_id\r\n\t\t\t\t\t\t\t\tORDER BY o.orders_id\r\n\t\t\t\t\t\t\t\t");
    } else {
        if (isset($_POST['export_orders_products'])) {
            // # export orders products details of orders_products table
            $result = tep_db_query("SELECT op.orders_id AS `Order ID`,\r\n\t\t\t\t\t\t\t\t\t   op.products_model AS `Product Model`,\r\n\t\t\t\t\t\t\t\t\t   op.products_name AS `Product Name`,\r\n\t\t\t\t\t\t\t\t\t   op.final_price AS `Final Price`,\r\n\t\t\t\t\t\t\t\t\t   op.products_quantity AS `Product Quantity`,\r\n\t\t\t\t\t\t\t\t\t   op.free_shipping AS `Shipped Free`,\r\n\t\t\t\t\t\t\t\t\t   op.products_weight AS `Shipped Weight`\r\n\t\t\t\t\t\t\t\tFROM orders_products op\r\n\t\t\t\t\t\t\t\tLEFT JOIN orders o ON o.orders_id = op.orders_id\r\n\t\t\t\t\t\t\t\t" . $where . "\r\n\t\t\t\t\t\t\t\tAND o.orders_status != 0\r\n\t\t\t\t\t\t\t\tORDER BY o.orders_id\r\n\t\t\t\t\t\t\t\t");
        }
    }
Example #7
0
     tep_db_query("DELETE FROM " . TABLE_SUPPLIERS_PRODUCTS_GROUPS . "\r\n\t\t\t\t\t\t\t  WHERE priority = '0'\r\n\t\t\t\t\t\t\t  AND suppliers_group_id='" . $suppliers_id . "' \r\n\t\t\t\t\t\t\t  AND products_id = '" . (int) $products_id . "'\r\n\t\t\t\t\t\t\t ");
 }
 $sql_data_array = array('products_class' => $pClass, 'products_quantity' => tep_db_prepare_input($_POST['products_quantity']), 'products_model' => tep_db_prepare_input($_POST['products_model']), 'products_price' => $products_price, 'products_price_myself' => $costPrice, 'products_last_modified' => $now, 'products_qty_blocks' => ($i = tep_db_prepare_input($_POST['products_qty_blocks'])) < 1 ? 1 : $i, 'products_weight' => tep_db_prepare_input($_POST['products_weight']), 'products_status' => tep_db_prepare_input($_POST['products_status']), 'bs_icon' => tep_db_prepare_input($_POST['bs_icon']), 'products_free_shipping' => tep_db_prepare_input($_POST['products_free_shipping']), 'products_separate_shipping' => tep_db_prepare_input($_POST['products_separate_shipping']), 'products_show_qview' => tep_db_prepare_input($_POST['products_show_qview']), 'products_sort_order' => tep_db_prepare_input($_POST['products_sort_order']), 'products_tax_class_id' => tep_db_prepare_input($_POST['products_tax_class_id']), 'manufacturers_id' => tep_db_prepare_input($_POST['manufacturers_id']), 'products_upc' => tep_db_prepare_input($_POST['products_upc']), 'products_sku' => $products_sku, 'products_make' => tep_db_prepare_input($_POST['products_make']), 'products_width' => tep_db_prepare_input($_POST['products_width']), 'products_height' => tep_db_prepare_input($_POST['products_height']), 'products_length' => tep_db_prepare_input($_POST['products_length']), 'suppliers_id' => $suppliers, 'products_harmonized_code' => (int) $_POST['products_harmonized_code'], 'products_origin_country' => tep_db_prepare_input($_POST['products_origin_country']));
 $supplier_data_array = array('suppliers_group_id' => $suppliers, 'suppliers_group_price' => $costPrice, 'products_id' => (int) $products_id, 'products_msrp' => $products_msrp, 'casepack_sku' => $casepack_sku, 'casepack_qty' => $casepack_qty, 'suppliers_sku' => $suppliers_sku, 'reup_threshold' => $reup_threshold, 'reup_quantity' => $reup_quantity, 'priority' => $priority);
 if (MULTI_WAREHOUSE_ACTIVE == 'true') {
     // # Insert the warehouse inventory levels if found.
     if (is_array($_POST['products_warehouse_id']) && is_array($_POST['products_warehouse_quantity'])) {
         $inventory_array = array_combine($_POST['products_warehouse_id'], $_POST['products_warehouse_quantity']);
         foreach ($inventory_array as $warehouse_id => $warehouse_products_quantity) {
             $warehouse_inventory_array = array('products_quantity' => $warehouse_products_quantity);
             tep_db_perform(TABLE_PRODUCTS_WAREHOUSE_INVENTORY, $warehouse_inventory_array, 'update', "products_id = '" . $_GET['pID'] . "' AND products_warehouse_id = '" . $warehouse_id . "'");
         }
     }
     if (!empty($_POST['addWarehouse'])) {
         $warehouse_id = (int) $_POST['addWarehouse'];
         $warehouse_name = tep_db_result(tep_db_query("SELECT products_warehouse_name FROM products_warehouse_profiles WHERE products_warehouse_id = '" . $warehouse_id . "'"), 0);
         tep_db_query("INSERT IGNORE INTO " . TABLE_PRODUCTS_WAREHOUSE_INVENTORY . " \r\n\t\t\t\t\t\t  SET products_warehouse_id = '" . $warehouse_id . "',\r\n\t\t\t\t\t\t  products_id = '" . $_GET['pID'] . "',\r\n\t\t\t\t\t\t  products_quantity = '0',\r\n\t\t\t\t\t\t  products_warehouse_name = '" . $warehouse_name . "'\r\n\t\t\t\t\t\t");
     }
 }
 if (empty($_POST['dateAvailable'])) {
     $sql_data_array['products_date_available'] = 'null';
 } else {
     $now = date('Y-m-d H:i:s', time());
     $postedDate = date('Y-m-d H:i:s', strtotime($_POST['dateAvailable']));
     if ($postedDate > 0 && $postedDate > $now) {
         $sql_data_array['products_date_available'] = $postedDate;
     }
 }
 if ($_POST['unlink_image'] == 'yes' or $_POST['delete_image'] == 'yes') {
     $sql_data_array['products_image'] = '';
 } else {
Example #8
0
 function customers_returning()
 {
     $customers_returning_query = tep_db_query("SELECT COUNT(0)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t   FROM (\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \tSELECT NULL\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM orders\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE date_purchased >= ADDDATE(CURDATE(), INTERVAL 1 - DAYOFWEEK(CURDATE())DAY)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND customers_id !=0\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tGROUP BY customers_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tHAVING COUNT(*) > 1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) AS cnt");
     $customers_returning = tep_db_num_rows($customers_new_query) > 0 ? tep_db_result($customers_returning_query, 0) : 0;
     tep_db_free_result($customers_returning_query);
     return $customers_returning;
 }
Example #9
0
     tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], STORE_OWNER_EMAIL_ADDRESS, EMAIL_PASSWORD_REMINDER_SUBJECT, sprintf(EMAIL_PASSWORD_REMINDER_BODY_ADMIN, $new_password), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
     $messageStack->add_session('New password sent to ' . $check_customer['customers_email_address'], 'success');
     $messageStack->add('New password sent to ' . $check_customer['customers_email_address'], 'success');
     //tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));
     break;
 case 'update':
     $customers_firstname = tep_db_input($_POST['customers_firstname']);
     $customers_lastname = tep_db_input($_POST['customers_lastname']);
     $customers_email_address = tep_db_input($_POST['customers_email_address']);
     $customers_telephone = tep_db_input($_POST['customers_telephone']);
     $customers_fax = tep_db_input($_POST['customers_fax']);
     $customers_newsletter = tep_db_input($_POST['customers_newsletter']);
     $customers_group_id = tep_db_input($_POST['customers_group_id']);
     $customers_group_ra = tep_db_input($_POST['customers_group_ra']);
     // # Password reset for customer edit form.
     $existing_customers_password = tep_db_result(tep_db_query("SELECT customers_password FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int) $_GET['cID'] . "'"));
     $new_password = tep_db_input($_POST['customers_password']);
     $customers_password = tep_encrypt_password($new_password);
     if (isset($customers_group_ra) && $customers_group_ra == '1') {
         $toName = $customers_firstname . ' ' . $customers_lastname;
         $toEmail = $customers_email_address;
         $emailSubject = EMAIL_VENDOR_CONFIRM_SUBJECT;
         $emailText = sprintf(EMAIL_VENDOR_CONFIRM_BODY, $toName, $customers_email_address);
         $fromName = STORE_OWNER;
         $fromEmail = STORE_OWNER_EMAIL_ADDRESS;
         tep_mail($toName, $toEmail, $emailSubject, $emailText, $fromName, $fromEmail);
         $messageStack->add_session('Approval email sent to ' . $check_customer['customers_email_address'], 'success');
         $messageStack->add('Approval email sent to ' . $check_customer['customers_email_address'], 'success');
     }
     $entry_company_tax_id = tep_db_input($_POST['entry_company_tax_id']);
     if ($_POST['customers_payment_allowed'] && $_POST['customers_payment_settings'] == '1') {
        }
        if (!empty($attributes_string)) {
            $products['products_name'] .= " (" . join('; ', $attributes_string) . ")";
        }
    }
    if (strlen($rows) < 2) {
        $rows = '0' . $rows;
    }
    ?>
		<tr class="dataTableRow <?php 
    echo $ct++ & 1 ? 'tabEven' : 'tabOdd';
    ?>
">
			<td class="dataTableContent" valign="top" style="padding:10px 5px; font:normal 10px arial;">
<?php 
    $product_url = tep_db_result(tep_db_query("SELECT url_new FROM url_rewrite_map WHERE item_id = 'p" . $products['master_products_id'] . "'"), 0, "url_new");
    echo '<a href="' . $product_url . '" style="font:normal 11px arial" target="_blank">' . $products['products_name'] . '</a>';
    echo '<br><br> ASIN: ' . (!empty($products['asin']) ? '<a href="https://www.amazon' . $tld . '/dp/' . $products['asin'] . '" target="_blank">' . $products['asin'] . '</a>' : '<b style="color:red">No Active Offers</b>');
    echo '<br><br> <b>Current Stock: <b style="font:bold 11px arial;">' . max($products['products_quantity'], 0) . '</b></b>';
    ?>
</td>

<td class="dataTableContent" valign="top" style="text-align:center; padding:10px 4px; font:normal 10px arial;"><?php 
    echo $products['products_model'];
    ?>
</td>

<td class="dataTableContent theCost" valign="top" style="width:50px; text-align:center; padding:5px 5px 0 5px;" id="theCost_<?php 
    echo $products['products_id'];
    ?>
">
Example #11
0
$query = tep_db_query("SELECT * FROM `admin_sessions` \r\n\t\t\t\t\t\t   WHERE admin_user NOT LIKE 'dbfeed_%'\r\n\t\t\t\t\t\t   ORDER BY `admin_sessions`.`access_time` DESC \r\n\t\t\t\t\t\t   LIMIT 1, 1\r\n\t\t\t\t\t\t  ");
echo '<table border="0" cellspacing="0" cellpadding="1" align="right"><tr><td nowrap>
			<b style="color:#7395C3; font:bold 11px arial;">Domain:&nbsp; </b><b style="font:bold 11px arial;">' . preg_replace('/^www\\./', '', SITE_DOMAIN) . '</b></td>';
echo '<td rowspan ="2" style="text-align:right; line-height:17px; padding-left:17px;" nowrap><b style="color:#7395C3; font:bold 11px arial;">Last login:&nbsp;</b> <b style="font:bold 11px arial;">';
if (tep_db_num_rows($query) > 0) {
    while ($user = tep_db_fetch_array($query)) {
        echo date('n/j/Y g:ia', strtotime($user['access_time']) - 18000);
        echo '</b><br><b style="color:#7395C3">by:&nbsp;</b> <b style="font:bold 11px arial;">' . ($user['admin_user'] == '.intensecart' ? 'Admin' : $user['admin_user']) . '</b>';
    }
    tep_db_free_result($query);
} else {
    echo 'No users found!';
}
echo '</td></tr><td nowrap>';
$logged_in_query = tep_db_query("SELECT admin_user FROM admin_sessions WHERE admin_sessid = '" . $_COOKIE['admin_sessid'] . "'");
$logged_in = tep_db_num_rows($logged_in_query) > 0 ? tep_db_result($logged_in_query, 0) : '';
echo '<b style="color:#7395C3; font:bold 11px arial;">Logged in as:</b> &nbsp;<b style="font:bold 11px arial; text-transform: capitalize;">' . ($logged_in == '.intensecart' ? 'Admin' : $logged_in) . '</b>';
echo '</td>';
echo '</tr></table>';
?>

</td></tr></table></div></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">
<div style="position:relative; height:75px;">
	<div style="position:absolute; top:0; left: 0px; width:100%; overflow-x:hidden;">

		<div id="headtabs" class="tabbed">

			<ul id="headtabs-nav" class="tabbed">