<?php
session_start();
require_once '../Conexion/conexion.php';
require_once('../Conexion/ConexionPDO.php');
$con = new ConexionPDO();
$rubro = $_REQUEST['rubro'];
$concepto = $_REQUEST['concepto'];
$valor = $con->Listar("SELECT rubro FROM gf_rubro_fuente WHERE id_unico = $rubro");
// $vall = $mysqli->query($es);
// $valor=  mysqli_fetch_row($vall);

//echo '<option value="">Cuenta</option>';
$res = $con->Listar("SELECT DISTINCT
                    cnt.id_unico cuenta,
                    cnt.codi_cuenta,
                    cnt.nombre
        FROM gf_concepto ct
        LEFT JOIN gf_concepto_rubro cnr ON cnr.concepto = ct.id_unico
        LEFT JOIN gf_rubro_fuente rbf ON rbf.rubro = cnr.rubro
        LEFT JOIN gf_rubro_pptal rb ON rbf.rubro = rb.id_unico
        LEFT JOIN gf_concepto_rubro_cuenta ctrb ON cnr.id_unico = ctrb.concepto_rubro
        LEFT JOIN gf_cuenta cnt ON ctrb.cuenta_debito = cnt.id_unico
        WHERE rb.id_unico = " . $valor[0][0] . " AND ct.id_unico = $concepto");
// $res = $mysqli->query($sql);

// while($row = mysqli_fetch_row($res)){
for ($row = 0; $row < count($res); $row++) {
    echo '<option value="' . $res[$row][0] . '">' . ucwords(strtolower($res[$row][1] . ' ' . $res[$row][2])) . '</option>';
}
