<?php
require_once('DataManager.Class.php');

class Operador {
    
    public $conn;

    function __construct($c) {
        
        if(isset($c)){
                $this->conn = $c;
        } else {
                $this->conn = DataManager::getInstance();
        }
    }


	public function informacionOperador($operID, $tipo_retorno)
	{
	
		$stmt = $this->conn->prepare("{CALL picking.SP_operador_informacion (?)}");
		$stmt->bindValue(1, $operID, PDO::PARAM_INT);
		$stmt->execute();

		if($tipo_retorno == 0) {
			return $stmt->fetch();
		} else {
			return $stmt->fetchAll();
		}

	}

    public function informacionFuncionarioRol($rolID, $estado, $tipo_retorno) {	
		$stmt = $this->conn->prepare("{CALL agenda.SP_funcionario_rol_informacion (?, ?)}");
		$stmt->bindValue(1, $rolID, PDO::PARAM_INT);
		$stmt->bindValue(2, $estado, PDO::PARAM_BOOL);
		$stmt->execute();
		if($tipo_retorno == 0) {
			return $stmt->fetch();
		} else {
			return $stmt->fetchAll();
		}
	}

    public function ingresarFuncionario($rut, $apellidoPaterno, $apellidoMaterno, $nombre, $email, $telfCel, $direccion, $rolId, $pass, $verif  ) 
    {
    $stmt = $this->conn->prepare("{CALL agenda.SP_funcionario_ingresa (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
    $stmt->execute(array($rut, $apellidoPaterno, $apellidoMaterno, $nombre, $email, $telfCel, $direccion, $rolId, $pass, $verif ));

    return $stmt->fetch();	
    }
 
    public function modificarFuncionario($funcId, $email, $telfCel, $direccion, $rolId, $estado  ) 
    {
    $stmt = $this->conn->prepare("{CALL agenda.SP_funcionario_modifica (?, ?, ?, ?, ?, ?)}");
    $stmt->execute(array($funcId, $email, $telfCel, $direccion, $rolId, $estado));

    return $stmt->fetch();	
    }

    public function eliminarFuncionario($funcID ) 
	{
		$stmt = $this->conn->prepare("{CALL agenda.SP_funcionario_eliminar (?)}");
		$stmt->execute(array($funcID ));

        return $stmt->fetch();	
    }
	 
    function Close() {
        
        $this->conn = null;
        
    }
}
?>