
//{block name="backend/order/view/detail/window" append}
//{namespace name=backend/order/view/magnalister/detail}
//alert( 'In magnalister');

Ext.define('Shopware.apps.Magnalister.order.detail.view.main.Window', {
    override: 'Shopware.apps.Order.view.detail.Window',
    createTabPanel: function () {
        var me = this;
        var tabPanel = me.callParent(arguments);
        html = me.isMyOrderValid();
        if(html !== false){
            tabPanel.add(Ext.create('Shopware.apps.Magnalister.view.main.Panel', {
                title: 'magnalister',
                id: 'xpcTab',
                historyStore: me.historyStore,
                record: me.record,
                orderStatusStore: me.orderStatusStore,
                paymentStatusStore:  me.paymentStatusStore ,
                magnacontent:html.magnaorderdetailhtml,
                logo : html.logo
            }));
        }
        return tabPanel;
    },
    isMyOrderValid: function(){
        var id = this.record.get('id');
        var result = false;
        Ext.Ajax.request({
            url: '{url controller=Magnalister action=isMagnalisterOrder}',
            method:'POST',
            async:false,
            params: {
                orderId:id
            },
            success: function(response){
                var decodeddata = Ext.decode(response.responseText);
                if(decodeddata.success === true){
                    result = decodeddata;
                    
                }else{
                    result =  false;
                }

            }
        });
        return result;
    }
});
//{/block}