Getting the receipt/payment data in order, getting ready to save (or at least experiment with save.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@157 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
class TransactionsController extends AppController {
|
class TransactionsController extends AppController {
|
||||||
|
|
||||||
|
var $components = array('RequestHandler');
|
||||||
|
|
||||||
var $sidemenu_links =
|
var $sidemenu_links =
|
||||||
array(array('name' => 'Transactions', 'header' => true),
|
array(array('name' => 'Transactions', 'header' => true),
|
||||||
array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')),
|
array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')),
|
||||||
@@ -92,4 +94,20 @@ class TransactionsController extends AppController {
|
|||||||
$title = 'Transaction #' . $transaction['Transaction']['id'];
|
$title = 'Transaction #' . $transaction['Transaction']['id'];
|
||||||
$this->set(compact('transaction', 'title', 'total'));
|
$this->set(compact('transaction', 'title', 'total'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* action: postReceipt
|
||||||
|
* - handles the creation of a payment receipt
|
||||||
|
*/
|
||||||
|
|
||||||
|
function postReceipt() {
|
||||||
|
if ($this->RequestHandler->isPost()) {
|
||||||
|
pr($this->data);
|
||||||
|
//$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
$this->autoRender = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ $grid_setup['onSelectRow'] = array
|
|||||||
function resetPaymentForm() {
|
function resetPaymentForm() {
|
||||||
// Get a clean slate for our payments
|
// Get a clean slate for our payments
|
||||||
$('#payments').html('');
|
$('#payments').html('');
|
||||||
$('#payment-id').val(1);
|
$('#payment-id').val(0);
|
||||||
addPaymentSource(false);
|
addPaymentSource(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,16 +176,27 @@ $grid_setup['onSelectRow'] = array
|
|||||||
|
|
||||||
'<DIV ID="payment-type-div-%{id}">' +
|
'<DIV ID="payment-type-div-%{id}">' +
|
||||||
<?php
|
<?php
|
||||||
|
/* REVISIT <AP> 20090616:
|
||||||
|
* MUST GET THIS FROM THE DATABASE!!
|
||||||
|
* HARDCODED VALUES BAD... VERY BAD...
|
||||||
|
*/
|
||||||
|
$monetary_type_ids = array('Cash' => 2,
|
||||||
|
'Check' => 3,
|
||||||
|
'Money Order' => 4,
|
||||||
|
'ACH' => 5,
|
||||||
|
'Credit Card' => 7,
|
||||||
|
);
|
||||||
|
|
||||||
$types = array();
|
$types = array();
|
||||||
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name)
|
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name)
|
||||||
$types[preg_replace("/ /", "", strtolower($name))] = $name;
|
$types[preg_replace("/ /", "", strtolower($name))] = $name;
|
||||||
|
|
||||||
foreach ($types AS $type => $name) {
|
foreach ($types AS $type => $name) {
|
||||||
$div = '<DIV>';
|
$div = '<DIV>';
|
||||||
$div .= '<INPUT TYPE="radio" NAME="data[Source][%{id}][type]"';
|
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][MonetarySource][monetary_type_id]"';
|
||||||
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"';
|
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"';
|
||||||
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"';
|
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"';
|
||||||
$div .= ' VALUE="'.$type.'" ' . ($type == 'cash' ? 'CHECKED ' : '') . '/>';
|
$div .= ' VALUE="'.$monetary_type_ids[$name].'" ' . ($name == 'Cash' ? 'CHECKED ' : '') . '/>';
|
||||||
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>';
|
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>';
|
||||||
$div .= '</DIV>';
|
$div .= '</DIV>';
|
||||||
echo "'$div' +\n";
|
echo "'$div' +\n";
|
||||||
@@ -196,7 +207,7 @@ $grid_setup['onSelectRow'] = array
|
|||||||
'<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[Source][%{id}][amount]"' +
|
' NAME="data[LedgerEntry][%{id}][amount]"' +
|
||||||
' ID="payment-amount-%{id}" />' +
|
' ID="payment-amount-%{id}" />' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
@@ -233,7 +244,8 @@ function switchPaymentType(paymentid, type) {
|
|||||||
html =
|
html =
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-check-number-'+paymentid+'">Check Number</LABEL>' +
|
' <LABEL FOR="payment-check-number-'+paymentid+'">Check Number</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="6" NAME="data[Source]['+paymentid+'][check][number]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]"' +
|
||||||
' ID="payment-check-number-'+paymentid+'" />' +
|
' ID="payment-check-number-'+paymentid+'" />' +
|
||||||
'</DIV>';
|
'</DIV>';
|
||||||
break;
|
break;
|
||||||
@@ -242,7 +254,8 @@ function switchPaymentType(paymentid, type) {
|
|||||||
html =
|
html =
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-moneyorder-number-'+paymentid+'">Money Order Number</LABEL>' +
|
' <LABEL FOR="payment-moneyorder-number-'+paymentid+'">Money Order Number</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="6" NAME="data[Source]['+paymentid+'][moneyorder][number]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]"' +
|
||||||
' ID="payment-moneyorder-number-'+paymentid+'" />' +
|
' ID="payment-moneyorder-number-'+paymentid+'" />' +
|
||||||
'</DIV>';
|
'</DIV>';
|
||||||
break;
|
break;
|
||||||
@@ -251,13 +264,15 @@ function switchPaymentType(paymentid, type) {
|
|||||||
html =
|
html =
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-ach-routing-'+paymentid+'">Routing Number</LABEL>' +
|
' <LABEL FOR="payment-ach-routing-'+paymentid+'">Routing Number</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="9" NAME="data[Source]['+paymentid+'][ach][routing]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="9" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]"' +
|
||||||
' ID="payment-ach-routing-'+paymentid+'" />' +
|
' ID="payment-ach-routing-'+paymentid+'" />' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-ach-account-'+paymentid+'">Account Number</LABEL>' +
|
' <LABEL FOR="payment-ach-account-'+paymentid+'">Account Number</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="17" NAME="data[Source]['+paymentid+'][ach][account]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="17" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]"' +
|
||||||
' ID="payment-ach-account-'+paymentid+'" />' +
|
' ID="payment-ach-account-'+paymentid+'" />' +
|
||||||
'</DIV>';
|
'</DIV>';
|
||||||
break;
|
break;
|
||||||
@@ -266,19 +281,22 @@ function switchPaymentType(paymentid, type) {
|
|||||||
html =
|
html =
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-creditcard-account-'+paymentid+'">Account Number</LABEL>' +
|
' <LABEL FOR="payment-creditcard-account-'+paymentid+'">Account Number</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="16" NAME="data[Source]['+paymentid+'][creditcard][account]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="16" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]' +
|
||||||
' ID="payment-creditcard-account-'+paymentid+'" />' +
|
' ID="payment-creditcard-account-'+paymentid+'" />' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-creditcard-expiration-'+paymentid+'">Expiration Date</LABEL>' +
|
' <LABEL FOR="payment-creditcard-expiration-'+paymentid+'">Expiration Date</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="10" NAME="data[Source]['+paymentid+'][creditcard][expiration]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][comment]' +
|
||||||
' ID="payment-creditcard-expiration-'+paymentid+'" />' +
|
' ID="payment-creditcard-expiration-'+paymentid+'" />' +
|
||||||
' </DIV>' +
|
' </DIV>' +
|
||||||
|
|
||||||
'<DIV CLASS="input text required">' +
|
'<DIV CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-creditcard-cvv2-'+paymentid+'">CVV2 Code</LABEL>' +
|
' <LABEL FOR="payment-creditcard-cvv2-'+paymentid+'">CVV2 Code</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="10" NAME="data[Source]['+paymentid+'][creditcard][cvv2]"' +
|
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||||
|
' <INPUT TYPE="text" SIZE="10" NAME=data[LedgerEntry]['+paymentid+'][MonetarySource][comment]' +
|
||||||
' ID="payment-creditcard-cvv2-'+paymentid+'" />' +
|
' ID="payment-creditcard-cvv2-'+paymentid+'" />' +
|
||||||
'</DIV>';
|
'</DIV>';
|
||||||
break;
|
break;
|
||||||
@@ -300,7 +318,7 @@ function switchPaymentType(paymentid, type) {
|
|||||||
//echo '<DIV ID="dialog">' . "\n";
|
//echo '<DIV ID="dialog">' . "\n";
|
||||||
|
|
||||||
echo $this->element('customers',
|
echo $this->element('customers',
|
||||||
array('caption' => '<A HREF="#" ONCLICK="$(\\\'.HeaderButton\\\').click(); return false;">Select Customer</A>',
|
array('caption' => '<A HREF="#" ONCLICK="$(\'.HeaderButton\').click(); return false;">Select Customer</A>',
|
||||||
'limit' => 7,
|
'limit' => 7,
|
||||||
'grid_setup' => $grid_setup,
|
'grid_setup' => $grid_setup,
|
||||||
));
|
));
|
||||||
@@ -311,14 +329,55 @@ echo ('<H2><SPAN id="payment_customer">' .
|
|||||||
: 'Please select customer') .
|
: 'Please select customer') .
|
||||||
'</SPAN></H2>' . "\n");
|
'</SPAN></H2>' . "\n");
|
||||||
|
|
||||||
//echo $form->create(null, array('id' => 'payment-form', 'action' => 'other'));
|
echo $form->create(null, array('id' => 'payment-form',
|
||||||
echo $form->create(null, array('id' => 'payment-form', 'url' => 'http://localhost/vars.php'));
|
'url' => array('controller' => 'transactions',
|
||||||
|
'action' => 'postReceipt')));
|
||||||
|
|
||||||
|
/***************************************************
|
||||||
|
* Post data should look like this:
|
||||||
|
*
|
||||||
|
* data => Array
|
||||||
|
* (
|
||||||
|
* [Transaction] => Array
|
||||||
|
* (
|
||||||
|
* stamp => <Transaction Time Stamp>
|
||||||
|
* through_date => <Transaction Through Date, if any>
|
||||||
|
* due_date => <Transaction Due Date, if any>
|
||||||
|
* comment => <Transaction Comment>
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* [LedgerEntry] => Array
|
||||||
|
* (
|
||||||
|
* [0] => Array
|
||||||
|
* (
|
||||||
|
* name => <NOT TO INCLUDE??>
|
||||||
|
* amount => <Payment Amount>
|
||||||
|
* debit_ledger_id => <ID of the debit account's current ledger>
|
||||||
|
* credit_ledger_id => <ID of the debit account's current ledger>
|
||||||
|
* comment => <Ledger Entry Comment>
|
||||||
|
*
|
||||||
|
* [MonetarySource] => Array
|
||||||
|
* (
|
||||||
|
* name => <Name (may be useless parameter)>
|
||||||
|
* monetary_type_id => <Monetary Type ID>
|
||||||
|
* comment => <Monetary Source Comment>
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* REVISIT: Reconciliations will be tricker.
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
***************************************************/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<input type="hidden" id="customer-id" name="data[Customer][id]" value="<?php echo $customer['Customer']['id']; ?>">
|
<input type="hidden" id="customer-id" name="data[Customer][id]" value="<?php echo $customer['Customer']['id']; ?>">
|
||||||
|
|
||||||
<fieldset CLASS="payment superset">
|
<fieldset CLASS="payment superset">
|
||||||
<legend>Payments</legend>
|
<legend>Payments</legend>
|
||||||
<input type="hidden" id="payment-id" value="1">
|
<input type="hidden" id="payment-id" value="0">
|
||||||
<div id="payments"></div>
|
<div id="payments"></div>
|
||||||
<fieldset> <legend>
|
<fieldset> <legend>
|
||||||
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
||||||
@@ -327,8 +386,8 @@ echo ('<H2><SPAN id="payment_customer">' .
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo 'Date: <input id="datepicker" name="data[Date]" type="text" /><BR>' . "\n";
|
echo 'Date: <input id="datepicker" name="data[Transaction][stamp]" type="text" /><BR>' . "\n";
|
||||||
echo 'Comment: <input id="comment" name="data[Comment]" type="text" SIZE=80 /><BR>' . "\n";
|
echo 'Comment: <input id="comment" name="data[Transaction][comment]" type="text" SIZE=80 /><BR>' . "\n";
|
||||||
echo $form->end('Post Payment');
|
echo $form->end('Post Payment');
|
||||||
|
|
||||||
//echo '</DIV>' . "\n"; // End of the dialog DIV
|
//echo '</DIV>' . "\n"; // End of the dialog DIV
|
||||||
|
|||||||
Reference in New Issue
Block a user