I'm doing a query on my BD
to mount a relationship with some NF numbers and their respective dates, but the result is being the last record, there being three.
What I've done so far:
// BUSCANDO DADOS DA AUTORIZAÇÃO $this->GetConnection()->ExecQueryToArray(' SELECT 'cadAutorizacaoNF'.NumeroNF, 'cadAutorizacaoNF'.DataEmissaoNF FROM 'cadAutorizacaoNF' INNER JOIN 'cadAutorizacao' ON ('cadAutorizacaoNF'.IdAutorizacao = 'cadAutorizacao'.IdAutorizacao) WHERE ('cadAutorizacaoNF'.IdAutorizacao = '.$IdAutorizacao.')', $queryResultNF); $RegistrosNF = array(); foreach ($queryResultNF as $RegInfNf) { $RegistrosNF[$RegInfNf['IdAutorizacao']] = array( 'NumeroNF' => $RegInfNf['NumeroNF'], 'DataEmissaoNF' => $RegInfNf['DataEmissaoNF'], ); } $params['RegistrosNF'] = $RegistrosNF;
My template that shows the result looks like this:
{foreach from=$RegistrosNF item=RegInfNf key=IdAutorizacao}
<td height="21" align="center">{$RegInfNf.NumeroNF}</td>
<td height="21" colspan="2" align="center">{if $RegInfNf.DataEmissaoNF != NULL} {$RegInfNf.DataEmissaoNF|date_format:"%d/%m/%Y"} {else} {/if}</td>
{/foreach}
The syntax for the current key, as specified in the Smarty manual, looks like this:
$IdAutorizacao = GetApplication()->GetGETValue('pk1');