Ext.namespace('com.domorewithsage.mock');


com.domorewithsage.mock.CustomerTaskTree = Ext.extend(Ext.tree.TreePanel, {

    initComponent : function()
    {
        Ext.apply(this, {
            lines : false,
            root  : new Ext.tree.TreeNode({
                text     : 'Tasks',
                expanded : true
            }),
            rootVisible : false
        });

        Ext.applyIf(this, {
            title : 'Customers'
        });

        this.on('render', this._initChildren, this);

        com.domorewithsage.mock.CustomerTaskTree.superclass.initComponent.call(this);
    },

    _initChildren : function()
    {
        var root = this.getRootNode();

        root.appendChild(
            new Ext.tree.TreeNode({
                text      : 'New customer',
                iconCls   : 'newCustomer',
                leaf      : true,
                listeners : {
                    click : function() {
                        var m = new com.domorewithsage.mock.CustomerFormWindow({
                            modal  : true,
                            width  : 860,
                            height : 480
                        });

                        m.show();
                    }
                }
            })
        );

        var nodes = [{
            text    : 'Edit Customer',
            iconCls : 'editCustomer'
        }, {
            text    : 'New Quotation',
            iconCls : 'newQuotation'
        }, {
            text    : 'New Sales Order',
            iconCls : 'newSalesOrder'
        }, {
            text    : 'New Invoice',
            iconCls : 'newInvoice'
        }, {
            text    : 'Allocate Stock',
            iconCls : 'allocateStock'
        }, {
            text    : 'Despatch Orders',
            iconCls : 'despatchOrders'
        }, {
            text    : 'Receive Payment',
            iconCls : 'receivePayment'
        }, {
            text    : 'Post Invoices',
            iconCls : 'postInvoices'
        }, {
            text    : 'New Credit',
            iconCls : 'newCredit'
        }, {
            text    : 'Write Off / Refund',
            iconCls : 'writeOffRefund'
        }, {
            text    : 'Manage Credit Control',
            iconCls : 'manageCreditControl'
        }, {
            text    : 'Customer Refund',
            iconCls : 'customerRefund'
        }];

        var config = {
            leaf : true
        };

        for (var i = 0, len = nodes.length; i < len; i++) {
            Ext.apply(nodes[i], config);
            root.appendChild(
                new Ext.tree.TreeNode(nodes[i])
            );
        }
    }


});