Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 13th, 2012  |  syntax: JavaScript  |  size: 9.17 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?echo $this->Helper('Html')->script('extjs/plugins/lovCombo/js/Ext.ux.form.LovCombo.js');?>
  2. <script>
  3.     // inicio da paginacao
  4.     var pageSize = 100;
  5.  
  6.     // exibe o nome do tipo de solicitação
  7.         function cover_status(val){
  8.                 if(val==0) {
  9.                         return '<span style="color:#EF5C2C;">Offline</span>';
  10.                 }else if(val==1)  {
  11.                         return '<span style="color:#85C974;">Online</span>';
  12.                 }else if(val==2){
  13.             return 'Oculto';
  14.         } else {
  15.             return val;
  16.         }
  17.         }
  18.  
  19.     Ext.onReady(function(){
  20.  
  21.     Ext.QuickTips.init();
  22.  
  23.     store = new Ext.data.Store({
  24.         proxy: new Ext.data.HttpProxy({
  25.             url: '<?=BASE_URL?>/Produto/DadosLogProduto',
  26.             method:'POST'
  27.         }),
  28.         reader: new Ext.data.JsonReader({
  29.                 fields: ['ProdutoNome', 'SiteNome', 'PrecoDe','PrecoPor', 'ParcelamentoMaximo', 'Status', 'DataAlteracao', 'NomeUsuario', 'DescontoAVista', 'UrlEspecialNome','LocalAlteracao'],
  30.                 root: 'rows',
  31.                 totalProperty: 'results'
  32.         }),
  33.         baseParams:{ start: 0,limit:pageSize},
  34.         autoLoad: false
  35.     });
  36.  
  37.         // Lista os sites
  38.     var siteStore = new Ext.data.JsonStore({
  39.         url             : '<?=BASE_URL?>/Usuario/GetSiteTodos',
  40.         method  : 'POST',
  41.         root    : 'data',
  42.         baseParams: {id: -1},
  43.         fields  : ['boxLabel','name','value', 'negrito'],
  44.         autoLoad : true
  45.     });
  46.     //Combo MultiSelect com opções dos Grupos e Sites
  47.     var lc = new Ext.ux.form.LovCombo({
  48.         id:'lovcombo'
  49.         ,width:180
  50.         ,hideOnSelect:false
  51.         ,editable: true
  52.         ,store: siteStore
  53.         ,triggerAction:'all'
  54.         ,valueField:'value'
  55.         ,displayField:'boxLabel'
  56.         ,boldField:'negrito'
  57.         ,mode:'local'
  58.         ,fieldLabel:'Sites'
  59.         ,hiddenName: 'Site'
  60.         ,hiddenValue: 'value'
  61.         ,checkField: 'checked'
  62.         ,labelWidth     :120
  63.     });
  64.  
  65.     lc.on('select', function (r,n) {
  66.         if(n.data.value.indexOf('sites') == 0){
  67.             n.data.checked ? lc.selectAll() : lc.deselectAll();
  68.         }
  69.  
  70.         if(n.data.value.indexOf('all_') == 0){
  71.             var inicio = n.data.value.indexOf('_') + 1;
  72.             var fim = n.data.value.length;
  73.             var GrupoId = n.data.value.substring(inicio, fim);
  74.  
  75.             n.data.checked ? lc.selectAllGroup(GrupoId) : lc.deselectAllGroup(GrupoId);
  76.         }
  77.     }, this);
  78.    
  79.    
  80.     //Cria input para inserção do número do pedido
  81.     var codigoProduto = new Ext.form.TextField({
  82.         id              : 'codigoProduto',
  83.         name            : 'codigoProduto',
  84.         fieldLabel      : 'Código Produto',
  85.         width                   : 180,
  86.         fireKey                 : function(e){//evento de tecla
  87.             if(e.getKey() == e.ENTER) {//precionar enter
  88.                 pesquisaLog();
  89.             }
  90.         }
  91.     });
  92.  
  93.     var infoProduto = new Ext.form.FieldSet({
  94.             title : 'Filtro',
  95.                 items           :
  96.                 [
  97.                         lc,
  98.                         {
  99.                                 id                      : 'EditorCodigoProduto',
  100.                                 name            : 'EditorCodigoProduto',
  101.                                 layout          : 'column',
  102.                                 width           : '100%',
  103.                                 defaults        :
  104.                                 {
  105.                                         labelWidth      :120,
  106.                                         xtype       :'panel',
  107.                                         layout      :'form',
  108.                                         border      :false
  109.                                 },
  110.                                 items:[
  111.                                 {
  112.                                         items    : [
  113.                         codigoProduto
  114.                                         ]
  115.                                 },
  116.                                 {
  117.                                         xtype   :'button',
  118.                                         formBind: true,
  119.                                         anchor  :'100%',
  120.                                         name    :'btnSearch',
  121.                                         id              :'btnSearch',
  122.                                         text    : ' &nbsp;&nbsp;Procurar&nbsp;&nbsp; ',
  123.                                         disabled: false,
  124.                                         handler : pesquisaLog
  125.                                 }
  126.                                 ]
  127.                         },
  128.                         {
  129.                                 layout          : 'column',
  130.                                 defaults        :
  131.                                 {
  132.                                         xtype       :'panel',
  133.                                         layout      :'form',
  134.                                         anchor          :'100%',
  135.                                     bodyStyle   :'padding: 10px 0 10px 0',
  136.                                         border      :false
  137.                                 },
  138.                                 items:[
  139.                                 {
  140.                                         items    : [
  141.                                         {
  142.                                            xtype                :'label',
  143.                                        name                     :'LblNomeProduto',
  144.                                        id                       :'LblNomeProduto',
  145.                                        width            :125,
  146.                                        text                     :'Nome Produto: ',
  147.                                        cls                      :'x-form-item',
  148.                                        allowBlank       :true,
  149.                                        hidden           :true
  150.                                         }
  151.                                         ]
  152.                                 }
  153.                                 ,{
  154.                                         items    : [
  155.                                         {
  156.                                            xtype                :'label',
  157.                                        name                     :'NomeProduto',
  158.                                        id                       :'NomeProduto',
  159.                                        text                     :'',
  160.                                        cls                      :'x-form-item',
  161.                                        allowBlank       :true,
  162.                                        hidden           :false
  163.                                         }
  164.                                         ]
  165.                                 }
  166.                                 ]
  167.                         }
  168.                 ]
  169.         });
  170.  
  171.  
  172.  
  173.     var PesqLog = new Ext.FormPanel({
  174.         title           : 'Log de Alterações do Produto',
  175.         labelWidth      : 120,
  176.         frame           : true,
  177.         defaultType     :'textfield',
  178.         monitorValid: true,
  179.         renderTo        : Ext.getBody(),
  180.         items: infoProduto
  181.     });
  182.  
  183.  
  184.     /* #### INÍCIO FUNÇÃO PARA PESQUISAR O Log PELO CODIGO DO PRODUTO #### */
  185.     function pesquisaLog() {
  186.         var codigoProduto = '';
  187.         store.removeAll();
  188.         GridWindow.hide();
  189.         Ext.getCmp('NomeProduto').setText('');
  190.         var values = PesqLog.getForm().getValues();
  191.         codigoProduto = values.codigoProduto;
  192.         site = values.Site;
  193.  
  194.         if(!codigoProduto){
  195.             Ext.Msg.alert('Pesquisa Log','Informe o código do produto');
  196.         } else {
  197.  
  198.             store.baseParams.codigoProduto = codigoProduto;
  199.             store.baseParams.siteId = site;
  200.             //store.load();
  201.             GridWindow.show();
  202.  
  203.  
  204.  
  205.             // Cria checkBox com as opcoes de site
  206.             store.load({callback: function(records,o,s){
  207.                 if(records.length == 0){
  208.                     Ext.Msg.alert('Pesquisa Log','Log não encontrado para este produto');
  209.                 }else{
  210.                     Ext.getCmp('NomeProduto').setText(records[0].get("ProdutoNome"));
  211.                 }
  212.             }});
  213.         }
  214.     }
  215.     /* #### FIM FUNÇÃO PARA PESQUISAR O PRODUTO PELO CÓDIGO #### */
  216.  
  217.  
  218.  
  219.     var GridWindow = new Ext.grid.GridPanel({
  220.         title                   : ' <div style="width:50%;float:left  "> Log de Alterações do Produto </div> <div style="color:gray;text-align:right;font-weight:normal;width:50%;float:right">  (*duplo clique sobre a linha para editar)</div> '
  221.         ,renderTo               : Ext.getBody()
  222.         ,stateful               : false
  223.         ,frame          : true
  224.         ,id             : 'grid'
  225.         ,height         : 350
  226.         ,store                  : store
  227.         ,deferRowRender : false
  228.         ,hidden         : true
  229.         ,viewConfig             : {
  230.             forceFit    : true
  231.         }
  232.         ,hideBorders: true
  233.         ,singleSelect: true
  234.         ,stripeRows     : true
  235.         ,width          : '100%'
  236.         ,columns        : [
  237.                 {id: 'SiteNome',               header: 'Site',                          dataIndex: 'SiteNome',              width: 100, sortable: true},
  238.                 {id: 'PrecoDe',                header: 'Preço De',                      dataIndex: 'PrecoDe',               width: 120, sortable: true},
  239.                 {id: 'PrecoPor',               header: 'Preco Por',                     dataIndex: 'PrecoPor',              width: 130, sortable: true},
  240.                 {id: 'ParcelamentoMaximo',     header: 'Parcelamento Máximo',                  dataIndex: 'ParcelamentoMaximo',    width: 130, sortable: true},
  241.                 {id: 'Status',                 header: 'Status',                        dataIndex: 'Status',                width: 130, sortable: true, renderer:cover_status},
  242.                 {id: 'DataAlteracao',          header: 'Data de Alteração'                    ,       dataIndex: 'DataAlteracao',         width: 130, sortable: true, xtype:'datecolumn', format: 'd/m/Y H:i:s'},
  243.                 {id: 'NomeUsuario',            header: 'Usuário',                       dataIndex: 'NomeUsuario',                      width: 130, sortable: true},
  244.                 {id: 'DescontoAVista',         header: 'Desconto A Vista',                              dataIndex: 'DescontoAVista',            width: 130, sortable: true},
  245.                 {id: 'UrlEspecialNome',        header: 'Url Especial',                  dataIndex: 'UrlEspecialNome',       width: 130, sortable: true},
  246.                 {id: 'LocalAlteracao',         header: 'Local Alteração',               dataIndex: 'LocalAlteracao',       width: 130, sortable: true}
  247.         ]
  248.  
  249.         ,bbar: new Ext.PagingToolbar({
  250.  
  251.                 pageSize: pageSize,
  252.                 store: store,
  253.                 displayMsg: 'Mostrando resultados {0} - {1} de {2}',
  254.                 emptyMsg: 'Nenhum resultado para mostrar',
  255.                 displayInfo: true,
  256.                 beforePageText: 'P&aacute;gina',
  257.                 firstText: 'Primeira p&aacute;gina',
  258.                 lastText: '&Uacute;ltima p&aacute;gina',
  259.                 nextText: 'Pr&oacute;xima p&aacute;gina',
  260.                 prevText: 'P&aacute;gina anterior',
  261.                 refreshText: 'Atualizar',
  262.                 afterPageText: 'de {0}',
  263.                 emptyMsg: "Sem dados para exibir.",
  264.                 plugins: new Ext.ux.ProgressBarPager()
  265.  
  266.         })
  267.  
  268.  
  269.         });
  270.         GridWindow.getSelectionModel().selectFirstRow();
  271.  
  272.                 var FieldSetObs = new Ext.Panel({
  273.                         xtype: 'fieldset',
  274.                         title: 'Observação',
  275.                         collapsible: true,
  276.                         autoHeight: true,
  277.                         renderTo                : Ext.getBody(),
  278.                         html: '<div style="text-align:left;font-weight:normal;width:100%;float:left;padding:10px">Este programa exibe o log de alterações realizadas em um produto.  </div>'
  279.                 });
  280.     });
  281.  
  282. </script>