<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
Ext.apply(Ext.form.VTypes, {
  <?php  $year= $_SESSION["cYear"];
  
$qry="SELECT year_name FROM lms_yearmaster WHERE year_id = $year ";
$out=dbQuery($qry);
$result = dbArray($out);
 $result['year_name'];
 ?>
    daterange : function(val, field) {
        var date = field.parseDate(val);

        if(!date){
            return;
        }
        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(date);
            start.validate();
            this.dateRangeMax = date;
        } 
        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(date);
            end.validate();
            this.dateRangeMin = date;
        }
        return true;
    }
});


var labelArray;
labelArray = [
				['Date :<span class="comp">*</span>']
			];


var ayear='<?php print $result['year_name']; ?>';
var start='1/4/';
start+=ayear.substring(0,4);

var end='31/3/';
end+=ayear.substring(5,9);

var startdate = new Ext.form.DateField({
    id: 'profitstartdate',
	labelSeparator:'',	
	fieldLabel :labelArray[0] ,
	name: 'profitstartdate',
	emptyText :'From',
	allowBlank:false,
	vtype: 'daterange',
	minValue:start,
	maxValue:end
	
});	


var enddate = new Ext.form.DateField({
    id: 'profitenddate',
	fieldLabel: '',
	name: 'profitenddate',
	emptyText :'To',
	allowBlank:false,
	minValue:start,
	maxValue:end
	
});	




Ext.onReady(function(){
    Ext.QuickTips.init();
    
  
 	

    var ProfitAndLose = new Ext.FormPanel({
        labelWidth: 45, // label settings here cascade unless overridden
        url:'report-form-day-book-result.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        
		defaultType: 'textfield',
        items :[
		  	    {
						xtype       : 'container',
						autoEl      : {},
						border      : false,
						layout      : 'column',
						anchor      : '100%',
						defaultType : 'field',
						items       : [{
										xtype  : 'container',
										autoEl : {},
										layout : 'form',
										columnWidth : .55,
										items  : [startdate]
									   },
									   {
										xtype       : 'container',
										autoEl      : {},
										layout      : 'form',
										columnWidth : .35,
										labelWidth  : 1,
										items       : [enddate]
									   }]
		             }
			   ]
		
    });	
	 var win = new Ext.Window({  
        title: 'Day Book Report',
        height: 120,
        width: 340,
		border: false,
		modal:true,
        layout: 'fit',
		closeAction:'close',
   	 	collapsible:'true',
		
		items: ProfitAndLose,
		buttons: [{
							text:'View Report',
							handler: function()
							{ 
							   var profitstartdate=ProfitAndLose.getForm().findField('profitstartdate').getValue().format('d/m/Y');
							var profitenddate=ProfitAndLose.getForm().findField('profitenddate').getValue().format('d/m/Y');
							
							  var redirect = 'report-form-day-book-result.php?profitstartdate='+profitstartdate + '&profitenddate='+profitenddate; 
							  window.location = redirect;	
							}
				  },
				  {
							text: 'Reset', 
							handler: function () {   
			                ProfitAndLose.getForm().reset();
		                    }
			      },
				  {
		   		           text: 'Close',
					       handler: function () {    
						   //window.location = 'loginhome.php';
						   win.close();
				           }
                  }
				 ]	
    });
	var varWidth =  (screen.width - win.width)/2;
win.setPosition(varWidth,((screen.height/4)-100));
	win.show();
});
</script>
<div align="center"><div id="main-content" style="width:600px" align="left"></div></div> 
<?php require "_footer.php";?>