include_once "/var/www/html/modules/hispana_clientes_manuales/libs/paloSantoClientesManuales.class.php";
/* Just for test
$_POST['action'] = 'mostrarAgentes';
$_POST['clase'] = 1;*/
if (isset($_POST['action'])) {
    $pDB = new paloDB($arrConfModule['dsn_conn_database']);
    $pClientes = new paloSantoClientesManuales($pDB);
    switch ($_POST['action']) {
        case 'mostrarAgentes':
            if (!isset($_POST['clase']) || empty($_POST['clase'])) {
                $content = "<option value=0>Seleccione una campaña</option>";
                break;
            }
            $arrOptions = $pClientes->getAgentesCampania($_POST['clase']);
            if (sizeof($arrOptions) > 0) {
                $content = crearOption($arrOptions);
            } else {
                $content = "";
            }
            break;
        default:
            $content = 'vacio';
            break;
    }
    echo $content;
    return $content;
}
function crearOption($arrOptions)
{
    $html_output = "";
    if (is_array($arrOptions)) {
    $pCampaniaDerivada = new paloSantoCampaniaDerivada($pDB);
    switch ($_POST['action']) {
        case 'getBases':
            $arrBases = $pCampaniaDerivada->getBases($_POST['campania']);
            // $_log->output("Bases:\n" . print_r($arrBases,true));
            if (sizeof($arrBases) > 0) {
                $content = crearOption($arrBases);
                $_log->output("Content: " . $content);
            } else {
                $content = '<option id=0>No hay bases</option>.';
            }
            break;
        case 'getCalltypes':
            $arrCalltypes = $pCampaniaDerivada->getCalltypes($_POST['campania']);
            if (sizeof($arrCalltypes) > 0) {
                $content = crearOption($arrCalltypes);
                // $_log->output("Content: " . $content);
            } else {
                $content = '<option id=0>No hay calltypes</option>.';
            }
            break;
        case 'getData':
            $numClientes = $pCampaniaDerivada->obtenerClientes($_POST['campania'], $_POST['values_calltypes'], $_POST['values_bases'], true);
            $_log->output("Clientes: " . print_r($numClientes, true));
            $content = $numClientes;
            break;
    }
    echo $content;
    return $content;
}
/**