Some cleanup from the last checkin

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@452 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 16:48:27 +00:00
parent 9bd37ba282
commit 33a677431f
2 changed files with 13 additions and 38 deletions

View File

@@ -192,27 +192,32 @@ class TransactionsController extends AppController {
$close_type_ids[] = $type_id;
}
// Make sure we actually have something to deposit
if (empty($deposit_type_ids) && empty($deposit_tender_ids)) {
$this->Session->setFlash(__('Nothing to Deposit', true));
$this->redirect(array('controller' => 'tenders', 'action'=>'deposit'));
}
// Build up a set of conditions based on user selection
$deposit_conditions = array();
if (!empty($deposit_type_ids))
$deposit_conditions[] = array('TenderType.id' => $deposit_type_ids);
if (!empty($deposit_tender_ids))
$deposit_conditions[] = array('DepositTender.id' => $deposit_tender_ids);
// Add in confirmation that items have not already been deposited
$deposit_conditions =
array(array('DepositTender.deposit_transaction_id' => null),
array('OR' => $deposit_conditions));
// Lookup the items to be deposited
$tenders = $this->Transaction->DepositTender->find
('all',
array('contain' => array('TenderType', 'LedgerEntry'),
'conditions' => $deposit_conditions,
));
// Build the deposit transaction
$deposit = array('Transaction' => array(), 'Entry' => array());
foreach ($tenders AS $tender) {
$deposit['Entry'][] =

View File

@@ -13,7 +13,6 @@ echo $form->create(null, array('id' => 'deposit-form',
'action' => 'postDeposit')));
foreach ($depositTypes AS $type) {
//$acct = $acct['Account'];
$names = Inflector::pluralize($type['name']);
$radioOptions =
@@ -39,7 +38,7 @@ foreach ($depositTypes AS $type) {
// REVISIT <AP>: 20090729
// Would like to present an option for the user to close the ledger
// associated with the form of tender, or to just leave it open.
// For now, just leave it open
// For now, just close it.
echo "\n";
echo $form->input("TenderType.{$type['id']}.close",
array('type' => 'hidden',
@@ -74,24 +73,15 @@ foreach ($depositTypes AS $type) {
array('hiddengrid' => true,
'multiselect' => true),
'grid_events' =>
array(
/* 'onHeaderClick' => */
/* array('gridstate' => */
/* 'onGridState("#"+$(this).attr("id"), gridstate)'), */
/* 'gridComplete' => */
/* array('' => "switchSelection({$type['id']})"), */
/* 'loadBeforeSend' => */
/* array('xhr' => "loadBeforeSend()"), */
),
'caption' => "{$names} on hand",
'filter' => array('deposit_transaction_id' => null,
'TenderType.id' => $type['id']),
'filter' => array('deposit_transaction_id' => null,
'TenderType.id' => $type['id']),
'exclude' => array('Type'),
),
));
// Add a hidden item to hold the jqGrid selection,
// which we'll populate prior to form submission.
echo "\n";
echo $form->input("TenderType.{$type['id']}.items",
array('type' => 'hidden',
@@ -111,17 +101,14 @@ echo '</div>' . "\n";
<script type="text/javascript"><!--
$(document).ready(function(){
$('#debug').html('ready()<BR>');
<?php foreach ($depositTypes AS $type): ?>
<?php /* Hide the multiselect column */ ?>
switchSelection(<?php echo $type['id']; ?>);
<?php endforeach; ?>
});
// pre-submit callback
function verifyRequest() {
// return false to prevent the form from being submitted;
// anything other than false will allow submission.
$('#debug').html('Verifying...');
<?php foreach ($depositTypes AS $type): ?>
var rows = $('#<?php echo "tenders-{$type['id']}-list-jqGrid"; ?>').getGridParam('selarrrow');
$('#<?php echo "TenderType{$type['id']}Items"; ?>').val(serialize(rows));
@@ -132,33 +119,16 @@ function verifyRequest() {
// Verify the request before submitting
?>
// return false to prevent the form from being submitted;
// anything other than false will allow submission.
return true;
}
function loadBeforeSend() {
$('#debug').append('<P>debugLBS');
<?php foreach ($depositTypes AS $type): ?>
var grid_div_id = '#<?php echo "tenders-{$type['id']}-list"; ?>'
var grid_id = grid_div_id+'-jqGrid';
$(grid_id).setGridParam({multiselect:true});
<?php endforeach; ?>
}
function switchSelection(type_id) {
//var selection = $('#TenderType'+type_id+'Selection').val();
var grid_div_id = '#tenders-'+type_id+'-list';
var grid_id = grid_div_id+'-jqGrid';
var selection = $('.type-selection-'+type_id+':checked').val();
var gridstate = $(grid_id).getGridParam('gridstate');
//var multiselect = $(grid_id).getGridParam('multiselect');
/* $('#debug').append('<P>' + */
/* 'type_id = ' + type_id + '<br>' + */
/* 'selection = ' + selection + '<br>' + */
/* 'gridstate = ' + gridstate + '<br>' + */
/* '' //'multiselect = ' + multiselect + '<br>' */
/* ); */
<?php
// It seems that jqGrid doesn't work too well with multiselect