| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: gv_send.php 14 2006-07-28 17:42:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax 9 10 Gift Voucher System v1.0 11 Copyright 2006 osCMax2001, 2002 Ian C Wilson 12 http://www.phesis.org 13 14 Released under the GNU General Public License 15 */ 16 17 // Most of this file is changed or moved to BTS - Basic Template System - format. 18 // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change). 19 // catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change). 20 // (Sub 'fallback' with your current template to see if there is a template specific file.) 21 22 require ('includes/application_top.php'); 23 24 require ('includes/classes/http_client.php'); 25 26 // if the customer is not logged on, redirect them to the login page 27 if (!tep_session_is_registered('customer_id')) { 28 $navigation->set_snapshot(); 29 tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 30 } 31 32 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_GV_SEND); 33 34 if (($HTTP_POST_VARS['back_x']) || ($HTTP_POST_VARS['back_y'])) { 35 $HTTP_GET_VARS['action'] = ''; 36 } 37 if ($HTTP_GET_VARS['action'] == 'send') { 38 $error = false; 39 if (!tep_validate_email(trim($HTTP_POST_VARS['email']))) { 40 $error = true; 41 $error_email = ERROR_ENTRY_EMAIL_ADDRESS_CHECK; 42 } 43 $gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'"); 44 $gv_result = tep_db_fetch_array($gv_query); 45 $customer_amount = $gv_result['amount']; 46 $gv_amount = trim($HTTP_POST_VARS['amount']); 47 if (ereg('[^0-9/.]', $gv_amount)) { 48 $error = true; 49 $error_amount = ERROR_ENTRY_AMOUNT_CHECK; 50 } 51 if ($gv_amount>$customer_amount || $gv_amount == 0) { 52 $error = true; 53 $error_amount = ERROR_ENTRY_AMOUNT_CHECK; 54 } 55 } 56 if ($HTTP_GET_VARS['action'] == 'process') { 57 $id1 = create_coupon_code($mail['customers_email_address']); 58 $gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id='".$customer_id."'"); 59 $gv_result=tep_db_fetch_array($gv_query); 60 $new_amount=$gv_result['amount']-$HTTP_POST_VARS['amount']; 61 if ($new_amount<0) { 62 $error= true; 63 $error_amount = ERROR_ENTRY_AMOUNT_CHECK; 64 $HTTP_GET_VARS['action'] = 'send'; 65 } else { 66 $gv_query=tep_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_amount . "' where customer_id = '" . $customer_id . "'"); 67 $gv_query=tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); 68 $gv_customer=tep_db_fetch_array($gv_query); 69 $gv_query=tep_db_query("insert into " . TABLE_COUPONS . " (coupon_type, coupon_code, date_created, coupon_amount) values ('G', '" . $id1 . "', NOW(), '" . $HTTP_POST_VARS['amount'] . "')"); 70 $insert_id = tep_db_insert_id($gv_query); 71 $gv_query=tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, sent_lastname, emailed_to, date_sent) values ('" . $insert_id . "' ,'" . $customer_id . "', '" . addslashes($gv_customer['customers_firstname']) . "', '" . addslashes($gv_customer['customers_lastname']) . "', '" . $HTTP_POST_VARS['email'] . "', now())"); 72 73 $gv_email = STORE_NAME . "\n" . 74 EMAIL_SEPARATOR . "\n" . 75 sprintf(EMAIL_GV_TEXT_HEADER, $currencies->format($HTTP_POST_VARS['amount'])) . "\n" . 76 EMAIL_SEPARATOR . "\n" . 77 sprintf(EMAIL_GV_FROM, stripslashes($HTTP_POST_VARS['send_name'])) . "\n"; 78 if (isset($HTTP_POST_VARS['message'])) { 79 $gv_email .= EMAIL_GV_MESSAGE . "\n"; 80 if (isset($HTTP_POST_VARS['to_name'])) { 81 $gv_email .= sprintf(EMAIL_GV_SEND_TO, stripslashes($HTTP_POST_VARS['to_name'])) . "\n\n"; 82 } 83 $gv_email .= stripslashes($HTTP_POST_VARS['message']) . "\n\n"; 84 } 85 $gv_email .= sprintf(EMAIL_GV_REDEEM, $id1) . "\n\n"; 86 $gv_email .= EMAIL_GV_LINK . ' ' . "<a HREF='" . tep_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $id1,'NONSSL',false) . "'>" . tep_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $id1,'NONSSL',false) . "</a>\n" ; 87 $gv_email .= "\n\n"; 88 $gv_email .= EMAIL_GV_FIXED_FOOTER . "\n\n"; 89 $gv_email .= EMAIL_GV_SHOP_FOOTER . "\n\n";; 90 $gv_email_subject = sprintf(EMAIL_GV_TEXT_SUBJECT, stripslashes($HTTP_POST_VARS['send_name'])); 91 tep_mail('', $HTTP_POST_VARS['email'], $gv_email_subject, nl2br($gv_email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, ''); 92 } 93 } 94 $breadcrumb->add(NAVBAR_TITLE); 95 96 $content = CONTENT_GV_SEND; 97 98 include (bts_select('main', $content_template)); // BTSv1.5 99 100 require (DIR_WS_INCLUDES . 'application_bottom.php'); 101 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |