 pageAppuntamenti = function() {
 
    this.tpl = new Ext.XTemplate('<tpl for=".">',
                                '<b>Data: {Data}<br>',
                                '<tpl if="Ora != \'NO\'">',
                                    'Ore: {Ora} - {Luogo}<br>',
                                '</tpl>',
                                '</b>{Appuntamento}<br><br>',
                                '</tpl>');
                  
    pageAppuntamenti.superclass.constructor.call(this, {
        header: false,
        border: false
    });
}

Ext.extend(pageAppuntamenti, Ext.Panel, {
    init: function() {
        Ext.Ajax.request({
            url: './php/getAllAppuntamenti.php',
            success: function(response, options)
            {
                data = eval(response.responseText);
                this.render('appuntamenti');
                for(i = 0; i < data.length; i++)
                {
                    if(data[i].Appuntamento)
                        data[i].Appuntamento = data[i].Appuntamento.replace('<br>', '');
                    else
                        data[i].Appuntamento = 'Nessuna descrizione';
                    if(data[i].Ora.length == 0)
                        data[i].Ora = 'NO';
                }
                this.tpl.overwrite(this.body, data);
            },
            scope: this
        });
    }
});
