<?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');

$bitForm = "cnt4035";
$bitMod = "cnt";
$empCod = $_SESSION['empCod'];
$usuCod = utf8_decode($_SESSION['usuCod']);
$usuNom = utf8_decode($_SESSION['usuNom']);

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

	case 'guardar':
		echo guardar();
		break;
}

function consultar() {
	global $empCod;

	$priv = new privileges();
	if (!$priv->consult($_SESSION['usuPriv'])) {
		return json_encode($priv->rErrorConsult());
	}

	$func = new functions();

	$numTasa=$_POST['numTasa'];

	# QUERYS
	$uPasw = "UPDATE pasw SET p_tcam='$numTasa'";
	
}


function guardar() {
	global $empCod, $usuNom, $bitMod, $bitForm;

	$priv = new privileges();
	if (!$priv->modify($_SESSION['usuPriv'])) {
		return json_encode($priv->rErrorModify());
	}

	$func = new functions();

	$numTasa=$_POST['numTasa'];
	
	# QUERYS PARA UN REGISTRO
	$uPasw = "UPDATE pasw SET p_tcam='$numTasa'";
	
	# EJECUCION DE QUERYS 
	$db = new dbExec();

	$resp = $db->uEx($uPasw);
	$db->iEx($func->iBitacora(utf8_decode("Se modificó Tasa de cambio:  $numTasa Usuario: ").$usuNom, $bitMod, $bitForm));

	$_SESSION['empTasa'] = $numTasa;
	$_SESSION['pTcam'] = $numTasa;	
	$db->close();

	return json_encode($resp);
}

?>