Commit 470f659302016ae50f4f40e0ba8c865031280d33

Authored by Lucas D'Avila
2 parents 509b5f80 c964d52d
Exists in master

Merge branch 'desfazer-abandono'

ieducar/intranet/educar_matricula_det.php
... ... @@ -33,6 +33,9 @@ require_once 'include/clsDetalhe.inc.php';
33 33 require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
35 35  
  36 +require_once 'App/Model/MatriculaSituacao.php';
  37 +require_once 'Portabilis/View/Helper/Application.php';
  38 +
36 39 /**
37 40 * clsIndexBase class.
38 41 *
... ... @@ -80,6 +83,12 @@ class indice extends clsDetalhe
80 83  
81 84 function Gerar()
82 85 {
  86 +
  87 + // carrega estilo para feedback messages, exibindo msgs da api.
  88 +
  89 + $style = "/modules/Portabilis/Assets/Stylesheets/Frontend.css";
  90 + Portabilis_View_Helper_Application::loadStylesheet($this, $style);
  91 +
83 92 @session_start();
84 93 $this->pessoa_logada = $_SESSION['id_pessoa'];
85 94 session_write_close();
... ... @@ -285,14 +294,25 @@ class indice extends clsDetalhe
285 294 $this->array_botao_url_script[] = "go(\"educar_transferencia_solicitacao_cad.php?ref_cod_matricula={$registro['cod_matricula']}&ref_cod_aluno={$registro['ref_cod_aluno']}&cancela=true&reabrir_matricula=true\")";
286 295 }
287 296  
288   - if ($registro['aprovado'] == 4 || $det_transferencia) {
289   - $this->array_botao[] = 'Imprimir Atestado Frequência';
290   - $this->array_botao_url_script[] = "showExpansivelImprimir(400, 200, \"educar_relatorio_atestado_frequencia.php?cod_matricula={$registro['cod_matricula']}\",[], \"Relatório Atestado de Freqüência\")";
  297 + if ($registro['aprovado'] == App_Model_MatriculaSituacao::ABANDONO) {
  298 + $this->array_botao[] = "Desfazer abandono";
  299 + $this->array_botao_url_script[] = "deleteAbandono({$registro['cod_matricula']})";
291 300 }
292 301 }
293 302  
294 303 $this->url_cancelar = 'educar_aluno_det.php?cod_aluno=' . $registro['ref_cod_aluno'];
295 304 $this->largura = '100%';
  305 +
  306 + // js
  307 + Portabilis_View_Helper_Application::loadJQueryLib($this);
  308 +
  309 + $scripts = array(
  310 + '/modules/Portabilis/Assets/Javascripts/Utils.js',
  311 + '/modules/Portabilis/Assets/Javascripts/ClientApi.js',
  312 + '/modules/Cadastro/Assets/Javascripts/MatriculaShow.js'
  313 + );
  314 +
  315 + Portabilis_View_Helper_Application::loadJavascript($this, $scripts);
296 316 }
297 317  
298 318  
... ...
ieducar/modules/Api/Views/MatriculaController.php
1 1 <?php
2 2  
3   -#error_reporting(E_ALL);
4   -#ini_set("display_errors", 1);
5   -
6 3 /**
7 4 * i-Educar - Sistema de gestão escolar
8 5 *
... ... @@ -35,6 +32,7 @@
35 32 require_once 'lib/Portabilis/Controller/ApiCoreController.php';
36 33 require_once 'lib/Portabilis/Array/Utils.php';
37 34 require_once 'lib/Portabilis/String/Utils.php';
  35 +require_once 'App/Model/MatriculaSituacao.php';
38 36  
39 37 class MatriculaController extends ApiCoreController
40 38 {
... ... @@ -44,6 +42,11 @@ class MatriculaController extends ApiCoreController
44 42 $this->validatesId('aluno');
45 43 }
46 44  
  45 + protected function canDeleteAbandono() {
  46 + return $this->validatesPresenceOf('id') &&
  47 + $this->validatesExistenceOf('matricula', $this->getRequest()->id);
  48 + }
  49 +
47 50 // search options
48 51  
49 52 protected function searchOptions() {
... ... @@ -189,6 +192,17 @@ class MatriculaController extends ApiCoreController
189 192 }
190 193 }
191 194  
  195 + protected function deleteAbandono() {
  196 + if ($this->canDeleteAbandono()) {
  197 + $matriculaId = $this->getRequest()->id;
  198 + $situacaoAndamento = App_Model_MatriculaSituacao::EM_ANDAMENTO;
  199 +
  200 + $sql = 'update pmieducar.matricula set aprovado = $1 where cod_matricula = $2';
  201 + $this->fetchPreparedQuery($sql, array($situacaoAndamento, $matriculaId));
  202 +
  203 + $this->messenger->append('Abandono desfeito.', 'success');
  204 + }
  205 + }
192 206  
193 207 public function Gerar() {
194 208 if ($this->isRequestFor('get', 'matricula'))
... ... @@ -200,6 +214,9 @@ class MatriculaController extends ApiCoreController
200 214 elseif ($this->isRequestFor('get', 'matricula-search'))
201 215 $this->appendResponse($this->search());
202 216  
  217 + elseif ($this->isRequestFor('delete', 'abandono'))
  218 + $this->appendResponse($this->deleteAbandono());
  219 +
203 220 else
204 221 $this->notImplementedOperationError();
205 222 }
... ...
ieducar/modules/Cadastro/Assets/Javascripts/MatriculaShow.js 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +var apiUrlBase = '/module/Api/matricula';
  2 +
  3 +var handleDeleteAbandono = function(dataResponse) {
  4 + handleMessages(dataResponse.msgs);
  5 + location.reload();
  6 +}
  7 +
  8 +function deleteAbandono(matriculaId) {
  9 + if (! confirm(stringUtils.toUtf8('Deseja desfazer o abandono?')))
  10 + return false;
  11 +
  12 + var options = {
  13 + url : deleteResourceUrlBuilder.buildUrl(apiUrlBase, 'abandono'),
  14 + dataType : 'json',
  15 + data : {
  16 + id : matriculaId
  17 + },
  18 + success : handleDeleteAbandono
  19 + };
  20 +
  21 + deleteResource(options);
  22 +}
0 23 \ No newline at end of file
... ...
ieducar/modules/Portabilis/Assets/Javascripts/Utils.js
... ... @@ -277,7 +277,7 @@ var handleMessages = messageUtils.handleMessages;
277 277 $(document).ready(function() {
278 278  
279 279 // add div for feedback messages
280   - $j('<div />').attr('id', 'feedback-messages').appendTo($j('form').last().parent());
  280 + $j('<div />').attr('id', 'feedback-messages').appendTo($j('#corpo'));
281 281  
282 282 }); // ready
283 283 })(jQuery);
... ...