Commit 7d25f250768b0579505f24cc6d0d029d95fc11cc

Authored by Edmar Moretti
1 parent 6485ca2a

--no commit message

admin/js/estat_tipo_regiao.js
... ... @@ -22,8 +22,12 @@ function montaTabela(dados){
22 22 formatMais = function(elCell, oRecord, oColumn){
23 23 elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
24 24 },
  25 + formatRel = function(elCell, oRecord, oColumn){
  26 + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
  27 + },
25 28 myColumnDefs = [
26 29 {key:"excluir",label:"excluir",formatter:formatExclui},
  30 + {key:"rel",label:"agrega&ccedil;&otilde;es",formatter:formatRel},
27 31 {key:"mais",label:"editar",formatter:formatMais},
28 32 {label:"c&oacute;digo",key:"codigo_tipo_regiao", formatter:formatTexto},
29 33 {label:"Nome",resizeable:true,key:"nome_tipo_regiao", formatter:formatTexto},
... ... @@ -77,11 +81,33 @@ function montaTabela(dados){
77 81 };
78 82 core_makeRequest(sUrl,callback);
79 83 }
  84 + if (column.key == 'rel'){
  85 + record = this.getRecord(target);
  86 + core_carregando("ativa");
  87 + core_carregando("buscando dados...");
  88 + $clicouId = record.getData('codigo_tipo_regiao');
  89 + $recordid = record.getId();
  90 + sUrl = "../php/metaestat.php?funcao=listaAgregaRegiao&codigo_tipo_regiao="+record.getData('codigo_tipo_regiao');
  91 + callback = {
  92 + success:function(o){
  93 + try{
  94 + montaTabelaAgregacoes(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
  95 + }
  96 + catch(e){core_handleFailure(e,o.responseText);}
  97 + },
  98 + failure:core_handleFailure,
  99 + argument: { foo:"foo", bar:"bar" }
  100 + };
  101 + core_makeRequest(sUrl,callback);
  102 + }
80 103 }
81 104 );
82 105 };
83 106 core_carregando("desativa");
84 107 }
  108 +function montaTabelaAgregacoes(){
  109 +
  110 +}
85 111 function montaEditor(dados,id,recordid){
86 112 function on_editorCheckBoxChange(p_oEvent){
87 113 if(p_oEvent.newValue.get("value") == "OK"){
... ...
admin/php/classe_metaestat.php
... ... @@ -1084,23 +1084,56 @@ class Metaestat{
1084 1084 }
1085 1085 $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">" . PHP_EOL;
1086 1086 $xml .= '<result-set>' . PHP_EOL;
  1087 + //tenta descobrir o tipo de coluna
  1088 + //$xml .= '<!--java.lang.String,java.lang.Integer-->' . PHP_EOL;
  1089 + $xmldados = "";
1087 1090 if($chaves){
1088 1091 foreach($dados as $d){
1089   - $xml .= "<row>" . PHP_EOL;
  1092 + $xmldados .= "<row>" . PHP_EOL;
1090 1093 foreach($chaves as $c){
1091   - $xml .= "<".$c.">".$d[$c]."</".$c.">" . PHP_EOL;
  1094 + $xmldados .= "<".$c.">".$d[$c]."</".$c.">" . PHP_EOL;
1092 1095 }
1093   - $xml .= "</row>" . PHP_EOL;
  1096 + $xmldados .= "</row>" . PHP_EOL;
1094 1097 }
  1098 + $tipos = array();
  1099 + $d = $dados[0];
  1100 + foreach($chaves as $c){
  1101 + if(is_numeric($d[$c])){
  1102 + $tipos[] = "java.lang.Integer";
  1103 + }
  1104 + else{
  1105 + $tipos[] = "java.lang.String";
  1106 + }
  1107 + }
  1108 + $xml .= '<!--'.implode($tipos,",").'-->' . PHP_EOL;
1095 1109 }
1096 1110 else{
1097 1111 while (list($key, $val) = each($dados)) {
1098   - $xml .= "<row>" . PHP_EOL;
1099   - $xml .= "<nome>".$key."</nome>" . PHP_EOL;
1100   - $xml .= "<valor>".$val."</valor>" . PHP_EOL;
1101   - $xml .= "</row>" . PHP_EOL;
  1112 + $xmldados .= "<row>" . PHP_EOL;
  1113 + $xmldados .= "<nome>".$key."</nome>" . PHP_EOL;
  1114 + $xmldados .= "<valor>".$val."</valor>" . PHP_EOL;
  1115 + $xmldados .= "</row>" . PHP_EOL;
  1116 + }
  1117 + reset($dados);
  1118 + $tipos = array();
  1119 + while (list($key, $val) = each($dados)) {
  1120 + if(is_numeric($val)){
  1121 + $tipos[] = "java.lang.Integer";
  1122 + }
  1123 + else{
  1124 + $tipos[] = "java.lang.String";
  1125 + }
  1126 + if(is_numeric($key)){
  1127 + $tipos[] = "java.lang.Integer";
  1128 + }
  1129 + else{
  1130 + $tipos[] = "java.lang.String";
  1131 + }
  1132 + break;
1102 1133 }
  1134 + $xml .= '<!--'.implode($tipos,",").'-->' . PHP_EOL;
1103 1135 }
  1136 + $xml .= $xmldados;
1104 1137 $xml .= '</result-set>' . PHP_EOL;
1105 1138 return $xml;
1106 1139 }
... ...