<?php require "_header.php";
	if($_SESSION['cCompany_id']!="" && isset($_SESSION['cCompany_id'])){
		$objQuotationMgmt = new QuotationMgmt();
		$out = $objQuotationMgmt->quotationtemplate_getRecordById();
	}	
?>

<script type="text/javascript">

	var varquotation_header = new Ext.form.HtmlEditor({
		name:'quotation_header',
		id:'quotation_header',
		fieldLabel: 'Header',
		width:500,
		height:150
	});
	
	var varquotation_footer = new Ext.form.HtmlEditor({
		name:'quotation_footer',
		id:'quotation_footer',
		fieldLabel: 'Footer',
		width:500,
		height:150 
	});

	var varcompany_id = new Ext.form.TextField({
		name:'company_id',
		id:'company_id',
		hidden:true
	});

	
	Ext.onReady(function(){
		Ext.QuickTips.init();
		
		Ext.form.Field.prototype.msgTarget = 'side';
		
		var quotation_template = new Ext.FormPanel({
			labelWidth: 50,
			url:'save-quotation-template.php',
			method:'post',
			frame:true,
			title: '',
			bodyStyle:'padding:6px 6px 0',
			defaultType: 'textfield',
			items :[
				varquotation_header, 
				varquotation_footer,
				varcompany_id
			]
		});
		
		var win = new Ext.Window({
			title: 'QUOTATION - Header/Footer',
			height: 400,
			width: 600,
			layout: 'fit',
			closeAction:'hide',
			collapsible:'true',
			resizable:false,
			maximizable:'true',
			border:false,
			items: quotation_template,
			buttonAlign:'center',
			buttons: [
				{
					text:'Save',
					iconCls:'icon-save',
					handler: function () {  
						quotation_template.getForm().submit({
							waitMsg: 'Saving...',		
							success: function () {		
								Ext.MessageBox.show({
									title: 'Message',
									msg: 'Data has been saved..',
									buttons: Ext.MessageBox.OK,
									icon:Ext.MessageBox.INFO
								});
								quotation_template.getForm().reset();
								window.location = 'addedit-quotation-header-footer.php' ;
							},
							failure: function () {	
								Ext.MessageBox.show({
									title: 'Error',
									msg: 'Please fill complete form!',
									buttons: Ext.MessageBox.OK,
									icon:Ext.MessageBox.ERROR
								});
							}
						});
					}
				},
				{
					text: 'Reset', 
					iconCls:'icon-reset',
					handler: function () {   
						quotation_template.getForm().reset();
					}
				},
				{
					text: 'Close',
					iconCls:'icon-close',
					handler: function () {    
						win.close();
					}
				}
			]
		});
		win.hide();
		win.show();
			 
	var varWidth =  (screen.width - win.width)/2;
	win.setPosition(varWidth,((screen.height/4)-110));

	});
	
	Ext.getCmp('quotation_header').setValue("<?php print $objQuotationMgmt->quotation_header; ?>");
	Ext.getCmp('quotation_footer').setValue("<?php print $objQuotationMgmt->quotation_footer; ?>");
	Ext.getCmp('company_id').setValue("<?php print $objQuotationMgmt->company_id; ?>");


</script>
<div id="main-content" align="left"></div>

<?php require "_footer.php";?>