1
I have a doubt, when making a select to fill a field if it is equal to real it should fill ex: the item 1 in the value of 1 real the item 2 in the value of 2 and the item in the value of 3, however in the three items it fills only with the 1st item.
the Controller code:
public function getItensNF()
{
$tipNota = @addslashes($_POST['tipNota']);
$codFil = @addslashes($_POST['codFil']);
$numNota = @addslashes($_POST['numNota']);
$codSnf = @addslashes($_POST['codSnf']);
switch($tipNota)
{
case 'Entrada':
$itemNFSaida = $this->step5ModelObj->getItemNFEntrada(10, $codFil, $numNota, $codSnf);
$seqCmp = 'SEQIPC';
$qtdFatRec = 'QTDREC';
break;
case 'Saida':
$itemNFSaida = $this->step5ModelObj->getItemNFSaida(10, $codFil, $numNota, $codSnf);
$seqCmp = 'SEQIPV';
$qtdFatRec = 'QTDFAT';
break;
default:
$itemNFSaida = array();
}
$parameters = "'$tipNota','$codFil','$numNota','$codSnf'";
echo '
<script type="text/javascript">
$("button").on("click", function(){
var botao = $(this);
botao.prop("disabled", true);
var texto = botao.find("span").text();
botao.find("span").text("Aguarde...");
botao.removeClass("btn-primary");
botao.addClass("btn-danger");
setTimeout(function(){
botao.prop("disabled",false);
botao.removeClass("btn-danger");
botao.addClass("btn-primary");
botao.find("span").text(texto);
},12000
);
});
</script>
<div class="container">
<div class="col-md-12">
<button id="btnProcessar" type="button" class="btn btn-primary" onclick="processEntSai('.$parameters.');"><span>Processar</span></button>
</div>
<div class="row">
<div class="col-md-12">
<table cellpadding="5" id="tableItemNota" class="display dataTable cell-border compact" cellspacing="0" style="textalign:center; border-bottom:1px solid black;">
<thead>
<tr style="border: 1px solid #ccc">
<th></th>
<th>Item</th>
<th>Imagem</th>
<th>Qtd</th>
<th>U.Medida</th>
<th>Peso</th>
<th>Código</th>
<th>Nº Série</th>
<th>Tamanho</th>
<th>Descrição</th>
<th>Coef.</th>
<th>Moeda</th>
<th>Valor Unitário</th>
<th>Valor Total</th>
</tr>
</thead>
<tbody>';
foreach($itemNFSaida as $item) {
if(file_exists('uploads/produtos/'.$item['CODREF'].'.JPG')){
$img_url = BASE_URL.'/uploads/produtos/'.$item['CODREF'].'.JPG';
} else {
$img_url = BASE_URL.'/assets/images/imgNotFound.png';
}
if($item['QTDDEV'] == $item[$qtdFatRec]){
$tdSelectBox = '<span class="glyphicon glyphicon-ban-circle"></span>';
} else{
$tdSelectBox = '<input type="checkbox" id="'.$item['NUMSEP'].'" name="checkSeq" value="'.$item[$seqCmp].'"/>';
}
if($item['USU_MOEVEN'] == 'AU'){
$item['valorEnt'] = $this->step5ModelObj->TotalentSaiComNota(10, $codFil, $numNota);
$item['PREUNI'] = $item['valorEnt']['USU_VLRMOE'];
}
echo '<tr>
<td class="order">'.$tdSelectBox.'</td>
<td>'.$item[$seqCmp].'</td>
<td><img src="'.$img_url.'" id="imgItemPed" data-codpro="'.$item['CODPRO'].'" onclick="itemModalDetalhes(this)"" style="width: 75px; border-radius: 5px; margin: 0px; cursor: pointer;"></td>
<td>'.number_format($item['QTD'], 2, '.', '').'</td>
<td>'.$item['UNIMED'].'</td>
<td>'.number_format($item['PESBRU'], 2, '.', '').'</td>
<td>'.$item['CODPRO'].'</td>
<td>'.$item['NUMSEP'].'</td>
<td>'.$item['CODDER'].'</td>
<td>'.$item['CPL'].'</td>
<td>'.number_format($item['USU_PREVEN'], 2, '.', '').'</td>
<td>'.$item['USU_MOEVEN'].'</td>
<td>'.number_format($item['PREUNI'], 2, ',', '').'</td>
<td>'.number_format($item['VLRLIQ'], 2, ',', '').'</td>
</tr>';
}
echo '</tbody>
</table>
</div>
</div>
</div>';
}
The code of Model:
public function TotalentSaiComNota($codEmp, $codFil, $numPed){
$sql = "SELECT
USU_VLRMOE
FROM
E140IPV
WHERE
CODEMP = ?
AND
CODFIL = ?
AND
NUMNFV = ?";
$sql = $this->db->prepare($sql);
$sql->execute(array($codEmp, $codFil, $numPed));
return $sql->fetch();
}
Summarizing I need you not to repeat the select item as you are repeating, I need you to bring the select items
- item 1
- item 2
- item 3
and not
- item 1
- item 1
- item 1
Your loop is on top of
$itemNFSaida
, not the result of this query that showed.– bfavaretto
so I’ve put the rest of the class, in case I can help, I appreciate
– Guilherme G. Bitencourt
The data is coming from the method
getItemNFEntrada
orgetItemNFSaida
of your model. That’s all you can say.– bfavaretto
the problem occurs when I have to put the if, when the codme != '01' it makes a new select bringing the correct value, however it is not working
– Guilherme G. Bitencourt