<?php
/*
JOHNN GUTIERREZ, 
FECHA DE CREACION   2021-01-01
ULTIMA MODIFICASION 2021-01-28
*/
include '../conn_obj/utiles_pdo.php';
include '../conn_obj/conn_param.php';
date_default_timezone_set("America/Panama");
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
#error_reporting(E_ALL);
session_start();
if ($_POST) {
    $_SESSION['db_che'] = $_POST['db_che'];
    $_SESSION['suc_id'] = $_POST['suc_id'];
    $_SESSION['usr_id'] = $_POST['usr_id'];
 
    $pDb_Nam = $_SESSION['db_che'];
    $pSuc_Id = $_SESSION['suc_id'];
    $pUsr_Id = $_SESSION['usr_id'];
 
    #$pDb_Nam = '74529_melo3';
    $oCnn = new Utiles($pDb_Nam, $Srv_Info['hostname'], $Srv_Info['username'], $Srv_Info['password']);

    $Sql_Cmd = '';
    $Sql_Cmd = $Sql_Cmd . 'SELECT u.u_id, u.u_descripcion, u.u_usuario, u.dias_de_caducidad, CAST(u.fecha_cambio AS Date) AS fecha_cambio, p.pers_codigo, p.pers_descripcion ';
    $Sql_Cmd = $Sql_Cmd . 'FROM usuarios u ';
    $Sql_Cmd = $Sql_Cmd . 'INNER JOIN personal p ON (u.pers_id= p.pers_id) ';
    $Sql_Cmd = $Sql_Cmd . 'WHERE (IFNULL(p.pers_fing_type,0)=0) ';
    $Sql_Cmd = $Sql_Cmd . 'AND   (u.u_id=?)';
   
    $oData = $oCnn->query($Sql_Cmd, $pUsr_Id)->fetchArray();
    
    if (trim($oData['u_id'])=='') {
        $aResp = array(
            "success" => 'false',
            "mensaje" => 'NO SE ENCONTRARON REGISTROS CON ESTOS PARAMETROS.',
            "jsonres" => ''
        );
    } else {

        $aResp = array(
            "success" => 'true',
            "mensaje" => 'ok',
            "jsonres" => $oData
        );
    }
    $oCnn->close;
} else {
    $aResp = array(
        "success" => 'false',
        "mensaje" => 'SOLO SE ADMITEN LLAMADOS POR METODO POST.',
        "jsonres" => ''
    );

    header('Temporary-Header: True', true, 403);
    header_remove('Temporary-Header');
}
header('content-type: application/json');
echo json_encode($aResp);
?>