/**
  * 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;
 }
if (setNoMenorQueCero($tipo_operacion) > 0) {
    $es_por_operacion = " AND (`operaciones_no_estadisticas`.`tipo_de_operacion` ='{$tipo_operacion}')";
}
$f3 = $_GET["f3"];
$out = parametro("out", SYS_DEFAULT);
/* ******************************************************************************/
$TR_head = "";
$setSql = "SELECT socios.nombre, creditos_solicitud.numero_socio AS 'socio', \n\tcreditos_solicitud.numero_solicitud AS 'solicitud', \n\tcreditos_tipoconvenio.descripcion_tipoconvenio AS 'modalidad', \n\tcreditos_periocidadpagos.descripcion_periocidadpagos AS 'condiciones_de_pago', \n\tcreditos_solicitud.fecha_ministracion AS 'fecha_de_otorgamiento', \n\tcreditos_solicitud.monto_autorizado AS 'monto_original', \n\tcreditos_solicitud.fecha_vencimiento AS 'fecha_de_vencimiento', \n\tcreditos_solicitud.tasa_interes AS 'tasa_ordinaria_nominal_anual',\n\t creditos_solicitud.pagos_autorizados AS 'numero_de_pagos', \n\tcreditos_solicitud.periocidad_de_pago AS 'frecuencia', \n\tcreditos_solicitud.saldo_actual AS 'saldo_insoluto', \n\tcreditos_solicitud.fecha_ultimo_mvto, \n\tcreditos_estatus.descripcion_estatus AS 'estatus', \n\tsocios.genero, socios.tipo_ingreso, \n\tcreditos_solicitud.tipo_autorizacion AS 'modaut',\n\t`operaciones_no_estadisticas`.* \n\tFROM \n\t`creditos_solicitud` `creditos_solicitud` \n\t\tINNER JOIN `creditos_periocidadpagos` `creditos_periocidadpagos` \n\t\tON `creditos_solicitud`.`periocidad_de_pago` = \n\t\t`creditos_periocidadpagos`.`idcreditos_periocidadpagos` \n\t\t\tINNER JOIN `socios` `socios` \n\t\t\tON `creditos_solicitud`.`numero_socio` = `socios`.`codigo` \n\t\t\t\tINNER JOIN `operaciones_no_estadisticas` \n\t\t\t\t`operaciones_no_estadisticas` \n\t\t\t\tON `creditos_solicitud`.`numero_solicitud` = \n\t\t\t\t`operaciones_no_estadisticas`.`documento` \n\t\t\t\t\tINNER JOIN `creditos_tipoconvenio` `creditos_tipoconvenio` \n\t\t\t\t\tON `creditos_solicitud`.`tipo_convenio` = \n\t\t\t\t\t`creditos_tipoconvenio`.`idcreditos_tipoconvenio` \n\t\t\t\t\t\tINNER JOIN `creditos_estatus` `creditos_estatus` \n\t\t\t\t\t\tON `creditos_solicitud`.`estatus_actual` = \n\t\t\t\t\t\t`creditos_estatus`.`idcreditos_estatus`\n\t\n\tWHERE creditos_solicitud.saldo_actual>=0.99\n\tAND\n\t(`creditos_solicitud`.`fecha_ultimo_mvto`>='{$fecha_inicial}')\n\t{$ByAutorizacion}\n\t{$es_por_estatus}\n\t{$es_por_frecuencia}\n\t{$es_por_convenio}\n\t{$es_por_operacion}\n\tAND\n\t(`operaciones_no_estadisticas`.`fecha` >='{$fecha_inicial}')\n\tAND\n\t(`operaciones_no_estadisticas`.`fecha` <='{$fecha_final}')\n\t\n\tORDER BY creditos_solicitud.tipo_autorizacion DESC,\n\t\t\t\tcreditos_solicitud.fecha_ministracion, \n\t\t\tcreditos_estatus.orden_clasificacion ASC, \n\t\t\tcreditos_solicitud.numero_socio, creditos_solicitud.numero_solicitud,\n\t\t\t`operaciones_no_estadisticas`.fecha";
exit($setSql);
$credito_anterior = false;
$TR_parent = "";
$TR_child = "";
//echo $setSql;
$rs = $query->getDataRecord($setSql);
// getRecordset($setSql);
$rows = $query->getNumberOfRows();
// mysql_num_rows($rs);
$counter = 0;
//while($rw = mysql_fetch_array($rs)){
foreach ($rs as $rw) {
    //$TR_head		= "";
    if ($credito_anterior == false) {
        $credito_anterior = $rw["solicitud"];
    }
    $credito = $rw["solicitud"];
    if ($credito != $credito_anterior) {
        //resetear TR_child
        $TR_parent .= "\n\n  \t\t\t\t{$TR_head}\n\n  \t\t\t\t<tr>\n  \t\t\t\t\t<td colspan='4'>\n  \t\t\t\t\t\t<table>\n  \t\t\t\t\t\t\t<thead>\n  \t\t\t\t\t\t\t\t<th width='10%'>Recibo</th>\n  \t\t\t\t\t\t\t\t<th width='15%'>Fecha</th>\n  \t\t\t\t\t\t\t\t<th width='25%'>Operacion</th>\n  \t\t\t\t\t\t\t\t<th width='20%'>Monto</th>\n  \t\t\t\t\t\t\t\t<th width='30%'>Detalles</th>\n  \t\t\t\t\t\t\t<thead>\n  \t\t\t\t\t\t\t<tbody>\n  \t\t\t\t\t\t\t{$TR_child}\n  \t\t\t\t\t\t\t</tbody>\n  \t\t\t\t\t\t</table>\n  \t\t\t\t\t</td>\n  \t\t\t\t\t<tr>\n  \t\t\t\t\t\t<td colspan='4'></td>\n  \t\t\t\t\t\t<td colspan='4'></td>\n  \t\t\t\t\t</tr>\n  \t\t\t\t</tr>\n  \t\t\t\t";
        $TR_child = "";
        $TR_head = "";
    }
 function initArbolRelaciones()
 {
     $QL = new MQL();
     $id = $this->mPersona;
     $msql = "SELECT `personas_relaciones_recursivas`.*, \n\t\tCONCAT(\tLEFT(`socios_relaciones`.`nombres`,5), ' ',\n\t`socios_relaciones`.`apellido_paterno`, ' ',\n\tLEFT(`socios_relaciones`.`apellido_materno`,5) ) AS `nombres`\n\t  \n\t\tFROM \n\n\t\t`personas_relaciones_recursivas` `personas_relaciones_recursivas` \n\t\tLEFT OUTER JOIN `socios_relaciones` `socios_relaciones` \n\t\tON `personas_relaciones_recursivas`.`relacion` = `socios_relaciones`.\n\t\t`numero_socio` ";
     $sql = "{$msql} WHERE\t(`personas_relaciones_recursivas`.`persona` ={$id})\tORDER BY\t`personas_relaciones_recursivas`.`persona`,\t`personas_relaciones_recursivas`.`nivel`";
     //setLog($sql);
     $rs = $QL->getDataRecord($sql);
     if ($QL->getNumberOfRows() <= 0) {
         $sql = "{$msql} WHERE\t(`personas_relaciones_recursivas`.`proxy` ={$id}) ";
         $rs = $QL->getDataRecord($sql);
     }
     if ($QL->getNumberOfRows() <= 0) {
         $sql = "{$msql} WHERE\t(`personas_relaciones_recursivas`.`relacion` ={$id}) ";
         $rs = $QL->getDataRecord($sql);
     }
     return $rs;
 }
$cuenta_anterior = "_INIT_";
$exoTR = "";
$exoTD = "";
$SCargos = 0;
//Suma de Cargos
$SAbonos = 0;
//SUma de Abonos
$SFinal = 0;
$exoCuenta = "";
$MActuales = 0;
$tcuenta = "";
//echo $sqlCta;
//Imprime la Cuenta
$xRPT->addContent("<table>\n<thead>\n\t<tr>\n\t\t<th width=\"10%\" >Fecha</th>\n\t\t<th width=\"10%\" >Poliza</th>\n\t\t<th width=\"10%\" >Numero</th>\n\t\t<th width=\"25%\" >Concepto</th>\n\t\t<th width=\"15%\" >Referencia</th>\n\t\t<th width=\"10%\" >Cargo</th>\n\t\t<th width=\"10%\" >Abono</th>\n\t\t<th width=\"10%\" >Saldo</th>\n\t</tr>\n\t</thead>\n\t<tbody>");
$rs = $ql->getDataRecord($sqlCta);
$rows = $ql->getNumberOfRows();
$crows = 1;
foreach ($rs as $rw) {
    //if(!isset($tcuenta)){$tcuenta 	= ""; }
    if ($crows == $rows) {
        $cuenta_anterior = "_FIN_";
        //======================================================================
        $MFecha = $rw["fecha"];
        $MTPoliza = $rw["tipo"];
        $MNumero = $rw["poliza"];
        $MConcepto = $rw["concepto"];
        $MReferencia = $rw["referencia"];
        $MCargo = $rw["cargo"];
        $MAbono = $rw["abono"];
        if ($naturaleza == NC_DEUDORA) {
            //Deudor