[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/ -> add_ccgvdc_application_top.php (source)

   1  <?php
   2    define('FILENAME_GV_FAQ', 'gv_faq.php');
   3    define('FILENAME_GV_REDEEM', 'gv_redeem.php');
   4    define('FILENAME_GV_REDEEM_PROCESS', 'gv_redeem_process.php');
   5    define('FILENAME_GV_SEND', 'gv_send.php');
   6    define('FILENAME_GV_SEND_PROCESS', 'gv_send_process.php');
   7    define('FILENAME_PRODUCT_LISTING_COL', 'product_listing_col.php');
   8    define('FILENAME_POPUP_COUPON_HELP', 'popup_coupon_help.php');
   9  
  10    define('TABLE_COUPON_GV_CUSTOMER', 'coupon_gv_customer');
  11    define('TABLE_COUPON_GV_QUEUE', 'coupon_gv_queue');
  12    define('TABLE_COUPON_REDEEM_TRACK', 'coupon_redeem_track');
  13    define('TABLE_COUPON_EMAIL_TRACK', 'coupon_email_track');
  14    define('TABLE_COUPONS', 'coupons');
  15    define('TABLE_COUPONS_DESCRIPTION', 'coupons_description');
  16  
  17  // Below are some defines which affect the way the discount coupon/gift voucher system work
  18  // Be careful when editing them.
  19  //
  20  // Set the length of the redeem code, the longer the more secure
  21    define('SECURITY_CODE_LENGTH', '10');
  22  //
  23  // The settings below determine whether a new customer receives an incentive when they first signup
  24  //
  25  // Set the amount of a Gift Voucher that the new signup will receive, set to 0 for none
  26  //  define('NEW_SIGNUP_GIFT_VOUCHER_AMOUNT', '10');  // placed in the admin configuration mystore
  27  //
  28  // Set the coupon ID that will be sent by email to a new signup, if no id is set then no email :)
  29  //  define('NEW_SIGNUP_DISCOUNT_COUPON', '3'); // placed in the admin configuration mystore
  30  
  31  
  32  ////
  33  // Create a Coupon Code. length may be between 1 and 16 Characters
  34  // $salt needs some thought.
  35  
  36    function create_coupon_code($salt="secret", $length = SECURITY_CODE_LENGTH) {
  37      $ccid = md5(uniqid("","salt"));
  38      $ccid .= md5(uniqid("","salt"));
  39      $ccid .= md5(uniqid("","salt"));
  40      $ccid .= md5(uniqid("","salt"));
  41      srand((double)microtime()*1000000); // seed the random number generator
  42      $random_start = @rand(0, (128-$length));
  43      $good_result = 0;
  44      while ($good_result == 0) {
  45        $id1=substr($ccid, $random_start,$length);        
  46        $query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . $id1 . "'");    
  47        if (tep_db_num_rows($query) == 0) $good_result = 1;
  48      }
  49      return $id1;
  50    }
  51  ////
  52  // Update the Customers GV account
  53    function tep_gv_account_update($customer_id, $gv_id) {
  54      $customer_gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'");
  55      $coupon_gv_query = tep_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . $gv_id . "'");
  56      $coupon_gv = tep_db_fetch_array($coupon_gv_query);
  57      if (tep_db_num_rows($customer_gv_query) > 0) {
  58        $customer_gv = tep_db_fetch_array($customer_gv_query);
  59        $new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount'];
  60     $gv_query = tep_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_gv_amount . "' where customer_id = '" . $customer_id . "'");  
  61      } else {
  62        $gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");
  63      }
  64    }
  65  ////
  66  // Get tax rate from tax description
  67    function tep_get_tax_rate_from_desc($tax_desc) {
  68      $tax_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_description = '" . $tax_desc . "'");
  69      $tax = tep_db_fetch_array($tax_query);
  70      return $tax['tax_rate'];
  71    }
  72  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7