Ext.ns('energy');

energy.shortInfos = Ext.extend(Ext.Panel,{
  title:"&nbsp;",
  url:'/process/EMBrowser/site/counter/process.energy_counter.php'
  ,tpl:new Ext.XTemplate('<div class="type-1">'
    +'<fieldset class="type-2">'
    +'<legend class="type-2">Compteur {energy}</legend>'
    +'<table cellspacing="0" cellpadding="0" class="type-1"><tr class="row-c10">'
    +'<td class="label" >Nom ou numéro du compteur: </td>'
    +'<td class="data">{name}</td>'
    +'</tr><tr class="row-c10">'
    +'<td class="label">Utilisation : </td>'
    +'<td class="data">{usage_type_name}</td>'
    +'</tr></table>'
    +'</fieldset>'
    +'</div>'
  )
  ,frame:false
  ,height:200
  ,bodyStyle: 'padding:2px'
  ,collapsible:true
  ,initComponent:function() {
    var config = {}; // eo config object
    // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    // call parent initComponent
    energy.shortInfos.superclass.initComponent.apply(this, arguments);

  } // end of function initComponent
  ,onRender:function() {
    energy.shortInfos.superclass.onRender.apply(this, arguments);
  } // eo function onRender
  ,init_tpl:function(with_division_name) {
    var tplcontent = '<div class="type-1">'
    +'<fieldset class="type-2">'
    +'<legend class="type-2">Compteur {energy}</legend>'
    +'<table cellspacing="0" cellpadding="0" class="type-1"><tr class="row-c10">'
    +'<td class="label" >Nom ou numéro du compteur : </td>'
    +'<td class="data" width="257px">{name}</td>'
    +'</tr><tr class="row-c10">'
    +'<td class="label">Utilisation : </td>'
    +'<td class="data" width="257px">{usage_type_name}</td>'
    +'</tr></table>'
    +'</fieldset>'
    +'</div>';
    this.tpl=new Ext.XTemplate(tplcontent);
  }
  ,initModifyAction:function() {
    this.height = 320;
    this.buttons = [new Ext.Button({text:"Modifier",cmd:"update",xtype:"button"})];
  }
  ,init:function(counter_id) {
    this.counter_id = counter_id;
    this.load({
         url:this.url
        ,waitMsg:'Loading...'
        ,scope:this
        ,method:'GET'
        ,params:{cmd:'read',counter_id:counter_id}
        ,callback:function(var1,var2,response,var3) {
          var result = Ext.util.JSON.decode(response.responseText);
          switch(result.success){
            case 1:
              this.tpl.overwrite(this.body, result.data);
              this.setTitle(result.title.countertitle);
              break;
            default:
              Ext.MessageBox.alert('Attention',result.error);
              break;
          }
        }
    });
  }
});

Ext.reg('energyshortinfos', energy.shortInfos);

