Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

151
 
368
 
368
 
order.php
_> 11 <?php
  22 /*
<> 3 -  $Id: order.php 151 2005-08-02 14:33:25Z mattice $
   3+  $Id: order.php 368 2005-12-22 16:27:23Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
     
 !
1313   class order {
  1414     var $info, $totals, $products, $customer, $delivery, $content_type;
  1515 
<>  16+/* Private variables */
   17+
   18+    var $_id;
   19+
   20+/* Class constructor */
   21+
1622     function order($order_id = '') {
<>  23+      if (is_numeric($order_id)) {
   24+        $this->_id = $order_id;
   25+      }
   26+
1727       $this->info = array();
  1828       $this->totals = array();
  1929       $this->products = array();
     
 !
2737       }
  2838     }
  2939 
<>  40+/* Public methods */
   41+
   42+    function &getListing($limit = null, $page_keyword = 'page') {
   43+      global $osC_Database, $osC_Customer;
   44+
   45+      $Qorders = $osC_Database->query('select o.orders_id, o.date_purchased, o.delivery_name, o.delivery_country, o.billing_name, o.billing_country, ot.text as order_total, s.orders_status_name from :table_orders o, :table_orders_total ot, :table_orders_status s where o.customers_id = :customers_id and o.orders_id = ot.orders_id and ot.class = "ot_total" and o.orders_status = s.orders_status_id and s.language_id = :language_id order by orders_id desc');
   46+      $Qorders->bindTable(':table_orders', TABLE_ORDERS);
   47+      $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
   48+      $Qorders->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
   49+      $Qorders->bindInt(':customers_id', $osC_Customer->getID());
   50+      $Qorders->bindInt(':language_id', $_SESSION['languages_id']);
   51+
   52+      if (is_numeric($limit)) {
   53+        $Qorders->setBatchLimit(isset($_GET[$page_keyword]) && is_numeric($_GET[$page_keyword]) ? $_GET[$page_keyword] : 1, $limit);
   54+      }
   55+
   56+      $Qorders->execute();
   57+
   58+      return $Qorders;
   59+    }
   60+
   61+    function &getStatusListing($id = null) {
   62+      global $osC_Database;
   63+
   64+      if ( ($id === null) && isset($this) ) {
   65+        $id = $this->_id;
   66+      }
   67+
   68+      $Qstatus = $osC_Database->query('select os.orders_status_name, osh.date_added, osh.comments from :table_orders_status os, :table_orders_status_history osh where osh.orders_id = :orders_id and osh.orders_status_id = os.orders_status_id and os.language_id = :language_id order by osh.date_added');
   69+      $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
   70+      $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
   71+      $Qstatus->bindInt(':orders_id', $id);
   72+      $Qstatus->bindInt(':language_id', $_SESSION['languages_id']);
   73+
   74+      return $Qstatus;
   75+    }
   76+
   77+    function getCustomerID($id = null) {
   78+      global $osC_Database;
   79+
   80+      if ( ($id === null) && isset($this) ) {
   81+        $id = $this->_id;
   82+      }
   83+
   84+      $Qcustomer = $osC_Database->query('select customers_id from :table_orders where orders_id = :orders_id');
   85+      $Qcustomer->bindTable(':table_orders', TABLE_ORDERS);
   86+      $Qcustomer->bindInt(':orders_id', $id);
   87+      $Qcustomer->execute();
   88+
   89+      return $Qcustomer->valueInt('customers_id');
   90+    }
   91+
   92+    function numberOfEntries() {
   93+      global $osC_Database, $osC_Customer;
   94+      static $total_entries;
   95+
   96+      if (is_numeric($total_entries) === false) {
   97+        if ($osC_Customer->isLoggedOn()) {
   98+          $Qorders = $osC_Database->query('select count(*) as total from :table_orders where customers_id = :customers_id');
   99+          $Qorders->bindTable(':table_orders', TABLE_ORDERS);
   100+          $Qorders->bindInt(':customers_id', $osC_Customer->getID());
   101+          $Qorders->execute();
   102+
   103+          $total_entries = $Qorders->valueInt('total');
   104+        } else {
   105+          $total_entries = 0;
   106+        }
   107+      }
   108+
   109+      return $total_entries;
   110+    }
   111+
   112+    function numberOfProducts($id = null) {
   113+      global $osC_Database;
   114+
   115+      if ( ($id === null) && isset($this) ) {
   116+        $id = $this->_id;
   117+      }
   118+
   119+      $Qproducts = $osC_Database->query('select count(*) as total from :table_orders_products where orders_id = :orders_id');
   120+      $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
   121+      $Qproducts->bindInt(':orders_id', $id);
   122+      $Qproducts->execute();
   123+
   124+      return $Qproducts->valueInt('total');
   125+    }
   126+
   127+
   128+
30129     function query($order_id) {
<> 31 -      global $osC_Database, $osC_Session;
   130+      global $osC_Database;
32131 
  33132       $Qorder = $osC_Database->query('select customers_id, 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, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, 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 = :orders_id');
  34133       $Qorder->bindTable(':table_orders', TABLE_ORDERS);
     
 !
63162       $Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
  64163       $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
  65164       $Qstatus->bindInt(':orders_status_id', $Qorder->valueInt('orders_status'));
<> 66 -      $Qstatus->bindInt(':language_id', $osC_Session->value('languages_id'));
   165+      $Qstatus->bindInt(':language_id', $_SESSION['languages_id']);
67166       $Qstatus->execute();
  68167 
  69168       $this->info = array('currency' => $Qorder->value('currency'),
     
 !
158257     }
  159258 
  160259     function cart() {
<> 161 -      global $osC_Database, $osC_Session, $osC_Customer, $osC_Tax, $cart, $osC_Currencies;
   260+      global $osC_Database, $osC_Customer, $osC_Tax, $osC_Currencies;
162261 
<> 163 -      $this->content_type = $cart->get_content_type();
   262+      $this->content_type = $_SESSION['cart']->get_content_type();
164263 
<> 165 -      $shipping =& $osC_Session->value('shipping');
  166 -      $payment =& $osC_Session->value('payment');
   264+      $shipping =& $_SESSION['shipping'];
   265+      $payment =& $_SESSION['payment'];
167266 
  168267       $Qcustomer = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from :table_customers c, :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries co on (ab.entry_country_id = co.countries_id) where c.customers_id = :customers_id and ab.customers_id = :customers_id and c.customers_default_address_id = ab.address_book_id');
  169268       $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
  170269       $Qcustomer->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
  171270       $Qcustomer->bindTable(':table_zones', TABLE_ZONES);
  172271       $Qcustomer->bindTable(':table_countries', TABLE_COUNTRIES);
<> 173 -      $Qcustomer->bindInt(':customers_id', $osC_Customer->id);
  174 -      $Qcustomer->bindInt(':customers_id', $osC_Customer->id);
   272+      $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
   273+      $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
175274       $Qcustomer->execute();
  176275 
  177276       $Qshipping = $osC_Database->query('select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries c on (ab.entry_country_id = c.countries_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
  178277       $Qshipping->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
  179278       $Qshipping->bindTable(':table_zones', TABLE_ZONES);
  180279       $Qshipping->bindTable(':table_countries', TABLE_COUNTRIES);
<> 181 -      $Qshipping->bindInt(':customers_id', $osC_Customer->id);
  182 -      $Qshipping->bindInt(':address_book_id', $osC_Session->value('sendto'));
   280+      $Qshipping->bindInt(':customers_id', $osC_Customer->getID());
   281+      $Qshipping->bindInt(':address_book_id', $_SESSION['sendto']);
183282       $Qshipping->execute();
  184283 
  185284       $Qbilling = $osC_Database->query('select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries c on (ab.entry_country_id = c.countries_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
  186285       $Qbilling->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
  187286       $Qbilling->bindTable(':table_zones', TABLE_ZONES);
  188287       $Qbilling->bindTable(':table_countries', TABLE_COUNTRIES);
<> 189 -      $Qbilling->bindInt(':customers_id', $osC_Customer->id);
  190 -      $Qbilling->bindInt(':address_book_id', $osC_Session->value('billto'));
   288+      $Qbilling->bindInt(':customers_id', $osC_Customer->getID());
   289+      $Qbilling->bindInt(':address_book_id', $_SESSION['billto']);
191290       $Qbilling->execute();
  192291 
  193292       $Qtax = $osC_Database->query('select ab.entry_country_id, ab.entry_zone_id from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
  194293       $Qtax->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
  195294       $Qtax->bindTable(':table_zones', TABLE_ZONES);
<> 196 -      $Qtax->bindInt(':customers_id', $osC_Customer->id);
  197 -      $Qtax->bindInt(':address_book_id', ($this->content_type == 'virtual' ? $osC_Session->value('billto') : $osC_Session->value('sendto')));
   295+      $Qtax->bindInt(':customers_id', $osC_Customer->getID());
   296+      $Qtax->bindInt(':address_book_id', ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']));
198297       $Qtax->execute();
  199298 
  200299       $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
<> 201 -                          'currency' => $osC_Session->value('currency'),
  202 -                          'currency_value' => $osC_Currencies->currencies[$osC_Session->value('currency')]['value'],
   300+                          'currency' => $_SESSION['currency'],
   301+                          'currency_value' => $osC_Currencies->currencies[$_SESSION['currency']]['value'],
203302                           'payment_method' => $payment,
  204303                           'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
  205304                           'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
     
 !
210309                           'subtotal' => 0,
  211310                           'tax' => 0,
  212311                           'tax_groups' => array(),
<> 213 -                          'comments' => ($osC_Session->exists('comments') ? $osC_Session->value('comments') : ''));
   312+                          'comments' => (isset($_SESSION['comments']) ? $_SESSION['comments'] : ''));
214313 
  215314       if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {
  216315         $this->info['payment_method'] = $GLOBALS[$payment]->title;
     
 !
261360                              'format_id' => $Qbilling->valueInt('address_format_id'));
  262361 
  263362       $index = 0;
<> 264 -      $products = $cart->get_products();
   363+      $products = $_SESSION['cart']->get_products();
265364       for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  266365         $this->products[$index] = array('qty' => $products[$i]['quantity'],
  267366                                         'name' => $products[$i]['name'],
     
 !
270369                                         'tax_description' => $osC_Tax->getTaxRateDescription($products[$i]['tax_class_id'], $Qtax->valueInt('entry_country_id'), $Qtax->valueInt('entry_zone_id')),
  271370                                         'tax_class_id' => $products[$i]['tax_class_id'],
  272371                                         'price' => $products[$i]['price'],
<> 273 -                                        'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
   372+                                        'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']),
274373                                         'weight' => $products[$i]['weight'],
  275374                                         'id' => $products[$i]['id']);
  276375 
     
 !
285384             $Qattributes->bindInt(':products_id', $products[$i]['id']);
  286385             $Qattributes->bindInt(':options_id', $option);
  287386             $Qattributes->bindInt(':options_values_id', $value);
<> 288 -            $Qattributes->bindInt(':language_id', $osC_Session->value('languages_id'));
  289 -            $Qattributes->bindInt(':language_id', $osC_Session->value('languages_id'));
   387+            $Qattributes->bindInt(':language_id', $_SESSION['languages_id']);
   388+            $Qattributes->bindInt(':language_id', $_SESSION['languages_id']);
<_ 290389             $Qattributes->execute();
  291390 
  292391             $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options_name'),