Further progress on payment entries. There is an outstanding charges grid, but it doesn't have amounts due to the way I designed the ledger_entries element. I'll do a bit of rework on that next.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@163 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-18 00:49:40 +00:00
parent 1fbc452581
commit de2319e93d
7 changed files with 255 additions and 48 deletions

View File

@@ -54,36 +54,14 @@
$grid_setup = array();
if (isset($customer['Customer']['id']))
if (isset($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());' .
' } }'
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), ids); } }'
);
/* $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
@@ -95,7 +73,7 @@ $grid_setup['onSelectRow'] = array
?>
<script type="text/javascript"><!--
<script type="text/javascript"><!--
// prepare the form when the DOM is ready
$(document).ready(function() {
@@ -127,8 +105,12 @@ $grid_setup['onSelectRow'] = array
// 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>');
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
$('#request-debug').html('Ommitted');
//return false;
$('#response-debug').html('Loading <BLINK>...</BLINK>');
$('#output-debug').html('Loading <BLINK>...</BLINK>');
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
@@ -311,6 +293,60 @@ function switchPaymentType(paymentid, type) {
}
function updateChargesCaption(customer_name, balance) {
$('#charge-entries-jqGrid').setCaption('Outstanding Charges for ' +
customer_name + ': ' +
fmtCurrency(balance));
}
function updateChargesGrid(idlist, balance) {
updateChargesCaption($("#payment_customer").html(), balance);
$('#charge-entries-jqGrid').setPostDataItem('idlist', serialize(idlist));
$('#charge-entries-jqGrid')
.setGridParam({ page: 1 })
.trigger("reloadGrid");
}
function updateCharges(id) {
var url = '<?php echo ($html->url(array("controller" => $this->params["controller"],
"action" => "unreconciled"))); ?>';
//url += '/'+$("#customer-id").val();
url += '/'+id;
$.ajax({
type: "GET",
url: url,
dataType: "xml",
success: function(xml) {
var ids = new Array();
$('#update-target ol').html('<A HREF="'+url+'">Data URL</A>');
$('entry',xml).each(function(i){
ids.push($(this).attr('id'));
$('#update-target').append("Push: len=" + ids.length + '<BR>');
});
updateChargesGrid(ids, $('entries',xml).attr('balance'));
}
});
}
function onRowSelect(grid_id, cust_id) {
// Set the customer id that will be returned with the form
$("#customer-id").val(cust_id);
// Get the customer name from the grid
$("#payment_customer").html($(grid_id).getCell(cust_id, "Customer-name"));
// Replace that with just the text portion of the hyperlink
$("#payment_customer").html($("#payment_customer a").html());
// Hide the "no customer" message and show the current customer
$("#no_customer").hide();
$("#current_customer").show();
updateCharges(cust_id);
}
--></script>
<?php
@@ -318,16 +354,34 @@ function switchPaymentType(paymentid, type) {
//echo '<DIV ID="dialog">' . "\n";
echo $this->element('customers',
array('caption' => '<A HREF="#" ONCLICK="$(\'.HeaderButton\').click(); return false;">Select Customer</A>',
array('grid_div_id' => 'customers-list',
'caption' => ('<A HREF="#" ONCLICK="$(\'#customers-list .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 $this->element('ledger_entries',
array('grid_div_id' => 'charge-entries',
'caption' => 'Outstanding Charges',
/* (isset($customer['name']) */
/* ? " for {$customer['name']}: ".FormatHelper::currency($charges['balance']) */
/* : '')), */
'limit' => 8,
'ledger_id' => 6,
'account_type' => 'credit',
'ledger_entries' => $charges['entry'],
));
echo ('<H2>' .
'<SPAN id="current_customer" style="display:'.(isset($customer['id'])?"inline":"none").'">' .
'Enter new receipt for ' .
'<SPAN id="payment_customer">' . (isset($customer['name']) ? $customer['name'] : "") . '</SPAN>' .
'</SPAN>' .
'<SPAN id="no_customer" style="display:'.(isset($customer['id'])?"none":"inline").'">' .
'Please select customer' .
'</SPAN>' .
'</H2>' . "\n");
echo $form->create(null, array('id' => 'payment-form',
'url' => array('controller' => 'transactions',
@@ -373,7 +427,7 @@ echo $form->create(null, array('id' => 'payment-form',
***************************************************/
?>
<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['id']; ?>">
<fieldset CLASS="payment superset">
<legend>Payments</legend>
@@ -393,12 +447,10 @@ 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>
@@ -412,6 +464,13 @@ echo $form->end('Post Payment');
$("#datepicker").datepicker()
.datepicker('setDate', '+0');
<?php if (isset($customer['id'])) { ?>
$("#customer-id").val(<?php echo $customer['id']; ?>);
updateChargesCaption("<?php echo $customer['name']; ?>",
<?php echo $charges['balance']; ?>);
<?php } ?>
/* $("#dialog").dialog({ */
/* bgiframe: true, */
/* autoOpen: false, */
@@ -439,8 +498,10 @@ echo $form->end('Post Payment');
/* }); */
});
</script>
</div>
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>

View File

@@ -15,7 +15,7 @@ $jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'customers');
// User requested options have priority
$jqGrid_options += compact('caption', 'grid_setup', 'limit');
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
if (isset($customers)) {
$jqGrid_options += array('custom_ids' =>

View File

@@ -18,11 +18,11 @@ $custom_post_data = array('ledger_id' => $ledger_id,
'account_type' => $account_type);
$jqGrid_options = array('jqGridColumns' => $cols,
'grid_id' => isset($grid_id) ? $grid_id : null,
'caption' => isset($caption) ? $caption : null,
'controller' => 'ledger_entries',
);
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
if (isset($ledger_entries)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',