git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@155 97e9348a-65ac-dc4b-aefc-98561f571b83
388 lines
12 KiB
PHP
388 lines
12 KiB
PHP
<?php /* -*- mode:PHP -*- */ ?>
|
|
|
|
<div class="payment input">
|
|
|
|
<?php
|
|
; // Editor alignment
|
|
|
|
|
|
/**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
* Transaction Detail Main Section
|
|
*/
|
|
|
|
/* $rows = array(array('ID', $transaction['Transaction']['id']), */
|
|
/* array('Timestamp', FormatHelper::datetime($transaction['Transaction']['stamp'])), */
|
|
/* array('Through', FormatHelper::date($transaction['Transaction']['through_date'])), */
|
|
/* array('Due', FormatHelper::date($transaction['Transaction']['due_date'])), */
|
|
/* array('Comment', $transaction['Transaction']['comment'])); */
|
|
|
|
/* echo $this->element('table', */
|
|
/* array('class' => 'item transaction detail', */
|
|
/* 'caption' => 'Transaction Detail', */
|
|
/* 'rows' => $rows, */
|
|
/* 'column_class' => array('field', 'value'))); */
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
* Transaction Info Box
|
|
*/
|
|
|
|
?>
|
|
|
|
<!--
|
|
<DIV CLASS="infobox">
|
|
<DIV CLASS="summary grand total">
|
|
Total: <?php /*echo FormatHelper::currency($total);*/ ?>
|
|
</DIV>
|
|
</DIV>
|
|
-->
|
|
|
|
|
|
<?php
|
|
; // Editor alignment
|
|
|
|
/**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
*
|
|
*/
|
|
|
|
$grid_setup = array();
|
|
|
|
if (isset($customer['Customer']['id']))
|
|
$grid_setup['hiddengrid'] = true;
|
|
|
|
$grid_setup['onSelectRow'] = array
|
|
('--special' =>
|
|
'function(ids) { if (ids != null)' .
|
|
' {' .
|
|
// Set the customer id that will be returned with the form
|
|
' $("#customer-id").val(ids);' .
|
|
// Get the customer name from the grid
|
|
' $("#payment_customer").html($("#"+$(this).attr("id"))' .
|
|
' .getCell(ids, "Customer-name"));' .
|
|
// Replace that with just the text portion of the hyperlink
|
|
' $("#payment_customer").html("Receipt for "+ $("#payment_customer a").html());' .
|
|
' } }'
|
|
);
|
|
|
|
/* $grid_setup['loadComplete'] = array */
|
|
/* ('--special' => */
|
|
/* 'function() { ' . */
|
|
/* //' $("#"+$(this).attr("id")).setSelection($("#customer-id").val());' . */
|
|
/* ' $(\'#customers-list-jqGrid\').setSelection($(\'#customer-id\').val());' . */
|
|
/* ' $("#"+$(this).attr("id")).setCaption("Hello");' . */
|
|
/* ' alert("Loaded");' . */
|
|
/* ' }' */
|
|
/* ); */
|
|
|
|
|
|
//pr($customer);
|
|
//echo ('<A HREF="#" ONCLICK="$(\'#debug\').append(htmlEncode($(\'#customers-list\').html())); return false">Get grid code</A><BR>');
|
|
|
|
// Customer
|
|
// Outstanding balance
|
|
// Balance on each lease
|
|
// Balance on personal account
|
|
// Multiple fields for payments (cash, check, charge, etc)
|
|
// How to apply (even split, oldest charges first, etc)
|
|
|
|
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
|
|
// prepare the form when the DOM is ready
|
|
$(document).ready(function() {
|
|
var options = {
|
|
target: '#output-debug', // target element(s) to be updated with server response
|
|
beforeSubmit: verifyRequest, // pre-submit callback
|
|
success: showResponse, // post-submit callback
|
|
|
|
// other available options:
|
|
//url: url, // override for form's 'action' attribute
|
|
//type: type, // 'get' or 'post', override for form's 'method' attribute
|
|
//dataType: null, // 'xml', 'script', or 'json' (expected server response type)
|
|
//clearForm: true, // clear all form fields after successful submit
|
|
resetForm: true, // reset the form after successful submit
|
|
|
|
// $.ajax options can be used here too, for example:
|
|
//timeout: 3000,
|
|
};
|
|
|
|
// get a clean slate
|
|
resetPaymentForm();
|
|
|
|
// bind form using 'ajaxForm'
|
|
$('#payment-form').ajaxForm(options);
|
|
});
|
|
|
|
// pre-submit callback
|
|
function verifyRequest(formData, jqForm, options) {
|
|
// 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
|
|
//var_dump(formData);
|
|
$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
|
//return false;
|
|
|
|
// here we could return false to prevent the form from being submitted;
|
|
// returning anything other than false will allow the form submit to continue
|
|
return true;
|
|
}
|
|
|
|
// post-submit callback
|
|
function showResponse(responseText, statusText) {
|
|
// for normal html responses, the first argument to the success callback
|
|
// is the XMLHttpRequest object's responseText property
|
|
|
|
// if the ajaxForm method was passed an Options Object with the dataType
|
|
// property set to 'xml' then the first argument to the success callback
|
|
// is the XMLHttpRequest object's responseXML property
|
|
|
|
// if the ajaxForm method was passed an Options Object with the dataType
|
|
// property set to 'json' then the first argument to the success callback
|
|
// is the json data object returned by the server
|
|
|
|
if (statusText == 'success') {
|
|
// get a clean slate
|
|
resetPaymentForm();
|
|
}
|
|
else {
|
|
alert('not successful??');
|
|
}
|
|
|
|
|
|
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
|
}
|
|
|
|
// Reset payment fields
|
|
function resetPaymentForm() {
|
|
// Get a clean slate for our payments
|
|
$('#payments').html('');
|
|
$('#payment-id').val(1);
|
|
addPaymentSource(false);
|
|
}
|
|
|
|
function addPaymentSource(flash) {
|
|
addDiv('payment-id', 'payment', 'payments', flash,
|
|
// HTML section
|
|
'<FIELDSET CLASS="payment subset">' +
|
|
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
|
|
|
'<DIV ID="payment-type-div-%{id}">' +
|
|
<?php
|
|
$types = array();
|
|
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name)
|
|
$types[preg_replace("/ /", "", strtolower($name))] = $name;
|
|
|
|
foreach ($types AS $type => $name) {
|
|
$div = '<DIV>';
|
|
$div .= '<INPUT TYPE="radio" NAME="data[Source][%{id}][type]"';
|
|
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"';
|
|
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"';
|
|
$div .= ' VALUE="'.$type.'" ' . ($type == 'cash' ? 'CHECKED ' : '') . '/>';
|
|
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>';
|
|
$div .= '</DIV>';
|
|
echo "'$div' +\n";
|
|
}
|
|
?>
|
|
'</DIV>' +
|
|
|
|
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
|
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="20"' +
|
|
' NAME="data[Source][%{id}][amount]"' +
|
|
' ID="payment-amount-%{id}" />' +
|
|
'</DIV>' +
|
|
|
|
<?php
|
|
foreach ($types AS $type => $name) {
|
|
if ($type == 'cash')
|
|
continue;
|
|
|
|
$div = '<DIV';
|
|
$div .= ' ID="payment-'.$type.'-div-%{id}"';
|
|
$div .= ' CLASS="payment-type-div-%{id}"';
|
|
$div .= ' STYLE="display:none;">';
|
|
$div .= '</DIV>';
|
|
echo "'$div' +\n";
|
|
}
|
|
?>
|
|
|
|
'</FIELDSET>'
|
|
);
|
|
|
|
|
|
}
|
|
|
|
function switchPaymentType(paymentid, type) {
|
|
$(".payment-type-div-"+paymentid).slideUp();
|
|
$(".payment-type-div-"+paymentid).html('');
|
|
|
|
switch(type)
|
|
{
|
|
case 'cash':
|
|
break;
|
|
|
|
case 'check':
|
|
html =
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-check-number-'+paymentid+'">Check Number</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="6" NAME="data[Source]['+paymentid+'][check][number]"' +
|
|
' ID="payment-check-number-'+paymentid+'" />' +
|
|
'</DIV>';
|
|
break;
|
|
|
|
case 'moneyorder':
|
|
html =
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-moneyorder-number-'+paymentid+'">Money Order Number</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="6" NAME="data[Source]['+paymentid+'][moneyorder][number]"' +
|
|
' ID="payment-moneyorder-number-'+paymentid+'" />' +
|
|
'</DIV>';
|
|
break;
|
|
|
|
case 'ach':
|
|
html =
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-ach-routing-'+paymentid+'">Routing Number</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="9" NAME="data[Source]['+paymentid+'][ach][routing]"' +
|
|
' ID="payment-ach-routing-'+paymentid+'" />' +
|
|
'</DIV>' +
|
|
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-ach-account-'+paymentid+'">Account Number</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="17" NAME="data[Source]['+paymentid+'][ach][account]"' +
|
|
' ID="payment-ach-account-'+paymentid+'" />' +
|
|
'</DIV>';
|
|
break;
|
|
|
|
case 'creditcard':
|
|
html =
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-creditcard-account-'+paymentid+'">Account Number</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="16" NAME="data[Source]['+paymentid+'][creditcard][account]"' +
|
|
' ID="payment-creditcard-account-'+paymentid+'" />' +
|
|
'</DIV>' +
|
|
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-creditcard-expiration-'+paymentid+'">Expiration Date</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="10" NAME="data[Source]['+paymentid+'][creditcard][expiration]"' +
|
|
' ID="payment-creditcard-expiration-'+paymentid+'" />' +
|
|
' </DIV>' +
|
|
|
|
'<DIV CLASS="input text required">' +
|
|
' <LABEL FOR="payment-creditcard-cvv2-'+paymentid+'">CVV2 Code</LABEL>' +
|
|
' <INPUT TYPE="text" SIZE="10" NAME="data[Source]['+paymentid+'][creditcard][cvv2]"' +
|
|
' ID="payment-creditcard-cvv2-'+paymentid+'" />' +
|
|
'</DIV>';
|
|
break;
|
|
|
|
default:
|
|
html = '<DIV><H2>INVALID TYPE ('+type+')</H2></DIV>';
|
|
break;
|
|
}
|
|
|
|
$("#payment-"+type+"-div-"+paymentid).html(html);
|
|
$("#payment-"+type+"-div-"+paymentid).slideDown();
|
|
}
|
|
|
|
|
|
--></script>
|
|
|
|
<?php
|
|
; // align
|
|
//echo '<DIV ID="dialog">' . "\n";
|
|
|
|
echo $this->element('customers',
|
|
array('caption' => '<A HREF="#" ONCLICK="$(\\\'.HeaderButton\\\').click(); return false;">Select Customer</A>',
|
|
'limit' => 7,
|
|
'grid_setup' => $grid_setup,
|
|
));
|
|
|
|
echo ('<H2><SPAN id="payment_customer">' .
|
|
(isset($customer['Customer']['id'])
|
|
? 'Receipt for ' . $customer['Customer']['name']
|
|
: 'Please select customer') .
|
|
'</SPAN></H2>' . "\n");
|
|
|
|
//echo $form->create(null, array('id' => 'payment-form', 'action' => 'other'));
|
|
echo $form->create(null, array('id' => 'payment-form', 'url' => 'http://localhost/vars.php'));
|
|
?>
|
|
<input type="hidden" id="customer-id" name="data[Customer][id]" value="<?php echo $customer['Customer']['id']; ?>">
|
|
|
|
<fieldset CLASS="payment superset">
|
|
<legend>Payments</legend>
|
|
<input type="hidden" id="payment-id" value="1">
|
|
<div id="payments"></div>
|
|
<fieldset> <legend>
|
|
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
|
</legend> </fieldset>
|
|
</fieldset>
|
|
|
|
<?php
|
|
|
|
echo 'Date: <input id="datepicker" name="data[Date]" type="text" /><BR>' . "\n";
|
|
echo 'Comment: <input id="comment" name="data[Comment]" type="text" SIZE=80 /><BR>' . "\n";
|
|
echo $form->end('Post Payment');
|
|
|
|
//echo '</DIV>' . "\n"; // End of the dialog DIV
|
|
?>
|
|
|
|
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
|
<?php
|
|
/* <button id="post-payment" class="ui-button ui-state-default ui-corner-all">Create Payment</button> */
|
|
?>
|
|
|
|
|
|
<div><H4>Request</H4><div id="request-debug"></div></div>
|
|
<div><H4>Response</H4><div id="response-debug"></div></div>
|
|
<div><H4>Output</H4><div id="output-debug"></div></div>
|
|
<?php
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function(){
|
|
$("#datepicker").datepicker()
|
|
.datepicker('setDate', '+0');
|
|
|
|
/* $("#dialog").dialog({ */
|
|
/* bgiframe: true, */
|
|
/* autoOpen: false, */
|
|
/* height: 500, */
|
|
/* width: 600, */
|
|
/* modal: true, */
|
|
/* buttons: { */
|
|
/* 'Post a Payment': function() { */
|
|
/* var bValid = true; */
|
|
/* if (bValid) { */
|
|
/* $('#debug').append('<H2>POSTED!</H2>'); */
|
|
/* $(this).dialog('close'); */
|
|
/* } */
|
|
/* }, */
|
|
/* Cancel: function() { */
|
|
/* $(this).dialog('close'); */
|
|
/* } */
|
|
/* }, */
|
|
/* close: function() { */
|
|
/* } */
|
|
/* }); */
|
|
|
|
/* $('#post-payment').click(function() { */
|
|
/* $('#dialog').dialog('open'); */
|
|
/* }); */
|
|
|
|
});
|
|
</script>
|
|
|
|
</div>
|
|
|
|
|