This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/core/list_card_type_menu.inc.php
2011-05-03 09:49:01 +10:00

84 lines
2.0 KiB
PHP

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Unknown
*/
/**
* The main AgileBill List Credit Card Method
*
* @package AgileBill
* @subpackage Unknown
*/
function list_card_type_menu($default_selected,$checkout_id,$field,$class,$all=false) {
global $C_translate;
# Define default list of accepted CC types
$def_accepted_arr = array(
'visa',
'mc',
'amex',
'discover',
'delta',
'solo',
'switch',
'jcb',
'diners',
'carteblanche',
'enroute');
$accepted_arr = array();
$db = &DB();
$rs = $db->Execute($q=sqlSelect($db,'checkout','plugin_data',$checkout_id ? array('id'=>$checkout_id) : ''));
if ($rs == false || $rs->RecordCount() == 0)
$accepted_arr = $def_accepted_arr;
else
while (! $rs->EOF) {
$cfg = unserialize($rs->fields['plugin_data']);
if ($cfg['card_type'])
$accepted_arr = array_merge($accepted_arr,$cfg['card_type']);
$rs->MoveNext();
}
if (! count($accepted_arr))
$accepted_arr = $def_accepted_arr;
else
$accepted_arr = array_values(array_unique($accepted_arr));
asort($accepted_arr);
$data = sprintf('<select id="%s" name="%s">',$field,$field);
if ($all)
$data .= '<option value="" selected>&nbsp;</option>';
foreach ($accepted_arr as $card)
$data .= sprintf('<option value="%s"%s>%s</option>',$card,($default_selected == $card) ? ' selected' : '',$C_translate->translate('card_type_'.$card,'checkout'));
$data .= '</select>';
return $data;
}
?>