suspender = {};
suspender.Invoked = false;

suspender.ViewSuspender = function(){
    // Prevent this from being called twice
    if(document.getElementById('pendingitems') == null || suspender.Invoked){
        return;
    }
    
    suspender.gridstore = new Ext.data.JsonStore({
        id:             "suspender",
        root:           'data',
        totalProperty:  'totalcount',
        idProperty:     'ticketid',
        remoteSort:     true,
        fields:         [
            'customer',
			'customer_id',
			'package_type',
            'package',
			'domain',
			'manual',
			'date',
			'action'
        ],
        proxy:          new Ext.data.HttpProxy({
            url:  'index.php?fuse=admin&action=getSuspenderList'
        })
    });
    
    suspender.renderName = function(value, p, record){
        return String.format('<a href="index.php?fuse=clients&amp;view=Admin_Profile_Contact&amp;frmClientID={0}">{1}</a>', record.data.customer_id, record.data.customer);
    }
	
	suspender.grid = new Ext.grid.GridPanel({
        el:               'pendingitems',
        autoHeight:       true,
        store:            suspender.gridstore,
        trackMouseOver:   true,
        disableSelection: true,
        loadMask:         true,
        columns:          [
			{
                id:         'customer',
                header:     "Customer",
                width:      50,
				renderer:	suspender.renderName,
                dataIndex:  "customer"
            },
            {
                id:         'package_type',
                header:     "Package Type",
                width:      50,
                dataIndex:  "package_type"
            },
			{
                id:         'package',
                header:    	"Package Name",
                width:      50,
                dataIndex:  "package"
            },
			{
                id:         'domain',
                header:    	"Domain",
                width:      50,
                dataIndex:  "domain"
            },
			{
                id:         'date',
                header:    	"Due Date",
                width:      30,
                dataIndex:  "date"
            },
			{
                id:         'manual',
                header:    	"Requires Manual Suspension",
                width:      50,
                dataIndex:  "manual"
            }
        ],
        stripeRows:       true,
        viewConfig:       {
            forceFit:       true,
            enableRowBody:  true,
            emptyText:      lang("There are no packages to be suspended or unsuspended."),
            scrollOffset:   1
        }
    });

    suspender.grid.render();
    suspender.gridstore.load({params:{start:0, limit:0}});
    suspender.Invoked = true;
}