<?php require "_header.php";?>
<!-- start custom CSS/JS -->
<script type="text/javascript">

Ext.onReady(function(){

	var date = new Date();
	var month_name=new Array(12);
		month_name[0]="January"; month_name[1]="February";  month_name[2]="March";
		month_name[3]="April";   month_name[4]="May";       month_name[5]="June";
		month_name[6]="July";    month_name[7]="August";    month_name[8]="September";
		month_name[9]="October"; month_name[10]="November"; month_name[11]="December";

	var currmonthno = date.getMonth();
	var currmonth = month_name[date.getMonth()];
	var year = date.getFullYear();
	currmonthno =currmonthno+1;
	
	Ext.QuickTips.init();
	Ext.namespace('Ext.exampledata');
		
    var sectionliststore = new Ext.data.Store({
			url: 'data/getsectionlist.php',          
	        reader: new Ext.data.JsonReader({			
                fields: ['section_id', 'section_name'],
                root: 'rows'
            }),
            autoLoad: true
        });

	var monthstore = new Ext.data.ArrayStore({
           fields: ['valuemonth','displaymonth'],
	       data: [['1','January'],['2','February'], ['3','March'], 
				['4','April'], ['5','May'],['6','June'],
				['7','July'],['8','August'],['9','September'],
					['10','October'],['11','November'],['12','December']]
        });
    
    
    var EmpMuster = new Ext.FormPanel({
        labelWidth: 100, // label settings here cascade unless overridden
        url: 'report-employee-muster.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        bodyStyle:'padding:5px 5px 0',
		layout:'form',
		 items :[
					   {
 	            	    xtype: 'combo',
                        fieldLabel: 'Section',
                        name: 'sectionid',
						id:'section',
						hiddenName: 'sectionid',
                        store: sectionliststore,
                        displayField:'section_name',
						valueField: 'section_id',
						width: 150,
                        typeAhead: true,
						selectOnFocus:true,
						forceSelection:true,
                        mode: 'local',
                        triggerAction: 'all',
					    emptyText:'Select Section...',
						editable:false ,
						allowBlank:true,
						hidden:true,
						listeners:{select:{fn:function(combo, value) 
									{										      
										var combostandard = Ext.getCmp('standard'); 
										secid=combo.getValue('section_id'); 
																																																						
									}
								  }
						   }
                       },
					   
					   {
						xtype:'combo',
                        fieldLabel: 'Month',
               			name: 'monthname',
						id:'monthid',
						hiddenName: 'monthname',	
                        store:monthstore,
                        displayField:'displaymonth',
						valueField: 'valuemonth',
                        typeAhead: true,
						selectOnFocus:true,						
						forceSelection:true,
                        mode: 'local',
						width: 150,
                        triggerAction: 'all',
						allowBlank:false,
                        emptyText:'Select Month...',
						value:currmonthno
                      },
					   {
                        xtype:'numberfield',
                        name: 'year',		
						id:'year',
						hiddenName: 'year_number',
                        fieldLabel: 'Year',
						value:year,
						minLength:4,
						width: 150,
						maxLength:4,
                        allowBlank:false,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '4'}
					  }
					  ]
    });
	EmpMuster.getForm().findField("monthname").setValue(currmonthno);					
	EmpMuster.getForm().findField("monthname").setRawValue(currmonth);	
	
	var EmployeeGeneralWindow = new Ext.Window({
        title: 'Employee Muster Report',
		width:300,		
		height:175,		
		border: false,
		modal:true,
		layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: EmpMuster,
		buttonAlign: 'center',
		buttons: [
				 {
					text:'View Report',	
					handler: function(b, e)
					{
						var monthname=EmpMuster.getForm().findField('monthname').getValue();
						var year=EmpMuster.getForm().findField('year').getValue();
						
			
var redirect = 'report-employee-muster.php?monthname='+monthname + '&year='+year ; 
                window.location = redirect;	
					}
				},
				 {
					text:'Reset',	
					handler: function(b, e)
					{		
					EmpMuster.getForm().reset();	
					}
				},
				{
				text: 'Close',
				handler: function () {   
				EmployeeGeneralWindow.close();
									 }
			   }
					]

	});
	var varWidth =  (screen.width - EmployeeGeneralWindow.width)/2;
	EmployeeGeneralWindow.setPosition(varWidth,((screen.height/4)-110));
	EmployeeGeneralWindow.show();
	
	SetSectionValue('add',sectionliststore,'section','section'); 		  

});




</script>
<!-- end custom CSS/JS -->
<div align="center"><div id="main-content" align="left" style="width:300px"></div></div>
<?php require "_footer.php";?>