pendingusers = {};
pendingusers.Invoked = false;

pendingusers.ViewPendingUsers = function(){
    // Prevent this from being called twice
    if(document.getElementById('pendingitems') == null || pendingusers.Invoked){
        return;
    }
    
    pendingusers.gridstore = new Ext.data.JsonStore({
        id:             "pendingusers",
        root:           'data',
        totalProperty:  'totalcount',
        idProperty:     'ticketid',
        remoteSort:     true,
        fields:         [
            'fname',
			'lname',
            'email'
        ],
        proxy:          new Ext.data.HttpProxy({
            url:  'index.php?fuse=clients&action=getPendingUsersList'
        })
    });
    
    pendingusers.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.customerid, record.data.customer);
    }
	
	pendingusers.grid = new Ext.grid.GridPanel({
        el:               'pendingitems',
        autoHeight:       true,
        store:            pendingusers.gridstore,
        trackMouseOver:   true,
        disableSelection: true,
        loadMask:         true,
        columns:          [
			{
                id:         'fname',
                header:     "First Name",
                width:      75,
                dataIndex:  "fname"
            },
            {
                id:         'lname',
                header:     "Last Name",
                width:      50,
                dataIndex:  "lname"
            },
			{
                id:         'email',
                header:     "E-Mail",
                width:      50,
                dataIndex:  "email"
            }			
        ],
        stripeRows:       true,
        viewConfig:       {
            forceFit:       true,
            enableRowBody:  true,
            emptyText:      lang("There are currently no pending users to be deleted."),
            scrollOffset:   1
        }
    });

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