Commit 9189a442ac5da98b8db8882c6fe6d95d26a2894c
1 parent
3287c412
Exists in
master
Alterado simpleSearchMatricula
Alterado para retornar sempre a última matrícula do aluno; portabilis/ieducar#95
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
ieducar/modules/Api/Views/MatriculaController.php
| ... | ... | @@ -61,26 +61,26 @@ class MatriculaController extends ApiCoreController |
| 61 | 61 | // seleciona por (codigo matricula ou codigo aluno), opcionalmente por codigo escola e |
| 62 | 62 | // opcionalmente por ano. |
| 63 | 63 | return "select distinct ON (aluno.cod_aluno) aluno.cod_aluno as aluno_id, |
| 64 | - matricula.cod_matricula as id, pessoa.nome as name from pmieducar.matricula, | |
| 64 | + max(matricula.cod_matricula) as id, pessoa.nome as name from pmieducar.matricula, | |
| 65 | 65 | pmieducar.aluno, cadastro.pessoa where aluno.cod_aluno = matricula.ref_cod_aluno and |
| 66 | 66 | pessoa.idpes = aluno.ref_idpes and aluno.ativo = matricula.ativo and |
| 67 | 67 | matricula.ativo = 1 and matricula.aprovado in (1, 2, 3, 4, 7, 8, 9) and |
| 68 | 68 | (matricula.cod_matricula like $1||'%' or matricula.ref_cod_aluno like $1||'%') and |
| 69 | 69 | (select case when $2 != 0 then matricula.ref_ref_cod_escola = $2 else 1=1 end) and |
| 70 | - (select case when $3 != 0 then matricula.ano = $3 else 1=1 end) limit 15"; | |
| 70 | + (select case when $3 != 0 then matricula.ano = $3 else 1=1 end) group by aluno.cod_aluno, pessoa.nome limit 15"; | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | protected function sqlsForStringSearch() { |
| 75 | 75 | // seleciona por nome aluno, opcionalmente por codigo escola e opcionalmente por ano. |
| 76 | 76 | return "select distinct ON (aluno.cod_aluno) aluno.cod_aluno as aluno_id, |
| 77 | - matricula.cod_matricula as id, pessoa.nome as name from pmieducar.matricula, | |
| 77 | + max(matricula.cod_matricula) as id, pessoa.nome as name from pmieducar.matricula, | |
| 78 | 78 | pmieducar.aluno, cadastro.pessoa where aluno.cod_aluno = matricula.ref_cod_aluno and |
| 79 | 79 | pessoa.idpes = aluno.ref_idpes and aluno.ativo = matricula.ativo and |
| 80 | 80 | matricula.ativo = 1 and matricula.aprovado in (1, 2, 3, 4, 7, 8, 9) and |
| 81 | 81 | lower(to_ascii(pessoa.nome)) like lower(to_ascii($1))||'%' and |
| 82 | 82 | (select case when $2 != 0 then matricula.ref_ref_cod_escola = $2 else 1=1 end) and |
| 83 | - (select case when $3 != 0 then matricula.ano = $3 else 1=1 end) limit 15"; | |
| 83 | + (select case when $3 != 0 then matricula.ano = $3 else 1=1 end) group by aluno.cod_aluno, pessoa.nome limit 15"; | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | ... | ... |