Begin the move from having receipts generated based on 'collectable' account, to being based on what the database considers to be a form of tender. This has the excellent benefit of removing all those hardcoded data1/2 fields for each different tender type. That's all database driven now. There is more to do, but this is a good step forward.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@382 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -367,21 +367,29 @@ class CustomersController extends AppController {
|
|||||||
$this->Customer->recursive = -1;
|
$this->Customer->recursive = -1;
|
||||||
$customer = $this->Customer->read(null, $id);
|
$customer = $this->Customer->read(null, $id);
|
||||||
$customer = $customer['Customer'];
|
$customer = $customer['Customer'];
|
||||||
$unreconciled = $this->Customer->findUnreconciledLedgerEntries($id);
|
$unreconciled = $this->Customer->unreconciledCharges($id);
|
||||||
$charges = $unreconciled['debit'];
|
//pr($unreconciled);
|
||||||
|
$charges = $unreconciled['entries'];
|
||||||
|
$stats = $unreconciled['summary']['Charge'];
|
||||||
|
// Kludge until we update receipt to have the unpaid
|
||||||
|
// charges grid generated from a dynamic query instead
|
||||||
|
// of simply pre-providing the list of charge IDs
|
||||||
|
foreach ($charges AS &$charge)
|
||||||
|
$charge['id'] = $charge['StatementEntry']['id'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$customer = null;
|
$customer = null;
|
||||||
$charges = array('balance' => 0, 'entry' => array());
|
$charges = array();
|
||||||
|
$stats = array('balance' => 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$A = new Account();
|
$TT = new TenderType();
|
||||||
$payment_accounts = $A->paymentAccounts();
|
$payment_types = $TT->paymentTypes();
|
||||||
$default_account = $A->cashAccountID();
|
$default_type = $TT->defaultPaymentType();
|
||||||
$this->set(compact('payment_accounts', 'default_account'));
|
$this->set(compact('payment_types', 'default_type'));
|
||||||
|
|
||||||
$title = ($customer['name'] . ': Payment Entry');
|
$title = ($customer['name'] . ': Payment Entry');
|
||||||
$this->set(compact('customer', 'charges', 'title'));
|
$this->set(compact('customer', 'charges', 'stats', 'title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ function verifyRequest(formData, jqForm, options) {
|
|||||||
// formData is an array; here we use $.param to convert it to a string to display it
|
// formData is an array; here we use $.param to convert it to a string to display it
|
||||||
// but the form plugin does this for you automatically when it submits the data
|
// but the form plugin does this for you automatically when it submits the data
|
||||||
//var_dump(formData);
|
//var_dump(formData);
|
||||||
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||||
$('#request-debug').html('Ommitted');
|
//$('#request-debug').html('Ommitted');
|
||||||
//return false;
|
return false;
|
||||||
|
|
||||||
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
@@ -147,8 +147,13 @@ function addPaymentSource(flash) {
|
|||||||
|
|
||||||
'<DIV ID="payment-div-%{id}">' +
|
'<DIV ID="payment-div-%{id}">' +
|
||||||
<?php
|
<?php
|
||||||
|
// Rearrange to be of the form (id => name)
|
||||||
|
$radioOptions = array();
|
||||||
|
foreach ($paymentTypes AS $type)
|
||||||
|
$radioOptions[$type['TenderType']['id']] = $type['TenderType']['name'];
|
||||||
|
|
||||||
echo FormatHelper::phpVarToJavascript
|
echo FormatHelper::phpVarToJavascript
|
||||||
($form->input('LedgerEntry.%{id}.account_id',
|
($form->input('Entry.%{id}.tender_type_id',
|
||||||
array('type' => 'radio',
|
array('type' => 'radio',
|
||||||
'separator' => '<BR>',
|
'separator' => '<BR>',
|
||||||
'onclick' => ('switchPaymentType(' .
|
'onclick' => ('switchPaymentType(' .
|
||||||
@@ -160,73 +165,36 @@ function addPaymentSource(flash) {
|
|||||||
''
|
''
|
||||||
),
|
),
|
||||||
'legend' => false,
|
'legend' => false,
|
||||||
'value' => $defaultAccount,
|
'value' => $defaultType,
|
||||||
'options' => $paymentAccounts))) . "+\n";
|
'options' => $radioOptions))) . "+\n";
|
||||||
?>
|
?>
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
|
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="20"' +
|
' <INPUT TYPE="text" SIZE="20"' +
|
||||||
' NAME="data[LedgerEntry][%{id}][amount]"' +
|
' NAME="data[Entry][%{id}][amount]"' +
|
||||||
' ID="payment-amount-%{id}" />' +
|
' ID="payment-amount-%{id}" />' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($paymentAccounts AS $account_id => $name) {
|
foreach ($paymentTypes AS $type) {
|
||||||
|
$type = $type['TenderType'];
|
||||||
$div = '<DIV';
|
$div = '<DIV';
|
||||||
$div .= ' ID="payment-type-div-%{id}-'.$account_id.'"';
|
$div .= ' ID="payment-type-div-%{id}-'.$type['id'].'"';
|
||||||
$div .= ' CLASS="payment-type-div-%{id}"';
|
$div .= ' CLASS="payment-type-div-%{id}"';
|
||||||
$div .= ' STYLE="display:none;">';
|
if ($type['id'] != $defaultType)
|
||||||
|
$div .= ' STYLE="display:none;"';
|
||||||
|
$div .= '>';
|
||||||
|
|
||||||
if ($name == 'Check') {
|
for ($i=1; $i<=4; ++$i) {
|
||||||
$div .= '<DIV CLASS="input text required">';
|
if (!empty($type["data{$i}_name"])) {
|
||||||
$div .= ' <LABEL FOR="payment-check-number-%{id}">Check Number</LABEL>';
|
$div .= '<DIV CLASS="input text required">';
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
$div .= ' <LABEL FOR="payment-data'.$i.'-%{id}">'.$type["data{$i}_name"].'</LABEL>';
|
||||||
$div .= ' ID="payment-check-number-%{id}" />';
|
$div .= ' <INPUT TYPE="text" SIZE="20" NAME="data[Entry][%{id}][type]['.$type['id'].'][data'.$i.']"';
|
||||||
$div .= '</DIV>';
|
$div .= ' ID="payment-data'.$i.'-%{id}" />';
|
||||||
}
|
$div .= '</DIV>';
|
||||||
elseif ($name == 'Money Order') {
|
}
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-moneyorder-number-%{id}">Money Order Number</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
|
||||||
$div .= ' ID="payment-moneyorder-number-%{id}" />';
|
|
||||||
$div .= '</DIV>';
|
|
||||||
}
|
|
||||||
elseif ($name == 'ACH') {
|
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-ach-routing-%{id}">Routing Number</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="9" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
|
||||||
$div .= ' ID="payment-ach-routing-%{id}" />';
|
|
||||||
$div .= '</DIV>';
|
|
||||||
|
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-ach-account-%{id}">Account Number</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="17" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data2]"';
|
|
||||||
$div .= ' ID="payment-ach-account-%{id}" />';
|
|
||||||
$div .= '</DIV>';
|
|
||||||
}
|
|
||||||
elseif ($name == 'Credit Card') {
|
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-creditcard-account-%{id}">Account Number</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="16" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
|
||||||
$div .= ' ID="payment-creditcard-account-%{id}" />';
|
|
||||||
$div .= '</DIV>';
|
|
||||||
|
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-creditcard-expiration-%{id}">Expiration Date</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data2]"';
|
|
||||||
$div .= ' ID="payment-creditcard-expiration-%{id}" />';
|
|
||||||
$div .= ' </DIV>';
|
|
||||||
|
|
||||||
$div .= '<DIV CLASS="input text required">';
|
|
||||||
$div .= ' <LABEL FOR="payment-creditcard-cvv2-%{id}">CVV2 Code</LABEL>';
|
|
||||||
$div .= ' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data3]"';
|
|
||||||
$div .= ' ID="payment-creditcard-cvv2-%{id}" />';
|
|
||||||
$div .= '</DIV>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$div .= '</DIV>';
|
$div .= '</DIV>';
|
||||||
@@ -240,8 +208,8 @@ function addPaymentSource(flash) {
|
|||||||
|
|
||||||
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
||||||
$("."+paymentid_base+"-"+paymentid).slideUp();
|
$("."+paymentid_base+"-"+paymentid).slideUp();
|
||||||
var account_id = $("#"+radioid).val();
|
var type_id = $("#"+radioid).val();
|
||||||
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).slideDown();
|
$("#"+paymentid_base+"-"+paymentid+"-"+type_id).slideDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -321,7 +289,7 @@ echo ('<DIV CLASS="receipt grid-selection-text">' .
|
|||||||
'</DIV>' . "\n");
|
'</DIV>' . "\n");
|
||||||
|
|
||||||
|
|
||||||
echo $this->element('ledger_entries', array
|
echo $this->element('statement_entries', array
|
||||||
(// Element configuration
|
(// Element configuration
|
||||||
'account_ftype' => 'credit',
|
'account_ftype' => 'credit',
|
||||||
'limit' => 8,
|
'limit' => 8,
|
||||||
@@ -332,7 +300,7 @@ echo $this->element('ledger_entries', array
|
|||||||
'grid_div_id' => 'charge-entries',
|
'grid_div_id' => 'charge-entries',
|
||||||
'grid_div_class' => 'text-below',
|
'grid_div_class' => 'text-below',
|
||||||
'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
||||||
'rows' => $charges['entry'],
|
'rows' => $charges,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -411,7 +379,7 @@ echo $form->submit('Generate Receipt') . "\n";
|
|||||||
"<?php echo $customer['id']; ?>" +
|
"<?php echo $customer['id']; ?>" +
|
||||||
'</A>');
|
'</A>');
|
||||||
$("#receipt-customer-name").html("<?php echo $customer['name']; ?>");
|
$("#receipt-customer-name").html("<?php echo $customer['name']; ?>");
|
||||||
$("#receipt-balance").html(fmtCurrency("<?php echo $charges['balance']; ?>"));
|
$("#receipt-balance").html(fmtCurrency("<?php echo $stats['balance']; ?>"));
|
||||||
onGridState(null, 'hidden');
|
onGridState(null, 'hidden');
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
onGridState(null, 'visible');
|
onGridState(null, 'visible');
|
||||||
|
|||||||
Reference in New Issue
Block a user