/**
  * Muestra el Plan de Pagos en Texto, o HTML, Simple o Completo
  *
  * @param string $InOut		Tipo de Sal�ida, por Defecto HTML
  * @param boolean $simple	Solo Imprime el Plan de Pagos sin detallarla Lista
  * @param boolen $NoExtend	SI es a TRue solo muestra el Plan de pagos
  * @return string			Plan de Pagos en Formto definido en OUT
  */
 function getPlanDePago($InOut = "html", $simple = false, $NoExtend = false)
 {
     $PlanBody = "";
     if ($this->mCreditoInicializado == false) {
         $this->init();
     }
     $xF = new cFecha();
     $xL = new cLang();
     $xQ = new MQL();
     $xF->init(FECHA_FORMATO_MX);
     $xF->setSeparador("/");
     if ($this->mPagosAutorizados > 1) {
         if (setNoMenorQueCero($this->mNumeroDePlanDePago) <= 0) {
             $extras = $this->getDatosDelPlanDePagos();
         } else {
             $sqlrs = "SELECT *\n\t\t\t\t\t\tFROM operaciones_recibos\n\t\t\t\t\t\tWHERE idoperaciones_recibos=" . $this->getNumeroDePlanDePagos();
             $idrecibo = $this->getNumeroDePlanDePagos();
             $extras = obten_filas($sqlrs);
         }
         //------------------------------------- DATOS DEL RECIBO
         //TODO: Validar IDRECIBO, si es Mayor a cero y si existe 2014-10-31
         //XXX: Terminar valicacion de IDRECIBO 201/10/31
         $idrecibo = $extras["idoperaciones_recibos"];
         $idsocio = $extras["numero_socio"];
         //"numero_socio"
         $idsolicitud = $extras["docto_afectado"];
         // docto_afectado
         $sumrec = $extras["total_operacion"];
         $nombre = getNombreSocio($idsocio);
         $SUMCap = 0;
         $SUMInt = 0;
         $SUMIva = 0;
         $SUMAh = 0;
         $SUMOtros = 0;
         $SumTotal = 0;
         // ------------------------------------ DATOS DE LA SOLICITUD.
         if ($this->mCreditoInicializado == false) {
             $sqlsol = "SELECT * FROM creditos_solicitud WHERE numero_solicitud={$idsolicitud}";
             $dsol = obten_filas($sqlsol);
             $tasa_ahorro = $dsol["tasa_ahorro"] * 100;
             $tasa_interes = $dsol["tasa_interes"] * 100;
             $dias_totales = $dsol["dias_autorizados"];
             $numero_pagos = $dsol["pagos_autorizados"];
             $nombre_otro = "";
         } else {
             $tasa_ahorro = $this->mTasaAhorro * 100;
             $tasa_interes = $this->mTasaInteres * 100;
             $dias_totales = $this->mDiasAutorizados;
             $numero_pagos = $this->mPagosAutorizados;
             $nombre_otro = "";
         }
         $this->mLimitPlan = ceil($numero_pagos / 3);
         if ($NoExtend == false) {
             $PlanBody .= $this->getFichaDeSocio();
             $PlanBody .= $this->getFicha();
         }
         if ($simple == false) {
             $sql = "\n\t\t\t\t\tSELECT operaciones_mvtos.periodo_socio AS 'parcialidad', fecha_afectacion,\n\t\t\t\t\t\t\toperaciones_tipos.idoperaciones_tipos  As 'tipo',\n\t\t\t\t\t\t\toperaciones_tipos.descripcion_operacion AS 'concepto' ,\n\t\t\t\t\t\t\toperaciones_mvtos.afectacion_real AS 'monto',\n\t\t\t\t\t\t\toperaciones_mvtos.saldo_actual AS 'saldo'\n\n\t\t\t\t\tFROM \t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos`\n\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t\t\t`idoperaciones_tipos`\n\n\t\t\t\t\tWHERE operaciones_mvtos.recibo_afectado={$idrecibo}\n\t\t\t\t\tORDER BY operaciones_mvtos.periodo_socio, operaciones_tipos.idoperaciones_tipos";
             $rs = $xQ->getDataRecord($sql);
             $trs = "";
             //Parcialidad, evaluador de inciio y final
             $PInit = 0;
             $PFin = 0;
             $capital = 0;
             $interes = 0;
             $iva = 0;
             $ahorro = 0;
             $otros = 0;
             $total = 0;
             $saldo = 0;
             $tds = "";
             foreach ($rs as $rw) {
                 $PInit = $rw["parcialidad"];
                 $tipo = $rw["tipo"];
                 switch ($tipo) {
                     case 410:
                         $capital = $rw["monto"];
                         $SUMCap += $capital;
                         $saldo = $rw["saldo"];
                         if ($saldo < 0) {
                             $saldo = 0;
                         }
                         break;
                     case 411:
                         $interes = $rw["monto"];
                         $SUMInt += $interes;
                         break;
                     case 412:
                         $ahorro = $rw["monto"];
                         $SUMAh += $ahorro;
                         break;
                     case 413:
                         $iva = $rw["monto"];
                         $SUMIva += $iva;
                         break;
                     default:
                         $otros = $rw["monto"];
                         $SUMOtros += $otros;
                         $top = getInfTOperacion($tipo);
                         $nombre_otro = $top["descripcion_operacion"];
                         break;
                 }
                 if ($PInit != $PFin) {
                     $trs .= $tds;
                 } else {
                     $total = $capital + $interes + $ahorro + $iva;
                     $tdAhorro = "<td class='mny'>" . getFMoney($ahorro) . "</td>";
                     $tdOtros = "<td class='mny'>" . getFMoney($otros) . "</td>";
                     if ($ahorro == 0) {
                         $tdAhorro = "";
                     }
                     if ($otros == 0) {
                         $tdOtros = "";
                     }
                     $tds = "<tr>\n\t\t\t\t\t\t\t<td>" . $rw["parcialidad"] . "</td>\n\t\t\t\t\t\t\t<td class='ctr'>" . getDiaDeLaSemana($rw["fecha_afectacion"]) . "</td><td class='ctr'>" . $xF->getFechaCorta($rw["fecha_afectacion"]) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($capital) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($interes) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($iva) . "</td>\n\t\t\t\t\t\t\t{$tdAhorro}\n\t\t\t\t\t\t\t{$tdOtros}\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($total) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($saldo) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
                 }
                 $PFin = $PInit;
             }
             $trs .= $tds;
             $SumTotal = $SUMCap + $SUMAh + $SUMInt + $SUMIva + $SUMOtros;
             $thAhorro = " <th>" . $xL->getT("TR.Ahorro") . "</th>";
             $thOtros = "<th>{$nombre_otro}</th>";
             $tfAhorro = "<th class='mny'>" . getFMoney($SUMAh) . "</th>";
             $tfOtros = "<th class='mny'>" . getFMoney($SUMOtros) . "</th>";
             if ($SUMAh == 0) {
                 $thAhorro = "";
                 $tfAhorro = "";
             }
             if ($SUMOtros == 0) {
                 $thOtros = "";
                 $tfOtros = "";
             }
             $PlanBody .= "<table >\n\t\t\t  <tbody>\n\t\t\t    <tr>\n\t\t\t      <th>" . $xL->getT("TR.Pago") . "</th>\n\t\t\t      <th colspan='2'>" . $xL->getT("TR.Fecha de Pago") . "</th>\n\t\t\t      <th>" . $xL->getT("TR.Capital") . "</th>\n\t\t\t      <th>" . $xL->getT("TR.Interes") . "</th>\n\t\t\t      <th>" . $xL->getT("TR.IVA") . "</th>\n\t\t\t     {$thAhorro}\n\t\t\t      {$thOtros}\n\t\t\t      <th>" . $xL->getT("TR.Total") . "</th>\n\t\t\t      <th>" . $xL->getT("TR.saldo") . "</th>\n\t\t\t    </tr>\n\t\t\t    {$trs}\n\t\t\t    <tr>\n\t\t\t      <td colspan='3'>" . $xL->getT("TR.SUMAS") . "</td>\n\t\t\t      <th class='mny'>" . getFMoney($SUMCap) . "</th>\n\t\t\t      <th class='mny'>" . getFMoney($SUMInt) . "</th>\n\t\t\t      <th class='mny'>" . getFMoney($SUMIva) . "</th>\n\t\t\t      {$tfAhorro}\n\t\t\t      {$tfOtros}\n\t\t\t      <th class='mny'>" . getFMoney($SumTotal) . "</th>\n\t\t\t      <td />\n\t\t\t    </tr>\n\t\t\t  </tbody>\n\t\t\t</table>";
         } else {
             $sqlparc = "SELECT periodo_socio AS 'parcialidad', MAX(fecha_afectacion)\n\t\t\t\t\t\t\t\tAS 'fecha_de_pago', SUM(afectacion_real) AS 'total_parcialidad',\n\t\t\t\t\t\t\t\t MAX(saldo_anterior) AS 'saldo_anterior_', MIN(saldo_actual) AS 'saldo_actual_'\n\t\t\t\t\t\t\t\tFROM operaciones_mvtos\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\trecibo_afectado={$idrecibo}\n\t\t\t\t\t\t\tGROUP BY periodo_socio ORDER BY periodo_socio";
             $rs = $xQ->getDataRecord($sqlparc);
             $pi = 1;
             $tp = "";
             $pt = 1;
             $lim = $xQ->getNumberOfRows();
             //si el Limite es mayor a 100, restar 100 y poner
             if ($lim > $this->mLimitPlan * 4) {
                 $this->mLimitPlan = ceil($lim / 4);
             }
             if ($lim < $this->mLimitPlan) {
                 $this->mLimitPlan = ceil($lim / 2);
             }
             $items = 1;
             foreach ($rs as $rw) {
                 $saldo = $rw["saldo_actual_"];
                 $saldo = $saldo < 0 ? 0 : $saldo;
                 $SumTotal += $rw["total_parcialidad"];
                 if ($items == 1) {
                     $this->mFechaPrimeraParc = $rw["fecha_de_pago"];
                 }
                 if ($pi == $this->mLimitPlan or $pt == $lim) {
                     $tp .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . $rw["parcialidad"] . "</td>\n\t\t\t\t\t\t<td>" . $xF->getFechaCorta($rw["fecha_de_pago"]) . "</td>\n\t\t\t\t\t\t<td class='mny'>" . getFMoney($rw["total_parcialidad"]) . "</td>\n\t\t\t\t\t\t<td class='mny'>" . getFMoney($saldo) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t</td>";
                     $pi = 1;
                 } elseif ($pi == 1) {
                     $tp .= "\n\t\t\t\t\t\t<td>\n\n\t\t\t\t\t\t<table class='sector_plan_simplificado'>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>" . $xL->getT("TR.PAGO") . "</th>\n\t\t\t\t\t\t\t<th>" . $xL->getT("TR.Fecha") . "</th>\n\t\t\t\t\t\t\t<th>" . $xL->getT("TR.Monto") . "</th>\n\t\t\t\t\t\t\t<th>" . $xL->getT("TR.Saldo") . "</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . $rw["parcialidad"] . "</td>\n\t\t\t\t\t\t\t<td>" . $xF->getFechaCorta($rw["fecha_de_pago"]) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($rw["total_parcialidad"]) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($saldo) . "</td>\n\t\t\t\t\t\t</tr>";
                     $pi++;
                 } else {
                     $tp .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . $rw["parcialidad"] . "</td>\n\t\t\t\t\t\t\t<td>" . $xF->getFechaCorta($rw["fecha_de_pago"]) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($rw["total_parcialidad"]) . "</td>\n\t\t\t\t\t\t\t<td class='mny'>" . getFMoney($saldo) . "</td>\n\t\t\t\t\t\t</tr>";
                     $pi++;
                 }
                 $pt++;
                 $items++;
                 $this->mFechaUltimaParc = $rw["fecha_de_pago"];
             }
             $PlanBody .= "<table class='plan_de_pagos'>\n\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t{$tp}\n\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t<!-- SUMAS -->\n\t\t\t\t\t\t\t\t<tfoot>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td colspan='2'><hr />TOTAL</th>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<td  class='mny'><hr />" . getFMoney($SumTotal) . "</th>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</tfoot>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t";
         }
         //END IF
         $PlanFoot = "<hr />\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><center>" . $xL->getT("TR.Firma del Solicitante") . "</td>\n\t\t\t\t\t<td><center>" . $xL->getT("TR.Genera el Plan de Pagos") . "</center></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><br /><br /><br /> </td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\t<td><center>{$nombre}</center></td>\n\t\t\t\t\t\t<td><center>" . $this->mOficialQueGenera . "</center></td>\n\t\t\t\t</tr>\n\t\t\t\t</table>";
         if ($NoExtend == false) {
             $PlanBody .= "<hr />\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t  \t<tr>\n\t\t\t\t\t\t    \t<td>" . $xL->getT("TR.Dias Totales") . ":</td>\n\t\t\t\t\t\t    \t<th>{$dias_totales} Dias</th>\n\t\t\t\t\t\t    \t<td>" . $xL->getT("TR.Tasa de Interes") . " :</td>\n\t\t\t\t\t\t    \t<th>{$tasa_interes} %</th>\n\t\t\t\t\t\t    \t<td>" . $xL->getT("TR.Tasa de Ahorro") . " :</td>\n\t\t\t\t\t\t    \t<th>{$tasa_ahorro} %</th>\n\t\t\t\t\t\t    </tr>\n\t\t\t\t\t    </table>\n\t\t\t\t\t\t";
             $PlanBody .= $PlanFoot;
         }
     }
     //End evaluate si es Mas Planes de pagos
     return $PlanBody;
 }
 /**
  * Genera la Tabla
  * @param string	$vCaption	Titulo de la Tabla
  * @param boolean	$retorna	Retornar la Tabla como Valor? true/false
  */
 function Show($vCaption = "", $retorna = true, $TableID = "")
 {
     $xHComm = new cHObject();
     $xD = new cFecha();
     $xLng = new cLang();
     $xT = new cTipos();
     $xQL = new MQL();
     $xBtn = new cHButton();
     $xIcs = $this->ODicIcons();
     $this->mID = $TableID == "" ? $this->mID : $TableID;
     if (MODO_DEBUG == true and isset($_SERVER["REQUEST_URI"])) {
         //setLog($_SERVER["REQUEST_URI"]);
         if (strpos($_SERVER["REQUEST_URI"], "rpt") === false) {
             $this->addTool(3);
         }
     }
     $xD->setSeparador("/");
     if ($this->mSql != "") {
         //Miembros de las Tablas
         $tds = "";
         $ths = "";
         //Inicio de Tabla
         $pushInit = "";
         $pushEnd = "";
         $vClassT = "";
         $vWidth = "";
         $tdt = "";
         $tht = "";
         $tab = "";
         $tfoot = "";
         $trick = 1;
         $capTable = "";
         $oldTags = false;
         if ($this->mTipoSalida == OUT_EXCEL) {
             $oldTags = true;
         }
         //si hay Caption formar el caption
         if ($vCaption != "" and $this->mPrepareChart == false) {
             $vCaption = $xLng->getT($vCaption);
             $vCaption = "<legend>[&nbsp;&nbsp;&nbsp;&nbsp;{$vCaption}&nbsp;&nbsp;&nbsp;&nbsp;]</legend>";
             $pushInit = "<fieldset>{$vCaption}";
             $pushEnd = "</fieldset>";
         }
         if ($vCaption != "" and $this->mPrepareChart == true) {
             $capTable = "<caption>{$vCaption}</caption>";
         }
         if ($vCaption != "" and $this->mTipoSalida == OUT_EXCEL) {
             $capTable = "<caption>{$vCaption}</caption>";
         }
         //Clase de la Tabla
         if ($this->mClassT != "") {
             $this->mClassT = " " . $this->mClassT;
         }
         $vClassT = "class=\"listado" . $this->mClassT . "\" ";
         //Contar Tools
         $il = count($this->mTool);
         $itmCmd = count($this->mEspCMD);
         $itmEspTool = count($this->mEspTool);
         $itmTot = $il + $itmCmd + $itmEspTool;
         if ($itmTot > 0) {
             $wd = setNoMenorQueCero($this->mWidthTool) <= 0 ? $itmTot * 26 . "px" : $this->mWidthTool;
             $tht = "<th style='min-width:" . $wd . ";width:" . $wd . ";'>Acciones</th>";
         }
         // --------------------------------------------------------------
         $rs = getRecordset($this->mSql);
         if ($this->mKeyField == "") {
             $this->mKeyField = mysql_field_name($rs, $this->mKey);
         }
         if ($this->mTbl == "") {
             $this->mTbl = mysql_field_table($rs, $this->mKey);
         }
         //Arrays de Nombres y tipo
         $arrFieldNames = array();
         $arrFieldTypes = array();
         $preCols = count($this->Fields) <= 1 ? false : true;
         //
         $ifl = mysql_num_fields($rs) - 1;
         //Limite de Fields
         //-------------------------------------------------------------	//Cabeceras de Columnas
         for ($iCols = 0; $iCols <= $ifl; $iCols++) {
             $fname = mysql_field_name($rs, $iCols);
             $ftypes = mysql_field_type($rs, $iCols);
             $this->Fields[] = $fname;
             if ($this->mKey == 0 and $this->mKeyField != "") {
                 if (strtolower($fname) == strtolower($this->mKeyField)) {
                     $this->mKey = $iCols;
                 }
             }
             $tths = "";
             if (isset($this->mColTitles[$fname])) {
                 $tths = $this->mColTitles[$fname];
             } else {
                 $tths = strtoupper(str_replace("_", " ", $fname));
             }
             $tths = $xLng->getT("TR.{$tths}");
             $cssTh = $iCols == $this->mKey ? " class='key' " : "";
             $scope = $this->mPrepareChart == true ? " scope='col' " : "";
             //Mejorar codigo
             if ($this->mTipoSalida == OUT_EXCEL) {
                 $ths .= "<th class=\"xl25\">{$tths}</th>";
             } else {
                 if ($this->mTipoSalida == OUT_TXT or $this->mTipoSalida == OUT_CSV) {
                     $ths .= $iCols == 0 ? $tths : $this->mDelimiter . $tths;
                     $ths .= $iCols == $ifl ? "\r\n" : "";
                 } else {
                     $ths .= ($this->mPrepareChart == true and $iCols == $this->mKey) ? "<td></td>" : "<th {$scope} {$cssTh}>{$tths}</th>";
                 }
             }
             /**
              * Construye el Array de Tipos y Nombres
              */
             $arrFieldNames[$iCols] = $fname;
             $arrFieldTypes[$iCols] = $ftypes;
         }
         //$ths . "\n $tht";
         // --------------------------------------------------------------
         while ($rw = mysql_fetch_array($rs)) {
             $this->mRowCount++;
             $tdt = "";
             $pKey = $this->mKey;
             $idKey = is_string($rw[$pKey]) == true ? "'" . $rw[$pKey] . "'" : $rw[$pKey];
             $dataCustom = "";
             $trick = $trick >= 2 ? 1 : $trick + 1;
             //switch oddr
             $lis = "";
             $liCss = $trick == 2 ? "tags green" : "tags blue";
             /*$t = array(
             			0 => $xBtn->getBasic("TR.Ejecutar", $this->mActionExec . "($idKey)", ) "<img src='../images/common/execute.png' onclick=\"" . $this->mActionExec . "($idKey);\" title='Ejecutar Una acci&oacute;n' />",
             			1 => "<img src='../images/common/edit.png' onclick=\"if(typeof actualizame" . $this->mRndK . " != 'undefined'){actualizame" . $this->mRndK . "($idKey);} else {jsUp('" . $this->mTbl . "','" . $this->mKeyField . "', $idKey); } \" title='Editar Registro' />",
             			SYS_DOS => "<img src='../images/common/trash.png' onclick=\"var xG = new Gen(); xG.rmRecord({tabla:'" . $this->mTbl .  "',id:" . $idKey . "});\" title='Eliminar Registro' />"
             		);*/
             $t = array(0 => $xBtn->getBasic("TR.Ejecutar", $this->mActionExec . "({$idKey})", $xIcs->EJECUTAR, "exec{$idKey}", false, true), 1 => $xBtn->getBasic("TR.Editar", "if(typeof actualizame" . $this->mRndK . " != 'undefined'){actualizame" . $this->mRndK . "({$idKey});} else {jsUp('" . $this->mTbl . "','" . $this->mKeyField . "', {$idKey}); }", $xIcs->EDITAR, "redit{$idKey}", false, true), 2 => $xBtn->getBasic("TR.Eliminar", "var xG = new Gen(); xG.rmRecord({tabla:'" . $this->mTbl . "',id:" . $idKey . "});", $xIcs->ELIMINAR, "rdel{$idKey}", false, true), 3 => $xBtn->getBasic("TR.Ver", "var xDev=new SafeDev(); xDev.recordRAW({tabla:'" . $this->mTbl . "',id:" . $idKey . "});", $xIcs->EXPORTAR, "idcmdview{$idKey}", false, true));
             foreach ($this->mTool as $idx => $clave) {
                 $lis .= isset($t[$clave]) ? "<li>" . $t[$clave] . "</li>" : "";
             }
             foreach ($this->mEspCMD as $idx => $cnt) {
                 $lis .= "<li>" . str_replace(HP_REPLACE_ID, $rw[$pKey], $cnt) . "</li>";
             }
             $tdt = $lis == "" ? "" : "<ul class='{$liCss}'>{$lis}</ul>";
             /**
              * Herramientas especiales
              */
             foreach ($this->mEspTool as $key => $value) {
                 $DefValue = str_replace(HP_REPLACE_ID, $rw[$pKey], $value);
                 //validar si no es PHP
                 if (strpos($DefValue, "PHP::") !== false) {
                     $cod = str_replace("PHP::", "\$DefValue=", $DefValue);
                     eval($cod);
                 }
                 $tdt .= "\n " . $DefValue;
             }
             $tdt = trim($tdt) != "" ? "<td id=\"options-" . $rw[$pKey] . "\" class=\"toolbar-24\">{$tdt}</td>" : "";
             if ($this->mTipoSalida == OUT_EXCEL) {
                 $tdt = "";
             }
             //-------------------------------------------------------
             $ttds = "";
             for ($i = 0; $i <= $ifl; $i++) {
                 $event = "";
                 $css = "";
                 $oprp = "";
                 $currVal = $rw[$i];
                 $sanID = str_replace(" ", "_", $currVal);
                 $type = isset($arrFieldTypes[$i]) ? $arrFieldTypes[$i] : "text";
                 $name = $arrFieldNames[$i];
                 $scope = "";
                 $delims = "td";
                 $mkEnd = "";
                 $extraCNT = "";
                 if ($i == $this->mKey) {
                     $event = $this->EventKey;
                     if ($event != "") {
                         $event = "<a class='button' onclick=\"{$event}('{$rw[$i]}');\" >";
                         $mkEnd = "</a>";
                     }
                     $css .= "key";
                     $oprp = " id=\"pk-" . $sanID . "\" ";
                     $scope = $this->mPrepareChart == true ? "scope=\"row\"" : "";
                     $delims = $this->mPrepareChart == true ? "th" : "td";
                 }
                 /**
                  *Agrega el data Custom
                  */
                 if ($this->mDataCustom == true) {
                     $dataCustom .= $dataCustom == "" ? "{$name}={$currVal}" : "|{$name}={$currVal}";
                 }
                 /**
                  * Agrega una suma si el tipo aplica
                  */
                 if (isset($this->arrTypesPHP[$type]) and $this->arrTypesPHP[$type] == "numeric") {
                     if (!isset($this->mFieldSum[$name])) {
                         $this->mFieldSum[$name] = 0;
                     }
                     $this->mFieldSum[$name] += $currVal;
                 }
                 //Agregar sub consulta
                 /*if($this->mSubsEnable	== true){
                 			$sqlSub			= "";
                 			//si no encuentra
                 			if(isset($this->mSubSQLs[$i])){
                 				$sqlSub		= $this->mSubSQLs[$i];
                 			} elseif(isset($this->mSubSQLs[$name])){
                 				$sqlSub		= $this->mSubSQLs[$name];
                 			} else {
                 				if ($i == $this->mKey OR $name == $this->mKeyField){
                 					$sqlSub		= (isset($this->mSubSQLs[0])) ? $this->mSubSQLs[0] : "";
                 				}
                 			}
                 			if($sqlSub == ""){
                 				
                 			} else {
                 				$sqlSub			= str_replace(HP_REPLACE_ID,$currVal, $sqlSub);
                 				//if($currVal == 	200039104){setLog($sqlSub);}
                 				$mql			= new MQL();
                 				$data			= $mql->getDataRecord($sqlSub);
                 				$cnt			= "";
                 				$outc			= new cHObject();
                 				
                 				foreach($data as $info){
                 					foreach($info as $pfield => $pvalue){
                 						$cnt		.= $pvalue . "\r\n";
                 					}
                 				}
                 				$extraCNT			.= $outc->Out($cnt, OUT_HTML);
                 			}
                 		}*/
                 //Tipo de Dato
                 /**
                  * Si la Opcion de Class por tipo es verdadero
                  * formatea cada Td como su tipo
                  */
                 $oStr = array("string" => "string", "varchar" => "varchar", "text" => "text", "tinytext" => "tinytext");
                 if (!isset($oStr[$type])) {
                     $css = $css == "" ? $type : "{$css} {$type}";
                 }
                 if (isset($this->arrRowCSS[$name])) {
                     $css = $css == "" ? $type : "{$css} " . $this->arrRowCSS[$name];
                 }
                 $css = $css == "" ? "" : " class=\"{$css}\" ";
                 //Formatea a Moneda el valor si es tpo real
                 if ($type == "real") {
                     $currVal = ($this->mPrepareChart == true or $this->mTipoSalida == OUT_EXCEL) ? round($currVal, 2) : getFMoney($currVal);
                 }
                 if ($type == "date") {
                     $currVal = $xD->getFechaMX($currVal);
                 }
                 if (isset($oStr[$type])) {
                     $currVal = $xHComm->Out($currVal, OUT_HTML);
                 }
                 if ($this->mTipoSalida == OUT_EXCEL) {
                     //class=xl2216681 nowrap
                     $ttds .= "<{$delims} class=\"xl25\" >" . $currVal . "</{$delims}>";
                 } else {
                     if ($this->mTipoSalida == OUT_TXT or $this->mTipoSalida == OUT_CSV) {
                         $ttds .= $i == 0 ? $currVal : $this->mDelimiter . $currVal;
                     } else {
                         $css = $this->mPrepareChart == true ? "" : $css;
                         $ttds .= "<{$delims} {$scope} {$css} {$oprp}>{$event}" . $currVal . "{$mkEnd}{$extraCNT}</{$delims}>";
                     }
                 }
             }
             //
             $trcss = $trick >= 2 ? " class='trOdd' " : "";
             if ($this->mTipoSalida == OUT_EXCEL) {
                 $tds .= "<tr>{$ttds}{$tdt}</tr>\r\n";
             } else {
                 if ($this->mTipoSalida == OUT_TXT or $this->mTipoSalida == OUT_CSV) {
                     $tds .= $ttds . "\r\n";
                 } else {
                     $dataCustom = $dataCustom != "" ? " data-info=\"{$dataCustom}\" " : "";
                     $tds .= "<tr id=\"tr-" . $this->mTbl . "-" . str_replace(" ", "_", $rw[$this->mKey]) . "\"{$dataCustom} {$trcss}>{$ttds} {$tdt} </tr>";
                 }
             }
             if ($this->mSubsEnable == true) {
                 foreach ($this->mSubSQLs as $idx => $sqls) {
                     if ($sqls != "") {
                         $sqlSub = str_replace(HP_REPLACE_ID, $rw[$this->mKey], $sqls);
                         $mql = new MQL();
                         $data = $mql->getDataRecord($sqlSub);
                         $outc = new cHObject();
                         foreach ($data as $info) {
                             foreach ($info as $pfield => $pvalue) {
                                 $cnt .= $pvalue . "\r\n";
                             }
                         }
                         $extraCNT .= $outc->Out($cnt, OUT_HTML);
                         $icx22 = $ifl + 2;
                         $tds .= "<tr id=\"tr-subs-" . $this->mTbl . "-" . str_replace(" ", "_", $rw[$this->mKey]) . "\"><td colspan='{$icx22}'>{$extraCNT}</td></tr>";
                     }
                 }
             }
         }
         $this->vFields = $rw;
         // --------------------------------------------------------------
         @mysql_free_result($rs);
         $ism = $this->mFootSums;
         //sumas
         $tfoot = "";
         for ($i = 0; $i <= $ifl; $i++) {
             if (isset($ism[$i])) {
                 if ($this->mTipoSalida == OUT_EXCEL) {
                     $tfoot .= isset($this->mFieldSum[$ism[$i]]) ? "<th>" . getFMoney($this->mFieldSum[$ism[$i]]) . "</th>" : "<td></td>";
                 } else {
                     $tfoot .= isset($this->mFieldSum[$ism[$i]]) ? "<th><input type='hidden' id='idsum-" . $ism[$i] . "' value='" . $this->mFieldSum[$ism[$i]] . "' /><mark id='sum-" . $ism[$i] . "'>" . getFMoney($this->mFieldSum[$ism[$i]]) . "</mark></th>" : "<td></td>";
                 }
             } else {
                 $tfoot .= $i == 0 ? "<th>Filas: " . $this->mRowCount . "</th>" : "<td></td>";
             }
         }
         $tfoot = $oldTags == true ? "<tr>{$tfoot}</tr>" : "<tfoot><tr>{$tfoot}</tr></tfoot>";
         $tfoot = ($this->mSumFoot == false or $this->mPrepareChart == true) ? "" : $tfoot;
         //Da Salida  a la Tbla
         $mID = $this->mID;
         $aProps = $this->mTipoSalida == OUT_EXCEL ? " x:str border=0   style='border-collapse: collapse' " : " {$vClassT} id=\"{$mID}\"";
         $aProps = $this->mPrepareChart == true ? "  style=\"display: none; text-align: center \" > " : $aProps;
         $tBody = $oldTags == true ? "{$tds}" : "<tbody>{$tds}</tbody>";
         $tHead = $oldTags == true ? "<tr>{$ths}{$tht}</tr>" : "<thead><tr>{$ths}{$tht}</tr></thead>";
         $tHead = trim($ths) == "" ? "" : $tHead;
         if ($this->mTipoSalida == OUT_TXT or $this->mTipoSalida == OUT_CSV) {
             $tab = "{$ths} {$tds}";
         } else {
             $tab = "{$pushInit}<table{$aProps}>{$capTable}{$tHead}{$tBody}{$tfoot}</table>{$pushEnd}";
         }
         if ($retorna == true) {
             return $tab;
         } else {
             echo $tab;
         }
     }
 }