Ext.ns('iPack');

iPack.WohnheimAufnahmeAntrag = Ext.extend(MyLib.BaseForm, {
	constructor : function(pTarget, pNLS, pLang) {
    var items = [{
					name: "AufnahmeantragInfo",
					autoHeight: true,
					autoWidth: true,
// 					style : 'font-weight:bold;',
					cls : 'aufnahmeantraginfo',
					value : "Bitte den Antrag vollständig ausfüllen",
					fieldLabel : "",
					hideLabel : true,
					noPost: true,
					xtype : 'displayfield'
				},
				{
					title : 'Angaben zum Mietobjekt',
					autoHeight : true,
					autoWidth : true,
					xtype : 'fieldset',
					items : [
							{
								id : "idOrt",
								name : "Ort_ID",
								fieldLabel : "Ort",
								xtype : "x_dblookupcombo",
								lookupid : "ort",
								dependendLBs : [ "WH_1",
										"WH_2", "WH_3" ],
								allowBlank : false

							},
							{
								name : "VOArtWunsch",
								fieldLabel : "Gewünschtes Mietobjekt",
								xtype : "x_dblookupcombo",
								lookupid : "mietobjekt",
								allowBlank : false
							},
							{
								id : "WH_1",
								name : "Wohnheim1",
								fieldLabel : "Wohnheimauswahl",
								xtype : "x_dblookupcombo",
								lookupid : "wohnheim",
								rightText : 'oder',
								allowBlank : false
							},
							{
								id : "WH_2",
								name : "Wohnheim2",
								fieldLabel : "",
								xtype : "x_dblookupcombo",
								lookupid : "wohnheim",
								rightText : 'oder',
								allowBlank : true
							},
							{
								id : "WH_3",
								name : "Wohnheim3",
								fieldLabel : "",
								xtype : "x_dblookupcombo",
								lookupid : "wohnheim",
								allowBlank : true
							},
							{
								id : "idHochschule",
								name : "Hochschule_ID",
								fieldLabel : "Hochschule",
								xtype : "x_dblookupcombo",
								lookupid : "hochschule",
								dependendLBs : ["idSemester"],
								allowBlank : true
							},
							{
								id : "idSemester",
								name : "Semester_ID",
								noPost: true,
								fieldLabel : "Gewünschter Einzugstermin",
								xtype : "x_dblookupcombo",
								lookupid : "hochschulesemester",
								listeners : {
									select : function(combo, record, index){
										var bn = Ext.getCmp('Beginnwunsch');
										var d = Date.parseDate(record.data.id.substring(0, 10), 'Y-m-d');
										bn.setValue(d);
									}
								},
								allowBlank : true
							},
							{
								id : "Beginnwunsch",
								name : "Beginnwunsch",
								fieldLabel : "",
								xtype : "x_datefield",
								minValue : new Date().clearTime(true),
								maxValue : new Date().add(
										Date.DAY, 365),
								listeners : {
									change : function (fld, newValue, oldValue ){
										var bn = Ext.getCmp('idSemester');
										bn.reset();
									}
								},
								allowBlank : true
							}, {
								name : "Mietobergrenze",
								fieldLabel : "Mietobergrenze",
								xtype : "numberfield",
								allowDecimals : false,
								minValue : 0,
								maxValue : 2000,
								rightText : '€',
								allowBlank : true,
								width: 88
							}, {
								name : "Mietdauer",
								fieldLabel : "Gewünschte Mietdauer",
								xtype : "numberfield",
								allowDecimals : false,
								minValue : 1,
								maxValue : 60,
								rightText : 'Monate',
								allowBlank : true,
								width: 88
							} ]
				},
				{
					title : 'Angaben zur Person',
					autoHeight : true,
					autoWidth : true,
					defaultType : 'x_textfield',
					xtype : 'fieldset',
					items : [{
								name : "Name",
								fieldLabel : "Name",
								allowBlank : false,
								fieldLength : 25
							}, {
								name : "Vorname",
								fieldLabel : "Vorname",
								allowBlank : false,
								fieldLength : 20
							}, {
								name : "Geburtsname",
								fieldLabel : "Geburtsname",
								fieldLength : 25,
								allowBlank : true
							}, {
								name : "Geburtsdatum",
								allowBlank : false,
								fieldLabel : "Geburtsdatum",
								xtype : "x_datefield",
								allowBlank : false,
								minValue : new Date().clearTime(false).add(Date.YEAR, -75),
								maxValue : new Date().clearTime(false).add(Date.YEAR, -16)
							}, {
								name : "Geschlecht",
								fieldLabel : 'Geschlecht',
								allowBlank : false,
								xtype : 'x_radiogroup',
								width: 210,
								items : [{
											boxLabel : 'männlich',
											name : 'Geschlecht',
											inputValue : 1
										}, {
											boxLabel : 'weiblich',
											name : 'Geschlecht',
											inputValue : 2
										}]
							}, {
								name : "Familienstand",
								fieldLabel : "Familienstand",
								xtype : "x_dblookupcombo",
								lookupid : "familienstand",
								allowBlank : true
							}, {
								name : "NameEhepartner",
								fieldLabel : "Name Ehepartner",
								fieldLength : 20,
								allowBlank : true
							}, {
								name : "AnzahlKinder",
								fieldLabel : "Anzahl Kinder",
								xtype : "numberfield",
								allowDecimals : false,
								minValue : 0,
								maxValue : 20,
								allowBlank : true,
								width: 88
							}, {
								name : "Nationalitaet_ID",
								fieldLabel : "Nationalität",
								xtype : "x_dblookupcombo",
								lookupid : "nationalitaet",
								allowBlank : true
							}, {
								id : 'idE_MAIL1',
								name : "EMail",
								fieldLabel : "E-Mail",
								vtype : 'email',
								allowBlank : false,
								fieldLength : 75,
								allowBlank : false,
								width: 300
							}, {
								id : 'idE_MAIL2',
								name : "EMail2",
								fieldLabel : "E-Mail wiederholen",
								vtype : 'emailrepeat',
								refField : 'idE_MAIL1',
								fieldLength : 75,
								allowBlank : false,
								width: 300
							},/* {
								name : "Behinderung_ID",
								fieldLabel : "Behinderung",
								xtype : "x_dblookupcombo",
								lookupid : "behinderung",
								allowBlank : true
							},*/ {
								name : "Raucher",
								fieldLabel : "Raucher",
								checked : false,
								xtype : "x_checkbox",
								allowBlank : true
							}
					]
				}, {
					title : 'Angaben zum Studiengang',
					collapsible: false,
					autoHeight : true,
					autoWidth : true,
					defaultType : 'textfield',
					xtype : 'fieldset',
					items : [{
								name : "Fachbereich_ID",
								fieldLabel : "Fachbereich",
								xtype : "x_dblookupcombo",
								lookupid : "fachbereich",
								allowBlank : true
							}, {
								name : "Programm_ID",
								fieldLabel : "Förderung",
								xtype : "x_dblookupcombo",
								lookupid : "foerderung",
								allowBlank : true
							}, {
								name : "HochschuleSemester",
								fieldLabel : "Semesterzahl",
								xtype : "numberfield",
								allowDecimals : false,
								minValue : 0,
								maxValue : 99,
								allowBlank : true,
								noPost: true,
								width: 88
							},{
								name : "KFZBesitzer",
								fieldLabel : "PKW/Kennzeichen",
								checked : false,
								xtype : "x_checkbox",
								allowBlank : true,
								listeners : {
									check : function(cb, checked) {
										var c = Ext.getCmp('idKFZKennzeichen');
										c.setDisabled(!checked);
										if (!checked)
											c.setValue('');
									}
								}
							},{
								id: "idKFZKennzeichen",
								name : "KFZKennzeichen",
								fieldLabel : "",
								fieldLength : 12,
								allowBlank : true,
								disabled: true
							}
							]
				}, {
					title : 'Heimatadresse',
					collapsible: false,
					autoHeight : true,
					autoWidth : true,
					defaultType : 'x_textfield',
					xtype : 'fieldset',
					items : [{
								name : "StrasseHeimat",
								fieldLabel : "Straße Heimat",
								fieldLength : 25,
								allowBlank : true
							}, {
								name : "PLZHeimat",
								fieldLabel : "PLZ/Ort Heimat",
								fieldLength : 7,
								allowBlank : true
							}, {
								name : "OrtHeimat",
								fieldLabel : "",
								fieldLength : 25,
								allowBlank : true
							}, {
								name : "LandHeimat_ID",
								fieldLabel : "Land Heimat",
								xtype : "x_dblookupcombo",
								lookupid : "land",
								allowBlank : true
							}, {
								name : "TelefonHeimat",
								fieldLabel : "Telefon Heimat",
								fieldLength : 15,
								allowBlank : true
							}, {
								name : "TelefonMobil",
								fieldLabel : "Mobiltelefon",
								fieldLength : 15,
								allowBlank : true
							}]
				}, {
					title : 'Semesteradresse',
					collapsible: false,
					autoHeight : true,
					autoWidth : true,
					defaultType : 'x_textfield',
					xtype : 'fieldset',
					items : [{
								name : "StrasseSemester",
								fieldLabel : "Straße Semester",
								fieldLength : 25,
								allowBlank : true
							}, {
								name : "PLZSemester",
								fieldLabel : "PLZ/Ort Semester",
								fieldLength : 7,
								allowBlank : true
							}, {
								name : "OrtSemester",
								fieldLabel : "",
								fieldLength : 25,
								allowBlank : true
							}, {
								name : "LandSemester_ID",
								fieldLabel : "Land Semester",
								xtype : "x_dblookupcombo",
								lookupid : "land",
								allowBlank : true
							}, {
								name : "TelefonSemester",
								fieldLabel : "Telefon Semester",
								fieldLength : 15,
								allowBlank : true
							}]
				}, {
					title : 'Hinweise',
					collapsible: false,
					autoHeight : true,
					autoWidth : true,
					defaultType : 'x_textfield',
					xtype : 'fieldset',
					items : [{
								name : "Hinweise",
								fieldLabel : "Hinweise",
								hideLabel : true,
								xtype : "textarea",
								maxLength : 2000,
								width : 550,
								height : 200,
								allowBlank : true
							}]
        }, {
          title : 'Sicherheitscode',
          collapsible: false,
          autoHeight : true,
          autoWidth : true,
          defaultType : 'x_textfield',
          xtype : 'fieldset',
          items : [{
              xtype : "x_captcha",
              width : 200,
              height : 50,
              fieldLabel : 'Sicherheitscode'
            }, {
              name : "__captcha__",
              fieldLabel : "Sicherheitscode Eingabe",
              fieldLength : 8,
              allowBlank : false
            }
          ]
        }, {
					name: "confirmtext",
					autoHeight: true,
					autoWidth: true,
// 					width: 750,
// 					width: 700,
					style : 'font-weight:bold;',
					value : "Ich versichere hiermit, daß meine Angaben wahr und vollständig sind.",
					fieldLabel : "Versicherung wahre Angaben",
					hideLabel : true,
					noPost: true,
					xtype : 'displayfield'
				}, {
					name : "confirm",
					fieldLabel : '',
					hideLabel : true,
					xtype : 'x_radiogroup',
					autoHeight : true,
					// autoWidth : true,
					width : 350,
					noPost: true,
					items : [{
								boxLabel : 'Einverstanden',
								name : 'confirm',
								inputValue : 1,
								listeners : {
									check : function(cb, checked) {
										if (checked) {
											bn = Ext.getCmp('bnSubmit');
											bn.enable();
										}
									}
								}
							}, {
								boxLabel : 'Nicht Einverstanden',
								name : 'confirm',
								inputValue : 0,
								checked : true,
								listeners : {
									check : function(cb, checked) {
										if (checked) {
											bn = Ext.getCmp('bnSubmit');
											bn.disable();
										}
									}
								}
							}]
				}];
		var cfg = {
			restless: getRestlessBase() + "wohnheimaufnahmeantrag/" + pLang,
			submitTarget: "insertbewerber",
			successMessage: "Ihr Bewerbung wurde an die Wohnheimverwaltung weitergeleitet",
			successRedirect: "",
			animCollapse : false,
			autoScroll : true,
			labelWidth : 250,
			collapsible : false,
			split : true,
			frame : true,
			title : 'Aufnahmeantrag',
// 			width : 850,
			autoHeight : true,
			defaults : {
				width : 230
			},
			defaultType : 'textfield',
			items : items,
			buttonAlign : 'left'
			//listeners: {afterrender: function(p){Ext.getCmp('idOrt').focus(false, 0);}}
		};
		iPack.WohnheimAufnahmeAntrag.superclass.constructor.call(this,  pTarget, pNLS, pLang, 'Wohnheimaufnahmeantrag', cfg);
		var fn_disable = function(){Ext.getCmp('bnSubmit').setDisabled(true);};
		fn_disable.defer(500, this);
		Ext.getCmp('idOrt').focus(false, 500);
	}
});






