  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: order.php 531 2006-04-25 15:42:48Z hpdl $ |
| |
| 3 | + | $Id: order.php 538 2006-04-27 16:53:59Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
336 | 336 | | $Qupdate->execute(); |
| |
337 | 337 | | } |
| |
338 | 338 | | |
  |
| 339 | + | osC_Order::sendEmail($order_id); |
| |
| 340 | + | |
|
339 | 341 | | unset($_SESSION['prepOrderID']); |
| |
340 | 342 | | } |
| |
341 | 343 | | |
  |
| 344 | + | function sendEmail($id) { |
| |
| 345 | + | global $osC_Database, $osC_Language, $osC_Currencies; |
| |
| 346 | + | |
| |
| 347 | + | $Qorder = $osC_Database->query('select * from :table_orders where orders_id = :orders_id limit 1'); |
| |
| 348 | + | $Qorder->bindTable(':table_orders', TABLE_ORDERS); |
| |
| 349 | + | $Qorder->bindInt(':orders_id', $id); |
| |
| 350 | + | $Qorder->execute(); |
| |
| 351 | + | |
| |
| 352 | + | if ($Qorder->numberOfRows() === 1) { |
| |
| 353 | + | $email_order = STORE_NAME . "\n" . |
| |
| 354 | + | $osC_Language->get('email_order_separator') . "\n" . |
| |
| 355 | + | sprintf($osC_Language->get('email_order_order_number'), $id) . "\n" . |
| |
| 356 | + | sprintf($osC_Language->get('email_order_invoice_url'), tep_href_link(FILENAME_ACCOUNT, 'orders=' . $id, 'SSL', false, true, true)) . "\n" . |
| |
| 357 | + | sprintf($osC_Language->get('email_order_date_ordered'), osC_DateTime::getLong()) . "\n\n"; |
| |
| 358 | + | |
| |
| 359 | + | if (isset($_SESSION['comments'])) { |
| |
| 360 | + | $email_order .= tep_output_string_protected($_SESSION['comments']) . "\n\n"; |
| |
| 361 | + | } |
| |
| 362 | + | |
| |
| 363 | + | $Qproducts = $osC_Database->query('select products_model, products_name, final_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id'); |
| |
| 364 | + | $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); |
| |
| 365 | + | $Qproducts->bindInt(':orders_id', $id); |
| |
| 366 | + | $Qproducts->execute(); |
| |
| 367 | + | |
| |
| 368 | + | $products_ordered = ''; |
| |
| 369 | + | |
| |
| 370 | + | while ($Qproducts->next()) { |
| |
| 371 | + | $products_ordered .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $Qproducts->value('products_model') . ') = ' . $osC_Currencies->displayPriceWithTaxRate($Qproducts->value('final_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n"; // . $products_ordered_attributes . "\n"; |
| |
| 372 | + | } |
| |
| 373 | + | |
| |
| 374 | + | $email_order .= $osC_Language->get('email_order_products') . "\n" . |
| |
| 375 | + | $osC_Language->get('email_order_separator') . "\n" . |
| |
| 376 | + | $products_ordered . |
| |
| 377 | + | $osC_Language->get('email_order_separator') . "\n"; |
| |
| 378 | + | |
| |
| 379 | + | $Qtotals = $osC_Database->query('select title, text from :table_orders_total where orders_id = :orders_id order by sort_order'); |
| |
| 380 | + | $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); |
| |
| 381 | + | $Qtotals->bindInt(':orders_id', $id); |
| |
| 382 | + | $Qtotals->execute(); |
| |
| 383 | + | |
| |
| 384 | + | while ($Qtotals->next()) { |
| |
| 385 | + | $email_order .= strip_tags($Qtotals->value('title') . ' ' . $Qtotals->value('text')) . "\n"; |
| |
| 386 | + | } |
| |
| 387 | + | |
| |
| 388 | + | // if ($order->content_type != 'virtual') { |
| |
| 389 | + | // $email_order .= "\n" . $osC_Language->get('email_order_delivery_address') . "\n" . |
| |
| 390 | + | // $osC_Language->get('email_order_separator') . "\n" . |
| |
| 391 | + | // tep_address_label($osC_Customer->getID(), $osC_ShoppingCart->getShippingAddress('id'), 0, '', "\n") . "\n"; |
| |
| 392 | + | // } |
| |
| 393 | + | |
| |
| 394 | + | // $email_order .= "\n" . $osC_Language->get('email_order_billing_address') . "\n" . |
| |
| 395 | + | // $osC_Language->get('email_order_separator') . "\n" . |
| |
| 396 | + | // tep_address_label($osC_Customer->getID(), $osC_ShoppingCart->getBillingAddress('id'), 0, '', "\n") . "\n\n"; |
| |
| 397 | + | |
| |
| 398 | + | // if (is_object($GLOBALS[$payment])) { |
| |
| 399 | + | // $email_order .= $osC_Language->get('email_order_payment_method') . "\n" . |
| |
| 400 | + | // $osC_Language->get('email_order_separator') . "\n"; |
| |
| 401 | + | |
| |
| 402 | + | // $email_order .= $osC_ShoppingCart->getBillingMethod('title') . "\n\n"; |
| |
| 403 | + | // if (isset($GLOBALS[$payment]->email_footer)) { |
| |
| 404 | + | // $email_order .= $GLOBALS[$payment]->email_footer . "\n\n"; |
| |
| 405 | + | // } |
| |
| 406 | + | // } |
| |
| 407 | + | |
| |
| 408 | + | tep_mail($Qorder->value('customers_name'), $Qorder->value('customers_email_address'), $osC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); |
| |
| 409 | + | |
| |
| 410 | + | // send emails to other people |
| |
| 411 | + | if (SEND_EXTRA_ORDER_EMAILS_TO != '') { |
| |
| 412 | + | tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, $osC_Language->get('email_order_subject'), $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); |
| |
| 413 | + | } |
| |
| 414 | + | } |
| |
| 415 | + | } |
| |
| 416 | + | |
|
342 | 417 | | function &getListing($limit = null, $page_keyword = 'page') { |
| |
343 | 418 | | global $osC_Database, $osC_Customer, $osC_Language; |
| |
344 | 419 | | |
| |
|
|
 |
… |
|
424 | 499 | | return $Qproducts->valueInt('total'); |
| |
425 | 500 | | } |
| |
426 | 501 | | |
  |
| 502 | + | function exists($id, $customer_id = null) { |
| |
| 503 | + | global $osC_Database; |
|
427 | 504 | | |
  |
| 505 | + | $Qorder = $osC_Database->query('select orders_id from :table_orders where orders_id = :orders_id'); |
|
428 | 506 | | |
  |
| 507 | + | if (isset($customer_id) && is_numeric($customer_id)) { |
| |
| 508 | + | $Qorder->appendQuery('and customers_id = :customers_id'); |
| |
| 509 | + | $Qorder->bindInt(':customers_id', $customer_id); |
| |
| 510 | + | } |
| |
| 511 | + | |
| |
| 512 | + | $Qorder->appendQuery('limit 1'); |
| |
| 513 | + | $Qorder->bindTable(':table_orders', TABLE_ORDERS); |
| |
| 514 | + | $Qorder->bindInt(':orders_id', $id); |
| |
| 515 | + | $Qorder->execute(); |
| |
| 516 | + | |
| |
| 517 | + | return ($Qorder->numberOfRows() === 1); |
| |
| 518 | + | } |
| |
| 519 | + | |
  |
429 | 520 | | function query($order_id) { |
| |
430 | 521 | | global $osC_Database, $osC_Language; |
| |
431 | 522 | | |