function oWin( aURL ) { var wOpen; var sOptions; sOptions = 'toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=no, resizable=yes'; sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString(); sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString(); sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0'; wOpen = window.open( aURL, '_blank', sOptions ); wOpen.focus(); wOpen.moveTo( 0, 0 ); wOpen.resizeTo( screen.availWidth, screen.availHeight ); return wOpen; } var printJob = hex_sha1("474ba5f8ee4566787c92d26e8981c60b192a8ac6"); var submitted = false; var printed = false; var invalidFieldType; var invalidFieldValue; Ext.onReady(function(){ Ext.apply(Ext.form.VTypes,{ phoneText: "Invalid phone number. Format:(###)###-####", phoneMask: /[\d-]| |\(|\)/, phoneRe: /^(\d{3}-){0,1}\d{3}-\d{4}$/, phone :function (v) { invalidFieldType = 'phone'; invalidFieldValue = v; return this.phoneRe.test(v); }, addressText: "Invalid Street Address.", addressMask: /[0-9]| |[a-zA-Z.]/, addressRe: /^[1-9]{1}[0-9]+ [a-zA-Z .]*$/, address :function (v) { invalidFieldType = 'address'; invalidFieldValue = v; return this.addressRe.test(v); }, zipText: "Invalid Zip Code.", zipMask: /[0-9]/, zipRe: /^[1-9]{1}[0-9]{4}$/, zip :function (v) { invalidFieldType = 'zip'; invalidFieldValue = v; return this.zipRe.test(v); }, decNumText: "Invalid GHIN #. Format: #######", decNumMask: /[0-9]/, decNumRe: /^[0-9]{7}$/, decNum : function (v) { invalidFieldType = 'decNum'; invalidFieldValue = v; return this.decNumRe.test(v); }, handicapText: "Invalid Handicap. Format: ##.#", handicapMask: /[0-9.]/, handicapRe: /^((\d{2})|(\d{1}))[.]{1}\d{1}$/, handicap : function (v) { invalidFieldType = 'handicap'; invalidFieldValue = v; return this.handicapRe.test(v); }, nameText: "Only letters are allowed.", nameMask: /[a-zA-Z]/, nameRe: /^[a-zA-Z]*$/, name : function (v) { invalidFieldType = 'name'; invalidFieldValue = v; return this.nameRe.test(v); }, name2Text: "Only letters are allowed.", name2Mask: /[a-zA-Z ]/, name2Re: /(^[a-zA-Z]*$)|^([a-zA-Z]*[ ]+[a-zA-Z]*)+$/, name2 : function (v) { invalidFieldType = 'name2'; invalidFieldValue = v; return this.name2Re.test(v); }, initialText: "Only letters are allowed.", initialMask: /[a-zA-Z]/, initialRe: /^[a-zA-Z]{1}$/, initial : function (v) { invalidFieldType = 'initial'; invalidFieldValue = v; return this.initialRe.test(v); }, passText: "Password must be between 6 to 15 characters long and can include letters, numbers, spaces, and symbols.", passMaks: /[ -~]/, passRe: /^[ -~]{6,15}$/, pass : function (v) { invalidFieldType = 'pass'; invalidFieldValue = v; return this.passRe.test(v); } }); Ext.QuickTips.init(); // turn on validation errors beside the field globally Ext.form.Field.prototype.msgTarget = 'side'; var win = null; // simple array store var store = new Ext.data.SimpleStore({ fields: ['abbr', 'state'], data : Ext.exampledata.states }); Ext.exampledata.tourneyData = [ ['Sacramento Valley 2 Person Better Ball'] ]; var tourney = new Ext.data.SimpleStore({ fields: ['name'], data : Ext.exampledata.tourneyData }); var tourneyTabs = new Ext.TabPanel({items: [{title: 'Sacramento Valley 2 Person Better Ball',html: 'Date of Tournament: June 7 2008, June 8 27 2008
Signup Deadline: June 6th
2 Person Better Ball
'}],border: false,activeTab: 0}); function submitForm(values) { var params = "user=" + values['user']; params += "&pwd=" + values['pwd']; params += "&tournaments=" + values['tournaments']; params += "&name_first=" + values['name_first']; params += "&name_initial=" + values['name_initial']; params += "&name_last=" + values['name_last']; params += "&address=" + values['address']; params += "&city=" + values['city']; params += "&zipcode=" + values['zipcode']; params += "&phone_home=" + values['phone_home']; params += "&phone_work=" + values['phone_work']; params += "&phone_cell=" + values['phone_cell']; params += "&ghin=" + values['ghin']; params += "&handicap=" + values['handicap']; params += "&club=" + values['club']; params += "&teammate=" + values['teammate']; params += "&email=" + values['email']; var ajax = Ext.Ajax; ajax.request({ url: 'submit.php?printJobID=' + printJob, method: 'POST', params: params, success:function(response, request) { if(response.responseText != '') { request.failure(response.responseText); } else { Ext.MessageBox.show({ title: 'Submitted', buttons: Ext.MessageBox.OK, msg: 'Your entry has been submitted successfully.' }); } }, failure:function(text) { Ext.MessageBox.show({ title: 'Error', buttons: Ext.MessageBox.OK, msg: text }); } }); } var myform = new Ext.FormPanel({ labelWidth: 75, // label settings here cascade unless overridden frame:true, title: 'NCGA Signup', bodyStyle:'padding:5px 5px 0', width: 400, defaults: {width: 230}, defaultType: 'textfield', items :[/*{ fieldLabel: 'Username', name: 'user', allowBlank:false },{ fieldLabel: 'Password', name: 'pwd', allowBlank:false, vtype: 'pass', inputType: 'password' },*/ new Ext.form.ComboBox({ store: tourney, fieldLabel: 'Tournament', name: 'tournaments', displayField:'name', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'Select a tournament...', selectOnFocus:true, allowBlank:false }),{ fieldLabel: 'Teammate\'s Name', name: 'teammate', value: '', vtype:'name', allowBlank:false },{ fieldLabel: 'First Name', name: 'name_first', value: 'John', vtype:'name', allowBlank:false },{ fieldLabel: 'Initial', name: 'name_initial', vtype:'name', value: 'F' },{ fieldLabel: 'Last Name', name: 'name_last', value: 'Doe', vtype:'name', allowBlank:false },{ fieldLabel: 'Street Address', name: 'address', vtype:'address', allowBlank:false },{ fieldLabel: 'City', name: 'city', vtype:'name2', allowBlank:false },{ fieldLabel: 'Zip Code', name: 'zipcode', vtype:'zip', allowBlank:false },new Ext.form.ComboBox({ store: store, fieldLabel: 'State', name: 'state', displayField:'state', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'Select a state...', selectOnFocus:true, allowBlank:false }),{ fieldLabel: 'Home Phone', name: 'phone_home', value: '916-885-2135', vtype: 'phone', allowBlank:false },{ fieldLabel: 'Work Phone', name: 'phone_work', vtype: 'phone', allowBlank:true },{ fieldLabel: 'Cell Phone', name: 'phone_cell', vtype: 'phone', allowBlank:true },{ fieldLabel: 'GHIN#', name: 'ghin', vtype:'decNum', value: '0000000', allowBlank:false },{ fieldLabel: 'Handicap', name: 'handicap', vtype:'handicap', value: '24.0', allowBlank:false },{ fieldLabel: 'Golf Club', name: 'club', vtype:'name2', allowBlank:false },{ fieldLabel: 'Email', name: 'email', vtype:'email', value: 'johndoe@gmail.com', allowBlank:false } ], bbar: [{ text: 'Submit', handler:function(){ if (myform.getForm().isValid()) { //myform.getForm().submit({ //url:'submit.php?printJobID=' + printJob, //method:'POST', //waitMsg:'Submitting...' //}); submitForm(myform.getForm().getValues()); submitted = true; printed = false; }else{ Ext.MessageBox.alert('Errors', 'Please fix the errors noted.'); } } },{ text: 'Print', handler:function(){ if(submitted && !printed){ oWin('print.php?printJobID=' + printJob); printJob = hex_sha1(printJob); submitted = false; printed = true; }else if(!submitted && printed){ Ext.MessageBox.alert('Submit Form', 'Please submit the form again before printing.'); printJob = hex_sha1(printJob); submitted = false; printed = false; }else if(!submitted && !printed){ Ext.MessageBox.alert('Submit Form', 'Please submit the form before printing.'); printJob = hex_sha1(printJob); } } },{ text: 'Reset', handler:function(){ Ext.MessageBox.alert('Resetting...', 'Resetting form...'); myform.getForm().reset(); } }], tbar: [{ text: 'Tournament Information', handler:function(){ if(win == null) { var win = new Ext.Window({ title: 'NCGA Tournament Information', width:500, height:300, float: true, closeAction:'hide', plain: true, items: tourneyTabs, buttons: [{ text: 'Close', handler: function(){ win.hide(); } }] }); } win.show(this); } }] }); myform.render(Ext.get("form")); });