<?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 'consultarCliencc':
		echo consultarCliencc();
		break;


}


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

	# QUERYS
	$sCliencc = "SELECT *, TRIM(cli_nom) AS cli_nom FROM cliencc WHERE cli_emp='$empCod' AND cli_cod='$txtCod'";

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

	$func = new functions();

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

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
	$sDoctoscc = "SELECT * FROM doctoscc 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($sDoctoscc, "doctoscc");
	$db->close();

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

?>