/*
 * Ext JS Library 3.0 RC1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 *
 * http://extjs.com/license
 */
// Some sample html




Ext.onReady(function(){
    Ext.QuickTips.init();
    // preventBodyReset: true
    var invoicestats = document.getElementById('invoicestats');
    var salestats = document.getElementById('salestats');
    var clientstats = document.getElementById('clientstats');
    var ticketstats = document.getElementById('ticketstats');
    var packagestats = document.getElementById('packagestats');

    var clienttotal = document.getElementById('clienttotal').value;
    var invoicetotal = document.getElementById('invoicetotal').value;
    var tickettotal = document.getElementById('tickettotal').value;
    var packagetotal = document.getElementById('packagetotal').value;

    var invoice = new Ext.Panel({
		title: 'Invoices Statistics (Total : '+invoicetotal+' )',
		preventBodyReset: true,
		//renderTo: 'invoicesdiv',
        collapsible:true,
		width: 450,
        height : 100,
        border : false,
        //html: invoicestats
        contentEl:invoicestats
        });
     var sales =   new Ext.Panel({
            title: 'Sales Statistics : ',
            preventBodyReset: true,
            //renderTo: 'salesdiv',
            collapsible:true,
            width: 400,
            height : 100,
            border : false,
            //html: invoicestats
            contentEl:salestats
        });
      var client =  new Ext.Panel({
            title: 'Client statistics (Total : '+clienttotal+' )',
            preventBodyReset: true,
            //renderTo: 'clientsdiv',
            collapsible:true,
            width: 450,
            border : false,
            height : 150,

            //html: invoicestats
            contentEl:clientstats
        });

        var packs = new Ext.Panel({
            title: 'Package Statistics (Total : '+packagetotal+' )',
            preventBodyReset: true,
           // renderTo: 'ticketsdiv',
            collapsible:true,
            width: 400,
            height : 150,
            border : false,
            //html: invoicestats
            contentEl: packagestats
        });
        var ticket = new Ext.Panel({
            title: 'Tickets Statistics (Total : '+tickettotal+' )',
            preventBodyReset: true,
           // renderTo: 'ticketsdiv',
            collapsible:true,
            collapsed : true,
            width: 450,
            height : 150,
            border : false,
            //html: invoicestats
            contentEl:ticketstats
        });

        var sample = new Ext.Panel({
		//title: 'Sample Statistics :',
        id:'main-panel',
		preventBodyReset: false ,
		renderTo: 'sample',
        layout:'table',
        layoutConfig: {columns:2},
        border : false,
       // collapsible:true,
		width: 950,
        items: [invoice,sales,client,packs,ticket]
        
        //html: invoicestats
        //contentEl:invoicestats

	});
        
       // sample.add(ticket);
       
    
});

//alert("FDsada"+invoicestats.id);
/*
    var storeItem = Ext.data.Record.create([{name:'myId',type:'string'},{name:'displayText',type:'string'}]);
    var domainsfiltercombo = new Ext.form.ComboBox({
        triggerAction: 'all',
        lazyRender:true,
        editable:false,
        value:'Total',
        mode: 'local',
        store: new Ext.data.ArrayStore({
            idIndex: 0,
            fields: [
                'myId',
                'displayText',
                'type',
                'private'
            ]
        }),
        valueField: 'myId',
        width: 220,
        displayField: 'displayText',
        applyTo: 'statisticsfilter',
        // all of your config options
        listeners:{
             'select': function(cb,record){

                FilterGrid(record.data.myId);
             }
        }

    });

    function FilterGrid(filter){
        //these are set in the viewusers.tpl
	    //if(customerid!=null) gridstore.setBaseParam('customerid', customerid);
        if(filter!=null) gridstore.setBaseParam('domainsfilter', filter);

        gridstore.load({params:{start:0,limit:15}});
        Ext.Ajax.request({
           url: requesturl,
           success: function(xhr) {
                        //refreshgrid
                        grid.enable()
                        gridstore.load({params:{start:0}});
                        var data = Ext.util.JSON.decode(xhr.responseText);
                        if(data.error){
                            //we do not need to repopulate the filters if there was a validation error
                           msg(lang("There was an error performing this action"),"");
                        }else if(data.message){
                            msg(data.message,"");
                        }else{
                            msg(lang("Ticket(s) have been updated"),"");
                        }
                    },
           failure: function() {
                grid.enable()
                Ext.Msg.alert("Fail");
           },
           params: { items: Ext.util.JSON.encode(getDomainItems()),
                     actionbutton: Ext.util.JSON.encode(button.id)


           }
        });
    }

   function updateButtonsWithContent(data){

        if(data.type == "filter"
           )
        {
            if(data.private == undefined){
                data.private = 0;
            }

            var comboitem = new storeItem({myId:data.id,displayText:data.name,type:data.type, private:data.private});
            domainsfiltercombo.getStore().insert(
                domainsfiltercombo.getStore().getCount(),
                comboitem
            );
        }

    }

    function PopulateDomainsFilters(){
        Ext.Ajax.request({
           url: 'index.php?fuse=home&action=GetStatisticsFilters',
           success: function(xhr) {

                        //clear the items from our combobox
                        domainsfiltercombo.getStore().removeAll();
                        //go through our options and add to the UI
                        var data = Ext.util.JSON.decode(xhr.responseText);
                        //data.options.forEach(updateButtonsWithContent);
                        for ( var i in data.options )
                        {
                            updateButtonsWithContent( data.options[i] );
                        }

                    },
           failure: function() {
                Ext.Msg.alert("Fail");
           },
           params: { foo: 'bar' }
        });
    }


    PopulateDomainsFilters();
});
*/


