1
How can I make the selected Month input bring me the selected user month and year? It is returning the user but when I input the Month to bring the user data for a given month does not come.
this is the query
public function RetornaAtualizacoesFuncionarios($data,$codusuario){
$WHERE = array();
if( !empty( $codusuario ) ) {$WHERE[] = "codusuario = :codusuario";}else{ $WHERE[] = "codusuario != '37'"; };
if( !empty( $data ) ) $WHERE[] = "DATE_FORMAT(data,'%Y-%m') = :data";
try {
$Query = "SELECT
DISTINCT(usuario),
date_format(data,'%d/%m/%Y %H:%i:%s') as data,
codigo,
nome
FROM funcionarios
WHERE codusuario = '$codusuario'
ORDER BY data DESC ";
if( !empty($WHERE) ) $this->$Query .= ' WHERE '.implode(' AND ', $WHERE );
//echo "<pre>"; print_r($_POST); exit;
include_once $_SESSION['pmodel'].'/mysqlconnection_class.php';
$p_sql = MysqlConnection::getInstance()->prepare($Query);
$_retorno = array();
if($p_sql->execute()) {
while ($_result = $p_sql->fetch(PDO::FETCH_ASSOC)) {
$_retorno[] = $_result;
}
}
return $_retorno;
} catch (PDOException $e) {
echo $e->getMessage();
}
}
public function RetornaUsuarios(){
try {
$Query = "SELECT distinct(funcionarios.codusuario),funcionarios.usuario
FROM funcionarios
LEFT JOIN usuarios ON funcionarios.usuario=usuarios.nome
WHERE funcionarios.codusuario != '37'
";
include_once $_SESSION['pmodel'].'/mysqlconnection_class.php';
$p_sql = MysqlConnection::getInstance()->prepare($Query);
$_retorno = array();
if($p_sql->execute()) {
while ($_result = $p_sql->fetch(PDO::FETCH_ASSOC)) {
$_retorno[] = $_result;
}
}
return $_retorno;
} catch (PDOException $e) {
echo $e->getMessage();
}
}
}
and that’s the input
<form class="form" id="exibefuncionarios" method="post" target='_blank' action="gerar">
<fieldset>
<div style="border-radius:5px;padding:10px;">
<table class="custom-select" cellspacing='0' width='100%' border ='0'>
<tr>
<td class='label_1'>Período:</td>
<td>
<input style="width: 290px;" name="data" type='month'/>
</td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<div style="border-radius:5px;padding:10px;">
<table class="custom-select" cellspacing='0' width='100%' border ='0'>
<tr>
<td class='label_1'>Funcionário:</td>
<td>
<select style="width: 290px;" name="codusuario" id="codusuario">
<option value=''>--Selecione--</option>
<?php foreach($lista_funcionarios as $funcionario){ ?>
<option value='<?php echo $funcionario["codusuario"]; ?>'><?php echo $funcionario["usuario"]; ?></option>
<?php } ?>
</select>
</td>
</tr>
</table>
</div>
</fieldset>
<br/>
<button id="gera_rel_funcionario" class="BlueButton" type="submit">Gera Relatório</button>
</form>
</div>
</div>
I will try to do so. And thank you.
– allan araujo
error in the code
– allan araujo
which error? can give more details.
– Igor Henrique
nothing appears on the screen , well the way I did it lists the name only the input Month is not entering the query .
– allan araujo
edita, after the old code puts like this now
– Igor Henrique