Ext.ns('ES');

ES.HeatingCounterInfos = Ext.extend(Ext.Panel,{
  url:'/process/extjs/site/consumption/heating/heatingcounterentries.php'
  ,tpl:new Ext.XTemplate('<div class="type-1">'
    +'<fieldset class="type-2">'
    +'<legend class="type-2">Compteur chauffage</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">{heatingcountername}</td>'
    +'</tr>'
    +' <tr class="row-c10">'
    +'<td class="label">Energie:</td>'
    +'<td class="data">{energy}</td>'
    +'</tr>'
    +' <tr class="row-c10">'
    +'<td class="label">Unité:</td>'
    +'<td class="data">{unit}</td>'
    +'</tr></table>'
    +'</fieldset>'
    +'</div>'
  )
  ,width:436
  ,frame:false
  ,height:130
  ,border:false
  ,initComponent:function() {
    this.addEvents("gotUnit");
    var config = {}; // eo config object
    // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    // call parent initComponent
    ES.HeatingCounterInfos.superclass.initComponent.apply(this, arguments);
  } // end of function initComponent
  ,onRender:function() {
    ES.HeatingCounterInfos.superclass.onRender.apply(this, arguments);
  } // eo function onRender
  ,refresh:function(counter_id) {
    this.show();
    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.unitArray=result.data.unit;
            this.fireEvent("gotUnit", this);
          break;
        default:
            Ext.MessageBox.alert('Attention',result.error);
        break;
        }
      }
    });
  }
});

Ext.reg('ESheatingcounterinfos', ES.HeatingCounterInfos);



