
<?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();

$code_info = strtoupper($_POST['code_info']);

$statement_1 = $db->query("SELECT * FROM actions_line ORDER BY line_name");
$res = $statement_1->fetchAll();

$html = "";

if (count($res) > 1) {
	$html = "<option value=''>- LÍNEA DE ACCIÓN -</option>";
} 

if (isset($res)) {
	foreach ($res as $row) {
		if (!in_array($code_info, explode(",",str_replace(" ","",$row['permisos'])) ) && $row['permisos'] != "" && $row['permisos'] != "TODOS" && $row['permisos'] != "Todos") {
			$html .= "<option value='" . $row['line_name'] . "' style='display:none' >" . $row['line_name'] . "</option>";

		}else{
			$html .= "<option value='" . $row['line_name'] . "'>" . $row['line_name'] . "</option>";
		}
	}
	$array = array(
		"html"  => $html,
		"total" => count($res),
	);
}
echo json_encode($array, JSON_FORCE_OBJECT);


?>


