<th width="1%" >Bairro</th> <th width="10%" >Endereço</th> <?php } ?> <th width="10%" class="td-actions"></th> </tr> </thead> <tbody> <?php $estado = new Estado(); $cidade = new Cidade(); foreach ($listaDeParticipantes as $p) { $estado->selecionarPorId($p->estado); $cidade->selecionarPorId($p->cidade); $idadeParticipante = Funcao::calculaIdade($p->data_nascimento); if ($p->funcao == 'participante') { if ($p->pago) { $botao = '<a id="participante-' . $p->id . '" title="Desaprovar o pagamento do participante" href="javascript:void(0);" class="btn btn-small btn-success btn-pagar" style="width:35%; margin-right:2%; color:white;">Pago</a>'; } else { $botao = '<a title="enviar boleto ao participante por email" href="javascript:void(0);" id="enviar_' . $p->id . '" class="btn btn-small" ><i class="btn-icon-only icon-envelope"> enviar boleto</i></a> <a id="participante-' . $p->id . '" title="Aprovar o pagamento do participante" href="javascript:void(0);" class="btn btn-small btn-danger btn-pagar" style="width:35%; margin-right:2%; color:white;">Não Pago</a>'; } //Com voucher if ($p->voucher) { $botao = '<a title="Voucher: ' . $p->voucher . '" href="javascript:void(0);" class="btn btn-small btn-info btn-pagar" style="width:35%; margin-right:2%; color:white;" >Voucher</a>'; } } else { $botao = '<a id="isento-' . $p->id . '" title="Participante isento de pagamento" href="javascript:void(0);" class="btn btn-small btn-primary" style="width:35%; margin-right:2%; color:white;">Isento</a>'; } ?> <tr>
public static function listarGrid() { $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if (!$sidx) { $sidx = 1; } // connect to the database if ($_GET['_search'] === 'true') { switch ($_GET['searchOper']) { case 'eq': $condicao = $_GET['searchField'] . " = " . $_GET['searchString']; break; case 'ne': $condicao = $_GET['searchField'] . " <> " . $_GET['searchString']; break; case 'bw': $condicao = $_GET['searchField'] . " LIKE '" . $_GET['searchString'] . "%'"; break; case 'bn': $condicao = $_GET['searchField'] . " NOT LIKE '" . $_GET['searchString'] . "%'"; break; case 'ew': $condicao = $_GET['searchField'] . " LIKE '%" . $_GET['searchString'] . "'"; break; case 'en': $condicao = $_GET['searchField'] . " NOT LIKE '%" . $_GET['searchString'] . "'"; break; case 'cn': $condicao = $_GET['searchField'] . " LIKE '%" . $_GET['searchString'] . "%'"; break; case 'nc': $condicao = $_GET['searchField'] . " NOT LIKE '%" . $_GET['searchString'] . "%'"; break; case 'nu': $condicao = $_GET['searchField'] . " IS NULL"; break; case 'nn': $condicao = $_GET['searchField'] . " IS NOT NULL"; break; case 'in': $condicao = $_GET['searchField'] . " IN (" . $_GET['searchString'] . ")"; break; case 'ni': $condicao = $_GET['searchField'] . " NOT IN (" . $_GET['searchString'] . ")"; break; } } else { $condicao = null; } $participante = new Participante(); $count = $participante->count($condicao); //$count = 10000000; if ($count > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; $limit = 0; } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; if ($sidx == "acoes") { $order = "pago ASC, nossonumero ASC"; } else { if ($sidx == 'idade') { $sidx = 'data_nascimento'; } $order = $sidx . " " . $sord; } $listaDeParticipantes = $participante->listar($condicao, $order, $start . "," . $limit); $responce = new stdClass(); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; foreach ($listaDeParticipantes as $indice => $participante) { if ($participante->funcao == 'participante') { if ($participante->pago) { $botao = '<a id="participante-' . $participante->id . '" title="Desaprovar o pagamento do participante" href="javascript:void(0);" class="btn btn-small btn-success btn-pagar" style="width:35%; margin-right:2%; color:white;">Pago</a>'; } else { $botao = '<a title="enviar boleto ao participante por email" href="javascript:void(0);" id="enviar_' . $participante->id . '" class="btn btn-small" ><i class="btn-icon-only icon-envelope"> enviar boleto</i></a> <a id="participante-' . $participante->id . '" title="Aprovar o pagamento do participante" href="javascript:void(0);" class="btn btn-small btn-danger btn-pagar" style="width:35%; margin-right:2%; color:white;">Não Pago</a>'; } //Com voucher if ($participante->voucher) { $botao = '<a title="Voucher: ' . $participante->voucher . '" href="javascript:void(0);" class="btn btn-small btn-info btn-pagar" style="width:35%; margin-right:2%; color:white;" >Voucher</a>'; } } else { $botao = '<a id="isento-' . $participante->id . '" title="Participante isento de pagamento" href="javascript:void(0);" class="btn btn-small btn-primary" style="width:35%; margin-right:2%; color:white;">Isento</a>'; } //TODO IDADE $idadeParticipante = Funcao::calculaIdade($participante->data_nascimento); $responce->rows[$indice]['id'] = $participante->id; $responce->rows[$indice]['cell'] = @array($participante->id, $participante->nome, $participante->funcao, $idadeParticipante, $participante->email, $participante->estado ? $participante->getEstado()->nome : '---', $participante->cidade ? $participante->getCidade()->nome : '---', $botao); } echo json_encode($responce); }