public function estoque($id_cliente, $id_evento) { $modelparticipacao = new participacaoModel(); $verificaseexiste = $modelparticipacao->getParticipacao("id_evento = {$id_evento} AND id_cliente = {$id_cliente}"); if ($verificaseexiste) { $this->smarty->assign('paginador', $this->mostraGrid()); $this->smarty->assign('error', 'O cliente já participa deste evento!'); $this->smarty->display('participacao/index.tpl'); return true; } else { //list all records $model_produtoevento = new produtoeventoModel(); $produtoevento_res = $model_produtoevento->getProdutoEvento('ep.id_evento=' . $id_evento); //Full table Scan :( or :) foreach ($produtoevento_res as $value) { $data['qtd_total'] = $value['qtdtotal'] - $value['qtd']; $data['codigo'] = $value['id_produto']; $model_produto = new produtoModel(); $resultado = $model_produto->updProduto($data); } return false; } }
public function mostraGrid() { $total_reg = "10"; // número de registros por página $pagina = $_SESSION['pagina']; if (!$pagina) { $pc = "1"; } else { $pc = $pagina; } $inicio = $pc - 1; $inicio = $inicio * $total_reg; //list all records $model_produtoevento = new produtoeventoModel(); $produtoevento_res = $model_produtoevento->getProdutoEventoLimit(null, $inicio, $total_reg); //Full table Scan :( or :) //send the records to template sytem $this->smarty->assign('listprodutoevento', $produtoevento_res); $query_total = $model_produtoevento->getCountProdutoEvento(); $total_registros = $query_total[0]['total']; //pega o valor $html = $this->paginador($pc, $total_registros, 'produtoevento'); return $html; }