Ext.ns('ES');

ES.PhysicDatasMainPanel = Ext.extend(Ext.Panel,{
  width: 700,
  layout:'table',
  layoutConfig:{columns:1},
  bodyStyle: 'padding:2px',
  frame:false,
  height:810,
  initComponent:function() {
// hard coded config - cannot be changed from outside
    var config = {
      items:[{
        xtype:'ESphysicdatasgrid',
        height:900,
        width:694
      }]
    };
    // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    ES.PhysicDatasMainPanel.superclass.initComponent.apply(this, arguments);
    this.physicDatasGrid=this.items.itemAt(0);
  }
  ,onRender:function() {
    ES.PhysicDatasMainPanel.superclass.onRender.apply(this, arguments);
    this.isPhysicDemo();
  }
  ,isPhysicDemo: function(){
    Ext.Ajax.request({
      ownerCt: this,
      waitMsg: 'Please wait...',
      url: '/process/extjs/site/profil/physicdatas/physicdatas.php',
      params: {cmd: 'demo'}
      ,success: function(response,scope){
        var result = Ext.util.JSON.decode(response.responseText);
        switch(result.success){
          case 1:
            scope.ownerCt.physicDatasGrid.demoModality();
          break;
        }
      },failure: function(response) {
        Ext.MessageBox.alert('error','L application n a pas pu se connecter a la base de données. Veuillez réessayer plus tard');
      }
    });
  } 
});

Ext.reg('ESphysicDatasMainPanel', ES.PhysicDatasMainPanel);
