• Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)
  • Cuixer, una forma de administrar páginas web que nunca viste!

Ayuda Urgente por favor!

Foros generales de ayuda Ext 2.0.

Ext.foro.Nuevo
Mensajes: 9
Registrado: 03 Abr 2011, 16:39
NotaPublicado: 04 Ene 2012, 19:47
hola, antes que nada, gracias por leer esta consulta.

Mi problema es el siguiente: Estoy intentando hacer un formulario de carga de clientes, donde ademas de cargar los datos de los combos (los cuales funcionan), deberia en caso de ser una CONSULTA ,cargar los datos del cliente en cuestion.

Como lo dije, los combos cargan bien, pero no me cargan los datos del cliente y si asi se pudiera, les consulto como deberia vincular el valor de los campos con los datos de la tabla.


mi codigo es:

formClientes.js:
Código: Seleccionar todo
formClientes = Ext.extend(Ext.app.Module, {
      id: 'frmClientes',
   init : function(){
        this.launcher = {
            text: 'Clientes ',
            iconCls:'bogus',
            handler : this.createWindow,
            scope: this,
            windowId:8
        }
    },

    createWindow : function(){
        /* Estructuras de Datos*/
      

      
       var storeCargo = new Ext.data.JsonStore({   // Construimos nuestra fuente de datos la cual se comunicara con nuestra Base de Datos
                       url: 'formClientes.php',
                       root: 'itemCliente',
                       baseParams: {
                                    task: 'CONSULTAR',
                               idCliente: 1
                                 },            // Parametro que utilizamos para listar los datos (Ver manteCargo.php)
        reader: new Ext.data.JsonReader({         // Sirve para cargar los datos y respuestas del servidor
         root: 'datosCliente',                  //   Resultado de la busqueda (viene con cada echo que devuelve el archivo PHP)
         totalProperty: 'total',               //   Total de filas de la busqueda (viene con cada echo que devuelve el archivo PHP)
         id:'idCliente'                           // Identificador
        },[                               // Filas
         {name: 'idCliente', type: 'integer'},   
         {name: 'apellido', type: 'string', mapping: 'text_apellido'},
         {name: 'nombre', type: 'string', mapping: 'text_nombre'}
        ])});         
   

storeCargo.on('load', function() {

   // data loaded, do something with it here...

});


storeCargo.load();

      var desktop = this.app.getDesktop();
        var win = desktop.getWindow('clientes');
        if(!win){
            win =
         desktop.createWindow({
                id: 'frmClientes',
                title:'Clientes',
                width:640,
                height:480,
                html : '',
                iconCls: 'bogus',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
            items:[               //Aquí incluimos los componentes que estaran dentro de nuestra ventana (en este caso el formulario)
                                                                              
                  {
                  id:'formulario',
                  xtype: 'form',      //Creamos nuestro formulario
                  frame: true,
                  border: true,
                  layout:'absolute',
                  height: 450,
                  url   : 'formClientes.php',
                  defaults: {         //Nos permite asignar ciertos parametros que afectaran a todos los componentes creados dentro de este formulario
                     width: 640      //En este caso asignaremos el parametro de ancho por defecto a todos los componentes, menos a las etiquetas
                  },
                  labelWidth: 130,   //Asigna el ancho de las etiquetas
                  items: [         //Aquí incluimos los componentes que estaran dentro de nuestro formulario (en este caso el combobox, textfield, etc.)
                  
               
            {
                xtype: 'label',
                text: 'Apellidos:',
                x: 10,
                y: 10
            
            },
            {
                xtype: 'label',
                text: 'Nombres:',
                x: 260,
                y: 10
            
            },
            {
                xtype: 'fieldset',
                title: 'Domicilio:',
                x: 0,
                y: 30,
                layout: 'absolute',
                height: 80,
            width:614,
            tabIndex: 3,
            items: [
                    {
                        xtype: 'label',
                        text: 'Num.:',
                        x: 300,
                        y: 0
                    },
                    {
                        xtype: 'label',
                        text: 'Piso:',
                        width: 30,
                        x: 400,
                        y: 0
                    },
                    {
                        xtype: 'label',
                        text: 'Calle:',
                        x: 0,
                        y: 0
                    },
                    {
                        xtype: 'label',
                        text: 'Depto.:',
                        x: 490,
                        y: 0
                    },
                    {
                        xtype: 'label',
                        text: 'Cod. Post.:',
                        x: -1,
                        y: 30
                    },
                    {
                        xtype: 'label',
                        text: 'Localidad:',
                        x: 370,
                        y: 30
                    },
                    {
                        xtype: 'label',
                        text: 'Provincia:',
                        x: 140,
                        y: 30
                    },
                    {
                        xtype: 'textfield',
                        x: 30,
                        y: -5,
                        width: 260,
                        name: 'cliente_calle'
                    },
                    {
                        xtype: 'textfield',
                        x: 330,
                        y: -3,
                        width: 60,
                        name: 'cliente_numero'
                    },
                    {
                        xtype: 'textfield',
                        x: 430,
                        y: -5,
                        width: 40,
                        name: 'cliente_piso'
                    },
                    {
                        xtype: 'textfield',
                        width: 60,
                        x: 530,
                        y: -2,
                        name: 'cliente_depto'
                    },
                    {
                        xtype: 'textfield',
                        x: 60,
                        y: 20,
                        width: 60,
                        name: 'cliente_cp'
                    },
                    {
                        xtype: 'combo',
                        x: 420,
                        y: 20,
                        id: 'cmbLocalidad',
                   fieldLabel: 'Localidades',
                      displayField: 'localidad',
                    valueField: 'idLocalidad',
                  hiddenName:'idLocalidad',
                  triggerAction: 'all',
                      mode: 'local',
                     store : new Ext.data.JsonStore({
                         url: 'cargarCombos.php',
                       root: 'datosLocalidades',
                       baseParams: {
                           combo: 'localidades'
                                 },
                             fields: [ 
                                 {name:'idLocalidad'}, 
                                 {name:'localidad'} 
                                  ] 
                                            })
                    },
                    {
                        xtype: 'combo',
                        x: 190,
                        y: 20,
                        id: 'cmbProvincias',
                    fieldLabel: 'provincias',
                    displayField: 'provincia',
                    valueField: 'idProvincia',
                  hiddenName:'idProvincia',
                      triggerAction: 'all',
                    mode: 'local',
                     store : new Ext.data.JsonStore({
                         url: 'cargarCombos.php',
                         autoLoad: true,
                         root: 'datosProvincias',
                         baseParams: {
                           combo: 'provincias'
                                  },
                            fields: [ 
                                 {name:'idProvincia'}, 
                                 {name:'provincia'} 
                                   ] 
                                         }),
                          listeners: {
                                  'select': function(c,r,i){
                                   st = Ext.getCmp('cmbLocalidad').getStore();
                                   st.load({
                                      params:{
                                        idProvincia:r.data.idProvincia
                                            }
                                       })
                                                    }
                                }
                                         }
                         ]
            },   
            {
                xtype: 'textfield',
                x: 60,
                y: 0,
                width: 190,
                id: 'text_apellido',
            tabIndex: 1
         },
            {
                xtype: 'textfield',
                x: 310,
                y: 0,
                width: 240,
                id: 'nombre',
            tabIndex: 2,
            value: 'rulo'
            },
            {
                xtype: 'fieldset',
                title: 'Telefonos y Mails:',
              tabIndex: 4,
              x: 0,
                y: 110,
                layout: 'absolute',
                height: 120,
            width: 614,
                items: [
                    {
                        xtype: 'textfield',
                        x: 90,
                        y: 0,
                  tabIndex: 2,
                        id: 'telefono_1'
                    },
                    {
                        xtype: 'textfield',
                        x: 90,
                        y: 30,
                  tabIndex: 6,
                        id: 'telefono_3'
                    },
                    {
                        xtype: 'textfield',
                        x: 460,
                        y: 0,
                  tabIndex: 4,
                        id: 'telefono_2'
                    },
                    {
                        xtype: 'textfield',
                        x: 460,
                        y: 30,
                  tabIndex: 8,
                        id: 'telefono_4'
                    },
                    {
                        xtype: 'combo',
                  tabIndex: 1,
                        x: 0,
                        y: 0,
                  id: 'cmbTipoTelefono1',
                  /**/
                  fieldLabel: 'Tipo de Telefono',
                       displayField:'tipoTelefono',                   
                     valueField:'idTipoTelefono',
                  hiddenName:'telefono1tipo',
                     triggerAction: 'all',
                  editable: false,
                     mode: 'local',
                  width: 80,
                  store : new Ext.data.JsonStore({
                            url: 'cargarCombos.php',
                            autoLoad: true,
                            root: 'datosTipoTelefono',
                          baseParams: {
                           combo: 'tipo_telefono'
                                     },
                            fields: [ 
                                 {name:'idTipoTelefono'}, 
                                 {name:'tipoTelefono'} 
                                  ] 
                                         })
                    },
                    {
                        xtype: 'combo',
                        x: 0,
                        y: 30,
                  tabIndex: 5,
                  id: 'cmbTipoTelefono3',
                  /**/
                  fieldLabel: 'Tipo de Telefono',
                       displayField:'tipoTelefono',                   
                     valueField:'idTipoTelefono',
                     triggerAction: 'all',
                  hiddenName:'telefono3tipo',
                  editable: false,
                     mode: 'local',
                  width: 80,
                  store : new Ext.data.JsonStore({
                            url: 'cargarCombos.php',
                            autoLoad: true,
                            root: 'datosTipoTelefono',
                          baseParams: {
                           combo: 'tipo_telefono'
                                     },
                            fields: [ 
                                 {name:'idTipoTelefono'}, 
                                 {name:'tipoTelefono'} 
                                  ] 
                                         })

                    },
                    {
                        xtype: 'combo',
                        x: 370,
                        y: 0,
                  tabIndex: 3,
                  id: 'cmbTipoTelefono2',
                  /**/
                  fieldLabel: 'Tipo de Telefono',
                       displayField:'tipoTelefono',                   
                     valueField:'idTipoTelefono',
                  hiddenName:'telefono2tipo',
                     triggerAction: 'all',
                  editable: false,
                     mode: 'local',
                  width: 80,
                  store : new Ext.data.JsonStore({
                            url: 'cargarCombos.php',
                            autoLoad: true,
                            root: 'datosTipoTelefono',
                          baseParams: {
                           combo: 'tipo_telefono'
                                     },
                            fields: [ 
                                 {name:'idTipoTelefono'}, 
                                 {name:'tipoTelefono'} 
                                  ] 
                                         })
               },
                    {
                        xtype: 'combo',
                        x: 370,
                        y: 30,
                  tabIndex: 7,
                  id: 'cmbTipoTelefono4',
                  /**/
                  fieldLabel: 'Tipo de Telefono',
                       displayField:'tipoTelefono',                   
                     valueField:'idTipoTelefono',
                  hiddenName:'telefono4tipo',
                     triggerAction: 'all',
                  editable: false,
                     mode: 'local',
                  width: 80,
                  store : new Ext.data.JsonStore({
                            url: 'cargarCombos.php',
                            autoLoad: true,
                            root: 'datosTipoTelefono',
                          baseParams: {
                           combo: 'tipo_telefono'
                                     },
                            fields: [ 
                                 {name:'idTipoTelefono'}, 
                                 {name:'tipoTelefono'} 
                                  ] 
                                         })


               },
                    {
                        xtype: 'label',
                        text: 'Correo Electronico:',
                        x: 0,
                        y: 70
                    },
                    {
                        xtype: 'textfield',
                        x: 100,
                        y: 60,
                        width: 390,
                  tabIndex: 9,
                  name: 'cliente_email'
                    }
                ]
            },
            {
                xtype: 'tabpanel',
                activeTab: 0,
                x: 0,
                y: 240,
                height: 190,
            width: 614,
                items: [
                    {
                        xtype: 'panel',
                        title: 'Datos Personales',
                        layout: 'absolute',
                        items: [
                            {
                                xtype: 'label',
                                text: 'F. de Nac.:',
                                x: 10,
                                y: 10
                            },
                            {
                                xtype: 'datefield',
                                x: 70,
                                y: 10,
                                name: 'cliente_fnac'
                            },
                            {
                                xtype: 'combo',
                                x: 250,
                                y: 10,
                                id: 'cmbTipo_Documento',
                        /**/
                        fieldLabel: 'Tipo de Documento',
                             displayField:'tipoDocumento',                   
                             valueField:'idTipoDocumento',
                        hiddenName:'idTipoDocumento',
                             triggerAction: 'all',
                        editable: false,
                             mode: 'local',
                        width: 60,
                         store : new Ext.data.JsonStore({
                                  url: 'cargarCombos.php',
                                  autoLoad: true,
                                  root: 'datosTipoDocumento',
                                 baseParams: {
                                    combo: 'tipo_documento'
                                           },
                                     fields: [ 
                                          {name:'idTipoDocumento'}, 
                                          {name:'tipoDocumento'} 
                                           ] 
                                               })
                     },
                            {
                              xtype: 'textfield',
                                x: 320,
                              y: 10,
                        width: 100,
                        id: 'documento'
                    },
                     {
                                xtype: 'label',
                                text: 'Documento:',
                                x: 180,
                                y: 10
                            }
                        ]
                    },
                    {
                        xtype: 'panel',
                        title: 'Carpetas'
                    },
                    {
                        xtype: 'panel',
                        title: 'Cuenta Corriente'
                    }
               ,
                    {
                        xtype: 'panel',
                        title: 'Comentarios'
                    }
                ]
            }

            
            
            
            ],
                  buttons:[         // Aqui incluiremos los botones del formulario
                  {
                     xtype: 'button',
                     text: 'Grabar',
                     handler:function(){   
                        if (Ext.getCmp('formulario').getForm().isValid()) {

                                    
                                 

                           Ext.getCmp('formulario').getForm().submit({                  
                                    method: 'POST',
                                    params:{ task:'GRABAR' },
                                    waitTitle: 'Validando datos',
                                    waitMsg: 'Enviando datos..',
                                    success: function(form, action){
                                       
                                     var data = Ext.util.JSON.decode(action.response.responseText);
                                    Ext.Msg.alert('Confirmación', data.message.reason);
                                    Ext.getCmp('formulario').getForm().reset();
                                    },
                                    failure: function(form, action){
                                          var data = Ext.util.JSON.decode(action.response.responseText);
                                          Ext.Msg.show({
                                          title:'Error',
                                          msg: data.errors.reason,
                                          buttons: Ext.Msg.OK,
                                          icon: Ext.MessageBox.ERROR
                                       });
                                          
                                          
                                    }
                                 });
                        }
                     }   
                  },
                  {
                     xtype: 'button',
                     text: 'Cancelar',
                     handler:function(){   
                     win.close();
                     }
                  }
                   ]
               }
            ]

            });

}

function mostrar(){
   
   win.show();
   
}
      

/*
      employee_data.load();
  */             
      storeCargo.load();
        win.show();
    }
});



formClientes.php:
Código: Seleccionar todo
<?php
header("Content-Type: text/plain");
require_once('../../../Gray/conexiones/GrayConn.php');
mysql_select_db($database_gray, $gray);
mysql_query("SET NAMES 'utf8'");

$task = '';
if ( isset($_GET['task'])){
  $task = $_GET['task'];
}
if ( isset($_POST['numero'])){
  $numero = $_POST['numero'];
}

switch($task){
   case "GRABAR":
      break;
      
      case "CONSULTAR":
      $idCliente = $_GET['idCliente'];
         $sql = "SELECT * FROM clientes WHERE idCliente = '" . $idCliente . "'";   
         if (!$rs = mysql_query($sql))
         {
            echo '{"success": false, "errors":{"reason": "Error al momento de grabar"}}';
         }else
         {
            while($obj = mysql_fetch_object($rs)){
      $arr[] = $obj;
    }
   
             
            echo '{"success":true, "total" : 1 , "itemCliente":'.json_encode($arr).'}';
            
            $sql = " INSERT INTO auxtabla (campo) values ('".json_encode($arr)."');";   
            $rsRegistro = mysql_query($sql, $gray) or die(mysql_error());
            

         }
      break;
default:
        echo "{failure:true}";

            $sql = " INSERT INTO auxtabla (campo) values ('Fallo');";   
            $rsRegistro = mysql_query($sql, $gray) or die(mysql_error());
        break;
   }
?>


DEsde ya, mil gracias por su ayuda.
Para no ver esta publicidad, debes ser usuario del Foro.
Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)


Cuixer, una forma de administrar páginas web que nunca viste!

Volver a Ext 2.0: Ayuda





  • Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)
  • Cuixer, una forma de administrar páginas web que nunca viste!