[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 ot_gv.php

Zen Cart 源代码 ot_gv.php




下载文件

文件名: ot_gv.php
文件类型: PHP文件
文件大小: 22.31 KiB
MD5: 72ffb25ad012a144f14591cb98c49f03

ot_gv.php - 关闭高亮
  1. <?php
  2. /**
  3.  * ot_gv order-total module
  4.  *
  5.  * @package orderTotal
  6.  * @copyright Copyright 2003-2014 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version GIT: $Id: Author: DrByte  Tue Apr 15 17:32:27 2014 -0400 Modified in v1.5.3 $
  10.  */
  11. /**
  12.  * Enter description here...
  13.  *
  14.  */
  15. class ot_gv {
  16.   /**
  17.    * Enter description here...
  18.    *
  19.    * @var unknown_type
  20.    */
  21.   var $title;
  22.   /**
  23.    * Enter description here...
  24.    *
  25.    * @var unknown_type
  26.    */
  27.   var $output;
  28.   /**
  29.    * Enter description here...
  30.    *
  31.    * @return ot_gv
  32.    */
  33.   function ot_gv() {
  34.     global $currencies;
  35.     $this->code = 'ot_gv';
  36.     $this->title = MODULE_ORDER_TOTAL_GV_TITLE;
  37.     $this->header = MODULE_ORDER_TOTAL_GV_HEADER;
  38.     $this->description = MODULE_ORDER_TOTAL_GV_DESCRIPTION;
  39.     $this->user_prompt = MODULE_ORDER_TOTAL_GV_USER_PROMPT;
  40.     $this->sort_order = MODULE_ORDER_TOTAL_GV_SORT_ORDER;
  41.     $this->include_shipping = MODULE_ORDER_TOTAL_GV_INC_SHIPPING;
  42.     $this->include_tax = MODULE_ORDER_TOTAL_GV_INC_TAX;
  43.     $this->calculate_tax = MODULE_ORDER_TOTAL_GV_CALC_TAX;
  44.     $this->credit_tax = MODULE_ORDER_TOTAL_GV_CREDIT_TAX;
  45.     $this->tax_class  = MODULE_ORDER_TOTAL_GV_TAX_CLASS;
  46.     $this->show_redeem_box = MODULE_ORDER_TOTAL_GV_REDEEM_BOX;
  47.     $this->credit_class = true;
  48.     if (!zen_not_null(ltrim($_SESSION['cot_gv'], ' 0')) || $_SESSION['cot_gv'] == '0') $_SESSION['cot_gv'] = '0.00';
  49.     if (IS_ADMIN_FLAG !== true) {
  50.       $this->checkbox = $this->user_prompt . '<input type="text" size="6" onkeyup="submitFunction()" name="cot_gv" value="' . number_format($_SESSION['cot_gv'], 2) . '" onfocus="if (this.value == \'' . number_format($_SESSION['cot_gv'], 2) . '\') this.value = \'\';" />' . ($this->user_has_gv_account($_SESSION['customer_id']) > 0 ? '<br />' . MODULE_ORDER_TOTAL_GV_USER_BALANCE . $currencies->format($this->user_has_gv_account($_SESSION['customer_id'])) : '');
  51.     }
  52.     $this->output = array();
  53.     if (IS_ADMIN_FLAG === true) {
  54.       if ($this->include_tax == 'true' && $this->calculate_tax != "None") {
  55.         $this->title .= '<span class="alert">' . MODULE_ORDER_TOTAL_GV_INCLUDE_ERROR . '</span>';
  56.       }
  57.     }
  58.   }
  59.   /**
  60.    * Enter description here...
  61.    *
  62.    */
  63.   function process() {
  64.     global $order, $currencies;
  65.     if ($_SESSION['cot_gv']) {
  66.       $od_amount = $this->calculate_deductions($this->get_order_total());
  67.       $this->deduction = $od_amount['total'];
  68.       if ($od_amount['total'] > 0) {
  69.         reset($order->info['tax_groups']);
  70.         $tax = 0;
  71.         while (list($key, $value) = each($order->info['tax_groups'])) {
  72.           if ($od_amount['tax_groups'][$key]) {
  73.             $order->info['tax_groups'][$key] -= $od_amount['tax_groups'][$key];
  74.             $tax += $od_amount['tax_groups'][$key];
  75.           }
  76.         }
  77.         $order->info['total'] = $order->info['total'] - $od_amount['total'];
  78.         if ($this->calculate_tax == "Standard") $order->info['total'] -= $tax;
  79.         if ($order->info['total'] < 0) $order->info['total'] = 0;
  80.         $order->info['tax'] = $order->info['tax'] - $od_amount['tax'];
  81.         // prepare order-total output for display and storing to invoice
  82.         $this->output[] = array('title' => $this->title . ':',
  83.                                 'text' => '-' . $currencies->format($od_amount['total']),
  84.                                 'value' => $od_amount['total']);
  85.       }
  86.     }
  87.   }
  88.   /**
  89.    * This is called to reset any GV values, effectively cancelling all GV's applied during current login session
  90.    */
  91.   function clear_posts() {
  92.     unset($_SESSION['cot_gv']);
  93.   }
  94.   /**
  95.    * This just checks to see whether the currently-logged-in customer has any GV credits on their account
  96.    */
  97.   function selection_test() {
  98.     if ($this->user_has_gv_account($_SESSION['customer_id'])) {
  99.       return true;
  100.     } else {
  101.       return false;
  102.     }
  103.   }
  104.   /**
  105.    * Check for validity of redemption amounts and recalculate order totals to include proposed GV redemption deductions
  106.    */
  107.   function pre_confirmation_check($order_total) {
  108.     global $order, $currencies, $messageStack;
  109.     // clean out negative values and strip common currency symbols
  110.     $_SESSION['cot_gv'] = preg_replace('/[^0-9,.%]/', '', $_SESSION['cot_gv']);
  111.     $_SESSION['cot_gv'] = abs($_SESSION['cot_gv']);
  112.  
  113.     if ($_SESSION['cot_gv'] > 0) {
  114.       // if cot_gv value contains any nonvalid characters, throw error
  115.       if (preg_match('/[^0-9\,.]/', trim($_SESSION['cot_gv']))) {
  116.         $messageStack->add_session('checkout_payment', TEXT_INVALID_REDEEM_AMOUNT, error);
  117.         zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  118.       }
  119.       // if requested redemption amount is greater than value of credits on account, throw error
  120.       if ($_SESSION['cot_gv'] > $currencies->value($this->user_has_gv_account($_SESSION['customer_id']))) {
  121.         $messageStack->add_session('checkout_payment', TEXT_INVALID_REDEEM_AMOUNT, error);
  122.         zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  123.       }
  124.       $od_amount = $this->calculate_deductions($order_total);
  125.       $order->info['total'] = $order->info['total'] - $od_amount['total'];
  126.       if (DISPLAY_PRICE_WITH_TAX != 'true') {
  127.         $order->info['total'] -= $tax;
  128.       }
  129.       return $od_amount['total'] + $od_amount['tax'];
  130.     }
  131.     return 0;
  132.   }
  133.   /**
  134.    * if customer has a GV balance, then we display the input field to allow entry of desired GV redemption amount
  135.    */
  136.   function use_credit_amount() {
  137.     if ($this->selection_test()) {
  138.       $output_string = $this->checkbox;
  139.     }
  140.     return $output_string;
  141.   }
  142.   /**
  143.    * queue or release newly-purchased GV's
  144.    */
  145.   function update_credit_account($i) {
  146.     global $db, $order, $insert_id;
  147.     // only act on newly-purchased gift certificates
  148.     if (preg_match('/^GIFT/', addslashes($order->products[$i]['model']))) {
  149.       // determine how much GV was purchased
  150.       // check if GV was purchased on Special
  151.       $gv_original_price = zen_products_lookup((int)$order->products[$i]['id'], 'products_price');
  152.        // if prices differ assume Special ang get Special Price
  153.        // Do not use this on GVs Priced by Attribute
  154.       if (MODULE_ORDER_TOTAL_GV_SPECIAL == 'true' && ($gv_original_price != 0 && $gv_original_price != $order->products[$i]['final_price'] && !zen_get_products_price_is_priced_by_attributes((int)$order->products[$i]['id']))) {
  155.         $gv_order_amount = ($gv_original_price * $order->products[$i]['qty']);
  156.       } else {
  157.       $gv_order_amount = ($order->products[$i]['final_price'] * $order->products[$i]['qty']);
  158.       }
  159.       // if tax is to be calculated on purchased GVs, calculate it
  160.       if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
  161.       $gv_order_amount = $gv_order_amount * 100 / 100;
  162.  
  163.       if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
  164.         // GV_QUEUE is false so release amount to account immediately
  165.         $gv_result = $this->user_has_gv_account($_SESSION['customer_id']);
  166.         $customer_gv = false;
  167.         $total_gv_amount = 0;
  168.         if ($gv_result) {
  169.           $total_gv_amount = $gv_result;
  170.           $customer_gv = true;
  171.         }
  172.         $total_gv_amount = $total_gv_amount + $gv_order_amount;
  173.         if ($customer_gv) {
  174.           $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
  175.         } else {
  176.           $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
  177.         }
  178.       } else {
  179.         // GV_QUEUE is true - so queue the gv for release by store owner
  180.         $db->Execute("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . (int)$_SESSION['customer_id'] . "', '" . (int)$insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $_SERVER['REMOTE_ADDR'] . "')");
  181.       }
  182.     }
  183.   }
  184.   /**
  185.    * check system to see if GVs should be made available or not. If true, then supply GV-selection fields on checkout pages
  186.    */
  187.   function credit_selection() {
  188.     global $db, $currencies;
  189.     $gv_query = $db->Execute("select coupon_id from " . TABLE_COUPONS . " where coupon_type = 'G' and coupon_active='Y'");
  190.     // checks to see if any GVs are in the system and active or if the current customer has any GV balance
  191.     if ($gv_query->RecordCount() > 0 || $this->use_credit_amount()) {
  192.       $selection = array('id' => $this->code,
  193.                          'module' => $this->title,
  194.                          'redeem_instructions' => MODULE_ORDER_TOTAL_GV_REDEEM_INSTRUCTIONS,
  195.                          'checkbox' => $this->use_credit_amount(),
  196.                          'fields' => array(array('title' => MODULE_ORDER_TOTAL_GV_TEXT_ENTER_CODE,
  197.                          'field' => zen_draw_input_field('gv_redeem_code', '', 'id="disc-'.$this->code.'" onkeyup="submitFunction(0,0)"'),
  198.                          'tag' => 'disc-'.$this->code
  199.                          )));
  200.  
  201.     }
  202.     return $selection;
  203.   }
  204.   /**
  205.    * Verify that the customer has entered a valid redemption amount, and return the amount that can be applied to this order
  206.    */
  207.   function apply_credit() {
  208.     global $db, $order, $messageStack;
  209.     // check for valid redemption amount vs available credit for current customer
  210.     if ($_SESSION['cot_gv'] != 0) {
  211.       $gv_result = $db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
  212.       // obtain final "deduction" amount
  213.       $gv_payment_amount = $this->deduction;
  214.       // determine amount of GV to redeem based on available balance minus qualified/calculated deduction suitable to this order
  215.       $gv_amount = $gv_result->fields['amount'] - $gv_payment_amount;
  216.       // reduce customer's GV balance by the amount redeemed
  217.       $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
  218.     }
  219.     // clear GV redemption flag since it's already been claimed and deducted
  220.     $_SESSION['cot_gv'] = false;
  221.     // send back the amount of GV used for payment on this order
  222.     return $gv_payment_amount;
  223.   }
  224.   /**
  225.    * Check to see if redemption code has been entered and redeem if valid
  226.    */
  227.   function collect_posts() {
  228.     global $db, $currencies, $messageStack;
  229.     // if we have no GV amount selected, set it to 0
  230.     if (!$_POST['cot_gv']) $_SESSION['cot_gv'] = '0.00';
  231.     // if we have a GV redemption code submitted, process it
  232.     if ($_POST['gv_redeem_code']) {
  233.       // check for validity
  234.       $_POST['gv_redeem_code'] = preg_replace('/[^0-9a-zA-Z]/', '', $_POST['gv_redeem_code']);
  235.       $gv_result = $db->Execute("select coupon_id, coupon_type, coupon_amount from " . TABLE_COUPONS . " where coupon_code = '" . zen_db_prepare_input($_POST['gv_redeem_code']) . "' and coupon_type = 'G'");
  236.       if ($gv_result->RecordCount() > 0) {
  237.         $redeem_query = $db->Execute("select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . (int)$gv_result->fields['coupon_id'] . "'");
  238.         // if already redeemed, throw error
  239.         if ( ($redeem_query->RecordCount() > 0) && ($gv_result->fields['coupon_type'] == 'G')  ) {
  240.           $messageStack->add_session('checkout_payment', ERROR_NO_INVALID_REDEEM_GV, error);
  241.           zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  242.         }
  243.       } else {
  244.         // if not valid redemption code, throw error
  245.         $messageStack->add_session('checkout_payment', ERROR_NO_INVALID_REDEEM_GV, error);
  246.         zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  247.       }
  248.       // if valid, add redeemed amount to customer's GV balance and mark as redeemed
  249.       if ($gv_result->fields['coupon_type'] == 'G') {
  250.         $gv_amount = $gv_result->fields['coupon_amount'];
  251.         // Things to set
  252.         // ip address of claimant
  253.         // customer id of claimant
  254.         // date
  255.         // redemption flag
  256.         // now update customer account with gv_amount
  257.         $gv_amount_result=$db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
  258.         $customer_gv = false;
  259.         $total_gv_amount = $gv_amount;
  260.         if ($gv_amount_result->RecordCount() > 0) {
  261.           $total_gv_amount = $gv_amount_result->fields['amount'] + $gv_amount;
  262.           $customer_gv = true;
  263.         }
  264.         $db->Execute("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_result->fields['coupon_id'] . "'");
  265.         $db->Execute("insert into  " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_result->fields['coupon_id'] . "', '" . (int)$_SESSION['customer_id'] . "', now(),'" . $_SERVER['REMOTE_ADDR'] . "')");
  266.         if ($customer_gv) {
  267.           // already has gv_amount so update
  268.           $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
  269.         } else {
  270.           // no gv_amount so insert
  271.           $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
  272.         }
  273.         //          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_REDEEMED_AMOUNT. $currencies->format($gv_amount)), 'SSL'));
  274.         $messageStack->add_session('redemptions',ERROR_REDEEMED_AMOUNT. $currencies->format($gv_amount), 'success' );
  275.         zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
  276.       }
  277.     }
  278.     if ($_POST['submit_redeem_x'] && $gv_result->fields['coupon_type'] == 'G') zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL'));
  279.   }
  280.   /**
  281.    * Calculate GV claim amount (GV amounts are always based on the STORE's default currency value)
  282.    */
  283.   function calculate_credit($save_total_cost) {
  284.     global $db, $order, $currencies;
  285.     // calculate value based on default currency
  286.     $gv_payment_amount = $currencies->value($_SESSION['cot_gv'], true, DEFAULT_CURRENCY);
  287.     $full_cost = $save_total_cost - $gv_payment_amount;
  288.     if ($full_cost < 0) {
  289.       $full_cost = 0;
  290.       $gv_payment_amount = $save_total_cost;
  291.     }
  292.     return zen_round($gv_payment_amount,2);
  293.   }
  294.   function calculate_deductions($order_total) {
  295.     global $db, $order, $messageStack;
  296.     $od_amount = array();
  297.     $deduction = $this->calculate_credit($this->get_order_total());
  298.     $od_amount['total'] = $deduction;
  299.     switch ($this->calculate_tax) {
  300.       case 'None':
  301.         $remainder = $order->info['total'] - $od_amount['total'];
  302.         $tax_deduct = $order->info['tax'] - $remainder;
  303.         // division by 0
  304.         if ($order->info['tax'] <= 0) {
  305.           $ratio_tax = 0;
  306.         } else {
  307.           $ratio_tax = $tax_deduct/$order->info['tax'];
  308.         }
  309.         $tax_deduct = 0;
  310. /*
  311.         if ($this->include_tax) {
  312.           reset($order->info['tax_groups']);
  313.           foreach ($order->info['tax_groups'] as $key=>$value) {
  314.             $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio_tax;
  315.             $tax_deduct += $od_amount['tax_groups'][$key];
  316.           }
  317.         }
  318. */
  319.       $od_amount['tax'] = $tax_deduct;
  320.       break;
  321.       case 'Standard':
  322.       if ($od_amount['total'] >= $order_total) {
  323.         $ratio = 1;
  324.       } else {
  325.         $ratio = ($od_amount['total'] / ($order_total - $order->info['tax']));
  326.       }
  327.       reset($order->info['tax_groups']);
  328.       $tax_deduct = 0;
  329.       foreach ($order->info['tax_groups'] as $key=>$value) {
  330.         $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
  331.         $tax_deduct += $od_amount['tax_groups'][$key];
  332.       }
  333.       $od_amount['tax'] = $tax_deduct;
  334.       break;
  335.       case 'Credit Note':
  336.         $od_amount['total'] = $deduction;
  337.         $tax_rate = zen_get_tax_rate($this->tax_class);
  338.         $od_amount['tax'] = zen_calculate_tax($deduction, $tax_rate);
  339.         $tax_description = zen_get_tax_description($this->tax_class);
  340.         $od_amount['tax_groups'][$tax_description] = $od_amount['tax'];
  341.       break;
  342.       default:
  343.     }
  344.     return $od_amount;
  345.   }
  346.   /**
  347.    * Check to see whether current customer has a GV balance available
  348.    * Returns amount of GV balance on account
  349.    */
  350.   function user_has_gv_account($c_id) {
  351.     global $db;
  352.     $gv_result = $db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$c_id . "'");
  353.     if ($gv_result->RecordCount() > 0) {
  354.       return $gv_result->fields['amount'];
  355.     }
  356.     return 0; // use 0 because 'false' was preventing checkout_payment from continuing
  357.   }
  358.   /**
  359.    * Recalculates base order-total amount for use in deduction calculations
  360.    */
  361.   function get_order_total() {
  362.     global $order;
  363.     $order_total = $order->info['total'];
  364.     // if we are not supposed to include tax in credit calculations, subtract it out
  365.     if ($this->include_tax != 'true') $order_total -= $order->info['tax'];
  366.     // if we are not supposed to include shipping amount in credit calcs, subtract it out
  367.     if ($this->include_shipping != 'true') $order_total -= $order->info['shipping_cost'];
  368.     $order_total = $order->info['total'];
  369.  
  370.     // check gv_amount in cart and do not allow GVs to pay for GVs
  371.     $chk_gv_amount = 0;
  372.     $chk_products = $_SESSION['cart']->get_products();
  373.     for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
  374.       if (preg_match('/^GIFT/', addslashes($chk_products[$i]['model']))) {
  375.         // determine how much GV was purchased
  376.         $chk_gv_amount += ($chk_products[$i]['price'] * $chk_products[$i]['quantity']);
  377.       }
  378.     }
  379.     // reduce Order Total less GVs
  380.     $order_total = ($order_total - $chk_gv_amount);
  381. //echo 'GV chk_gv_amount: ' . $chk_gv_amount . ' $order_total: ' . $order_total . '<br>';
  382.  
  383.     return $order_total;
  384.   }
  385.   /**
  386.    * Enter description here...
  387.    *
  388.    * @return unknown
  389.    */
  390.   function check() {
  391.     global $db;
  392.     if (!isset($this->check)) {
  393.       $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_GV_STATUS'");
  394.       $this->check = $check_query->RecordCount();
  395.     }
  396.  
  397.     return $this->check;
  398.   }
  399.   /**
  400.    * Enter description here...
  401.    *
  402.    * @return unknown
  403.    */
  404.   function keys() {
  405.     return array('MODULE_ORDER_TOTAL_GV_STATUS', 'MODULE_ORDER_TOTAL_GV_SORT_ORDER', 'MODULE_ORDER_TOTAL_GV_QUEUE', 'MODULE_ORDER_TOTAL_GV_INC_SHIPPING', 'MODULE_ORDER_TOTAL_GV_INC_TAX', 'MODULE_ORDER_TOTAL_GV_CALC_TAX', 'MODULE_ORDER_TOTAL_GV_TAX_CLASS', 'MODULE_ORDER_TOTAL_GV_CREDIT_TAX',  'MODULE_ORDER_TOTAL_GV_ORDER_STATUS_ID');
  406.   }
  407.   /**
  408.    * Enter description here...
  409.    *
  410.    */
  411.   function install() {
  412.     global $db;
  413.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_GV_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
  414.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_GV_SORT_ORDER', '840', 'Sort order of display.', '6', '2', now())");
  415.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Queue Purchases', 'MODULE_ORDER_TOTAL_GV_QUEUE', 'true', 'Do you want to queue purchases of the Gift Voucher?', '6', '3','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
  416.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_ORDER_TOTAL_GV_INC_SHIPPING', 'true', 'Include Shipping in calculation', '6', '5', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
  417.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_GV_INC_TAX', 'false', 'Include Tax in calculation.', '6', '6','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
  418.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_GV_CALC_TAX', 'None', 'Re-Calculate Tax', '6', '7','zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
  419.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_GV_TAX_CLASS', '0', 'Use the following tax class when treating Gift Voucher as Credit Note.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
  420.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Credit including Tax', 'MODULE_ORDER_TOTAL_GV_CREDIT_TAX', 'false', 'Add tax to purchased Gift Voucher when crediting to Account', '6', '8','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
  421.     $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_ORDER_TOTAL_GV_ORDER_STATUS_ID', '0', 'Set the status of orders made where GV covers full payment', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
  422.   }
  423.   /**
  424.    * Enter description here...
  425.    *
  426.    */
  427.   function remove() {
  428.     global $db;
  429.     $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  430.   }
  431. }
  432.