| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: fee.module,v 1.1.2.2 2007/09/17 13:52:07 kbahey Exp $ |
// $Id: fee.module,v 1.1.2.3 2008/05/14 03:15:57 kbahey Exp $ |
| 4 |
|
|
| 5 |
// Variables |
// Variables |
| 6 |
define('FEE_EMAIL', 'fee_email'); |
define('FEE_EMAIL', 'fee_email'); |
| 8 |
define('FEE_CURRENCY', 'fee_currency'); |
define('FEE_CURRENCY', 'fee_currency'); |
| 9 |
define('FEE_RECEIPT_PAGE', 'fee_receipt_page'); |
define('FEE_RECEIPT_PAGE', 'fee_receipt_page'); |
| 10 |
define('FEE_RECEIPT_EMAIL', 'fee_receipt_email'); |
define('FEE_RECEIPT_EMAIL', 'fee_receipt_email'); |
| 11 |
|
define('FEE_ITEM_NAME', 'fee_item_name'); |
| 12 |
|
|
| 13 |
// Defaults |
// Defaults |
| 14 |
define('FEE_DEFAULT_EMAIL', 'donations@drupal.org'); |
define('FEE_DEFAULT_EMAIL', 'donations@drupal.org'); |
| 15 |
define('FEE_DEFAULT_AMOUNT', 60.00); |
define('FEE_DEFAULT_AMOUNT', 60.00); |
| 16 |
define('FEE_DEFAULT_CURRENCY', 'EUR'); |
define('FEE_DEFAULT_CURRENCY', 'EUR'); |
| 17 |
|
define('FEE_DEFAULT_ITEM_NAME', 'Registration fee'); |
| 18 |
define('FEE_DEFAULT_RECEIPT', ' |
define('FEE_DEFAULT_RECEIPT', ' |
| 19 |
Thank you for registering<br/> |
Thank you for registering<br/> |
| 20 |
|
Item: @item<br/> |
| 21 |
Date: @date<br/> |
Date: @date<br/> |
| 22 |
Payment method: @method<br/> |
Payment method: @method<br/> |
| 23 |
Amount: @amount<br/> |
Amount: @amount<br/> |
| 35 |
|
|
| 36 |
function fee_get_methods() { |
function fee_get_methods() { |
| 37 |
return array( |
return array( |
| 38 |
FEE_METHOD_PAYPAL => t('Paypal'), |
FEE_METHOD_PAYPAL => t('Credit Card/Paypal'), |
| 39 |
FEE_METHOD_CHEQUE => t('Cheque'), |
FEE_METHOD_CHEQUE => t('Cheque'), |
| 40 |
FEE_METHOD_CASH => t('Cash'), |
FEE_METHOD_CASH => t('Cash'), |
| 41 |
FEE_METHOD_BANK_TRANSFER => t('Bank transfer'), |
FEE_METHOD_BANK_TRANSFER => t('Bank transfer'), |
| 57 |
|
|
| 58 |
function fee_settings() { |
function fee_settings() { |
| 59 |
$form[FEE_EMAIL] = array( |
$form[FEE_EMAIL] = array( |
| 60 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 61 |
'#title' => t('fees email address'), |
'#title' => t('fees email address'), |
| 62 |
'#default_value' => variable_get(FEE_EMAIL, FEE_DEFAULT_EMAIL), |
'#default_value' => variable_get(FEE_EMAIL, FEE_DEFAULT_EMAIL), |
| 63 |
'#description' => t('Email address to send Paypal payments to.'), |
'#description' => t('Email address to send Paypal payments to.'), |
| 64 |
); |
); |
| 65 |
|
|
| 66 |
$form[FEE_AMOUNT] = array( |
$form[FEE_AMOUNT] = array( |
| 67 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 68 |
'#title' => t('Amount to collect as a fee'), |
'#title' => t('Amount to collect as a fee'), |
| 69 |
'#default_value' => variable_get(FEE_AMOUNT, FEE_DEFAULT_AMOUNT), |
'#default_value' => variable_get(FEE_AMOUNT, FEE_DEFAULT_AMOUNT), |
| 70 |
'#description' => t('Amount to collect as a fee from each user. Do not change this after the first person pays.'), |
'#description' => t('Amount to collect as a fee from each user. Do not change this after the first person pays.'), |
| 71 |
); |
); |
| 72 |
|
|
| 73 |
|
$form[FEE_ITEM_NAME] = array( |
| 74 |
|
'#type' => 'textfield', |
| 75 |
|
'#title' => t('Item name'), |
| 76 |
|
'#default_value' => variable_get(FEE_ITEM_NAME, FEE_DEFAULT_ITEM_NAME), |
| 77 |
|
'#description' => t('Item name as it will appear to the user in Paypal when paying.'), |
| 78 |
|
); |
| 79 |
|
|
| 80 |
|
|
| 81 |
$form[FEE_CURRENCY] = array( |
$form[FEE_CURRENCY] = array( |
| 82 |
'#type' => 'select', |
'#type' => 'select', |
| 83 |
'#title' => t('Currency'), |
'#title' => t('Currency'), |
| 84 |
'#default_value' => variable_get(FEE_CURRENCY, FEE_DEFAULT_CURRENCY), |
'#default_value' => variable_get(FEE_CURRENCY, FEE_DEFAULT_CURRENCY), |
| 85 |
'#options' => fee_get_currency(), |
'#options' => fee_get_currency(), |
| 86 |
'#description' => t('Amount to collect as a fee from each user. Do not change this after the first person pays.'), |
'#description' => t('Amount to collect as a fee from each user. Do not change this after the first person pays.'), |
| 87 |
); |
); |
| 88 |
|
|
| 89 |
$form[FEE_RECEIPT_PAGE] = array( |
$form[FEE_RECEIPT_PAGE] = array( |
| 90 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 91 |
'#title' => t('Template for receipt page'), |
'#title' => t('Template for receipt page'), |
| 92 |
'#default_value' => variable_get(FEE_RECEIPT_PAGE, FEE_DEFAULT_RECEIPT), |
'#default_value' => variable_get(FEE_RECEIPT_PAGE, FEE_DEFAULT_RECEIPT), |
| 93 |
'#description' => t('Template for receipt when displayed on the web site as a page. You can use any HTML, including the following tokens Date: @date, Payment method: @method, Amount: @amount, Name: @name, Email: @mail'), |
'#description' => t('Template for receipt when displayed on the web site as a page. You can use any HTML, including the following tokens Date: @date, Item: @item, Payment method: @method, Amount: @amount, Name: @name, Email: @mail'), |
| 94 |
); |
); |
| 95 |
|
|
| 96 |
$form[FEE_RECEIPT_EMAIL] = array( |
$form[FEE_RECEIPT_EMAIL] = array( |
| 97 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 98 |
'#title' => t('Template for receipt email'), |
'#title' => t('Template for receipt email'), |
| 99 |
'#default_value' => variable_get(FEE_RECEIPT_EMAIL, FEE_DEFAULT_RECEIPT), |
'#default_value' => variable_get(FEE_RECEIPT_EMAIL, FEE_DEFAULT_RECEIPT), |
| 100 |
'#description' => t('Template for receipt when emailed to the user. You can use any HTML, including the following tokens Date: @date, Payment method: @method, Amount: @amount, Name: @name, Email: @mail'), |
'#description' => t('Template for receipt when emailed to the user. You can use any HTML, including the following tokens Date: @date, Item: @item, Payment method: @method, Amount: @amount, Name: @name, Email: @mail'), |
| 101 |
); |
); |
| 102 |
|
|
| 103 |
return system_settings_form($form); |
return system_settings_form($form); |
| 515 |
'@amount' => _fee_format_amount($row->amount, $row->currency), |
'@amount' => _fee_format_amount($row->amount, $row->currency), |
| 516 |
'@method' => $methods[$row->method_id], |
'@method' => $methods[$row->method_id], |
| 517 |
'@date' => format_date($row->time_paid, 'custom', 'Y-m-d'), |
'@date' => format_date($row->time_paid, 'custom', 'Y-m-d'), |
| 518 |
|
'@item' => variable_get(FEE_ITEM_NAME, FEE_DEFAULT_ITEM_NAME), |
| 519 |
)); |
)); |
| 520 |
} |
} |
| 521 |
return $output; |
return $output; |
| 620 |
); |
); |
| 621 |
$form['item_name'] = array( |
$form['item_name'] = array( |
| 622 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 623 |
'#value' => 'Registration fee', |
'#value' => variable_get(FEE_ITEM_NAME, FEE_DEFAULT_ITEM_NAME), |
| 624 |
'#name' => 'item_name', |
'#name' => 'item_name', |
| 625 |
); |
); |
| 626 |
$form['no_shipping'] = array( |
$form['no_shipping'] = array( |
| 645 |
); |
); |
| 646 |
$form['submit'] = array( |
$form['submit'] = array( |
| 647 |
'#type' => 'submit', |
'#type' => 'submit', |
| 648 |
'#value' => t('Pay'), |
'#value' => t('Pay via Credit Card or Paypal'), |
| 649 |
'#name' => 'submit', |
'#name' => 'submit', |
| 650 |
); |
); |
| 651 |
} |
} |