<?php
class gestion_model2{
    private $db;

    public function __construct(){
		//$this->guarda_log("Ingresando");
        $this->db = database2::conexion();
	}

	public function get_trabajadores(){
		
		$con = "select DOCIDEN,NOMBRES from VWTRABAJ;";
		$stmt = sqlsrv_query($this->db, $con);
		$lista = array();
        while($tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
			$lista[] = $tmp;
		}
		return $lista;
	}

	public function get_trabajador($documento_identidad){
		
		$con = "select NOMBRES,DOCIDEN,CENTRO,CARGO from VWTRABAJ WHERE FECHACESE IS NULL and DOCIDEN = '".$documento_identidad."';";
		$stmt = sqlsrv_query($this->db, $con);
        $tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
		return $tmp;
	}

	public function get_usuario_comprobar($user){
		$con = "select count(DOCIDEN) as total from VWTRABAJ where DOCIDEN = '".$user."';";
		$stmt = sqlsrv_query($this->db, $con);
        $tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
		return $tmp;
	}

	public function get_centros_costo(){
		$con = "select * from CCOSTOS where CODCCOSTO = '102' or CODCCOSTO = '115' or CODCCOSTO = '119' or CODCCOSTO = '120' or CODCCOSTO = '130' or CODCCOSTO = '132' or CODCCOSTO = '131' or CODCCOSTO = '300' or CODCCOSTO = '100' or CODCCOSTO = '301' or CODCCOSTO = '302' or CODCCOSTO = '303' or CODCCOSTO = '101' or CODCCOSTO = '102';";
		$stmt = sqlsrv_query($this->db, $con);
		$lista = array();
        while($tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
			$lista[] = $tmp;
		}
		return $lista;
	}

	public function get_centro_costo($id){
		$con = "select * from CCOSTOS where CODCCOSTO = '".$id."';";
		$stmt = sqlsrv_query($this->db, $con);
        $tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
		return $tmp;
	}
	
	//CREADO MICHELLI 
	public function get_usuario_documento($dociden){
		
		$con = "select NOMBRES, DOCIDEN, CARGO from VWTRABAJ where DOCIDEN = '".$dociden."';";
		$stmt = sqlsrv_query($this->db, $con);
        $tmp = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
		
		return $tmp;
	}
	

	
}

?>