').appendTo('body')
.attr('data-check', 1)
.css('width', '225px')
.css('height', '170px')
.css('text-align', 'center')
.css('padding', '0.5em')
.position({my : "center center", at : "center center", of : window})
.addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front')
.html('
Reopening Form...

Please wait, this may take a while to process...
');
// Submit the form
window.location.href = "{{ url('/forms/ticket-report/' . $info['report']->id . '/reopen?matchup=' . $info['matchup']->id) }}";
}
},
{
text : "Cancel",
'class' : "float_right",
'data-autofocus' : "true",
icons : { primary : 'ui-icon-cancel'},
click : function()
{
// Close the dialog box
$(this).dialog("close");
}
}
],
open : function ()
{
var dialog_object = $(this);
var html = '
';
html += '
';
html += '
Are you sure you want to reopen this report??';
html += '
';
html += '
By reopening this form, you can allow additional data to be input. However, the school may have already sent in an older printed version, you may receive duplicate printed forms for the same contest.
';
html += '
';
dialog_object.html(html);
$('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
$('[data-autofocus="true"]').focus();
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
});
@endif
/* showCheckResults
*
* Shows the results of the form check operation.
*/
function showCheckResults(check)
{
var pass = check[0];
if (pass)
{
$('
')
.appendTo('body')
.dialog(
{
draggable : true,
resizable : false,
height : 280,
width : 400,
modal : true,
title : 'Form Check: Pass',
open : function ()
{
var dialog_object = $(this);
var html = '
';
html += '
';
html += '
 }})
';
html += 'Your Form Passed Inspection';
html += '
';
html += 'All required information has been provided. This ticket report is ready to be submitted.
When you are ready, click the "Submit" button to generate a printable version of your form.
';
html += '
';
dialog_object.html(html);
$('.close_button', dialog_object)
.button({'icons' : {'secondary' : 'ui-icon-check'}})
.css({'font-size' : '9pt'})
.focus()
.click(function(event)
{
event.preventDefault();
dialog_object.dialog('close');
});
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
else
{
$('
')
.appendTo('body')
.dialog(
{
draggable : true,
resizable : false,
height : 330,
width : 500,
modal : true,
title : 'Form Check: Fail',
open : function ()
{
var dialog_object = $(this);
var html = '
';
html += '
';
html += '
 }})
';
html += 'Your Form Failed Inspection';
html += '
';
html += 'You are missing some required information or some other item. Your ticket report is incomplete.
Error Details';
html += '
';
$.each(check, function (i, item)
{
if (i > 0)
{
html += '- ' + item + '
';
}
});
html += '
';
html += '
';
html += '
';
dialog_object.html(html);
$('.close_button', dialog_object)
.button({'icons' : {'secondary' : 'ui-icon-check'}})
.css({'font-size' : '9pt'})
.focus()
.click(function(event)
{
event.preventDefault();
dialog_object.dialog('close');
});
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
}
/* Positioned elements
*
* Elements that contain the attribute data-position="true" will be positioned
* using JQuery's UI positioning utility. Other expected attributes define the
* element's position:
* data-position-my
* data-position-at
* data-position-of
*/
$('[data-position="true"]').each(function()
{
var element = $(this);
var my = element.attr('data-position-my');
var at = element.attr('data-position-at');
var of = element.attr('data-position-of');
var options = $.parseJSON('{ "my" : "' + my + '", "at": "' + at + '", "of": "' + of + '"}');
element.position(options);
});
// Required field marker
$('[data-required]:not([data-required-indicator])').after('
*');
// Table row highlighter
function colorRows ()
{
$('table').each(function ()
{
var i = 0;
$('tbody tr:visible', $(this)).each(function ()
{
if (i % 2 == 1)
{
$(this).addClass('odd');
}
else
{
$(this).removeClass('odd');
}
i = i + 1;
});
});
}
colorRows();
/* alertRequiredField
*
* Shows an alert box when attempting to save a blank value to a required field.
*/
function alertRequiredField()
{
$('
')
.appendTo('body')
.dialog(
{
modal : true,
draggable : false,
resizable : false,
height : 275,
width : 415,
title : 'Required Field',
buttons: [
{
text : "OK",
'class' : "float_right",
icons : { primary : 'ui-icon-check'},
click : function()
{
// Close the dialog box
$(this).dialog("close");
}
}
],
open : function ()
{
var dialog_object = $(this);
dialog_object.html('
You\'ve entered in a blank value for a required field. Required fields cannot be empty.
The original value has been restored.
');
$('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
$('.ui-dialog-buttonpane .ui-dialog-buttonset').append('
Still having trouble?
(503) 682-6722 x228
');
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
/* alertLimitedField
*
* Shows an alert box when attempting to save a value that exceeds the allowed max limit.
*/
function alertLimitedField(max, field_name)
{
$('
')
.appendTo('body')
.dialog(
{
modal : true,
draggable : false,
resizable : false,
height : 275,
width : 415,
title : 'Limit Exceeded',
buttons: [
{
text : "OK",
'class' : "float_right",
icons : { primary : 'ui-icon-check'},
click : function()
{
// Close the dialog box
$(this).dialog("close");
}
}
],
open : function ()
{
var dialog_object = $(this);
dialog_object.html('
The maximum allowed number of ' + field_name + ' for {{ strtolower(Helpers::getActivityName($info['report']->activity)) }} is ' + max + '.
Your entry will be adjusted to the maximum number of ' + max + '.
');
$('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
{{-- $('.ui-dialog-buttonpane .ui-dialog-buttonset').append('
Still having trouble?
(503) 682-6722 x228
'); --}}
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
/* saveFormData
*
* Given a form field and a value, this function will do a
* JSON POST request to save the form's information. The optional
* third parameter will determine if the page will be reloaded or not.
*/
function saveFormData(field, value, type, reload)
{
// Ensure the field and value parameters are provided
if (typeof field == 'undefined' || typeof value == 'undefined' || typeof type == 'undefined')
{
alert('Scripting error. Unable to save form data.');
}
// Get the optional reload parameter
reload = typeof reload !== 'undefined' ? reload : false;
// Get the form ID (same across all pages for this form)
var form_id = {{ $info['report']->id }};
$('*').css({'cursor':'wait'});
var jqxhr = $.ajax(
{
type : 'POST',
url : '{{ url('/forms/ticket-report') }}/' + form_id + '/update',
data : { 'field' : field,
'value' : value,
'type' : type },
dataType : 'html'
})
.done(function(returned_data)
{
// Success
//console.log("Successfully saved {'" + form_id + "|" + field + "' : '" + value + "'}");
var info = $.parseJSON(returned_data);
$('#updated_at').html(info.updated_at);
if (info.force_reload)
{
reload = true;
}
})
.fail(function(jqXHR, status, error)
{
// Error
var response = jqXHR.responseText;
var errorData = $.parseJSON(response);
//console.log(errorData);
alert("There was an error saving this form's data.\n\n" + errorData.error.message + "\n\nThis page will now be reloaded.");
location.reload();
})
.complete(function ()
{
// Reload if necessary
if (reload)
{
location.reload();
}
else
{
$('*').css({'cursor':''});
}
});
}
// Autosave text fields
function autoSaveTextField(input_field)
{
clearTimeout(autoSaveTextField.timeout);
autoSaveTextField.timeout = setTimeout(function (){
var value = input_field.val();
var original_value = input_field.attr('data-original');
var field = input_field.attr('data-field');
var type = input_field.attr('data-type');
var readonly_attr = input_field.attr('readonly');
if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
{
return false;
}
var reload = false;
var reload_attr = input_field.attr('data-reload');
if (typeof reload_attr !== typeof undefined && reload_attr !== false)
{
reload = true;
}
var required = false;
var required_attr = input_field.attr('data-required');
if (typeof required_attr !== typeof undefined && required_attr !== false)
{
required = true;
}
if (required && value == '' && !(original_value == '' || typeof original_value === typeof undefined || original_value === false))
{
input_field.val(original_value);
input_field.focus();
alertRequiredField();
return;
}
if (value != original_value && ((required && value != '') || !required))
{
saveFormData(field, value, type, reload);
input_field.attr('data-original', value);
}
}, 50);
}
// Autosave text fields and textareas
$('input[type="text"][data-autosave]').on('change blur autocompletechange autocompleteselect', function (event)
{
var field = $(this);
if (field.has('[data-format="number"]') && field.has('[data-max-value]'))
{
var max = parseInt(field.attr('data-max-value'));
if (parseInt(field.val()) > max)
{
field.val(max);
alertLimitedField(max, field.attr('data-title'));
}
}
autoSaveTextField ($(this));
if (field.has('[data-format="number"]'))
{
var value = parseInt(field.val());
var row = field.parents('tr');
var rate = parseFloat(row.attr('data-rate'));
var position = row.attr('data-position');
var total = value * rate;
$('[name="' + position + '_total"]').html(total.toFixed(2));
updateExpenseTotals('approved-expense');
}
});
$('textarea[data-autosave]').on('change blur autocompletechange autocompleteselect', function (event)
{
autoSaveTextField ($(this));
});
function updateExpenseTotals(type)
{
if (type == 'approved-expense')
{
var sub_total = 0.00;
$('[data-total="' + type + '"]').each(function()
{
sub_total += parseFloat($(this).text());
});
$('[name="approved_expense_total"]').html(sub_total.toFixed(2));
}
if (type == 'other-expense')
{
/* No need to update this */
}
// Update expense total
var approved_expenses = parseFloat($('[name="approved_expense_total"]').text());
var other_expenses = parseFloat($('[name="other_expense_total"]').text());
if (isNaN(other_expenses))
{
other_expenses = 0.00;
}
var expense_total = (approved_expenses + other_expenses).toFixed(2);
$('[name="expense_total"]').html(expense_total);
}
updateExpenseTotals('approved-expense');
// Autosave select fields
$('select[data-autosave]').on('change', function(event)
{
var select_field = $(this);
var selected = $(':selected', select_field);
var value = selected.val();
var original_value = select_field.attr('data-original');
var field = select_field.attr('data-field');
var type = select_field.attr('data-type');
var readonly_attr = select_field.attr('readonly');
if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
{
return false;
}
var reload = false;
var reload_attr = select_field.attr('data-reload');
if (typeof reload_attr !== typeof undefined && reload_attr !== false)
{
reload = true;
}
if (value != original_value)
{
saveFormData(field, value, type, reload);
select_field.attr('data-original', value);
}
});
// Autosave check-box fields
$('input[type="checkbox"][data-autosave]').on('change', function(event)
{
var checkbox_field = $(this);
var value = checkbox_field.is(':checked');
var original_value = checkbox_field.attr('data-original');
var field = checkbox_field.attr('data-field');
var type = checkbox_field.attr('data-type');
var readonly_attr = checkbox_field.attr('readonly');
if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
{
return false;
}
var reload = false;
var reload_attr = checkbox_field.attr('data-reload');
if (typeof reload_attr !== typeof undefined && reload_attr !== false)
{
reload = true;
}
if (value != original_value)
{
saveFormData(field, value, type, reload);
checkbox_field.attr('data-original', value);
}
});
@if (Session::has('new_form') or Input::has('new-form'))
showHelp('new-form', true);
@endif
/* ShowHelp
*
* Shows a help topic.
*/
function showHelp(help_topic, no_button)
{
if (no_button !== true)
{
$('
')
.appendTo('body')
.dialog(
{
draggable : true,
resizable : true,
height : 745,
minHeight : 400,
width : 650,
minWidth : 330,
modal : false,
title : 'Ticket Report Help',
open : function ()
{
var dialog_object = $(this);
dialog_object.html("
");
var jqxhr = $.ajax(
{
type : 'GET',
url : '{{ url('forms/ticket-report/' . $info['report']->id . '/help') }}?topic=' + help_topic,
dataType : 'html'
})
.done(function (returned_data)
{
dialog_object.html(returned_data);
})
.fail(function (jqXHR, status, error)
{
var response = jqXHR.responseText;
var errorData = $.parseJSON(response);
//console.log(errorData);
alert ("There was an error looking up help information.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
location.reload();
})
.complete(function ()
{
});
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
else
{
$('
')
.appendTo('body')
.css({'z-index':'2000 !important'})
.dialog(
{
draggable : false,
resizable : false,
height : 745,
minHeight : 745,
width : 650,
modal : true,
dialogClass : 'no-close',
title : 'New Ticket Report Created',
open : function ()
{
var dialog_object = $(this);
dialog_object.html("
");
var jqxhr = $.ajax(
{
type : 'GET',
url : '{{ url('forms/ticket-report/' . $info['report']->id . '/help') }}?topic=' + help_topic,
dataType : 'html'
})
.done(function (returned_data)
{
dialog_object.html(returned_data);
})
.fail(function (jqXHR, status, error)
{
var response = jqXHR.responseText;
var errorData = $.parseJSON(response);
//console.log(errorData);
alert ("There was an error looking up help information.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
location.reload();
})
.complete(function ()
{
$('.close_first_view_button', dialog_object)
.button()
.click(function ()
{
dialog_object.dialog("close");
});
// Shake action items
function shakeTheseActionImages (object)
{
var direction;
if ($(object).has('[data-direction]'))
{
var direction = $(object).attr('data-direction');
}
if (typeof direction == 'undefined')
{
var direction = 'left';
}
$(object).effect("shake", {direction : direction, distance : 5, times : 1}, 600, function ()
{
$(this).delay(Math.floor(Math.random() * 4000) + 2000);
shakeTheseActionImages($(this));
});
}
var img = $('img.action_item', dialog_object);
img.position({my:"center center", at : "right+30 center", of : ".close_first_view_button"});
shakeTheseActionImages(img);
});
},
close : function ()
{
var dialog_object = $(this);
$(dialog_object).remove();
}
});
}
}
/*
* Help button
*/
$('.help_button')
.button({'icons':{'primary':'ui-icon-help'}})
.css({'font-size':'9pt'})
.click(function(event)
{
var object = $(this);
event.preventDefault();
var topic = object.attr('data-topic');
showHelp(topic);
object.blur();
});
/*
* Special help buttons
*/
$('[name="category_help"]')
.hover(function ()
{
$(this).css({'cursor':'pointer'});
},
function ()
{
})
.click(function(event)
{
var object = $(this);
var topic = object.attr('data-topic');
showHelp(topic);
});
/*
* Close button
*/
$('.close_button')
.button({'icons':{'primary':'ui-icon-circle-close'}})
.css({'font-size':'9pt', 'margin-left':'10px'});
/*
* Add staff contact button
*/
$('.add_staff_contact')
.button({ icons : { primary : 'ui-icon-plusthick'}})
.css({'font-size' : '9pt'})
.tooltip()
.click(function ()
{
var button_obj = $(this);
var school_id = $(button_obj).attr('data-school-id');
var school_district_id = '';
$('
')
.appendTo('body')
.dialog(
{
dialogClass: 'add_staff_contact_dialog',
resizable: false,
height: 430,
width: 700,
modal: true,
title: 'Add Staff Contact',
buttons: [
{
text : "Create Contact",
'class' : "float_left",
icons : { primary : 'ui-icon-disk'},
click : function()
{
// Submit the form
$('form', $(this)).submit();
$(this).dialog("close");
return true;
}
},
{
text : "Cancel",
'class' : "float_right",
'autofocus' : true,
icons : { primary : 'ui-icon-cancel'},
click : function()
{
$(this).dialog( "close" );
$(this).remove();
return false;
}
}
],
open : function ()
{
function checkRole()
{
var value = $('#role').val();
if (value == 'Prin.' || value == 'AD' || value == 'AT' || value == 'Doc.' || value == 'Supt.')
{
$('#is_on_rosters').val(1);
}
else
{
$('#is_on_rosters').val(0);
}
}
var dialog_object = $(this);
dialog_object.html("
");
var jqxhr = $.ajax(
{
type : 'GET',
url : 'http://www.osaa.org/schools/add-staff',
data : { 'school_id' : school_id, 'school_district_id' : school_district_id},
dataType : 'html'
})
.done(function (data)
{
dialog_object.html(data);
$('
')
.html('
Once you create a new contact, your form will automatically reload.
')
.appendTo($('form', dialog_object));
$('#role option[value="Book"]').attr('selected', 'selected');
$('#role').on('change', function ()
{
checkRole();
});
checkRole();
@if (Auth::check() and Auth::user()->isOsaaUser())
$('#is_on_rosters').removeAttr('disabled');
@endif
}).fail(function (jqXHR, status, error)
{
var response = jqXHR.responseText;
var errorData = $.parseJSON(response);
console.log(errorData);
dialog_object.html('