<?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');
include_once('../../../php/maxExecTime.php');

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

switch ($_POST['action']) {

	case 'consultar':
		echo consultar();
		break;

	case 'consultarProvcp':
		echo consultarProvcp();
		break;


}


function consultarProvcp() {
	global $empCod;
	$txtCod=utf8_decode($_POST['txtCod']);

	# QUERYS
	$sProvcp = "SELECT *, TRIM(pro_nom) AS pro_nom, TRIM(pro_retsn) AS pro_retsn FROM provcp WHERE pro_emp='$empCod' AND pro_cod='$txtCod'";

	# EJECUCION DE QUERYS
	$db = new dbExec();
	$resp = $db->sEx($sProvcp, "provcp");
	$db->close();

	$func = new functions();

	return $func->jsonEncodeArray($resp, "provcp");
}

function consultar() {
	global $empCod, $usuNom;

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

	$func = new functions();

	$txtSerie=$_POST['txtSerie'];
	$numNum=$_POST['numNum'];
	$txtCod=$_POST['txtCod'];

	# QUERYS
	$sDoctosc = "SELECT * FROM doctosc WHERE dc_emp='$empCod' AND dc_serie='$txtSerie' AND dc_num='$numNum' AND dc_codp='$txtCod'";

	
	# EJECUCION DE QUERYS
	$db = new dbExec();
	$resp = $db->sEx($sDoctosc, "doctosc");
	$db->close();

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

?>