<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require('../../../core/controller/Database_admin.php');
$db = Database::connectPDO();

$html = "<option value=''>- SELECCIONE -</option>";

$area_formativa = $_POST['area_formativa'];
$tipo_taller = $_POST['tipo_taller'];

$statement_1 = $db->query("SELECT tipo_taller.nombre_taller,tipo_taller.nivel,tipo_taller.modalidad,tipo_taller.duracion_horas,training_type.contenido_curso FROM tipo_taller INNER JOIN training_type ON (tipo_taller.name_training_type = training_type.name_training_type) where training_type.name_training_type='$area_formativa' and tipo_taller.nombre_taller='$tipo_taller' ORDER BY tipo_taller.id");
$res = $statement_1->fetchAll();

if (count($res) > 0) {
	$html = "<option value=''>- SELECCIONE -</option>";
}
if (isset($res)) {
	foreach ($res as $row) {
		$html .= "<option value='" . $row['nombre_taller'] . "'>" . $row['nombre_taller'] . " </option>";
		$array = array(
			"nivel"  => $row['nivel'],
			"modalidad"  => $row['modalidad'],
			"duracion"  => $row['duracion_horas'],
			"contenido"  => $row['contenido_curso'],
			"html"  => $html,
		);
	}
	
}



echo json_encode($array, JSON_FORCE_OBJECT);


