<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
include_once(PATH_TO_ROOT."CRM/class/class.checkString.php");

	
$db->ChangeDatabase(DB_WARPIT_WEBCATI_BASE);
include_once (PATH_TO_ROOT."CRM/_CRM_config.php");
include_once(PATH_TO_ROOT."CRM/class/class.Language-Pack.php");

$LangPack = new LanguagePack($db, $aLanguage);
$ajax = "CRM/_forms/nastavitve/_ajax/ajax.tipDostave.php";

$windowId = "WindowAddPla";
?>
var <?php echo $windowId;?> = new Ext.Window({
	title: '<?php echo $LangPack->GetLabel("CRM_settings_panel", "shipping_window_add_title","Dodaj tip dostave"); ?>',
    id		: '<?php echo $windowId;?>',
    width	: 350,
    height	: 130,
    plain	: true,
    layout	: 'fit',
    frame: true,
    modal: true,
    items:[new Ext.form.FormPanel({
    	bodyStyle: 'padding: 20px',
		border: false,
		id: 'addPlacForm',
		items:[{
			xtype: 'textfield',
        	name: 'tip_dostave',
        	fieldLabel: '<?php echo $LangPack->GetLabel("CRM_settings_panel", "order_type_title","Tip Dostave"); ?>',
        	anchor: '100%',
        	allowBlank: false
		}]
    })],
    listeners: {
		afterRender: function(grid){
			var X = (screen.width/2) - ((Ext.getCmp('<?php echo $windowId;?>').getSize().width)/2);
			var Y = (screen.height/2) - ((Ext.getCmp('<?php echo $windowId;?>').getSize().height)/2);
			Ext.getCmp('<?php echo $windowId;?>').setPosition(X, Y);
		}
	},
	buttons:[{
		text: '<?php echo $LangPack->GetLabel("CRM_all", "CRM_cancle_button","Prekliči"); ?>',
		handler: function(){
			<?php echo $windowId;?>.close();
		}
	},{
		text:'<?php echo $LangPack->GetLabel("CRM_all", "CRM_add_button","Dodaj"); ?>',
		handler: function(){
			if(Ext.getCmp('addPlacForm').getForm().isValid()){
				Ext.getCmp('addPlacForm').getForm().submit({
					url:'<?php echo $ajax;?>',
					params: {
						action: 'submit'
					},
					success: function(resp, opt){
						<?php echo $windowId;?>.close();			
						Ext.getCmp('<?php echo StringChecker::Check($_POST['name']); ?>').getStore().reload();
					}
				});
			}
		}
	}]
}).show();
