Changed the list of payment types to be dynamically generated. This works OK, but the list is longer than is probably useful, and more importantly, some of these types need to be associated with a lease, such as a security deposit. Not sure how I'll handle that.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@289 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -170,24 +170,21 @@ function addPaymentSource(flash) {
|
||||
|
||||
'<DIV ID="payment-div-%{id}">' +
|
||||
<?php
|
||||
|
||||
$types = array();
|
||||
foreach(array('Cash', 'Check', 'Money Order', 'ACH', /*'Credit Card'*/ 'Concession') AS $name) {
|
||||
$type = preg_replace("/ /", "", strtolower($name));
|
||||
$acct = $name;
|
||||
$types[] = array('key' => $type, 'name' => $name, 'acct' => $acct);
|
||||
}
|
||||
|
||||
foreach ($types AS $type) {
|
||||
$div = '<DIV>';
|
||||
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][account_name]"';
|
||||
$div .= ' ONCLICK="switchPaymentType(\\\'payment-type-div\\\', %{id}, \\\''.$type['key'].'\\\')"';
|
||||
$div .= ' CLASS="payment-radio-%{id}" ID="payment-radio-%{id}-'.$type['key'].'"';
|
||||
$div .= ' VALUE="'.$type['acct'].'" ' . ($type['name'] == 'Cash' ? 'CHECKED ' : '') . '/>';
|
||||
$div .= ' <LABEL FOR="payment-radio-%{id}-'.$type['key'].'">'.$type['name'].'</LABEL>';
|
||||
$div .= '</DIV>';
|
||||
echo "'$div' +\n";
|
||||
}
|
||||
echo FormatHelper::phpVarToJavascript
|
||||
($form->input('LedgerEntry.%{id}.account_id',
|
||||
array('type' => 'radio',
|
||||
'separator' => '<BR>',
|
||||
'onclick' => ('switchPaymentType(' .
|
||||
'\\\'payment-type-div\\\', ' .
|
||||
'%{id}, ' .
|
||||
'$(this).attr("id")' .
|
||||
')' .
|
||||
//' return false;'
|
||||
''
|
||||
),
|
||||
'legend' => false,
|
||||
'value' => $defaultAccount,
|
||||
'options' => $paymentAccounts))) . "+\n";
|
||||
?>
|
||||
'</DIV>' +
|
||||
|
||||
@@ -199,9 +196,9 @@ function addPaymentSource(flash) {
|
||||
'</DIV>' +
|
||||
|
||||
<?php
|
||||
foreach ($types AS $type) {
|
||||
foreach ($paymentAccounts AS $account_id => $name) {
|
||||
$div = '<DIV';
|
||||
$div .= ' ID="payment-type-div-%{id}-'.$type['key'].'"';
|
||||
$div .= ' ID="payment-type-div-%{id}-'.$account_id.'"';
|
||||
$div .= ' CLASS="payment-type-div-%{id}"';
|
||||
$div .= ' STYLE="display:none;">';
|
||||
$div .= '</DIV>';
|
||||
@@ -213,18 +210,18 @@ function addPaymentSource(flash) {
|
||||
);
|
||||
}
|
||||
|
||||
function switchPaymentType(paymentid_base, paymentid, type) {
|
||||
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
||||
//alert(paymentid_base + ";\n" + paymentid + ";\n" + radioid);
|
||||
$("."+paymentid_base+"-"+paymentid).slideUp();
|
||||
$("."+paymentid_base+"-"+paymentid).html('');
|
||||
|
||||
var html;
|
||||
var type = $("#"+radioid+ " + label").html();
|
||||
var account_id = $("#"+radioid).val();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 'cash':
|
||||
return;
|
||||
|
||||
case 'check':
|
||||
case 'Check':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-check-number-'+paymentid+'">Check Number</LABEL>' +
|
||||
@@ -234,7 +231,7 @@ function switchPaymentType(paymentid_base, paymentid, type) {
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'moneyorder':
|
||||
case 'Money Order':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-moneyorder-number-'+paymentid+'">Money Order Number</LABEL>' +
|
||||
@@ -244,7 +241,7 @@ function switchPaymentType(paymentid_base, paymentid, type) {
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'ach':
|
||||
case 'ACH':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-ach-routing-'+paymentid+'">Routing Number</LABEL>' +
|
||||
@@ -261,7 +258,7 @@ function switchPaymentType(paymentid_base, paymentid, type) {
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'creditcard':
|
||||
case 'Credit Card':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-creditcard-account-'+paymentid+'">Account Number</LABEL>' +
|
||||
@@ -285,16 +282,12 @@ function switchPaymentType(paymentid_base, paymentid, type) {
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'concession':
|
||||
return;
|
||||
|
||||
default:
|
||||
html = '<H2>INVALID TYPE ('+type+')</H2>';
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+type).html(html);
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+type).slideDown();
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).html(html);
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).slideDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user