<?php
include_once('../../../php/sessionStart.php');
include_once('../../../php/db/dbExec.php');
include_once('../../../php/functions.php');
include_once('../../../php/timezone.php');
include_once('../../../php/privileges.php');


switch ($_POST['action']) {
	case 'consultar':
		echo consultar();
		break;
}

function consultar() {
	global $empCod;

	$func = new functions();

	$txtUsuCod=$_POST['txtUsuCod'];

	# QUERYS
	if ($txtUsuCod!="888") {
		$sEmpresas = "SELECT * FROM empresas ORDER BY emp_nom ASC";
	} else {
		$sEmpresas = "SELECT * FROM empresas emp INNER JOIN empreauto ea ON emp.emp_cod=ea.ea_cod ORDER BY emp_nom ASC";
	}		
	# EJECUCION DE QUERYS
	$db = new dbExec();
	$resp["empresas"] = $db->sFetchAll($sEmpresas);
	$db->close();

	$func = new functions();
	return $func->jsonEncodeArray($resp, "empresas");
}

?>