Hello, I have the following difficulty: I have a field that the user fills in with the value of the cnpj, I need to retrieve this value for the controller, set this dynamic value in a query within a method to be able to fill in a select on another page referring to this cnpj in question. I do not program in the slim framework, I am trying to do it for days, I would like an example or a way to implement a solution according to this need.
// This is the input that I should get the value
<input type="tel" class="form-control numeric" name="cgc" id="cgc" placeholder="CPF / CNPJ">
// this is the query that i must fill in with the return of the typed cnpj
public function getDevolucoes($request, $response, $args) {
$cnpj = $request->getParam('cgc');
$devolucoes = $this->database->query('
select distinct
dev_devolucoes.id_devolucao as cod_devolucao,
dev_devolucoes.numeronf As nfvendaccgl,
dev_devolucoes.numeronf_devolucao as nfdevolucaocliente,
dev_devolucoes.valor_devolucao,
itenspedido.embalagem,
dev_itensdevolucao.quantidade_devolvida as quantidade
from
itenspedido
join
itenscarregamento on itenspedido.iditenspedido = itenscarregamento.iditenspedido
join
pedido on itenspedido.idpedido = pedido.idpedido
join
dev_devolucoes on itenscarregamento.numeronf = dev_devolucoes.numeronf
join
dev_itensdevolucao on dev_devolucoes.id_devolucao = dev_itensdevolucao.id_devolucao
WHERE
pedido.cnpj = :cgc AND
dev_devolucoes.dev_status = :devstatusId
', [
':devstatusId' => '6',
':cgc' => $cnpj
])->fetchAll();
$response = $response->withJson($devolucoes);
$response = $response->withAddedHeader('cache-control', 'no-cache');
$response = $response->withAddedHeader('pragma', 'no-cache');
$response = $response->withAddedHeader('expires', '0');
return $devolucoes;
}
Thank you for your suggestions.