<?php
require "_header.php";
require "data/combo_student.php";
require "data/combo_semester.php";
require "data/combo_branchyear.php";
require "includeGridFilters.php";
if ($_SESSION["VedantnrUserRole"] == 'Hod') {
	$hod_sql = " SELECT branch_id FROM `cms_employeemaster` WHERE `user_id` ='" . $_SESSION["VedantnrUserId"] . "'";
	$hod_out = dbQuery($hod_sql);
	$branch_id = dbArray($hod_out);
	$branch_id = $branch_id['branch_id'];
}

?>
<div id="main-content">
	<script language="javascript" type="text/javascript">
		Ext.onReady(function () {
			Ext.QuickTips.init();



			var labelArray;
			labelArray = [
				['Branch <span class="comp">*</span>'],
				['Batch Year <span class="comp">*</span>'],
				['Course Year <span class="comp">*</span>'],
				['Semester <span class="comp">*</span>'],
				['Subject '],
				['Employee '],
				['Lec Type ']
				['Batch  ']

			];


			var employeestore = new Ext.data.ArrayStore({
				fields: ['employee_id', 'employee_name', 'branch_name'],
				data: Ext.semester.employee
			});

			var branchstore = new Ext.data.ArrayStore({
				fields: ['branch_id', 'branch_name'],
				data: Ext.semester.branch
			});

			var batchyearstore = new Ext.data.ArrayStore({
				fields: ['year_id', 'year_name'],
				data: Ext.semester.yearname
			});

			var semesterstore = new Ext.data.ArrayStore({
				fields: ['branch_id', 'semester_id', 'semester_name'],
				data: Ext.semester.semester
			});

			var yearstore = new Ext.data.ArrayStore({
				fields: ['branch_id', 'branchyear_id', 'branchyear_name'],
				data: Ext.year.year
			});

			var subjectstore = new Ext.data.JsonStore({
				url: 'data/get-subject.php',
				root: 'data',
				totalProperty: 'total',
				fields: ['subject_id', 'subject_name']
			});
			subjectstore.load({ params: { task: 'getall' } });




			var startdate = new Ext.form.DateField({
				id: 'startdate',
				labelSeparator: '',
				fieldLabel: 'Date <span class="comp">*</span>',
				name: 'startdate',
				allowBlank: false,
				value: '<?php echo date('Y-m-01'); ?>'
			});

			var enddate = new Ext.form.DateField({
				id: 'enddate',
				fieldLabel: '',
				name: 'enddate',
				allowBlank: false,
				value: '<?php echo date('Y-m-t'); ?>'
			});

			/*var lectypestore = new Ext.data.ArrayStore({
				fields: ['lectype_id', 'lectype_name'],
				data: Ext.semester.lectype
			});*/




			var BatchStore = new Ext.data.JsonStore({
				url: 'data/get-batch.php',
				root: 'data',
				remoteSort: true,
				fields: [{
					name: 'batch_id',
					type: 'int'
				}, {
					name: 'batch_name',
					type: 'string'
				}], autoLoad: true,
			});





			var PresentForm = new Ext.FormPanel({
				method: 'post',
				frame: true,
				autoHeight: true,
				id: 'PresentForm',
				name: 'PresentForm',
				url: 'report-syllabus-covered-result.php',
				standardSubmit: true,
				items: [{
					xtype: 'combo',
					name: 'branch_name',
					id: 'branch_name',
					hiddenName: 'branch_hidden',
					fieldLabel: labelArray[0],
					displayField: 'branch_name',
					valueField: 'branch_id',
					width: 180,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: branchstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							//		Ext.getCmp('branch_disp').setValue(this.getRawValue());
							Ext.getCmp('semester_name').reset();
							Ext.getCmp('year_name').reset();
							Ext.getCmp('branchyear_name').reset();
							Ext.getCmp('employee_id').reset();
							employeestore.filter('branch_id', cmb.getValue(), false, true, true);
							semesterstore.filter('branch_id', cmb.getValue(), false, true, true);
							yearstore.filter('branch_id', cmb.getValue(), false, true, true);
							var semesterCombo = Ext.getCmp('semester_name');
							if (cmb.getValue() == 3 || cmb.getValue() == 5) {
								semesterCombo.enable();
							} else {
								semesterCombo.disable();
								semesterCombo.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'year_name',
					id: 'year_name',
					hiddenName: 'year_hidden',
					fieldLabel: labelArray[1],
					displayField: 'year_name',
					valueField: 'year_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: batchyearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							//Ext.getCmp('year_disp').setValue(this.getRawValue());

							Ext.getCmp('employee_id').reset();

						}
					}
				}, {
					xtype: 'combo',
					name: 'branchyear_name',
					id: 'branchyear_name',
					hiddenName: 'branchyear_hidden',
					fieldLabel: labelArray[2],
					displayField: 'branchyear_name',
					valueField: 'branchyear_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: yearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							//Ext.getCmp('branchyear_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('employee_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'semester_name',
					id: 'semester_name',
					hiddenName: 'semester_hidden',
					fieldLabel: labelArray[3],
					displayField: 'semester_name',
					valueField: 'semester_id',
					lastQuery: '',
					disabled: true,
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: semesterstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							//	Ext.getCmp('semester_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('employee_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'subject_name',
					id: 'subject_name',
					hiddenName: 'subject_hidden',
					fieldLabel: labelArray[4],
					displayField: 'subject_name',
					valueField: 'subject_id',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: subjectstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('employee_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'employee_id',
					id: 'employee_id',
					hiddenName: 'employee_hidden',
					fieldLabel: labelArray[5],
					displayField: 'employee_name',
					valueField: 'employee_id',
					editable: true,
					width: 180,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: employeestore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {

							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				},
			/*	{
					xtype: 'combo', 
					name: 'lectype',
					id: 'lectype',
					hiddenName: 'lectype_hid',
					labelSeparator: '',
					fieldLabel: 'Lec Type:',
					displayField: 'lectype_name',
					valueField: 'lectype_id',
					editable: true,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: lectypestore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('lectype_disp').setValue(this.getRawValue());

						}
					}
				},*/
				 {
					xtype: 'combo',
					name: 'batch_id',
					id: 'batch_id',
					hiddenName: 'batch_idhidden',
					allowBlank: true,
					fieldLabel: 'Batch :',
					forceSelection: true,
					labelSeparator: '',
					displayField: 'batch_name',
					valueField: 'batch_id',
					triggerAction: 'all',
					mode: 'local',
					store: BatchStore,
					listeners: {
						'select': function (cmb, rec, idx) {
						
						}
					}
				},
				{
					xtype: 'container',
					autoEl: {},
					border: false,
					layout: 'column',
					anchor: '100%',
					defaultType: 'field',
					items: [{
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .65,
						items: [startdate]
					}, {
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .35,
						labelWidth: 1,
						items: [enddate]
					}]
				}]
			});


			var PresentWindow = new Ext.Window({
				title: 'Employee Syllabus Covered Report',
				width: 350,
				autoHeight: true,
				modal: true,
				border: false,
				layout: 'fit',
				closeAction: 'close',
				collapsible: true,
				items: PresentForm,
				buttonAlign: 'center',
				buttons: [{
					xtype: 'button',
					text: 'View Report',
					iconCls: 'new-tab',
					width: 70,
					tabIndex: 9,
					name: 'btnSave',
					id: 'btnSave',
					handler: function () {

						var branch_hidden = PresentForm.getForm().findField('branch_hidden').getValue();
						var year_hidden = PresentForm.getForm().findField('year_hidden').getValue();
						var branchyear_hidden = PresentForm.getForm().findField('branchyear_hidden').getValue();
						var semester_hidden = PresentForm.getForm().findField('semester_hidden').getValue();
						var subject_hidden = PresentForm.getForm().findField('subject_hidden').getValue();
						var employee_hidden = PresentForm.getForm().findField('employee_hidden').getValue();
						//var lectype_hid = PresentForm.getForm().findField('lectype_hid').getValue();
						var batch_idhidden = PresentForm.getForm().findField('batch_idhidden').getValue();
						var enddate = PresentForm.getForm().findField('enddate').getValue().format('Y-m-d');
						var startdate = PresentForm.getForm().findField('startdate').getValue().format('Y-m-d');
						
						

						var redirect = 'report-syllabus-covered-result.php?branch_hidden=' + branch_hidden +
							'&semester_hidden=' + semester_hidden +
							'&year_hidden='+year_hidden+'&branchyear_hidden='+branchyear_hidden+
							'&subject_hidden=' + subject_hidden +
							'&batch_idhidden=' + batch_idhidden +
							'&enddate=' + enddate +
							'&startdate=' + startdate +
							
							'&employee_hidden=' + employee_hidden 	;


						window.location = redirect;

					}
				}, {
					xtype: 'button',
					iconCls: 'icon-reset',
					text: 'Reset',
					width: 70,
					tabIndex: 11,
					name: 'btnReset',
					id: 'btnReset',
					handler: function () {
						PresentForm.getForm().reset();
						Ext.getCmp('btnSave').enable();
						//grid.getSelectionModel().clearSelections();
						Ext.getCmp('branch_name').focus(true, 500);
						store.load();
					}
				}, {
					xtype: 'button',
					id: 'btnClose',
					text: 'Close',
					name: 'btnClose',
					iconCls: 'icon-close',
					width: 70,
					tabIndex: 11,
					handler: function () {
						PresentWindow.close();
					}
				}]
			});

			var varWidth = (screen.width - PresentWindow.width) / 2;
			PresentWindow.setPosition(varWidth, ((screen.height / 4) - 85));
			PresentWindow.show();
			<?php if ($branch_name != "") { ?>
				branchstore.filter('branch_id', '<?php echo $branch_name ?>', true, true, true);
			<?php } ?>
			Ext.getCmp('branch_name').focus(true, 1000);

		});
	</script>
	<div id="abcd" align="center"></div>
</div>
<?php require "_footer.php"; ?>