Added util function to allow us to capture client side logging, and utilize it in the invoice view to find out why the app is not working on site. Also, since everything depends so heavily on jQuery, added an internal error if jQuery fails to load.

git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@840 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-09-06 15:32:41 +00:00
parent 2628edfbdd
commit 0ad68f4d6a
3 changed files with 63 additions and 21 deletions

View File

@@ -62,4 +62,15 @@ class UtilController extends AppController {
function rebuild_sandbox() { $this->rebuild_box('sand'); }
function rebuild_devbox() { $this->rebuild_box('dev'); }
/**************************************************************************
**************************************************************************
**************************************************************************
* function: logmsg
* - action to allow posting log message data
*/
function logmsg() {
}
}

View File

@@ -86,6 +86,18 @@
echo $javascript->link('pmgr') . "\n";
echo $scripts_for_layout . "\n";
?>
<?php if ($this->params['action'] !== 'INTERNAL_ERROR'): ?>
<script type="text/javascript"><!--
if (typeof(jQuery) == 'undefined') {
window.location.href =
"<?php echo $html->url(array('controller' => 'util',
'action' => 'INTERNAL_ERROR',
'jQuery NOT LOADED!')); ?>";
}
--></script>
<?php endif; ?>
</head>
<body>

View File

@@ -24,10 +24,22 @@ Configure::write('debug', '0');
?>
<script type="text/javascript"><!--
var debugmsg = new Array();
if ($().accordion)
debugmsg.push('accordion loaded');
else
debugmsg.push('accordion NOT loaded');
if ($().ajaxForm)
debugmsg.push('ajaxForm loaded');
else
debugmsg.push('ajaxForm NOT loaded');
// prepare the form when the DOM is ready
$(document).ready(function() {
$("#debug").append('doc ready1' + '<BR>');
debugmsg.push('doc ready1');
var options = {
target: '#output-debug', // target element(s) to be updated with server response
beforeSubmit: verifyRequest, // pre-submit callback
@@ -41,19 +53,17 @@ Configure::write('debug', '0');
//resetForm: true, // reset the form after successful submit
};
if ($('#invoice-form').ajaxForm != null)
$("#debug").append('ajax present' + '<BR>');
else
$("#debug").append('ajax not present' + '<BR>');
// bind form using 'ajaxForm'
if ($('#invoice-form').ajaxForm != null) {
$("#debug").append('go ajax' + '<BR>');
debugmsg.push('bind ajaxForm');
$('#invoice-form').ajaxForm(options);
$("#debug").append('ajax set' + '<BR>');
debugmsg.push('ajaxForm bound');
}
else
else {
debugmsg.push('remove repeat label');
$('#repeat, label[for=repeat]').remove();
}
});
// pre-submit callback
@@ -131,13 +141,13 @@ function showResponse(responseText, statusText) {
// Reset the form
function resetForm(nocharge) {
$("#debug").append('reset form: ' + nocharge + '<BR>');
debugmsg.push('reset form: ' + nocharge);
$('#charge-entry-id').val(1);
$('#charges').html('');
if (!nocharge)
addChargeSource(false);
$("#debug").append('reset form done' + '<BR>');
debugmsg.push('reset form done');
}
@@ -163,7 +173,7 @@ function onRowSelect(grid_id, lease_id) {
}
function onGridState(grid_id, state) {
$("#debug").append('on grid state: ' + grid_id + '; ' + state + '<BR>');
debugmsg.push('on grid state: ' + grid_id + '; ' + state + '; lid=' + $("#lease-id").val());
if (state == 'visible') {
$(".lease-selection-invalid").hide();
$(".lease-selection-valid").hide();
@@ -177,12 +187,12 @@ function onGridState(grid_id, state) {
$(".lease-selection-invalid").show();
}
}
$("#debug").append('on grid state done' + '<BR>');
debugmsg.push('on grid state done');
}
function addChargeSource(flash) {
$("#debug").append('add charge source' + '<BR>');
var id = $("#charge-entry-id").val();
debugmsg.push('add charge source: flash=' + flash + '; id=' + id);
addDiv('charge-entry-id', 'charge', 'charges', flash,
// HTML section
'<FIELDSET CLASS="charge subset">' +
@@ -218,14 +228,14 @@ function addChargeSource(flash) {
'</FIELDSET>'
);
$("#debug").append('add div complete' + '<BR>');
debugmsg.push('add div complete: id=' + id);
$("#debug").append('add datepicker1' + '<BR>');
debugmsg.push('add datepicker1: id=' + id);
datepicker("Entry"+id+"EffectiveDate");
$("#debug").append('add datepicker2' + '<BR>');
debugmsg.push('add datepicker2: id=' + id);
datepicker("Entry"+id+"ThroughDate");
$("#debug").append('add charge source complete' + '<BR>');
debugmsg.push('add charge source complete: id=' + id);
return id;
}
@@ -349,8 +359,10 @@ Configure::write('debug', '0');
};
$(document).ready(function(){
$("#debug").append('doc ready2' + '<BR>');
debugmsg.push('doc ready2');
debugmsg.push('make transaction-stamp datepicker');
datepicker('TransactionStamp');
debugmsg.push('datepicker OK');
$("#lease-id").val(0);
$("#invoice-lease").html("INTERNAL ERROR");
@@ -362,13 +374,14 @@ Configure::write('debug', '0');
<?php if (empty($movein)): ?>
$("#debug").append('movein empty' + '<BR>');
debugmsg.push('movein empty');
resetForm();
debugmsg.push('transaction-stamp now');
datepickerNow('TransactionStamp');
<?php else: ?>
$("#debug").append('movein not empty' + '<BR>');
debugmsg.push('movein not empty');
var id;
resetForm(true);
@@ -450,6 +463,12 @@ Configure::write('debug', '0');
$('#output-debug').show();
<?php endif; ?>
$.post("<?php echo $html->url(array('controller' => 'util',
'action' => 'logmsg')); ?>",
{ 'messages[]' : debugmsg }
);
//$('#debug').html(debugmsg.join('<BR>'));
});
--></script>