Commit 74b2dc5666203d82fb188d5268e80fdc3016fade
1 parent
fcbe8585
Exists in
master
Adicionado bibliotecas Portabilis
Showing
68 changed files
with
7105 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,187 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * Portabilis_Array_Utils class. | |
33 | + * | |
34 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
35 | + * @category i-Educar | |
36 | + * @license @@license@@ | |
37 | + * @package Portabilis | |
38 | + * @since Classe disponível desde a versão 1.1.0 | |
39 | + * @version @@package_version@@ | |
40 | + */ | |
41 | +class Portabilis_Array_Utils { | |
42 | + | |
43 | + /* Mescla $defaultArray com $array, | |
44 | + preservando os valores de $array nos casos em que ambos tem a mesma chave. */ | |
45 | + public static function merge($array, $defaultArray) { | |
46 | + foreach($array as $key => $value) { | |
47 | + $defaultArray[$key] = $value; | |
48 | + } | |
49 | + | |
50 | + return $defaultArray; | |
51 | + } | |
52 | + | |
53 | + | |
54 | + /* Mescla os valores de diferentes arrays, onde no array mesclado, cada valor (unico), | |
55 | + passa a ser a chave do array. | |
56 | + ex: mergeValues(array(array(1,2), array(2,3,4)) resulta em array(1=>1, 2=>2, 3=>3, 4=>4) */ | |
57 | + public function mergeValues($arrays) { | |
58 | + if (! is_array($arrays)) | |
59 | + $arrays = array($arrays); | |
60 | + | |
61 | + $merge = array(); | |
62 | + | |
63 | + foreach($arrays as $array) { | |
64 | + foreach($array as $value) { | |
65 | + if (! in_array($value, $merge)) | |
66 | + $merge[$value] = $value; | |
67 | + } | |
68 | + } | |
69 | + | |
70 | + return $merge; | |
71 | + } | |
72 | + | |
73 | + | |
74 | + /* Insere uma chave => valor no inicio do $array, | |
75 | + preservando os indices inteiros dos arrays (sem reiniciar) */ | |
76 | + public static function insertIn($key, $value, $array) { | |
77 | + $newArray = array($key => $value); | |
78 | + | |
79 | + foreach($array as $key => $value) { | |
80 | + $newArray[$key] = $value; | |
81 | + } | |
82 | + | |
83 | + return $newArray; | |
84 | + } | |
85 | + | |
86 | + | |
87 | + public static function filterSet($arrays, $attrs = array()){ | |
88 | + if (empty($arrays)) | |
89 | + return array(); | |
90 | + | |
91 | + if (! is_array($arrays)) | |
92 | + $arrays = array($arrays); | |
93 | + | |
94 | + $arraysFiltered = array(); | |
95 | + | |
96 | + foreach($arrays as $array) | |
97 | + $arraysFiltered[] = self::filter($array, $attrs); | |
98 | + | |
99 | + return $arraysFiltered; | |
100 | + } | |
101 | + | |
102 | + | |
103 | + /* Retorna um array {key => value, key => value} | |
104 | + de atributos filtrados de um outro array, podendo renomear nome dos attrs, | |
105 | + util para filtrar um array a ser retornado por uma api | |
106 | + | |
107 | + $arrays - array a ser(em) filtrado(s) | |
108 | + $attrs - atributo ou array de atributos para filtrar objeto, | |
109 | + ex: $attrs = array('cod_escola' => 'id', 'nome') | |
110 | + */ | |
111 | + public static function filter($array, $attrs = array()){ | |
112 | + if (! is_array($attrs)) | |
113 | + $attrs = array($attrs); | |
114 | + | |
115 | + $arrayFiltered = array(); | |
116 | + | |
117 | + // apply filter | |
118 | + foreach($attrs as $attrName => $attrValueName) { | |
119 | + if (! is_string($attrName)) | |
120 | + $attrName = $attrValueName; | |
121 | + | |
122 | + $arrayFiltered[$attrValueName] = $array[$attrName]; | |
123 | + } | |
124 | + | |
125 | + return $arrayFiltered; | |
126 | + } | |
127 | + | |
128 | + | |
129 | + /* transforma um conjunto de arrays "chave => valor, chave => valor" em um array "id => value", | |
130 | + ex: (('id' => 1, 'nome' => 'lucas'), ('id' => 2, 'nome' => 'davila')) | |
131 | + é transformado em (1 => 'lucas', 2 => davila), caso uma mesma chave se repita em mais de um array, | |
132 | + será mantido a chave => valor do ultimo array que a contem. | |
133 | + */ | |
134 | + public static function setAsIdValue($arrays, $keyAttr, $valueAtt) { | |
135 | + if (empty($arrays)) | |
136 | + return array(); | |
137 | + | |
138 | + if (! is_array($arrays)) | |
139 | + $arrays = array($arrays); | |
140 | + | |
141 | + $idValueArray = array(); | |
142 | + | |
143 | + foreach ($arrays as $array) | |
144 | + $idValueArray = self::merge($idValueArray, self::asIdValue($array, $keyAttr, $valueAtt)); | |
145 | + | |
146 | + return $idValueArray; | |
147 | + } | |
148 | + | |
149 | + | |
150 | + /* transforma um array "chave => valor, chave => valor" em um array "id => value", | |
151 | + ex: ('id' => 1, 'nome' => 'lucas') é transformado em (1 => 'lucas') */ | |
152 | + public static function asIdValue($array, $keyAttr, $valueAtt) { | |
153 | + return array($array[$keyAttr] => $array[$valueAtt]); | |
154 | + } | |
155 | + | |
156 | + | |
157 | + /* ordena array por uma chave usando função php usort, ex: | |
158 | + $ordenedResources = Portabilis_Array_Utils::sortByKey($resources, 'resource_att_name'); */ | |
159 | + public static function sortByKey($key, $array) { | |
160 | + usort($array, function ($a, $b) use ($key) { | |
161 | + return Portabilis_Array_Utils::_keySorter($key, $a, $b); | |
162 | + }); | |
163 | + | |
164 | + return $array; | |
165 | + } | |
166 | + | |
167 | + | |
168 | + public static function _keySorter($key, $array, $otherArray) { | |
169 | + $a = $array[$key]; | |
170 | + $b = $otherArray[$key]; | |
171 | + | |
172 | + if ($a == $b) | |
173 | + return 0; | |
174 | + | |
175 | + return ($a < $b) ? -1 : 1; | |
176 | + } | |
177 | + | |
178 | + | |
179 | + /* trim values for a given array */ | |
180 | + public static function trim($array) { | |
181 | + | |
182 | + foreach ($array as $i => $v) | |
183 | + $array[$i] = trim($v); | |
184 | + | |
185 | + return $array; | |
186 | + } | |
187 | +} | ... | ... |
... | ... | @@ -0,0 +1,145 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'include/pmieducar/clsPmieducarServidorAlocacao.inc.php'; | |
32 | + | |
33 | +/** | |
34 | + * Portabilis_Business_Professor class. | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package Portabilis | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | +class Portabilis_Business_Professor { | |
44 | + | |
45 | + public static function isProfessor($instituicaoId, $userId) { | |
46 | + $sql = "select funcao.professor from pmieducar.servidor_funcao, pmieducar.funcao | |
47 | + where funcao.cod_funcao = servidor_funcao.ref_cod_funcao and funcao.professor = 1 and | |
48 | + servidor_funcao.ref_ref_cod_instituicao = $1 and servidor_funcao.ref_cod_servidor = $2"; | |
49 | + | |
50 | + $options = array('params' => array($instituicaoId, $userId), 'return_only' => 'first-field'); | |
51 | + return self::fetchPreparedQuery($sql, $options) == '1'; | |
52 | + } | |
53 | + | |
54 | + | |
55 | + public static function escolasAlocado($instituicaoId, $userId) { | |
56 | + $sql = "select ref_cod_escola as id, ref_cod_servidor as servidor_id, ref_ref_cod_instituicao as | |
57 | + instituicao_id, (select juridica.fantasia from escola, cadastro.juridica | |
58 | + where cod_escola = ref_cod_escola and escola.ref_idpes = juridica.idpes limit 1 | |
59 | + ) as nome, carga_horaria, periodo, hora_final, hora_inicial, dia_semana | |
60 | + from pmieducar.servidor_alocacao where ref_ref_cod_instituicao = $1 and ref_cod_servidor = $2 | |
61 | + and ativo = 1"; | |
62 | + | |
63 | + $options = array('params' => array($instituicaoId, $userId)); | |
64 | + return self::fetchPreparedQuery($sql, $options); | |
65 | + } | |
66 | + | |
67 | + | |
68 | + public static function cursosAlocado($instituicaoId, $escolaId, $userId){ | |
69 | + $sql = "select cod_curso as id, nm_curso as nome from pmieducar.servidor_curso_ministra, | |
70 | + pmieducar.curso, pmieducar.escola_curso, pmieducar.escola | |
71 | + where escola.ref_cod_instituicao = $1 and escola.cod_escola = $2 | |
72 | + and escola_curso.ref_cod_curso = cod_curso and escola_curso.ref_cod_escola = cod_escola | |
73 | + and servidor_curso_ministra.ref_cod_curso = curso.cod_curso and ref_cod_servidor = $3"; | |
74 | + | |
75 | + $options = array('params' => array($instituicaoId, $escolaId, $userId)); | |
76 | + return self::fetchPreparedQuery($sql, $options); | |
77 | + } | |
78 | + | |
79 | + /* public function seriesAlocado() { | |
80 | + | |
81 | + }*/ | |
82 | + | |
83 | + public static function turmasAlocado($escolaId, $serieId, $userId) { | |
84 | + $sql = "select cod_turma as id, nm_turma as nome from pmieducar.turma where ref_ref_cod_escola = $1 | |
85 | + and (ref_ref_cod_serie = $2 or ref_ref_cod_serie_mult = $2) and ativo = 1 and | |
86 | + visivel != 'f' and turma_turno_id in ( select periodo from servidor_alocacao where | |
87 | + ref_cod_escola = ref_ref_cod_escola and ref_cod_servidor = $3 and ativo = 1 limit 1) | |
88 | + order by nm_turma asc"; | |
89 | + | |
90 | + return self::fetchPreparedQuery($sql, array('params' => array($escolaId, $serieId, $userId))); | |
91 | + } | |
92 | + | |
93 | + | |
94 | + public static function componentesCurricularesAlocado($turmaId, $anoLetivo, $userId) { | |
95 | + $componentes = self::componentesCurricularesTurmaAlocado($turmaId, $anoLetivo, $userId); | |
96 | + | |
97 | + if (empty($componentes)) | |
98 | + $componentes = self::componentesCurricularesCursoAlocado($turmaId, $anoLetivo, $userId); | |
99 | + | |
100 | + return $componentes; | |
101 | + } | |
102 | + | |
103 | + | |
104 | + protected static function componentesCurricularesTurmaAlocado($turmaId, $anoLetivo, $userId) { | |
105 | + $sql = "select cc.id, cc.nome | |
106 | + from modules.componente_curricular_turma as cct, pmieducar.turma, modules.componente_curricular as cc, | |
107 | + pmieducar.escola_ano_letivo as al, pmieducar.servidor_disciplina as scc | |
108 | + where turma.cod_turma = $1 and cct.turma_id = turma.cod_turma and cct.escola_id = turma.ref_ref_cod_escola | |
109 | + and cct.componente_curricular_id = cc.id and al.ano = $2 and cct.escola_id = al.ref_cod_escola and | |
110 | + scc.ref_ref_cod_instituicao = turma.ref_cod_instituicao and scc.ref_cod_servidor = $3 and | |
111 | + scc.ref_cod_curso = turma.ref_cod_curso and scc.ref_cod_disciplina = cc.id"; | |
112 | + | |
113 | + $options = array('params' => array($turmaId, $anoLetivo, $userId)); | |
114 | + | |
115 | + return self::fetchPreparedQuery($sql, $options); | |
116 | + } | |
117 | + | |
118 | + | |
119 | + protected static function componentesCurricularesCursoAlocado($turmaId, $anoLetivo, $userId) { | |
120 | + $sql = "select cc.id as id, cc.nome as nome from pmieducar.serie, pmieducar.escola_serie_disciplina as esd, | |
121 | + pmieducar.turma, modules.componente_curricular as cc, pmieducar.escola_ano_letivo as al, | |
122 | + pmieducar.servidor_disciplina as scc where turma.cod_turma = $1 and serie.cod_serie = | |
123 | + turma.ref_ref_cod_serie and esd.ref_ref_cod_escola = turma.ref_ref_cod_escola and esd.ref_ref_cod_serie = | |
124 | + serie.cod_serie and esd.ref_cod_disciplina = cc.id and al.ano = $2 and esd.ref_ref_cod_escola = | |
125 | + al.ref_cod_escola and serie.ativo = 1 and esd.ativo = 1 and al.ativo = 1 and scc.ref_ref_cod_instituicao = | |
126 | + turma.ref_cod_instituicao and scc.ref_cod_servidor = $3 and scc.ref_cod_curso = serie.ref_cod_curso and | |
127 | + scc.ref_cod_disciplina = cc.id"; | |
128 | + | |
129 | + $options = array('params' => array($turmaId, $anoLetivo, $userId)); | |
130 | + | |
131 | + return self::fetchPreparedQuery($sql, $options); | |
132 | + } | |
133 | + | |
134 | + | |
135 | + /*public static function alocacoes($instituicaoId, $escolaId, $userId) { | |
136 | + $alocacoes = new ClsPmieducarServidorAlocacao(); | |
137 | + return $alocacoes->lista(null, $instituicaoId, null, null, $escolaId, $userId); | |
138 | + }*/ | |
139 | + | |
140 | + // wrappers for Portabilis*Utils* | |
141 | + | |
142 | + protected static function fetchPreparedQuery($sql, $options = array()) { | |
143 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
144 | + } | |
145 | +} | |
0 | 146 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,572 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @subpackage lib | |
31 | + * @since Arquivo disponível desde a versão ? | |
32 | + * @version $Id$ | |
33 | + */ | |
34 | + | |
35 | +require_once 'include/clsBanco.inc.php'; | |
36 | + | |
37 | +require_once 'Core/Controller/Page/EditController.php'; | |
38 | +require_once 'CoreExt/Exception.php'; | |
39 | + | |
40 | +require_once 'lib/Portabilis/Messenger.php'; | |
41 | +require_once 'lib/Portabilis/Validator.php'; | |
42 | +require_once 'lib/Portabilis/DataMapper/Utils.php'; | |
43 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
44 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
45 | +require_once 'lib/Portabilis/String/Utils.php'; | |
46 | +require_once 'lib/Portabilis/Utils/User.php'; | |
47 | + | |
48 | +class ApiCoreController extends Core_Controller_Page_EditController | |
49 | +{ | |
50 | + | |
51 | + // variaveis usadas apenas em formulários, desnecesário subescrever nos filhos. | |
52 | + | |
53 | + protected $_saveOption = FALSE; | |
54 | + protected $_deleteOption = FALSE; | |
55 | + protected $_titulo = ''; | |
56 | + | |
57 | + | |
58 | + // adicionar classe do data mapper que se deseja usar, em tais casos. | |
59 | + protected $_dataMapper = null; | |
60 | + | |
61 | + | |
62 | + /* Variaveis utilizadas pelos validadores validatesAuthorizationToDestroy e validatesAuthorizationToChange. | |
63 | + Notar que todos usuários tem autorização para o processo 0, | |
64 | + nos controladores em que se deseja verificar permissões, adicionar o processo AP da funcionalidade. | |
65 | + */ | |
66 | + protected $_processoAp = 0; | |
67 | + protected $_nivelAcessoOption = App_Model_NivelAcesso::INSTITUCIONAL; | |
68 | + | |
69 | + | |
70 | + public function __construct() { | |
71 | + $this->messenger = new Portabilis_Messenger(); | |
72 | + $this->validator = new Portabilis_Validator($this->messenger); | |
73 | + $this->response = array(); | |
74 | + } | |
75 | + | |
76 | + protected function currentUser() { | |
77 | + return Portabilis_Utils_User::load($this->getSession()->id_pessoa); | |
78 | + } | |
79 | + | |
80 | + | |
81 | + // validators | |
82 | + | |
83 | + protected function validatesAccessKey() { | |
84 | + $valid = false; | |
85 | + | |
86 | + if (! is_null($this->getRequest()->access_key)) { | |
87 | + $accessKey = $GLOBALS['coreExt']['Config']->apis->access_key; | |
88 | + $valid = $accessKey == $this->getRequest()->access_key; | |
89 | + | |
90 | + if (! $valid) | |
91 | + $this->messenger->append('Chave de acesso inválida!'); | |
92 | + } | |
93 | + | |
94 | + return $valid; | |
95 | + } | |
96 | + | |
97 | + protected function validatesSignature() { | |
98 | + // #TODO implementar validação urls assinadas | |
99 | + return true; | |
100 | + } | |
101 | + | |
102 | + protected function validatesUserIsLoggedIn(){ | |
103 | + $canAccess = is_numeric($this->getSession()->id_pessoa); | |
104 | + | |
105 | + if (! $canAccess) | |
106 | + $canAccess = ($this->validatesAccessKey() && $this->validatesSignature()); | |
107 | + | |
108 | + if (! $canAccess) { | |
109 | + $msg = 'Usuário deve estar logado ou a chave de acesso deve ser enviada!'; | |
110 | + $this->messenger->append($msg, 'error', $encodeToUtf8 = false, $ignoreIfHasMsgWithType = 'error'); | |
111 | + } | |
112 | + | |
113 | + return $canAccess; | |
114 | + } | |
115 | + | |
116 | + | |
117 | + protected function validatesUserIsAdmin() { | |
118 | + $user = $this->currentUser(); | |
119 | + | |
120 | + if(! $user['super']) { | |
121 | + $this->messenger->append("O usuário logado deve ser o admin"); | |
122 | + return false; | |
123 | + } | |
124 | + | |
125 | + return true; | |
126 | + } | |
127 | + | |
128 | + protected function validatesId($resourceName, $options = array()) { | |
129 | + $attrName = $resourceName . ($resourceName ? '_id' : 'id'); | |
130 | + | |
131 | + return $this->validatesPresenceOf($attrName) && | |
132 | + $this->validatesExistenceOf($resourceName, $this->getRequest()->$attrName, $options); | |
133 | + } | |
134 | + | |
135 | + // subescrever nos controladores cujo recurso difere do padrao (schema pmieducar, tabela <resource>, pk cod_<resource>) | |
136 | + protected function validatesResourceId() { | |
137 | + return $this->validatesPresenceOf('id') && | |
138 | + $this->validatesExistenceOf($this->getRequest()->resource, $this->getRequest()->id); | |
139 | + } | |
140 | + | |
141 | + protected function validatesAuthorizationToDestroy() { | |
142 | + $can = $this->getClsPermissoes()->permissao_excluir($this->getBaseProcessoAp(), | |
143 | + $this->getSession()->id_pessoa, | |
144 | + $this->_nivelAcessoOption); | |
145 | + | |
146 | + if (! $can) | |
147 | + $this->messenger->append("Usuário sem permissão para excluir '{$this->getRequest()->resource}'."); | |
148 | + | |
149 | + return $can; | |
150 | + } | |
151 | + | |
152 | + protected function validatesAuthorizationToChange() { | |
153 | + $can = $this->getClsPermissoes()->permissao_cadastra($this->getBaseProcessoAp(), | |
154 | + $this->getSession()->id_pessoa, | |
155 | + $this->_nivelAcessoOption); | |
156 | + | |
157 | + if (! $can) | |
158 | + $this->messenger->append("Usuário sem permissão para cadastrar '{$this->getRequest()->resource}'."); | |
159 | + | |
160 | + return $can; | |
161 | + } | |
162 | + | |
163 | + | |
164 | + // validation | |
165 | + | |
166 | + protected function canAcceptRequest() { | |
167 | + return $this->validatesUserIsLoggedIn() && | |
168 | + $this->validatesPresenceOf(array('oper', 'resource')); | |
169 | + } | |
170 | + | |
171 | + | |
172 | + protected function canGet() { | |
173 | + return $this->validatesResourceId(); | |
174 | + } | |
175 | + | |
176 | + | |
177 | + protected function canChange() { | |
178 | + throw new Exception('canChange must be overwritten!'); | |
179 | + } | |
180 | + | |
181 | + | |
182 | + protected function canPost() { | |
183 | + return $this->canChange() && | |
184 | + $this->validatesAuthorizationToChange(); | |
185 | + } | |
186 | + | |
187 | + | |
188 | + protected function canPut() { | |
189 | + return $this->canChange() && | |
190 | + $this->validatesResourceId() && | |
191 | + $this->validatesAuthorizationToChange(); | |
192 | + } | |
193 | + | |
194 | + | |
195 | + protected function canSearch() { | |
196 | + return $this->validatesPresenceOf('query'); | |
197 | + } | |
198 | + | |
199 | + | |
200 | + protected function canDelete() { | |
201 | + return $this->validatesResourceId() && | |
202 | + $this->validatesAuthorizationToDestroy(); | |
203 | + } | |
204 | + | |
205 | + | |
206 | + protected function canEnable() { | |
207 | + return $this->validatesResourceId() && | |
208 | + $this->validatesAuthorizationToChange(); | |
209 | + } | |
210 | + | |
211 | + | |
212 | + // api | |
213 | + | |
214 | + protected function notImplementedOperationError() { | |
215 | + $this->messenger->append("Operação '{$this->getRequest()->oper}' não implementada para o recurso '{$this->getRequest()->resource}'"); | |
216 | + } | |
217 | + | |
218 | + | |
219 | + protected function appendResponse($name, $value = '') { | |
220 | + if (is_array($name)) { | |
221 | + foreach($name as $k => $v) { | |
222 | + $this->response[$k] = $v; | |
223 | + } | |
224 | + } | |
225 | + elseif (! is_null($name)) | |
226 | + $this->response[$name] = $value; | |
227 | + } | |
228 | + | |
229 | + | |
230 | + // subscrever nas classes filhas sentando os recursos disponibilizados e operacoes permitidas, ex: | |
231 | + // return array('resources1' => array('get'), 'resouce2' => array('post', 'delete')); | |
232 | + protected function getAvailableOperationsForResources() { | |
233 | + throw new CoreExt_Exception('É necessário sobrescrever o método "getExpectedOperationsForResources()" de ApiCoreController.'); | |
234 | + } | |
235 | + | |
236 | + | |
237 | + protected function isRequestFor($oper, $resource) { | |
238 | + return $this->getRequest()->resource == $resource && | |
239 | + $this->getRequest()->oper == $oper; | |
240 | + } | |
241 | + | |
242 | + | |
243 | + protected function prepareResponse(){ | |
244 | + try { | |
245 | + if (isset($this->getRequest()->oper)) | |
246 | + $this->appendResponse('oper', $this->getRequest()->oper); | |
247 | + | |
248 | + if (isset($this->getRequest()->resource)) | |
249 | + $this->appendResponse('resource', $this->getRequest()->resource); | |
250 | + | |
251 | + $this->appendResponse('msgs', $this->messenger->getMsgs()); | |
252 | + $this->appendResponse('any_error_msg', $this->messenger->hasMsgWithType('error')); | |
253 | + | |
254 | + $response = json_encode($this->response); | |
255 | + } | |
256 | + catch (Exception $e){ | |
257 | + error_log("Erro inesperado no metodo prepareResponse da classe ApiCoreController: {$e->getMessage()}"); | |
258 | + $response = array('msgs' => array('msg' => 'Erro inesperado no servidor. Por favor, tente novamente.', | |
259 | + 'type' => 'error')); | |
260 | + | |
261 | + $response = json_encode($response); | |
262 | + } | |
263 | + | |
264 | + echo $response; | |
265 | + } | |
266 | + | |
267 | + | |
268 | + public function generate(CoreExt_Controller_Page_Interface $instance){ | |
269 | + header('Content-type: application/json; charset=UTF-8'); | |
270 | + | |
271 | + try { | |
272 | + if ($this->canAcceptRequest()) | |
273 | + $instance->Gerar(); | |
274 | + } | |
275 | + catch (Exception $e){ | |
276 | + $this->messenger->append('Exception: ' . $e->getMessage(), 'error', $encodeToUtf8 = true); | |
277 | + } | |
278 | + | |
279 | + echo $this->prepareResponse(); | |
280 | + } | |
281 | + | |
282 | + | |
283 | + /* subescrever nas classes filhas setando as verificações desejadas e retornando a resposta, | |
284 | + conforme recurso e operação recebida ex: get, post ou delete, ex: | |
285 | + | |
286 | + if ($this->getRequest()->oper == 'get') | |
287 | + { | |
288 | + // caso retorne apenas um recurso | |
289 | + $this->appendResponse('matriculas', $matriculas); | |
290 | + | |
291 | + // ou para multiplos recursos, pode-se usar o argumento resource | |
292 | + if ($this->getRequest()->resource == 'matriculas') | |
293 | + $this->appendResponse('matriculas', $this->getMatriculas()); | |
294 | + elseif ($this->getRequest()->resource == 'alunos') | |
295 | + $this->appendResponse('alunos', $this->getAlunos); | |
296 | + else | |
297 | + $this->notImplementedError(); | |
298 | + } | |
299 | + elseif ($this->getRequest()->oper == 'post') | |
300 | + $this->postMatricula(); | |
301 | + else | |
302 | + $this->notImplementedError(); | |
303 | + */ | |
304 | + public function Gerar(){ | |
305 | + throw new CoreExt_Exception("The method 'Gerar' must be overwritten!"); | |
306 | + } | |
307 | + | |
308 | + | |
309 | + // #TODO mover validadores para classe lib/Portabilis/Validator.php / adicionar wrapper para tais | |
310 | + | |
311 | + protected function validatesPresenceOf($requiredParamNames) { | |
312 | + if (! is_array($requiredParamNames)) | |
313 | + $requiredParamNames = array($requiredParamNames); | |
314 | + | |
315 | + $valid = true; | |
316 | + | |
317 | + foreach($requiredParamNames as $param) { | |
318 | + if (! $this->validator->validatesPresenceOf($this->getRequest()->$param, $param) and $valid) { | |
319 | + $valid = false; | |
320 | + } | |
321 | + } | |
322 | + | |
323 | + return $valid; | |
324 | + } | |
325 | + | |
326 | + | |
327 | + protected function validatesExistenceOf($resourceName, $value, $options = array()) { | |
328 | + $defaultOptions = array('schema_name' => 'pmieducar', | |
329 | + 'field_name' => "cod_{$resourceName}", | |
330 | + 'add_msg_on_error' => true); | |
331 | + | |
332 | + $options = $this->mergeOptions($options, $defaultOptions); | |
333 | + | |
334 | + return $this->validator->validatesValueIsInBd($options['field_name'], | |
335 | + $value, | |
336 | + $options['schema_name'], | |
337 | + $resourceName, | |
338 | + $raiseExceptionOnFail = false, | |
339 | + $addMsgOnError = $options['add_msg_on_error']); | |
340 | + } | |
341 | + | |
342 | + protected function validatesUniquenessOf($resourceName, $value, $options = array()) { | |
343 | + $defaultOptions = array('schema_name' => 'pmieducar', | |
344 | + 'field_name' => "cod_{$resourceName}", | |
345 | + 'add_msg_on_error' => true); | |
346 | + | |
347 | + $options = $this->mergeOptions($options, $defaultOptions); | |
348 | + | |
349 | + return $this->validator->validatesValueNotInBd($options['field_name'], | |
350 | + $value, | |
351 | + $options['schema_name'], | |
352 | + $resourceName, | |
353 | + $raiseExceptionOnFail = false, | |
354 | + $addMsgOnError = $options['add_msg_on_error']); | |
355 | + } | |
356 | + | |
357 | + | |
358 | + protected function validatesIsNumeric($expectedNumericParamNames) { | |
359 | + if (! is_array($expectedNumericParamNames)) | |
360 | + $expectedNumericParamNames = array($expectedNumericParamNames); | |
361 | + | |
362 | + $valid = true; | |
363 | + | |
364 | + foreach($requiredParamNames as $param) { | |
365 | + if (! $this->validator->validatesValueIsNumeric($this->getRequest()->$param, $param) and $valid) { | |
366 | + $valid = false; | |
367 | + } | |
368 | + } | |
369 | + | |
370 | + return $valid; | |
371 | + } | |
372 | + | |
373 | + | |
374 | + // wrappers for Portabilis_*Utils* | |
375 | + | |
376 | + | |
377 | + // DEPRECADO | |
378 | + // #TODO nas classes filhas, migrar chamadas de fetchPreparedQuery para usar novo padrao com array de options | |
379 | + protected function fetchPreparedQuery($sql, $params = array(), $hideExceptions = true, $returnOnly = '') { | |
380 | + $options = array('params' => $params, | |
381 | + 'show_errors' => ! $hideExceptions, | |
382 | + 'return_only' => $returnOnly, | |
383 | + 'messenger' => $this->messenger); | |
384 | + | |
385 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
386 | + } | |
387 | + | |
388 | + protected function getDataMapperFor($packageName, $modelName){ | |
389 | + return Portabilis_DataMapper_Utils::getDataMapperFor($packageName, $modelName); | |
390 | + } | |
391 | + | |
392 | + protected function getEntityOf($dataMapper, $id) { | |
393 | + return $dataMapper->find($id); | |
394 | + } | |
395 | + | |
396 | + protected function tryGetEntityOf($dataMapper, $id) { | |
397 | + try { | |
398 | + $entity = $this->getEntityOf($dataMapper, $id); | |
399 | + } | |
400 | + catch(Exception $e) { | |
401 | + $entity = null; | |
402 | + } | |
403 | + | |
404 | + return $entity; | |
405 | + } | |
406 | + | |
407 | + protected function createEntityOf($dataMapper, $data = array()) { | |
408 | + return $dataMapper->createNewEntityInstance($data); | |
409 | + } | |
410 | + | |
411 | + protected function getOrCreateEntityOf($dataMapper, $id) { | |
412 | + $entity = $this->tryGetEntityOf($dataMapper, $id); | |
413 | + return (is_null($entity) ? $this->createEntityOf($dataMapper) : $entity); | |
414 | + } | |
415 | + | |
416 | + protected function deleteEntityOf($dataMapper, $id) { | |
417 | + $entity = $this->tryGetEntityOf($dataMapper, $id); | |
418 | + return (is_null($entity) ? true : $dataMapper->delete($entity)); | |
419 | + } | |
420 | + | |
421 | + protected function saveEntity($dataMapper, $entity) { | |
422 | + if ($entity->isValid()) | |
423 | + $dataMapper->save($entity); | |
424 | + | |
425 | + else { | |
426 | + $errors = $entity->getErrors(); | |
427 | + $msgs = array(); | |
428 | + | |
429 | + foreach ($errors as $attr => $msg) { | |
430 | + if (! is_null($msg)) | |
431 | + $msgs[] = "$attr => $msg"; | |
432 | + } | |
433 | + | |
434 | + //$msgs transporte_aluno | |
435 | + $msg = 'Erro ao salvar o recurso ' . $dataMapper->resourceName() . ': ' . join(', ', $msgs); | |
436 | + $this->messenger->append($msg, 'error', true); | |
437 | + } | |
438 | + } | |
439 | + | |
440 | + protected static function mergeOptions($options, $defaultOptions) { | |
441 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
442 | + } | |
443 | + | |
444 | + protected function toUtf8($str, $options = array()) { | |
445 | + return Portabilis_String_Utils::toUtf8($str, $options); | |
446 | + } | |
447 | + | |
448 | + protected function toLatin1($str, $options = array()) { | |
449 | + return Portabilis_String_Utils::toLatin1($str, $options); | |
450 | + } | |
451 | + | |
452 | + // DEPRECADO #TODO nas classe filhas migrar de safeString => toUtf8 | |
453 | + protected function safeString($str, $transform = true) { | |
454 | + return $this->toUtf8($str, array('transform' => $transform)); | |
455 | + } | |
456 | + | |
457 | + // DEPRECADO #TODO nas classe filhas migrar de safeStringForDb => toLatin1 | |
458 | + protected function safeStringForDb($str) { | |
459 | + return $this->toLatin1($str); | |
460 | + } | |
461 | + | |
462 | + | |
463 | + // search | |
464 | + | |
465 | + protected function defaultSearchOptions() { | |
466 | + $resourceName = Portabilis_String_Utils::underscore($this->getDispatcher()->getActionName()); | |
467 | + | |
468 | + return array('namespace' => 'pmieducar', | |
469 | + 'table' => $resourceName, | |
470 | + 'idAttr' => "cod_$resourceName", | |
471 | + 'labelAttr' => 'nome', | |
472 | + 'selectFields' => array(), | |
473 | + 'sqlParams' => array()); | |
474 | + } | |
475 | + | |
476 | + // overwrite in subclass to chande search options | |
477 | + protected function searchOptions() { | |
478 | + return array(); | |
479 | + } | |
480 | + | |
481 | + protected function sqlsForNumericSearch() { | |
482 | + $searchOptions = $this->mergeOptions($this->searchOptions(), $this->defaultSearchOptions()); | |
483 | + | |
484 | + $namespace = $searchOptions['namespace']; | |
485 | + $table = $searchOptions['table']; | |
486 | + $idAttr = $searchOptions['idAttr']; | |
487 | + $labelAttr = $searchOptions['labelAttr']; | |
488 | + | |
489 | + $searchOptions['selectFields'][] = "$idAttr as id, $labelAttr as name"; | |
490 | + $selectFields = join(', ', $searchOptions['selectFields']); | |
491 | + | |
492 | + return "select distinct $selectFields from $namespace.$table | |
493 | + where $idAttr like $1||'%' order by $idAttr limit 15"; | |
494 | + } | |
495 | + | |
496 | + | |
497 | + protected function sqlsForStringSearch() { | |
498 | + $searchOptions = $this->mergeOptions($this->searchOptions(), $this->defaultSearchOptions()); | |
499 | + | |
500 | + $namespace = $searchOptions['namespace']; | |
501 | + $table = $searchOptions['table']; | |
502 | + $idAttr = $searchOptions['idAttr']; | |
503 | + $labelAttr = $searchOptions['labelAttr']; | |
504 | + | |
505 | + $searchOptions['selectFields'][] = "$idAttr as id, $labelAttr as name"; | |
506 | + $selectFields = join(', ', $searchOptions['selectFields']); | |
507 | + | |
508 | + return "select distinct $selectFields from $namespace.$table | |
509 | + where lower(to_ascii($labelAttr)) like lower(to_ascii($1))||'%' order by $labelAttr limit 15"; | |
510 | + } | |
511 | + | |
512 | + protected function sqlParams($query) { | |
513 | + $searchOptions = $this->mergeOptions($this->searchOptions(), $this->defaultSearchOptions()); | |
514 | + $params = array($query); | |
515 | + | |
516 | + foreach($searchOptions['sqlParams'] as $param) | |
517 | + $params[] = $param; | |
518 | + | |
519 | + return $params; | |
520 | + } | |
521 | + | |
522 | + protected function loadResourcesBySearchQuery($query) { | |
523 | + $results = array(); | |
524 | + $numericQuery = preg_replace("/[^0-9]/", "", $query); | |
525 | + | |
526 | + if (! empty($numericQuery)) { | |
527 | + $sqls = $this->sqlsForNumericSearch(); | |
528 | + $params = $this->sqlParams($numericQuery); | |
529 | + } | |
530 | + else { | |
531 | + | |
532 | + // convertido query para latin1, para que pesquisas com acentuação funcionem. | |
533 | + $query = Portabilis_String_Utils::toLatin1($query, array('escape' => false)); | |
534 | + | |
535 | + $sqls = $this->sqlsForStringSearch(); | |
536 | + $params = $this->sqlParams($query); | |
537 | + } | |
538 | + | |
539 | + if (! is_array($sqls)) | |
540 | + $sqls = array($sqls); | |
541 | + | |
542 | + foreach($sqls as $sql) { | |
543 | + $_results = $this->fetchPreparedQuery($sql, $params, false); | |
544 | + | |
545 | + foreach($_results as $result) { | |
546 | + if (! isset($results[$result['id']])) | |
547 | + $results[$result['id']] = $this->formatResourceValue($result); | |
548 | + } | |
549 | + } | |
550 | + | |
551 | + return $results; | |
552 | + } | |
553 | + | |
554 | + // formats the value of each resource, that will be returned in api as a label. | |
555 | + | |
556 | + protected function formatResourceValue($resource) { | |
557 | + return $resource['id'] . ' - ' . $this->toUtf8($resource['name'], array('transform' => true)); | |
558 | + } | |
559 | + | |
560 | + | |
561 | + // default api responders | |
562 | + | |
563 | + protected function search() { | |
564 | + if ($this->canSearch()) | |
565 | + $resources = $this->loadResourcesBySearchQuery($this->getRequest()->query); | |
566 | + | |
567 | + if (empty($resources)) | |
568 | + $resources = array('' => 'Sem resultados.'); | |
569 | + | |
570 | + return array('result' => $resources); | |
571 | + } | |
572 | +} | ... | ... |
ieducar/lib/Portabilis/Controller/ErrorCoreController.php
0 → 100644
... | ... | @@ -0,0 +1,89 @@ |
1 | +<?php | |
2 | + | |
3 | +error_reporting(E_ALL); | |
4 | +ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @subpackage lib | |
31 | + * @since Arquivo disponível desde a versão ? | |
32 | + * @version $Id$ | |
33 | + */ | |
34 | + | |
35 | +require_once 'Core/View.php'; | |
36 | +require_once 'Core/Controller/Page/ViewController.php'; | |
37 | +require_once 'lib/Portabilis/View/Helper/Application.php'; | |
38 | + | |
39 | +class Portabilis_Controller_ErrorCoreController extends Core_Controller_Page_ViewController | |
40 | +{ | |
41 | + protected $_titulo = 'Error'; | |
42 | + | |
43 | + public function __construct() { | |
44 | + parent::__construct(); | |
45 | + $this->loadAssets(); | |
46 | + } | |
47 | + | |
48 | + /* overwrite Core/Controller/Page/Abstract.php para renderizar html | |
49 | + sem necessidade de usuário estar logado */ | |
50 | + public function generate(CoreExt_Controller_Page_Interface $instance) | |
51 | + { | |
52 | + $this->setHeader(); | |
53 | + | |
54 | + $viewBase = new Core_View($instance); | |
55 | + $viewBase->titulo = $this->_titulo; | |
56 | + $viewBase->addForm($instance); | |
57 | + | |
58 | + $html = $viewBase->MakeHeadHtml(); | |
59 | + | |
60 | + foreach ($viewBase->clsForm as $form) { | |
61 | + $html .= $form->Gerar(); | |
62 | + } | |
63 | + | |
64 | + $html .= $form->getAppendedOutput(); | |
65 | + $html .= $viewBase->MakeFootHtml(); | |
66 | + | |
67 | + echo $html; | |
68 | + } | |
69 | + | |
70 | + protected function loadAssets() { | |
71 | + $styles = array( | |
72 | + 'styles/reset.css', | |
73 | + 'styles/portabilis.css', | |
74 | + 'styles/min-portabilis.css', | |
75 | + '/modules/Error/Assets/Stylesheets/Error.css' | |
76 | + ); | |
77 | + | |
78 | + Portabilis_View_Helper_Application::loadStylesheet($this, $styles); | |
79 | + } | |
80 | + | |
81 | + | |
82 | + protected function setHeader() { | |
83 | + die('setHeader must be overwritten!'); | |
84 | + } | |
85 | + | |
86 | + public function Gerar() { | |
87 | + die('Gerar must be overwritten!'); | |
88 | + } | |
89 | +} | ... | ... |
ieducar/lib/Portabilis/Controller/Page/EditController.php
0 → 100644
... | ... | @@ -0,0 +1,215 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @subpackage lib | |
31 | + * @since Arquivo disponível desde a versão ? | |
32 | + * @version $Id$ | |
33 | + */ | |
34 | + | |
35 | +require_once 'Core/Controller/Page/EditController.php'; | |
36 | + | |
37 | +require_once 'lib/Portabilis/Messenger.php'; | |
38 | +require_once 'lib/Portabilis/Validator.php'; | |
39 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
40 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
41 | +require_once 'lib/Portabilis/DataMapper/Utils.php'; | |
42 | + | |
43 | +require_once 'lib/Portabilis/View/Helper/Application.php'; | |
44 | + | |
45 | +// Resource controller | |
46 | +class Portabilis_Controller_Page_EditController extends Core_Controller_Page_EditController | |
47 | +{ | |
48 | + | |
49 | + protected $_dataMapper = null; | |
50 | + | |
51 | + # vars that must be overwritten in subclasses | |
52 | + # protected $_processoAp = 0; | |
53 | + # protected $_nivelAcessoOption = App_Model_NivelAcesso::SOMENTE_ESCOLA; | |
54 | + | |
55 | + # vars that can be overwritten | |
56 | + # protected $_dataMapper = 'Avaliacao_Model_NotaComponenteDataMapper'; | |
57 | + # protected $_saveOption = FALSE; | |
58 | + # protected $_deleteOption = FALSE; | |
59 | + # protected $_titulo = 'Cadastro de aluno'; | |
60 | + | |
61 | + protected $_nivelAcessoInsuficiente = "/module/Error/unauthorized"; | |
62 | + | |
63 | + | |
64 | + protected $_titulo = ''; | |
65 | + protected $backwardCompatibility = false; | |
66 | + | |
67 | + public function __construct(){ | |
68 | + parent::__construct(); | |
69 | + $this->loadAssets(); | |
70 | + } | |
71 | + | |
72 | + // methods that can be overwritten | |
73 | + | |
74 | + protected function canSave() | |
75 | + { | |
76 | + return true; | |
77 | + } | |
78 | + | |
79 | + | |
80 | + // methods that must be overwritten | |
81 | + | |
82 | + function Gerar() | |
83 | + { | |
84 | + throw new Exception("The method 'Gerar' must be overwritten!"); | |
85 | + } | |
86 | + | |
87 | + | |
88 | + protected function save() | |
89 | + { | |
90 | + throw new Exception("The method 'save' must be overwritten!"); | |
91 | + } | |
92 | + | |
93 | + | |
94 | + // methods that cannot be overwritten | |
95 | + | |
96 | + protected function _save() | |
97 | + { | |
98 | + $result = false; | |
99 | + | |
100 | + // try set or load entity before validation or save | |
101 | + if (! $this->_initNovo()) | |
102 | + $this->_initEditar(); | |
103 | + | |
104 | + if (! $this->messenger()->hasMsgWithType('error') && $this->canSave()) { | |
105 | + try { | |
106 | + $result = $this->save(); | |
107 | + | |
108 | + if (is_null($result)) | |
109 | + $result = ! $this->messenger()->hasMsgWithType('error'); | |
110 | + elseif(! is_bool($result)) | |
111 | + throw new Exception("Invalid value returned from '_save' method: '$result', please return null, true or false!"); | |
112 | + } | |
113 | + catch (Exception $e) { | |
114 | + $this->messenger()->append('Erro ao gravar alterações, por favor, tente novamente.', 'error'); | |
115 | + error_log("Erro ao gravar alteracoes: " . $e->getMessage()); | |
116 | + | |
117 | + $result = false; | |
118 | + } | |
119 | + | |
120 | + $result = $result && ! $this->messenger()->hasMsgWithType('error'); | |
121 | + | |
122 | + if ($result) | |
123 | + $this->messenger()->append('Alterações gravadas com sucesso.', 'success', false, 'success'); | |
124 | + } | |
125 | + | |
126 | + return $result; | |
127 | + } | |
128 | + | |
129 | + | |
130 | + protected function flashMessage() | |
131 | + { | |
132 | + if (! $this->hasErrors()) | |
133 | + return $this->messenger()->toHtml(); | |
134 | + | |
135 | + return ''; | |
136 | + } | |
137 | + | |
138 | + | |
139 | + // helpers | |
140 | + | |
141 | + protected function validator() { | |
142 | + if (! isset($this->_validator)) | |
143 | + $this->_validator = new Portabilis_Validator(); | |
144 | + | |
145 | + return $this->_validator; | |
146 | + } | |
147 | + | |
148 | + | |
149 | + protected function messenger() { | |
150 | + if (! isset($this->_messenger)) | |
151 | + $this->_messenger = new Portabilis_Messenger(); | |
152 | + | |
153 | + return $this->_messenger; | |
154 | + } | |
155 | + | |
156 | + | |
157 | + protected function mailer() { | |
158 | + if (! isset($this->_mailer)) | |
159 | + $this->_mailer = new Portabilis_Mailer(); | |
160 | + | |
161 | + return $this->_mailer; | |
162 | + } | |
163 | + | |
164 | + | |
165 | + protected function loadResourceAssets($dispatcher){ | |
166 | + $rootPath = $_SERVER['DOCUMENT_ROOT']; | |
167 | + $controllerName = ucwords($dispatcher->getControllerName()); | |
168 | + $actionName = ucwords($dispatcher->getActionName()); | |
169 | + | |
170 | + $style = "/modules/$controllerName/Assets/Stylesheets/$actionName.css"; | |
171 | + $script = "/modules/$controllerName/Assets/Javascripts/$actionName.js"; | |
172 | + | |
173 | + if (file_exists($rootPath . $style)) | |
174 | + Portabilis_View_Helper_Application::loadStylesheet($this, $style); | |
175 | + | |
176 | + if (file_exists($rootPath . $script)) | |
177 | + Portabilis_View_Helper_Application::loadJavascript($this, $script); | |
178 | + } | |
179 | + | |
180 | + protected function loadAssets(){ | |
181 | + Portabilis_View_Helper_Application::loadJQueryLib($this); | |
182 | + Portabilis_View_Helper_Application::loadJQueryFormLib($this); | |
183 | + | |
184 | + $styles = array('/modules/Portabilis/Assets/Stylesheets/Frontend.css', | |
185 | + '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css'); | |
186 | + Portabilis_View_Helper_Application::loadStylesheet($this, $styles); | |
187 | + | |
188 | + | |
189 | + $scripts = array('/modules/Portabilis/Assets/Javascripts/ClientApi.js', | |
190 | + '/modules/Portabilis/Assets/Javascripts/Validator.js', | |
191 | + '/modules/Portabilis/Assets/Javascripts/Utils.js'); | |
192 | + | |
193 | + if (! $this->backwardCompatibility) | |
194 | + $scripts[] = '/modules/Portabilis/Assets/Javascripts/Frontend/Resource.js'; | |
195 | + | |
196 | + Portabilis_View_Helper_Application::loadJavascript($this, $scripts); | |
197 | + } | |
198 | + | |
199 | + | |
200 | + // wrappers for Portabilis_*Utils* | |
201 | + | |
202 | + protected static function mergeOptions($options, $defaultOptions) { | |
203 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
204 | + } | |
205 | + | |
206 | + | |
207 | + protected function fetchPreparedQuery($sql, $options = array()) { | |
208 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
209 | + } | |
210 | + | |
211 | + | |
212 | + protected function getDataMapperFor($packageName, $modelName){ | |
213 | + return Portabilis_DataMapper_Utils::getDataMapperFor($packageName, $modelName); | |
214 | + } | |
215 | +} | ... | ... |
ieducar/lib/Portabilis/Controller/Page/ListController.php
0 → 100644
... | ... | @@ -0,0 +1,94 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Avaliacao | |
30 | + * @subpackage Modules | |
31 | + * @since Arquivo disponível desde a versão ? | |
32 | + * @version $Id$ | |
33 | + */ | |
34 | + | |
35 | +require_once 'Core/Controller/Page/ListController.php'; | |
36 | +require_once 'lib/Portabilis/View/Helper/Application.php'; | |
37 | +require_once "lib/Portabilis/View/Helper/Inputs.php"; | |
38 | + | |
39 | +// Process controller | |
40 | +class Portabilis_Controller_Page_ListController extends Core_Controller_Page_ListController | |
41 | +{ | |
42 | + | |
43 | + protected $backwardCompatibility = false; | |
44 | + | |
45 | + public function __construct() { | |
46 | + $this->rodape = ""; | |
47 | + $this->largura = '100%'; | |
48 | + | |
49 | + $this->loadAssets(); | |
50 | + parent::__construct(); | |
51 | + } | |
52 | + | |
53 | + protected function inputsHelper() { | |
54 | + if (! isset($this->_inputsHelper)) | |
55 | + $this->_inputsHelper = new Portabilis_View_Helper_Inputs($this); | |
56 | + | |
57 | + return $this->_inputsHelper; | |
58 | + } | |
59 | + | |
60 | + protected function loadResourceAssets($dispatcher){ | |
61 | + $rootPath = $_SERVER['DOCUMENT_ROOT']; | |
62 | + $controllerName = ucwords($dispatcher->getControllerName()); | |
63 | + $actionName = ucwords($dispatcher->getActionName()); | |
64 | + | |
65 | + $style = "/modules/$controllerName/Assets/Stylesheets/$actionName.css"; | |
66 | + $script = "/modules/$controllerName/Assets/Javascripts/$actionName.js"; | |
67 | + | |
68 | + if (file_exists($rootPath . $style)) | |
69 | + Portabilis_View_Helper_Application::loadStylesheet($this, $style); | |
70 | + | |
71 | + if (file_exists($rootPath . $script)) | |
72 | + Portabilis_View_Helper_Application::loadJavascript($this, $script); | |
73 | + } | |
74 | + | |
75 | + protected function loadAssets(){ | |
76 | + Portabilis_View_Helper_Application::loadJQueryLib($this); | |
77 | + Portabilis_View_Helper_Application::loadJQueryFormLib($this); | |
78 | + | |
79 | + $styles = array('/modules/Portabilis/Assets/Stylesheets/Frontend.css', | |
80 | + '/modules/Portabilis/Assets/Stylesheets/Frontend/Process.css'); | |
81 | + Portabilis_View_Helper_Application::loadStylesheet($this, $styles); | |
82 | + | |
83 | + $scripts = array( | |
84 | + '/modules/Portabilis/Assets/Javascripts/ClientApi.js', | |
85 | + '/modules/Portabilis/Assets/Javascripts/Validator.js', | |
86 | + '/modules/Portabilis/Assets/Javascripts/Utils.js' | |
87 | + ); | |
88 | + | |
89 | + if (! $this->backwardCompatibility) | |
90 | + $scripts[] = '/modules/Portabilis/Assets/Javascripts/Frontend/Process.js'; | |
91 | + | |
92 | + Portabilis_View_Helper_Application::loadJavascript($this, $scripts); | |
93 | + } | |
94 | +} | |
0 | 95 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/Controller/ReportCoreController.php
0 → 100644
... | ... | @@ -0,0 +1,232 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Controller | |
30 | + * @subpackage Portabilis | |
31 | + * @since Arquivo disponível desde a versão 1.1.0 | |
32 | + * @version $Id$ | |
33 | + */ | |
34 | + | |
35 | +require_once 'Core/Controller/Page/EditController.php'; | |
36 | +require_once 'lib/Portabilis/View/Helper/Inputs.php'; | |
37 | +require_once 'Avaliacao/Model/NotaComponenteDataMapper.php'; | |
38 | +require_once 'lib/Portabilis/String/Utils.php'; | |
39 | + | |
40 | +//require_once 'include/pmieducar/clsPermissoes.inc.php'; | |
41 | + | |
42 | +/** | |
43 | + * Portabilis_Controller_ReportCoreController class. | |
44 | + * | |
45 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
46 | + * @category i-Educar | |
47 | + * @license @@license@@ | |
48 | + * @package Controller | |
49 | + * @subpackage Portabilis | |
50 | + * @since Classe disponível desde a versão 1.1.0 | |
51 | + * @version @@package_version@@ | |
52 | + */ | |
53 | +class Portabilis_Controller_ReportCoreController extends Core_Controller_Page_EditController | |
54 | +{ | |
55 | + | |
56 | + // setado qualquer dataMapper pois é obrigatório. | |
57 | + protected $_dataMapper = 'Avaliacao_Model_NotaComponenteDataMapper'; | |
58 | + | |
59 | + # 624 código permissão página index, por padrão todos usuários tem permissão. | |
60 | + protected $_processoAp = 624; | |
61 | + | |
62 | + protected $_titulo = 'Relatório'; | |
63 | + | |
64 | + public function __construct() { | |
65 | + $this->validatesIfUserIsLoggedIn(); | |
66 | + | |
67 | + $this->validationErrors = array(); | |
68 | + | |
69 | + // clsCadastro settings | |
70 | + $this->acao_executa_submit = false; | |
71 | + $this->acao_enviar = 'printReport()'; | |
72 | + | |
73 | + parent::__construct(); | |
74 | + } | |
75 | + | |
76 | + | |
77 | + public function Gerar() { | |
78 | + if (count($_POST) < 1) { | |
79 | + $this->appendFixups(); | |
80 | + $this->renderForm(); | |
81 | + } | |
82 | + else { | |
83 | + $this->report = $this->report(); | |
84 | + | |
85 | + $this->beforeValidation(); | |
86 | + $this->validatesPresenseOfRequiredArgsInReport(); | |
87 | + $this->aftervalidation(); | |
88 | + | |
89 | + if (count($this->validationErrors) > 0) | |
90 | + $this->onValidationError(); | |
91 | + else | |
92 | + $this->renderReport(); | |
93 | + | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + | |
98 | + function headers($result) { | |
99 | + header('Content-type: application/pdf'); | |
100 | + header('Content-Length: ' . strlen($result)); | |
101 | + header('Content-Disposition: inline; filename=report.pdf'); | |
102 | + } | |
103 | + | |
104 | + | |
105 | + function renderForm() { | |
106 | + $this->form(); | |
107 | + $this->nome_url_sucesso = "Exibir"; | |
108 | + } | |
109 | + | |
110 | + | |
111 | + function renderReport() { | |
112 | + try { | |
113 | + $result = $this->report->dumps(); | |
114 | + | |
115 | + if (! $result) | |
116 | + throw new Exception('No report result to render!'); | |
117 | + | |
118 | + $this->headers($result); | |
119 | + echo $result; | |
120 | + } | |
121 | + catch (Exception $e) { | |
122 | + if ($GLOBALS['coreExt']['Config']->report->show_error_details == true) | |
123 | + $details = 'Detalhes: ' . $e->getMessage(); | |
124 | + else | |
125 | + $details = "Visualização dos detalhes sobre o erro desativada."; | |
126 | + | |
127 | + $this->renderError($details); | |
128 | + } | |
129 | + } | |
130 | + | |
131 | + | |
132 | + // methods that must be overridden | |
133 | + | |
134 | + function form() { | |
135 | + throw new Exception("The method 'form' must be overridden!"); | |
136 | + } | |
137 | + | |
138 | + | |
139 | + // metodo executado após validação com sucesso (antes de imprimir) , como os argumentos ex: $this->addArg('id', 1); $this->addArg('id_2', 2); | |
140 | + function beforeValidation() { | |
141 | + throw new Exception("The method 'beforeValidation' must be overridden!"); | |
142 | + } | |
143 | + | |
144 | + | |
145 | + // methods that can be overridden | |
146 | + | |
147 | + function afterValidation() { | |
148 | + //colocar aqui as validacoes serverside, exemplo se histórico possui todos os campos... | |
149 | + //retornar dict msgs, se nenhuma msg entao esta validado ex: $this->addValidationError('O cadastro x esta em y status'); | |
150 | + } | |
151 | + | |
152 | + | |
153 | + | |
154 | + protected function validatesIfUserIsLoggedIn() { | |
155 | + if (! $this->getSession()->id_pessoa) | |
156 | + header('Location: logof.php'); | |
157 | + } | |
158 | + | |
159 | + | |
160 | + function addValidationError($message) { | |
161 | + $this->validationErrors[] = array('message' => utf8_encode($message)); | |
162 | + } | |
163 | + | |
164 | + | |
165 | + function validatesPresenseOfRequiredArgsInReport() { | |
166 | + foreach($this->report->requiredArgs as $requiredArg) { | |
167 | + | |
168 | + if (! isset($this->report->args[$requiredArg]) || empty($this->report->args[$requiredArg])) | |
169 | + $this->addValidationError('Informe um valor no campo "' . $requiredArg . '"'); | |
170 | + } | |
171 | + } | |
172 | + | |
173 | + | |
174 | + function onValidationError() { | |
175 | + $msg = Portabilis_String_Utils::toLatin1('O relatório não pode ser emitido, dica(s):\n\n'); | |
176 | + | |
177 | + foreach ($this->validationErrors as $e) { | |
178 | + $error = Portabilis_String_Utils::escape($e['message']); | |
179 | + $msg .= '- ' . $error . '\n'; | |
180 | + } | |
181 | + | |
182 | + $msg .= '\nPor favor, verifique esta(s) situação(s) e tente novamente.'; | |
183 | + | |
184 | + $msg = Portabilis_String_Utils::toLatin1($msg, array('escape' => false)); | |
185 | + echo "<script type='text/javascript'>alert('$msg'); close();</script> "; | |
186 | + } | |
187 | + | |
188 | + | |
189 | + function renderError($details = "") { | |
190 | + $details = Portabilis_String_Utils::escape($details); | |
191 | + $msg = Portabilis_String_Utils::toLatin1('Ocorreu um erro ao emitir o relatório.') . '\n\n' . $details; | |
192 | + | |
193 | + $msg = Portabilis_String_Utils::toLatin1($msg, array('escape' => false)); | |
194 | + $msg = "<script type='text/javascript'>alert('$msg'); close();</script>"; | |
195 | + | |
196 | + echo $msg; | |
197 | + } | |
198 | + | |
199 | + protected function loadResourceAssets($dispatcher) { | |
200 | + $rootPath = $_SERVER['DOCUMENT_ROOT']; | |
201 | + $controllerName = ucwords($dispatcher->getControllerName()); | |
202 | + $actionName = ucwords($dispatcher->getActionName()); | |
203 | + | |
204 | + $style = "/modules/$controllerName/Assets/Stylesheets/$actionName.css"; | |
205 | + $script = "/modules/$controllerName/Assets/Javascripts/$actionName.js"; | |
206 | + | |
207 | + if (file_exists($rootPath . $style)) | |
208 | + Portabilis_View_Helper_Application::loadStylesheet($this, $style); | |
209 | + | |
210 | + if (file_exists($rootPath . $script)) | |
211 | + Portabilis_View_Helper_Application::loadJavascript($this, $script); | |
212 | + } | |
213 | + | |
214 | + | |
215 | + function appendFixups() { | |
216 | + $js = <<<EOT | |
217 | + | |
218 | +<script type="text/javascript"> | |
219 | + function printReport() { | |
220 | + if (validatesPresenseOfValueInRequiredFields()) { | |
221 | + document.formcadastro.target = '_blank'; | |
222 | + document.formcadastro.submit(); | |
223 | + } | |
224 | + | |
225 | + document.getElementById( 'btn_enviar' ).disabled = false; | |
226 | + } | |
227 | +</script> | |
228 | + | |
229 | +EOT; | |
230 | + $this->appendOutput($js); | |
231 | + } | |
232 | +} | ... | ... |
... | ... | @@ -0,0 +1,67 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * Portabilis_DataMapper_Utils class. | |
33 | + * | |
34 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
35 | + * @category i-Educar | |
36 | + * @license @@license@@ | |
37 | + * @package Portabilis | |
38 | + * @since Classe disponível desde a versão 1.1.0 | |
39 | + * @version @@package_version@@ | |
40 | + */ | |
41 | +class Portabilis_DataMapper_Utils { | |
42 | + | |
43 | + /* | |
44 | + this method returns a data mapper loaded by module_package and model_name, eg: | |
45 | + | |
46 | + $resourceDataMapper = $this->getDataMapperFor('module_package', 'model_name'); | |
47 | + $columns = array('col_1', 'col_2'); | |
48 | + $where = array('col_3' => 'val_1', 'ativo' => '1'); | |
49 | + $orderBy = array('col_4' => 'ASC'); | |
50 | + | |
51 | + $resources = $resourceDataMapper->findAll($columns, $where, $orderBy, $addColumnIdIfNotSet = false); | |
52 | + | |
53 | + */ | |
54 | + public function getDataMapperFor($packageName, $modelName){ | |
55 | + $dataMapperClassName = ucfirst($packageName) . "_Model_" . ucfirst($modelName) . "DataMapper"; | |
56 | + $classPath = str_replace('_', '/', $dataMapperClassName) . '.php'; | |
57 | + | |
58 | + // don't raise any error if the file to be included not exists or it already included. | |
59 | + include_once $classPath; | |
60 | + | |
61 | + if (! class_exists($dataMapperClassName)) | |
62 | + throw new CoreExt_Exception("Class '$dataMapperClassName' not found in path $classPath."); | |
63 | + | |
64 | + return new $dataMapperClassName(); | |
65 | + } | |
66 | + | |
67 | +} | |
0 | 68 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,70 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis_Date | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * Portabilis_Date_Utils class. | |
33 | + * | |
34 | + * Possui métodos | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package App_Date | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | + | |
44 | +class Portabilis_Date_Utils | |
45 | +{ | |
46 | + /** | |
47 | + * Recebe uma data no formato dd/mm/yyyy e retorna no formato postgres yyyy-mm-dd. | |
48 | + * @param string $date | |
49 | + */ | |
50 | + public static function brToPgSQL($date) { | |
51 | + // #TODO usar classe nativa datetime http://www.phptherightway.com/#date_and_time ? | |
52 | + list($dia, $mes, $ano) = explode("/", $date); | |
53 | + return "$ano-$mes-$dia"; | |
54 | + } | |
55 | + | |
56 | + /** | |
57 | + * Recebe uma data no formato postgres yyyy-mm-dd hh:mm:ss.uuuu e retorna no formato br dd/mm/yyyy hh:mm:ss. | |
58 | + * @param string $timestamp | |
59 | + */ | |
60 | + public static function pgSQLToBr($timestamp) { | |
61 | + $format = 'Y-m-d H:i:s'; | |
62 | + $hasMicroseconds = strpos($timestamp, '.') > -1; | |
63 | + | |
64 | + if ($hasMicroseconds) | |
65 | + $format .= '.u'; | |
66 | + | |
67 | + $d = DateTime::createFromFormat($format, $timestamp); | |
68 | + return ($d ? $d->format('d/m/Y H:i:s') : null); | |
69 | + } | |
70 | +} | ... | ... |
... | ... | @@ -0,0 +1,105 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | + | |
32 | +/** | |
33 | + * Portabilis_Mailer class. | |
34 | + * | |
35 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
36 | + * @category i-Educar | |
37 | + * @license @@license@@ | |
38 | + * @package Portabilis | |
39 | + * @since Classe disponível desde a versão 1.1.0 | |
40 | + * @version @@package_version@@ | |
41 | + */ | |
42 | + | |
43 | +// requer bibliotecas Mail e Net_SMTP, ver /scripts/install_pear_packages.sh | |
44 | +require_once 'Mail.php'; | |
45 | + | |
46 | +class Portabilis_Mailer { | |
47 | + | |
48 | + static $selfMailer; | |
49 | + | |
50 | + // #TODO refatorar classe para ser singleton ? | |
51 | + | |
52 | + public function __construct() { | |
53 | + /* Configurações podem ser alteradas em tempo de execução, ex: | |
54 | + $mailerInstance->configs->smtp->username = 'new_username'; */ | |
55 | + | |
56 | + $this->configs = $GLOBALS['coreExt']['Config']->app->mailer; | |
57 | + } | |
58 | + | |
59 | + | |
60 | + public function sendMail($to, $subject, $message) { | |
61 | + $from = "{$this->configs->smtp->from_name} <{$this->configs->smtp->from_email}>"; | |
62 | + $headers = array ('From' => $from, | |
63 | + 'To' => $to, | |
64 | + 'Subject' => $subject); | |
65 | + | |
66 | + $smtp = Mail::factory('smtp', array ('host' => $this->configs->smtp->host, | |
67 | + 'port' => $this->configs->smtp->port, | |
68 | + 'auth' => $this->configs->smtp->auth == '1', | |
69 | + 'username' => $this->configs->smtp->username, | |
70 | + 'password' => $this->configs->smtp->password, | |
71 | + 'debug' => $this->configs->debug == '1', | |
72 | + 'persist' => false)); | |
73 | + | |
74 | + // if defined some allowed domain defined in config, check if $to is allowed | |
75 | + | |
76 | + if (! is_null($this->configs->allowed_domains)) { | |
77 | + foreach ($this->configs->allowed_domains as $domain) { | |
78 | + if (strpos($to, "@$domain") != false) { | |
79 | + $sendResult = ! PEAR::isError($smtp->send($to, $headers, $message)); | |
80 | + break; | |
81 | + } | |
82 | + } | |
83 | + } | |
84 | + else | |
85 | + $sendResult = ! PEAR::isError($smtp->send($to, $headers, $message)); | |
86 | + | |
87 | + error_log("** Sending email from: $from, to: $to, subject: $subject, message: $message"); | |
88 | + error_log("sendResult: $sendResult"); | |
89 | + | |
90 | + return $sendResult; | |
91 | + } | |
92 | + | |
93 | + | |
94 | + static function mail($to, $subject, $message) { | |
95 | + if (! isset(self::$selfMailer)) | |
96 | + self::$selfMailer = new Portabilis_Mailer(); | |
97 | + | |
98 | + return self::$selfMailer->sendMail($to, $subject, $message); | |
99 | + } | |
100 | + | |
101 | + | |
102 | + static protected function host() { | |
103 | + return $_SERVER['HTTP_HOST']; | |
104 | + } | |
105 | +} | |
0 | 106 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,102 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | + | |
32 | +/** | |
33 | + * Portabilis_Messenger class. | |
34 | + * | |
35 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
36 | + * @category i-Educar | |
37 | + * @license @@license@@ | |
38 | + * @package Portabilis | |
39 | + * @since Classe disponível desde a versão 1.1.0 | |
40 | + * @version @@package_version@@ | |
41 | + */ | |
42 | + | |
43 | +class Portabilis_Messenger { | |
44 | + | |
45 | + public function __construct() { | |
46 | + $this->_msgs = array(); | |
47 | + } | |
48 | + | |
49 | + | |
50 | + public function append($msg, $type="error", $encodeToUtf8 = false, $ignoreIfHasMsgWithType = '') { | |
51 | + if (empty($ignoreIfHasMsgWithType) || ! $this->hasMsgWithType($ignoreIfHasMsgWithType)) { | |
52 | + | |
53 | + if ($encodeToUtf8) | |
54 | + $msg = utf8_encode($msg); | |
55 | + | |
56 | + $this->_msgs[] = array('msg' => $msg, 'type' => $type); | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + | |
61 | + public function hasMsgWithType($type) { | |
62 | + $hasMsg = false; | |
63 | + | |
64 | + foreach ($this->_msgs as $m){ | |
65 | + if ($m['type'] == $type) { | |
66 | + $hasMsg = true; | |
67 | + break; | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + return $hasMsg; | |
72 | + } | |
73 | + | |
74 | + | |
75 | + public function toHtml($tag = 'p') { | |
76 | + $msgs = ''; | |
77 | + | |
78 | + foreach($this->getMsgs() as $m) | |
79 | + $msgs .= "<$tag class='{$m['type']}'>{$m['msg']}</$tag>"; | |
80 | + | |
81 | + return $msgs; | |
82 | + } | |
83 | + | |
84 | + | |
85 | + public function getMsgs() { | |
86 | + $msgs = array(); | |
87 | + | |
88 | + // expoe explicitamente apenas as chaves 'msg' e 'type', evitando exposição | |
89 | + // indesejada de chaves adicionadas futuramente ao array $this->_msgs | |
90 | + foreach($this->_msgs as $m) | |
91 | + $msgs[] = array('msg' => $m['msg'], 'type' => $m['type']); | |
92 | + | |
93 | + return $msgs; | |
94 | + } | |
95 | + | |
96 | + // merge messages from another messenger with it self | |
97 | + public function merge($anotherMessenger) { | |
98 | + foreach($anotherMessenger->getMsgs() as $msg) { | |
99 | + $this->append($msg['msg'], $msg['type']); | |
100 | + } | |
101 | + } | |
102 | +} | |
0 | 103 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,71 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Report | |
27 | + * @subpackage Model | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'CoreExt/Enum.php'; | |
33 | + | |
34 | +/** | |
35 | + * RegraAvaliacao_Model_TipoParecerDescritivo class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Report | |
41 | + * @subpackage Model | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_Model_Report_TipoBoletim extends CoreExt_Enum | |
46 | +{ | |
47 | + const BIMESTRAL = 1; | |
48 | + const TRIMESTRAL = 2; | |
49 | + const TRIMESTRAL_CONCEITUAL = 3; | |
50 | + const SEMESTRAL = 4; | |
51 | + const SEMESTRAL_CONCEITUAL = 5; | |
52 | + const SEMESTRAL_EDUCACAO_INFANTIL = 6; | |
53 | + const PARECER_DESCRITIVO_COMPONENTE = 7; | |
54 | + const PARECER_DESCRITIVO_GERAL = 8; | |
55 | + | |
56 | + protected $_data = array( | |
57 | + self::BIMESTRAL => 'Bimestral', | |
58 | + self::TRIMESTRAL => 'Trimestral', | |
59 | + self::TRIMESTRAL_CONCEITUAL => 'Trimestral conceitual', | |
60 | + self::SEMESTRAL => 'Semestral', | |
61 | + self::SEMESTRAL_CONCEITUAL => 'Semestral conceitual', | |
62 | + self::SEMESTRAL_EDUCACAO_INFANTIL => 'Semestral educação infantil', | |
63 | + self::PARECER_DESCRITIVO_COMPONENTE => 'Parecer descritivo por componente curricular', | |
64 | + self::PARECER_DESCRITIVO_GERAL => 'Parecer descritivo geral' | |
65 | + ); | |
66 | + | |
67 | + public static function getInstance() | |
68 | + { | |
69 | + return self::_getInstance(__CLASS__); | |
70 | + } | |
71 | +} | |
0 | 72 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,100 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * Portabilis_Object_Utils class. | |
33 | + * | |
34 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
35 | + * @category i-Educar | |
36 | + * @license @@license@@ | |
37 | + * @package Portabilis | |
38 | + * @since Classe disponível desde a versão 1.1.0 | |
39 | + * @version @@package_version@@ | |
40 | + */ | |
41 | +class Portabilis_Object_Utils { | |
42 | + | |
43 | + public static function filterSet($objects, $attrs = array()){ | |
44 | + if (! is_array($objects)) | |
45 | + $objects = array($objects); | |
46 | + | |
47 | + $objectsFiltered = array(); | |
48 | + | |
49 | + foreach($objects as $object) | |
50 | + $objectsFiltered[] = self::filter($object, $attrs); | |
51 | + | |
52 | + return $objectsFiltered; | |
53 | + } | |
54 | + | |
55 | + | |
56 | + /* Retorna um array {key => value, key => value} | |
57 | + de atributos filtrados de um objeto, podendo renomear nome dos attrs, | |
58 | + util para filtrar um objetos a ser retornado por uma api | |
59 | + | |
60 | + $objects - objeto ou array de objetos a ser(em) filtrado(s) | |
61 | + $attrs - atributo ou array de atributos para filtrar objeto, | |
62 | + ex: $attrs = array('cod_escola' => 'id', 'nome') | |
63 | + */ | |
64 | + public static function filter($object, $attrs = array()){ | |
65 | + if (! is_array($attrs)) | |
66 | + $attrs = array($attrs); | |
67 | + | |
68 | + $objectFiltered = array(); | |
69 | + | |
70 | + // apply filter | |
71 | + foreach($attrs as $keyAttr => $valueAtt) { | |
72 | + if (! is_string($keyAttr)) | |
73 | + $keyAttr = $valueAtt; | |
74 | + | |
75 | + $objectFiltered[$valueAtt] = $object->$keyAttr; | |
76 | + } | |
77 | + | |
78 | + return $objectFiltered; | |
79 | + } | |
80 | + | |
81 | + | |
82 | + /* Retorna um array { key => value, key2 => value2 }, filtrados de um array (lista) de objetos, | |
83 | + util para filtar uma lista de objetos a ser usado para criar um input select. | |
84 | + $objects - objeto ou array de objetos a ser(em) filtrado(s) | |
85 | + $keyAttr - nome do atributo respectivo a chave, a filtrar no objeto, | |
86 | + $valueAtt - nome do atributo respectivo ao valor a filtrar no objeto, | |
87 | + */ | |
88 | + public static function asIdValue($objects, $keyAttr, $valueAtt){ | |
89 | + $objectsFiltered = array(); | |
90 | + | |
91 | + if (! is_array($objects)) | |
92 | + $objects = array($objects); | |
93 | + | |
94 | + // apply filter | |
95 | + foreach($objects as $object) | |
96 | + $objectsFiltered[$object->$keyAttr] = $object->$valueAtt; | |
97 | + | |
98 | + return $objectsFiltered; | |
99 | + } | |
100 | +} | ... | ... |
... | ... | @@ -0,0 +1,116 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Report/ReportFactoryRemote.php'; | |
32 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_Report_ReportCore class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | + | |
45 | +class Portabilis_Report_ReportCore | |
46 | +{ | |
47 | + | |
48 | + function __construct() { | |
49 | + $this->requiredArgs = array(); | |
50 | + $this->args = array(); | |
51 | + | |
52 | + // set required args on construct, because ReportCoreController access it args before call dumps | |
53 | + $this->requiredArgs(); | |
54 | + } | |
55 | + | |
56 | + // wrapper for Portabilis_Array_Utils::merge | |
57 | + protected static function mergeOptions($options, $defaultOptions) { | |
58 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
59 | + } | |
60 | + | |
61 | + function addArg($name, $value) { | |
62 | + if (is_string($value)) | |
63 | + $value = utf8_encode($value); | |
64 | + | |
65 | + $this->args[$name] = $value; | |
66 | + } | |
67 | + | |
68 | + function addRequiredArg($name) { | |
69 | + $this->requiredArgs[] = $name; | |
70 | + } | |
71 | + | |
72 | + function validatesPresenseOfRequiredArgs() { | |
73 | + foreach($this->requiredArgs as $requiredArg) { | |
74 | + | |
75 | + if (! isset($this->args[$requiredArg]) || empty($this->args[$requiredArg])) | |
76 | + throw new Exception("The required arg '{$requiredArg}' wasn't set or is empty!"); | |
77 | + } | |
78 | + } | |
79 | + | |
80 | + function dumps($options = array()) { | |
81 | + $defaultOptions = array('report_factory' => null, 'options' => array()); | |
82 | + $options = self::mergeOptions($options, $defaultOptions); | |
83 | + | |
84 | + $this->validatesPresenseOfRequiredArgs(); | |
85 | + | |
86 | + $reportFactory = ! is_null($options['report_factory']) ? $options['report_factory'] : $this->reportFactory(); | |
87 | + | |
88 | + return $reportFactory->dumps($this, $options['options']); | |
89 | + } | |
90 | + | |
91 | + function reportFactory() { | |
92 | + $factoryClassName = $GLOBALS['coreExt']['Config']->report->default_factory; | |
93 | + $factoryClassPath = str_replace('_', '/', $factoryClassName) . '.php'; | |
94 | + | |
95 | + if (! $factoryClassName) | |
96 | + throw new CoreExt_Exception("No report.default_factory defined in configurations!"); | |
97 | + | |
98 | + // don't fail if path not exists. | |
99 | + include_once $factoryClassPath; | |
100 | + | |
101 | + if (! class_exists($factoryClassName)) | |
102 | + throw new CoreExt_Exception("Class '$factoryClassName' not found in path '$factoryClassPath'"); | |
103 | + | |
104 | + return new $factoryClassName(); | |
105 | + } | |
106 | + | |
107 | + // methods that must be overridden | |
108 | + | |
109 | + function templateName() { | |
110 | + throw new Exception("The method 'templateName' must be overridden!"); | |
111 | + } | |
112 | + | |
113 | + function requiredArgs() { | |
114 | + throw new Exception("The method 'requiredArgs' must be overridden!"); | |
115 | + } | |
116 | +} | ... | ... |
... | ... | @@ -0,0 +1,66 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
32 | + | |
33 | +/** | |
34 | + * Portabilis_Report_ReportFactory class. | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package Portabilis | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | + | |
44 | +class Portabilis_Report_ReportFactory | |
45 | +{ | |
46 | + | |
47 | + function __construct() { | |
48 | + $this->config = $GLOBALS['coreExt']['Config']; | |
49 | + $this->settings = array(); | |
50 | + | |
51 | + $this->setSettings($this->config); | |
52 | + } | |
53 | + | |
54 | + // wrapper for Portabilis_Array_Utils::merge | |
55 | + protected static function mergeOptions($options, $defaultOptions) { | |
56 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
57 | + } | |
58 | + | |
59 | + function setSettings($config) { | |
60 | + throw new Exception("The method 'setSettings' from class Portabilis_Report_ReportFactory must be overridden!"); | |
61 | + } | |
62 | + | |
63 | + function dumps($report, $options = array()) { | |
64 | + throw new Exception("The method 'dumps' from class Portabilis_Report_ReportFactory must be overridden!"); | |
65 | + } | |
66 | +} | |
0 | 67 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/Report/ReportFactoryPHPJasperXML.php
0 → 100644
... | ... | @@ -0,0 +1,108 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Report/ReportFactory.php'; | |
32 | + | |
33 | +require_once 'relatorios/phpjasperxml/class/fpdf/fpdf.php'; | |
34 | +require_once 'relatorios/phpjasperxml/class/PHPJasperXML.inc'; | |
35 | + | |
36 | +//set_include_path(get_include_path() . PATH_SEPARATOR . 'include/portabilis/libs'); | |
37 | +//require_once 'include/portabilis/libs/XML/RPC2/Client.php'; | |
38 | + | |
39 | +/** | |
40 | + * Portabilis_Report_ReportFactoryPHPJasperXML class. | |
41 | + * | |
42 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
43 | + * @category i-Educar | |
44 | + * @license @@license@@ | |
45 | + * @package Portabilis | |
46 | + * @since Classe disponível desde a versão 1.1.0 | |
47 | + * @version @@package_version@@ | |
48 | + */ | |
49 | + | |
50 | +class Portabilis_Report_ReportFactoryPHPJasperXML extends Portabilis_Report_ReportFactory | |
51 | +{ | |
52 | + function setSettings($config) { | |
53 | + $this->settings['db'] = $config->app->database; | |
54 | + $this->settings['logo_file_name'] = $config->report->logo_file_name; | |
55 | + } | |
56 | + | |
57 | + | |
58 | + function loadReportSource($templateName) { | |
59 | + $rootPath = dirname(dirname(dirname(dirname(__FILE__)))); | |
60 | + $fileName = "$templateName.jrxml"; | |
61 | + $filePath = $rootPath . "/modules/Reports/ReportSources/$fileName"; | |
62 | + | |
63 | + if (! file_exists($filePath)) | |
64 | + throw new CoreExt_Exception("Report source '$fileName' not found in path '$filePath'"); | |
65 | + | |
66 | + return simplexml_load_file($filePath); | |
67 | + } | |
68 | + | |
69 | + | |
70 | + function logoPath() { | |
71 | + if (! $this->settings['logo_file_name']) | |
72 | + throw new Exception("No report.logo_file_name defined in configurations!"); | |
73 | + | |
74 | + $rootPath = dirname(dirname(dirname(dirname(__FILE__)))); | |
75 | + $filePath = $rootPath . "/modules/Reports/ReportLogos/{$this->settings['logo_file_name']}"; | |
76 | + | |
77 | + if (! file_exists($filePath)) | |
78 | + throw new CoreExt_Exception("Report logo '{$this->settings['logo_file_name']}' not found in path '$filePath'"); | |
79 | + | |
80 | + return $filePath; | |
81 | + } | |
82 | + | |
83 | + | |
84 | + function dumps($report, $options = array()) { | |
85 | + $defaultOptions = array('add_logo_arg' => true); | |
86 | + $options = self::mergeOptions($options, $defaultOptions); | |
87 | + | |
88 | + if ($options['add_logo_arg']) | |
89 | + $report->addArg('logo', $this->logoPath()); | |
90 | + | |
91 | + $xml = $this->loadReportSource($report->templateName()); | |
92 | + | |
93 | + $builder = new PHPJasperXML(); | |
94 | + $builder->debugsql = false; | |
95 | + $builder->arrayParameter = $report->args; | |
96 | + | |
97 | + $builder->xml_dismantle($xml); | |
98 | + | |
99 | + $builder->transferDBtoArray($this->settings['db']->hostname, | |
100 | + $this->settings['db']->username, | |
101 | + $this->settings['db']->password, | |
102 | + $this->settings['db']->dbname, | |
103 | + $this->settings['db']->port); | |
104 | + | |
105 | + // I: standard output, D: Download file, F: file | |
106 | + $builder->outpage('I'); | |
107 | + } | |
108 | +} | |
0 | 109 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,146 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
32 | + | |
33 | +/** | |
34 | + * Portabilis_String_Utils class. | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package Portabilis | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | +class Portabilis_String_Utils { | |
44 | + | |
45 | + // wrapper for Portabilis_Array_Utils::merge | |
46 | + protected static function mergeOptions($options, $defaultOptions) { | |
47 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
48 | + } | |
49 | + | |
50 | + /* splits a string in a array, eg: | |
51 | + | |
52 | + $divisors = array('-', ' '); // or $divisors = '-'; | |
53 | + $options = array('limit' => 2, 'trim' => true); | |
54 | + | |
55 | + Portabilis_String_Utils::split($divisors, '123 - Some value', $options); | |
56 | + => array([0] => '123', [1] => 'Some value'); | |
57 | + */ | |
58 | + public static function split($divisors, $string, $options = array()) { | |
59 | + $result = array($string); | |
60 | + | |
61 | + $defaultOptions = array('limit' => -1, 'trim' => true); | |
62 | + $options = self::mergeOptions($options, $defaultOptions); | |
63 | + | |
64 | + if (! is_array($divisors)) | |
65 | + $divisors = array($divisors); | |
66 | + | |
67 | + foreach ($divisors as $divisor) { | |
68 | + if (is_numeric(strpos($string, $divisor))) { | |
69 | + $result = split($divisor, $string, $options['limit']); | |
70 | + break; | |
71 | + } | |
72 | + } | |
73 | + | |
74 | + if ($options['trim']) | |
75 | + $result = Portabilis_Array_Utils::trim($result); | |
76 | + | |
77 | + return $result; | |
78 | + } | |
79 | + | |
80 | + /* scapes a string, adding backslashes before characters that need to be quoted, | |
81 | + this method is useful to scape values to be inserted via database queries. */ | |
82 | + public static function escape($str) { | |
83 | + return addslashes($str); | |
84 | + } | |
85 | + | |
86 | + /* encodes latin1 strings to utf-8, | |
87 | + this method is useful to return latin1 strings (with accents) stored in db, in json api's. | |
88 | + */ | |
89 | + public static function toUtf8($str, $options = array()) { | |
90 | + $defaultOptions = array('transform' => false, 'escape' => false, 'convert_html_special_chars' => false); | |
91 | + $options = self::mergeOptions($options, $defaultOptions); | |
92 | + | |
93 | + if ($options['escape']) | |
94 | + $str = self::escape($str); | |
95 | + | |
96 | + if ($options['transform']) | |
97 | + $str = ucwords(mb_strtolower($str)); | |
98 | + | |
99 | + $str = utf8_encode($str); | |
100 | + | |
101 | + if ($options['convert_html_special_chars']) | |
102 | + $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8'); | |
103 | + | |
104 | + return $str; | |
105 | + } | |
106 | + | |
107 | + /* encodes utf-8 strings to latin1, | |
108 | + this method is useful to store utf-8 string (with accents) get from json api's, in latin1 db's. | |
109 | + */ | |
110 | + public static function toLatin1($str, $options = array()) { | |
111 | + $defaultOptions = array('transform' => false, 'escape' => true, 'convert_html_special_chars' => false); | |
112 | + $options = self::mergeOptions($options, $defaultOptions); | |
113 | + | |
114 | + if ($options['escape']) | |
115 | + $str = self::escape($str); | |
116 | + | |
117 | + if ($options['transform']) | |
118 | + $str = ucwords(mb_strtolower($str)); | |
119 | + | |
120 | + if (mb_detect_encoding($str, 'utf-8, iso-8859-1') == 'UTF-8') | |
121 | + $str = utf8_decode($str); | |
122 | + | |
123 | + if ($options['convert_html_special_chars']) | |
124 | + $str = htmlspecialchars($str, ENT_QUOTES, 'ISO-8859-1'); | |
125 | + | |
126 | + return $str; | |
127 | + } | |
128 | + | |
129 | + public static function camelize($str) { | |
130 | + return str_replace(' ', '', ucwords(str_replace('_', ' ', $str))); | |
131 | + } | |
132 | + | |
133 | + public static function underscore($str) { | |
134 | + $words = preg_split('/(?=[A-Z])/', $str, -1, PREG_SPLIT_NO_EMPTY); | |
135 | + return strtolower(implode('_', $words)); | |
136 | + } | |
137 | + | |
138 | + public static function humanize($str) { | |
139 | + $robotWords = array('_id', 'ref_cod_', 'ref_ref_cod_'); | |
140 | + | |
141 | + foreach ($robotWords as $word) | |
142 | + $str = str_replace($word, '', $str); | |
143 | + | |
144 | + return str_replace('_', ' ', ucwords($str)); | |
145 | + } | |
146 | +} | ... | ... |
... | ... | @@ -0,0 +1,123 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @since Arquivo disponível desde a versão 1.1.0 | |
31 | + * @version $Id$ | |
32 | + */ | |
33 | + | |
34 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
35 | + | |
36 | +/** | |
37 | + * Portabilis_Utils_Database class. | |
38 | + * | |
39 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
40 | + * @category i-Educar | |
41 | + * @license @@license@@ | |
42 | + * @package Portabilis | |
43 | + * @since Classe disponível desde a versão 1.1.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class Portabilis_Utils_Database { | |
47 | + | |
48 | + static $_db; | |
49 | + | |
50 | + // wrapper for Portabilis_Array_Utils::merge | |
51 | + protected static function mergeOptions($options, $defaultOptions) { | |
52 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
53 | + } | |
54 | + | |
55 | + public static function db() { | |
56 | + if (! isset(self::$_db)) | |
57 | + self::$_db = new clsBanco(); | |
58 | + | |
59 | + return self::$_db; | |
60 | + } | |
61 | + | |
62 | + public static function fetchPreparedQuery($sql, $options = array()) { | |
63 | + $result = array(); | |
64 | + | |
65 | + $defaultOptions = array('params' => array(), | |
66 | + 'show_errors' => true, | |
67 | + 'return_only' => '', | |
68 | + 'messenger' => null); | |
69 | + | |
70 | + $options = self::mergeOptions($options, $defaultOptions); | |
71 | + | |
72 | + // options validations | |
73 | + //if ($options['show_errors'] and is_null($options['messenger'])) | |
74 | + // throw new Exception("When 'show_errors' is true you must pass the option messenger too."); | |
75 | + | |
76 | + | |
77 | + try { | |
78 | + if (self::db()->execPreparedQuery($sql, $options['params']) != false) { | |
79 | + while (self::db()->ProximoRegistro()) | |
80 | + $result[] = self::db()->Tupla(); | |
81 | + | |
82 | + if (in_array($options['return_only'], array('first-line', 'first-row', 'first-record')) and count($result) > 0) | |
83 | + $result = $result[0]; | |
84 | + elseif ($options['return_only'] == 'first-field' and count($result) > 0 and count($result[0]) > 0) | |
85 | + $result = $result[0][0]; | |
86 | + } | |
87 | + } | |
88 | + catch(Exception $e) { | |
89 | + if ($options['show_errors'] and ! is_null($options['messenger'])) | |
90 | + $options['messenger']->append($e->getMessage(), 'error'); | |
91 | + else | |
92 | + throw $e; | |
93 | + } | |
94 | + | |
95 | + return $result; | |
96 | + } | |
97 | + | |
98 | + // helper para consultas que buscam apenas o primeiro campo, | |
99 | + // considera o segundo argumento o array de options esperado por fetchPreparedQuery | |
100 | + // a menos que este não possua um chave params ou não seja um array, | |
101 | + // neste caso o considera como params | |
102 | + public static function selectField($sql, $paramsOrOptions = array()) { | |
103 | + | |
104 | + if (! is_array($paramsOrOptions) || ! isset($paramsOrOptions['params'])) | |
105 | + $paramsOrOptions = array('params' => $paramsOrOptions); | |
106 | + | |
107 | + $paramsOrOptions['return_only'] = 'first-field'; | |
108 | + return self::fetchPreparedQuery($sql, $paramsOrOptions); | |
109 | + } | |
110 | + | |
111 | + // helper para consultas que buscam apenas a primeira linha | |
112 | + // considera o segundo argumento o array de options esperado por fetchPreparedQuery | |
113 | + // a menos que este não possua um chave params ou não seja um array, | |
114 | + // neste caso o considera como params | |
115 | + public static function selectRow($sql, $paramsOrOptions = array()) { | |
116 | + | |
117 | + if (! is_array($paramsOrOptions) || ! isset($paramsOrOptions['params'])) | |
118 | + $paramsOrOptions = array('params' => $paramsOrOptions); | |
119 | + | |
120 | + $paramsOrOptions['return_only'] = 'first-row'; | |
121 | + return self::fetchPreparedQuery($sql, $paramsOrOptions); | |
122 | + } | |
123 | +} | ... | ... |
... | ... | @@ -0,0 +1,77 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
32 | + | |
33 | +/** | |
34 | + * Portabilis_Utils_Float class. | |
35 | + * | |
36 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
37 | + * @category i-Educar | |
38 | + * @license @@license@@ | |
39 | + * @package Portabilis | |
40 | + * @since Classe disponível desde a versão 1.1.0 | |
41 | + * @version @@package_version@@ | |
42 | + */ | |
43 | +class Portabilis_Utils_Float { | |
44 | + | |
45 | + // wrapper for Portabilis_Array_Utils::merge | |
46 | + protected static function mergeOptions($options, $defaultOptions) { | |
47 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
48 | + } | |
49 | + | |
50 | + | |
51 | + /* Limita as casas decimais de um numero float, SEM arredonda-lo, | |
52 | + ex: para 4.96, usando limit = 1, retornará 4.9 e não 5. */ | |
53 | + public static function limitDecimal($value, $options = array()) { | |
54 | + if (! is_numeric($value)) | |
55 | + throw new Exception("Value must be numeric!"); | |
56 | + elseif(is_integer($value)) | |
57 | + return (float)$value; | |
58 | + | |
59 | + $locale = localeconv(); | |
60 | + | |
61 | + $defaultOptions = array('limit' => 2, | |
62 | + 'decimal_point' => $locale['decimal_point'], | |
63 | + 'thousands_sep' => $locale['thousands_sep']); | |
64 | + | |
65 | + $options = self::mergeOptions($options, $defaultOptions); | |
66 | + | |
67 | + | |
68 | + // split the values after and before the decimal point. | |
69 | + $digits = explode($options['decimal_point'], (string)$value); | |
70 | + | |
71 | + // limit the decimal using the limit option (defaults to 2), eg: .96789 will be limited to .96 | |
72 | + $digits[1] = substr($digits[1], 0, $options['limit']); | |
73 | + | |
74 | + // join the the digits and convert it to float, eg: '4' and '96', will be '4.96' | |
75 | + return (float)($digits[0] . '.' . $digits[1]); | |
76 | + } | |
77 | +} | ... | ... |
... | ... | @@ -0,0 +1,57 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +// requer a biblioteca Services_ReCaptcha, ver /scripts/install_pear_packages.sh | |
32 | +require_once 'Services/ReCaptcha.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_Utils_ReCaptcha class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | + | |
45 | +class Portabilis_Utils_ReCaptcha { | |
46 | + | |
47 | + static function getWidget() { | |
48 | + $recaptchaConfigs = $GLOBALS['coreExt']['Config']->app->recaptcha; | |
49 | + $recaptcha = new Services_ReCaptcha($recaptchaConfigs->public_key, | |
50 | + $recaptchaConfigs->private_key, | |
51 | + array('lang' => $recaptchaConfigs->options->lang, | |
52 | + 'theme' => $recaptchaConfigs->options->theme, | |
53 | + 'secure' => $recaptchaConfigs->options->secure == '1')); | |
54 | + return $recaptcha; | |
55 | + } | |
56 | + | |
57 | +} | |
0 | 58 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,189 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * Portabilis_Utils_User class. | |
33 | + * | |
34 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
35 | + * @category i-Educar | |
36 | + * @license @@license@@ | |
37 | + * @package Portabilis | |
38 | + * @since Classe disponível desde a versão 1.1.0 | |
39 | + * @version @@package_version@@ | |
40 | + */ | |
41 | +class Portabilis_Utils_User { | |
42 | + | |
43 | + static $_currentUserId; | |
44 | + static $_nivelAcesso; | |
45 | + static $_permissoes; | |
46 | + | |
47 | + static function currentUserId() { | |
48 | + if (! isset(self::$_currentUserId)) { | |
49 | + @session_start(); | |
50 | + self::$_currentUserId = $_SESSION['id_pessoa']; | |
51 | + session_write_close(); | |
52 | + } | |
53 | + | |
54 | + return self::$_currentUserId; | |
55 | + } | |
56 | + | |
57 | + static function redirectToLogoff() { | |
58 | + header('Location: /intranet/logof.php'); | |
59 | + } | |
60 | + | |
61 | + | |
62 | + static function loggedIn(){ | |
63 | + return is_numeric(self::currentUserId()); | |
64 | + } | |
65 | + | |
66 | + // database helpers | |
67 | + | |
68 | + static function loadUsingCredentials($username, $password) { | |
69 | + $sql = "SELECT ref_cod_pessoa_fj FROM portal.funcionario WHERE matricula = $1 and senha = $2"; | |
70 | + $options = array('params' => array($username, $password), 'show_errors' => false, 'return_only' => 'first-field'); | |
71 | + $userId = self::fetchPreparedQuery($sql, $options); | |
72 | + | |
73 | + if (is_numeric($userId)) | |
74 | + return self::load($userId); | |
75 | + | |
76 | + return null; | |
77 | + } | |
78 | + | |
79 | + // TODO usar modules/Usuario/Model/Funcionario ao invés de executar select | |
80 | + static function load($id) { | |
81 | + if ($id == 'current_user') | |
82 | + $id = self::currentUserId(); | |
83 | + elseif (! is_numeric($id)) | |
84 | + throw new Exception("'$id' is not a valid id, please send a numeric value or a string 'current_user'"); | |
85 | + | |
86 | + $sql = "SELECT ref_cod_pessoa_fj as id, opcao_menu, ref_cod_setor_new, tipo_menu, matricula, email, status_token, | |
87 | + ativo, proibido, tempo_expira_conta, data_reativa_conta, tempo_expira_senha, data_troca_senha, | |
88 | + ip_logado as ip_ultimo_acesso, data_login FROM portal.funcionario WHERE ref_cod_pessoa_fj = $1"; | |
89 | + | |
90 | + $options = array('params' => array($id), 'show_errors' => false, 'return_only' => 'first-line'); | |
91 | + $user = self::fetchPreparedQuery($sql, $options); | |
92 | + $user['super'] = $GLOBALS['coreExt']['Config']->app->superuser == $user['matricula']; | |
93 | + | |
94 | + | |
95 | + /* considera como expirado caso usuario não admin e data_reativa_conta + tempo_expira_conta <= now | |
96 | + obs: ao salvar drh > cadastro funcionario, seta data_reativa_conta = now */ | |
97 | + $user['expired_account'] = ! $user['super'] && ! empty($user['tempo_expira_conta']) && | |
98 | + ! empty($user['data_reativa_conta']) && | |
99 | + time() - strtotime($user['data_reativa_conta']) > $user['tempo_expira_conta'] * 60 * 60 * 24; | |
100 | + | |
101 | + | |
102 | + // considera o periodo para expiração de senha definido nas configs, caso o tenha sido feito. | |
103 | + $tempoExpiraSenha = $GLOBALS['coreExt']['Config']->app->user_accounts->default_password_expiration_period; | |
104 | + | |
105 | + if (! is_numeric($tempoExpiraSenha)) | |
106 | + $tempoExpiraSenha = $user['tempo_expira_senha']; | |
107 | + | |
108 | + /* considera como expirado caso data_troca_senha + tempo_expira_senha <= now */ | |
109 | + $user['expired_password'] = ! empty($user['data_troca_senha']) && ! empty($tempoExpiraSenha) && | |
110 | + time() - strtotime($user['data_troca_senha']) > $tempoExpiraSenha * 60 * 60 * 24; | |
111 | + | |
112 | + return $user; | |
113 | + } | |
114 | + | |
115 | + | |
116 | + static function disableAccount($userId) { | |
117 | + $sql = "UPDATE portal.funcionario SET ativo = 0 WHERE ref_cod_pessoa_fj = $1"; | |
118 | + $options = array('params' => array($userId), 'show_errors' => false); | |
119 | + | |
120 | + self::fetchPreparedQuery($sql, $options); | |
121 | + } | |
122 | + | |
123 | + | |
124 | + /* | |
125 | + Destroi determinado tipo de status_token de um usuário, como ocorre por exemplo após fazer login, | |
126 | + onde solicitações de redefinição de senha em aberto são destruidas. | |
127 | + */ | |
128 | + static function destroyStatusTokenFor($userId, $withType) { | |
129 | + $sql = "UPDATE portal.funcionario set status_token = '' WHERE ref_cod_pessoa_fj = $1 and status_token like $2"; | |
130 | + $options = array('params' => array($userId, "$withType-%"), 'show_errors' => false); | |
131 | + | |
132 | + self::fetchPreparedQuery($sql, $options); | |
133 | + } | |
134 | + | |
135 | + | |
136 | + static function logAccessFor($userId, $clientIP) { | |
137 | + $sql = "UPDATE portal.funcionario SET ip_logado = '$clientIP', data_login = NOW() WHERE ref_cod_pessoa_fj = $1"; | |
138 | + $options = array('params' => array($userId), 'show_errors' => false); | |
139 | + | |
140 | + self::fetchPreparedQuery($sql, $options); | |
141 | + } | |
142 | + | |
143 | + | |
144 | + | |
145 | + // permissões | |
146 | + | |
147 | + static function getClsPermissoes() { | |
148 | + if (! isset(self::$_permissoes)) | |
149 | + self::$_permissoes = new clsPermissoes(); | |
150 | + | |
151 | + return self::$_permissoes; | |
152 | + } | |
153 | + | |
154 | + | |
155 | + static function getNivelAcesso() { | |
156 | + if (! isset(self::$_nivelAcesso)) | |
157 | + self::$_nivelAcesso = self::getClsPermissoes()->nivel_acesso(self::currentUserId()); | |
158 | + | |
159 | + return self::$_nivelAcesso; | |
160 | + } | |
161 | + | |
162 | + | |
163 | + # TODO verificar se é possivel usar a logica de App_Model_NivelAcesso | |
164 | + static function hasNivelAcesso($nivelAcessoType) { | |
165 | + $niveisAcesso = array('POLI_INSTITUCIONAL' => 1, | |
166 | + 'INSTITUCIONAL' => 2, | |
167 | + 'SOMENTE_ESCOLA' => 4, | |
168 | + 'SOMENTE_BIBLIOTECA' => 8); | |
169 | + | |
170 | + if (! isset($niveisAcesso[$nivelAcessoType])) | |
171 | + throw new CoreExt_Exception("Nivel acesso '$nivelAcessoType' não definido."); | |
172 | + | |
173 | + return self::getNivelAcesso() == $niveisAcesso[$nivelAcessoType]; | |
174 | + } | |
175 | + | |
176 | + | |
177 | + static function canAccessEscola($id) { | |
178 | + return (self::hasNivelAcesso('POLI_INSTITUCIONAL') || | |
179 | + self::hasNivelAcesso('INSTITUCIONAL') || | |
180 | + self::getClsPermissoes()->getEscola(self::currentUserId()) == $id); | |
181 | + } | |
182 | + | |
183 | + | |
184 | + // wrappers for Portabilis*Utils* | |
185 | + | |
186 | + protected static function fetchPreparedQuery($sql, $options = array()) { | |
187 | + return Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
188 | + } | |
189 | +} | |
0 | 190 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,157 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package Portabilis | |
27 | + * @since Arquivo disponível desde a versão 1.1.0 | |
28 | + * @version $Id$ | |
29 | + */ | |
30 | + | |
31 | +require_once 'include/clsBanco.inc.php'; | |
32 | +require_once 'CoreExt/Exception.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_Validator class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_Validator { | |
46 | + | |
47 | + public function __construct(&$messenger) { | |
48 | + $this->messenger = $messenger; | |
49 | + } | |
50 | + | |
51 | + | |
52 | + // TODO refatorar todos metodos, para não receber mais argumento $raiseException* | |
53 | + | |
54 | + /* TODO refatorar todos metodos, para não receber mais argumento $addMsg* | |
55 | + caso $msg falso pode-se disparar erro */ | |
56 | + | |
57 | + public function validatesPresenceOf(&$value, $name, $raiseExceptionOnFail = false, $msg = '', $addMsgOnEmpty = true){ | |
58 | + if (! isset($value) || (empty($value) && !is_numeric($value))){ | |
59 | + if ($addMsgOnEmpty) | |
60 | + { | |
61 | + $msg = empty($msg) ? "É necessário receber uma variavel '$name'" : $msg; | |
62 | + $this->messenger->append($msg); | |
63 | + } | |
64 | + | |
65 | + if ($raiseExceptionOnFail) | |
66 | + throw new CoreExt_Exception($msg); | |
67 | + | |
68 | + return false; | |
69 | + } | |
70 | + return true; | |
71 | + } | |
72 | + | |
73 | + | |
74 | + public function validatesValueIsNumeric(&$value, $name, $raiseExceptionOnFail = false, $msg = '', $addMsgOnError = true){ | |
75 | + if (! is_numeric($value)){ | |
76 | + if ($addMsgOnError) | |
77 | + { | |
78 | + $msg = empty($msg) ? "O valor recebido para variavel '$name' deve ser numerico" : $msg; | |
79 | + $this->messenger->append($msg); | |
80 | + } | |
81 | + | |
82 | + if ($raiseExceptionOnFail) | |
83 | + throw new CoreExt_Exception($msg); | |
84 | + | |
85 | + return false; | |
86 | + } | |
87 | + return true; | |
88 | + } | |
89 | + | |
90 | + | |
91 | + public function validatesValueIsArray(&$value, $name, $raiseExceptionOnFail = false, $msg = '', $addMsgOnError = true){ | |
92 | + | |
93 | + if (! is_array($value)){ | |
94 | + if ($addMsgOnError) { | |
95 | + $msg = empty($msg) ? "Deve ser recebido uma lista de '$name'" : $msg; | |
96 | + $this->messenger->append($msg); | |
97 | + } | |
98 | + | |
99 | + if ($raiseExceptionOnFail) | |
100 | + throw new CoreExt_Exception($msg); | |
101 | + | |
102 | + return false; | |
103 | + } | |
104 | + return true; | |
105 | + } | |
106 | + | |
107 | + | |
108 | + public function validatesValueInSetOf(&$value, $setExpectedValues, $name, $raiseExceptionOnFail = false, $msg = ''){ | |
109 | + if (! empty($setExpectedValues) && ! in_array($value, $setExpectedValues)){ | |
110 | + $msg = empty($msg) ? "Valor recebido na variavel '$name' é invalido" : $msg; | |
111 | + $this->messenger->append($msg); | |
112 | + | |
113 | + if ($raiseExceptionOnFail) | |
114 | + throw new CoreExt_Exception($msg); | |
115 | + | |
116 | + return false; | |
117 | + } | |
118 | + | |
119 | + return true; | |
120 | + } | |
121 | + | |
122 | + public function validatesValueIsInBd($fieldName, &$value, $schemaName, $tableName, $raiseExceptionOnFail = true, $addMsgOnError = true){ | |
123 | + $sql = "select 1 from $schemaName.$tableName where $fieldName = $1 limit 1"; | |
124 | + | |
125 | + if (Portabilis_Utils_Database::selectField($sql, $value) != 1){ | |
126 | + if ($addMsgOnError) { | |
127 | + $msg = "O valor informado {$value} para $tableName, não esta presente no banco de dados."; | |
128 | + $this->messenger->append($msg); | |
129 | + } | |
130 | + | |
131 | + if ($raiseExceptionOnFail) | |
132 | + throw new CoreExt_Exception($msg); | |
133 | + | |
134 | + return false; | |
135 | + } | |
136 | + | |
137 | + return true; | |
138 | + } | |
139 | + | |
140 | + public function validatesValueNotInBd($fieldName, &$value, $schemaName, $tableName, $raiseExceptionOnFail = true, $addMsgOnError = true){ | |
141 | + $sql = "select 1 from $schemaName.$tableName where $fieldName = $1 limit 1"; | |
142 | + | |
143 | + if (Portabilis_Utils_Database::selectField($sql, $value) == 1) { | |
144 | + if ($addMsgOnError) { | |
145 | + $msg = "O valor informado {$value} para $tableName já existe no banco de dados."; | |
146 | + $this->messenger->append($msg); | |
147 | + } | |
148 | + | |
149 | + if ($raiseExceptionOnFail) | |
150 | + throw new CoreExt_Exception($msg); | |
151 | + | |
152 | + return false; | |
153 | + } | |
154 | + | |
155 | + return true; | |
156 | + } | |
157 | +} | |
0 | 158 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,186 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @since Arquivo disponível desde a versão 1.1.0 | |
31 | + * @version $Id$ | |
32 | + */ | |
33 | + | |
34 | +require_once 'CoreExt/View/Helper/Abstract.php'; | |
35 | +require_once 'Portabilis/Assets/Version.php'; | |
36 | + | |
37 | +/** | |
38 | + * ApplicationHelper class. | |
39 | + * | |
40 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
41 | + * @category i-Educar | |
42 | + * @license @@license@@ | |
43 | + * @package Portabilis | |
44 | + * @since Classe disponível desde a versão 1.1.0 | |
45 | + * @version @@package_version@@ | |
46 | + */ | |
47 | + | |
48 | +class Portabilis_View_Helper_Application extends CoreExt_View_Helper_Abstract { | |
49 | + | |
50 | + // previne carregar mais de uma vez o mesmo asset js ou css | |
51 | + protected static $javascriptsLoaded = array(); | |
52 | + protected static $stylesheetsLoaded = array(); | |
53 | + | |
54 | + | |
55 | + /** | |
56 | + * Construtor singleton. | |
57 | + */ | |
58 | + protected function __construct() | |
59 | + { | |
60 | + } | |
61 | + | |
62 | + | |
63 | + /** | |
64 | + * Retorna uma instância singleton. | |
65 | + * @return CoreExt_View_Helper_Abstract | |
66 | + */ | |
67 | + public static function getInstance() | |
68 | + { | |
69 | + return self::_getInstance(__CLASS__); | |
70 | + } | |
71 | + | |
72 | + | |
73 | + | |
74 | + /** | |
75 | + * Adiciona elementos chamadas scripts javascript para instancia da view recebida, exemplo: | |
76 | + * | |
77 | + * <code> | |
78 | + * $applicationHelper->javascript($viewInstance, array('/modules/ModuleName/Assets/Javascripts/ScriptName.js', '...')); | |
79 | + * </code> | |
80 | + * | |
81 | + * @param object $viewInstance Istancia da view a ser carregado os scripts. | |
82 | + * @param array ou string $files Lista de scripts a serem carregados. | |
83 | + * @return null | |
84 | + */ | |
85 | + public static function loadJavascript($viewInstance, $files, $expireCacheDateFormat = 'dmY') { | |
86 | + if (! is_array($files)) | |
87 | + $files = array($files); | |
88 | + | |
89 | + foreach ($files as $file) { | |
90 | + // somente carrega o asset uma vez | |
91 | + if (! in_array($file, self::$javascriptsLoaded)) { | |
92 | + self::$javascriptsLoaded[] = $file; | |
93 | + | |
94 | + // cache controll | |
95 | + $file .= '?assets_version=' . Portabilis_Assets_Version::VERSION; | |
96 | + $file .= $expireCacheDateFormat ? '×tamp=' . date($expireCacheDateFormat) : ''; | |
97 | + | |
98 | + $viewInstance->appendOutput("<script type='text/javascript' src='$file'></script>"); | |
99 | + } | |
100 | + } | |
101 | + } | |
102 | + | |
103 | + | |
104 | + /** | |
105 | + * Adiciona links css para instancia da view recebida, exemplo: | |
106 | + * | |
107 | + * <code> | |
108 | + * $applicationHelper->stylesheet($viewInstance, array('/modules/ModuleName/Assets/Stylesheets/StyleName.css', '...')); | |
109 | + * </code> | |
110 | + * | |
111 | + * @param object $viewInstance1 Istancia da view a ser adicionado os links para os estilos. | |
112 | + * @param array ou string $files Lista de estilos a serem carregados. | |
113 | + * @return null | |
114 | + */ | |
115 | + public static function loadStylesheet($viewInstance, $files, $expireCacheDateFormat = 'dmY') { | |
116 | + if (! is_array($files)) | |
117 | + $files = array($files); | |
118 | + | |
119 | + foreach ($files as $file) { | |
120 | + // somente carrega o asset uma vez | |
121 | + if (! in_array($file, self::$stylesheetsLoaded)) { | |
122 | + self::$stylesheetsLoaded[] = $file; | |
123 | + | |
124 | + // cache controll | |
125 | + $file .= '?assets_version=' . Portabilis_Assets_Version::VERSION; | |
126 | + $file .= $expireCacheDateFormat ? '×tamp=' . date($expireCacheDateFormat) : ''; | |
127 | + | |
128 | + $viewInstance->appendOutput("<link type='text/css' rel='stylesheet' href='$file'></script>"); | |
129 | + } | |
130 | + } | |
131 | + } | |
132 | + | |
133 | + | |
134 | + public static function embedJavascript($viewInstance, $script, $afterReady = false) { | |
135 | + if ($afterReady) { | |
136 | + self::loadJQueryLib($viewInstance); | |
137 | + | |
138 | + $script = "(function($){ | |
139 | + $(document).ready(function(){ | |
140 | + $script | |
141 | + }); | |
142 | + })(jQuery);"; | |
143 | + } | |
144 | + | |
145 | + $viewInstance->appendOutput("<script type='text/javascript'>$script</script>"); | |
146 | + } | |
147 | + | |
148 | + | |
149 | + public static function embedStylesheet($viewInstance, $css) { | |
150 | + $viewInstance->appendOutput("<style type='text/css'>$css</style>"); | |
151 | + } | |
152 | + | |
153 | + public static function embedJavascriptToFixupFieldsWidth($viewInstance) { | |
154 | + Portabilis_View_Helper_Application::loadJQueryLib($viewInstance); | |
155 | + | |
156 | + Portabilis_View_Helper_Application::loadJavascript( | |
157 | + $viewInstance, '/modules/Portabilis/Assets/Javascripts/Utils.js' | |
158 | + ); | |
159 | + | |
160 | + Portabilis_View_Helper_Application::embedJavascript( | |
161 | + $viewInstance, 'fixupFieldsWidth();', $afterReady = true | |
162 | + ); | |
163 | + | |
164 | + } | |
165 | + | |
166 | + // load lib helpers | |
167 | + | |
168 | + public static function loadJQueryLib($viewInstance) { | |
169 | + self::loadJavascript($viewInstance, '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false); | |
170 | + self::embedJavascript($viewInstance, "if (typeof(\$j) == 'undefined') { var \$j = jQuery.noConflict(); }"); | |
171 | + } | |
172 | + | |
173 | + | |
174 | + public static function loadJQueryFormLib($viewInstance) { | |
175 | + self::loadJavascript($viewInstance, 'scripts/jquery/jquery.form.js', false); | |
176 | + } | |
177 | + | |
178 | + | |
179 | + public static function loadJQueryUiLib($viewInstance) { | |
180 | + self::loadJavascript($viewInstance, '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js', false); | |
181 | + self::loadStylesheet($viewInstance, '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-lightness/jquery-ui.css', false); | |
182 | + | |
183 | + // ui-autocomplete fixup | |
184 | + self::embedStylesheet($viewInstance, ".ui-autocomplete { font-size: 11px; }"); | |
185 | + } | |
186 | +} | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?php | |
2 | + | |
3 | +require_once 'lib/Portabilis/View/Helper/Input/Ano.php'; | |
4 | + | |
5 | + | |
6 | +/* | |
7 | + | |
8 | + Helper DEPRECADO | |
9 | + | |
10 | + #TODO mover referencias de $this->inputsHelper()->dynamic('ano'); | |
11 | + para $this->inputsHelper()->input('ano'); | |
12 | + | |
13 | +*/ | |
14 | + | |
15 | +if (strpos($_SERVER['HTTP_HOST'], 'local') > -1) | |
16 | + echo "Helper DynamicInput_Ano DEPRECADO"; | |
17 | + | |
18 | +class Portabilis_View_Helper_DynamicInput_Ano extends Portabilis_View_Helper_Input_Ano { | |
19 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/AnoLetivo.php
0 → 100644
... | ... | @@ -0,0 +1,89 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_AnoLetivo class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_AnoLetivo extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + // subscreve para não acrescentar '_id' no final | |
48 | + protected function inputName() { | |
49 | + return 'ano'; | |
50 | + } | |
51 | + | |
52 | + protected function filtroSituacao() { | |
53 | + $tiposSituacao = array('nao_iniciado' => 0, 'em_andamento' => 1, 'finalizado' => 2); | |
54 | + $situacaoIn = array(); | |
55 | + | |
56 | + foreach ($tiposSituacao as $nome => $flag) { | |
57 | + if (in_array("$nome", $this->options['situacoes'])) | |
58 | + $situacaoIn[] = $flag; | |
59 | + } | |
60 | + | |
61 | + return (empty($situacaoIn) ? '' : 'and andamento in ('. implode(',', $situacaoIn) . ')'); | |
62 | + } | |
63 | + | |
64 | + protected function inputOptions($options) { | |
65 | + $resources = $options['resources']; | |
66 | + $escolaId = $this->getEscolaId($options['escolaId']); | |
67 | + | |
68 | + if ($escolaId && empty($resources)) { | |
69 | + $sql = "select ano from pmieducar.escola_ano_letivo as al where ref_cod_escola = $1 | |
70 | + and ativo = 1 {$this->filtroSituacao()} order by ano desc"; | |
71 | + | |
72 | + $resources = Portabilis_Utils_Database::fetchPreparedQuery($sql, array('params' => $escolaId)); | |
73 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'ano', 'ano'); | |
74 | + } | |
75 | + | |
76 | + return $this->insertOption(null, "Selecione um ano letivo", $resources); | |
77 | + } | |
78 | + | |
79 | + protected function defaultOptions() { | |
80 | + return array('escolaId' => null, 'situacoes' => array('em_andamento', 'nao_iniciado', 'finalizado')); | |
81 | + } | |
82 | + | |
83 | + public function anoLetivo($options = array()) { | |
84 | + parent::select($options); | |
85 | + | |
86 | + foreach ($this->options['situacoes'] as $situacao) | |
87 | + $this->viewInstance->appendOutput("<input type='hidden' name='situacoes_ano_letivo' value='$situacao' />"); | |
88 | + } | |
89 | +} | |
0 | 90 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Biblioteca.php
0 → 100644
... | ... | @@ -0,0 +1,113 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_DynamicInput_Biblioteca class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_DynamicInput_Biblioteca extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
45 | + | |
46 | + protected function inputValue($value = null) { | |
47 | + return $this->getBibliotecaId($value); | |
48 | + } | |
49 | + | |
50 | + | |
51 | + protected function inputName() { | |
52 | + return 'ref_cod_biblioteca'; | |
53 | + } | |
54 | + | |
55 | + | |
56 | + protected function inputOptions($options) { | |
57 | + $resources = $options['resources']; | |
58 | + $instituicaoId = $this->getInstituicaoId(); | |
59 | + $escolaId = $this->getEscolaId(); | |
60 | + | |
61 | + if ($instituicaoId and $escolaId and empty($resources)) { | |
62 | + // se possui id escola então filtra bibliotecas pelo id desta escola | |
63 | + $resources = App_Model_IedFinder::getBibliotecas($instituicaoId, $escolaId); | |
64 | + } | |
65 | + | |
66 | + return $this->insertOption(null, "Selecione uma biblioteca", $resources); | |
67 | + } | |
68 | + | |
69 | + | |
70 | + public function selectInput($options = array()) { | |
71 | + parent::select($options); | |
72 | + } | |
73 | + | |
74 | + | |
75 | + public function stringInput($options = array()) { | |
76 | + $defaultOptions = array('options' => array()); | |
77 | + $options = $this->mergeOptions($options, $defaultOptions); | |
78 | + | |
79 | + // subescreve $options['options']['value'] com nome escola | |
80 | + if (isset($options['options']['value']) && $options['options']['value']) | |
81 | + $bibliotecaId = $options['options']['value']; | |
82 | + else | |
83 | + $bibliotecaId = $this->getBibliotecaId($options['id']); | |
84 | + | |
85 | + $biblioteca = App_Model_IedFinder::getBiblioteca($bibliotecaId); | |
86 | + $options['options']['value'] = $biblioteca['nm_biblioteca']; | |
87 | + | |
88 | + $defaultInputOptions = array('id' => 'ref_cod_biblioteca', | |
89 | + 'label' => 'Biblioteca', | |
90 | + 'value' => '', | |
91 | + 'inline' => false, | |
92 | + 'descricao' => '', | |
93 | + 'separador' => ':'); | |
94 | + | |
95 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
96 | + | |
97 | + $this->viewInstance->campoOculto($inputOptions['id'], $bibliotecaId); | |
98 | + | |
99 | + $inputOptions['id'] = 'biblioteca_nome'; | |
100 | + call_user_func_array(array($this->viewInstance, 'campoRotulo'), $inputOptions); | |
101 | + } | |
102 | + | |
103 | + | |
104 | + public function biblioteca($options = array()) { | |
105 | + if ($this->hasNivelAcesso('POLI_INSTITUCIONAL') || $this->hasNivelAcesso('INSTITUCIONAL')) | |
106 | + $this->selectInput($options); | |
107 | + | |
108 | + elseif($this->hasNivelAcesso('SOMENTE_ESCOLA') || $this->hasNivelAcesso('SOMENTE_BIBLIOTECA')) | |
109 | + $this->stringInput($options); | |
110 | + | |
111 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, '/modules/DynamicInput/Assets/Javascripts/Biblioteca.js'); | |
112 | + } | |
113 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaFonte.php
0 → 100644
... | ... | @@ -0,0 +1,64 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaFonte class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaFonte extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_fonte'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $bibliotecaId = $this->getBibliotecaId(); | |
54 | + | |
55 | + if ($bibliotecaId and empty($resources)) | |
56 | + $resources = App_Model_IedFinder::getBibliotecaFontes($bibliotecaId); | |
57 | + | |
58 | + return $this->insertOption(null, "Selecione uma fonte", $resources); | |
59 | + } | |
60 | + | |
61 | + public function bibliotecaFonte($options = array()) { | |
62 | + parent::select($options); | |
63 | + } | |
64 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaPesquisaCliente.php
0 → 100644
... | ... | @@ -0,0 +1,110 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaPesquisaCliente class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaPesquisaCliente extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + | |
47 | + | |
48 | + protected function getResourceId($id = null) { | |
49 | + if (! $id && $this->viewInstance->ref_cod_cliente) | |
50 | + $id = $this->viewInstance->ref_cod_cliente; | |
51 | + | |
52 | + return $id; | |
53 | + } | |
54 | + | |
55 | + | |
56 | + public function bibliotecaPesquisaCliente($options = array()) { | |
57 | + $defaultOptions = array('id' => null, 'options' => array(), 'hiddenInputOptions' => array()); | |
58 | + $options = $this->mergeOptions($options, $defaultOptions); | |
59 | + | |
60 | + $inputHint = "<img border='0' onclick='pesquisaCliente();' id='lupa_pesquisa_cliente' name='lupa_pesquisa_cliente' src='imagens/lupa.png' />"; | |
61 | + | |
62 | + // input | |
63 | + $defaultInputOptions = array('id' => 'nome_cliente', | |
64 | + 'label' => 'Cliente', | |
65 | + 'value' => '', | |
66 | + 'size' => '30', | |
67 | + 'max_length' => '255', | |
68 | + 'required' => true, | |
69 | + 'expressao' => false, | |
70 | + 'inline' => false, | |
71 | + 'label_hint' => '', | |
72 | + 'input_hint' => $inputHint, | |
73 | + 'callback' => '', | |
74 | + 'event' => 'onKeyUp', | |
75 | + 'disabled' => true); | |
76 | + | |
77 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
78 | + call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); | |
79 | + | |
80 | + // hidden input | |
81 | + $defaultHiddenInputOptions = array('id' => 'ref_cod_cliente', | |
82 | + 'value' => $this->getResourceId($options['id'])); | |
83 | + | |
84 | + $hiddenInputOptions = $this->mergeOptions($options['hiddenInputOptions'], $defaultHiddenInputOptions); | |
85 | + call_user_func_array(array($this->viewInstance, 'campoOculto'), $hiddenInputOptions); | |
86 | + | |
87 | + // js | |
88 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, ' | |
89 | + var resetCliente = function(){ | |
90 | + $("#ref_cod_cliente").val(""); | |
91 | + $("#nome_cliente").val(""); | |
92 | + } | |
93 | + | |
94 | + $("#ref_cod_biblioteca").change(resetCliente);', true); | |
95 | + | |
96 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, " | |
97 | + function pesquisaCliente() { | |
98 | + var additionalFields = getElementFor('biblioteca'); | |
99 | + var exceptFields = getElementFor('nome_cliente'); | |
100 | + | |
101 | + if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) { | |
102 | + var bibliotecaId = getElementFor('biblioteca').val(); | |
103 | + var attrIdName = getElementFor('cliente').attr('id'); | |
104 | + | |
105 | + pesquisa_valores_popless('educar_pesquisa_cliente_lst.php?campo1='+attrIdName+'&campo2=nome_cliente&ref_cod_biblioteca='+bibliotecaId); | |
106 | + } | |
107 | + } | |
108 | + "); | |
109 | + } | |
110 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaPesquisaObra.php
0 → 100644
... | ... | @@ -0,0 +1,124 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaPesquisaObra class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaPesquisaObra extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + | |
47 | + protected function getAcervoId($id = null) { | |
48 | + if (! $id && $this->viewInstance->ref_cod_acervo) | |
49 | + $id = $this->viewInstance->ref_cod_acervo; | |
50 | + | |
51 | + return $id; | |
52 | + } | |
53 | + | |
54 | + | |
55 | + protected function getObra($id) { | |
56 | + if (! $id) | |
57 | + $id = $this->getAcervoId($id); | |
58 | + | |
59 | + // chama finder somente se possuir id, senão ocorrerá exception | |
60 | + $obra = empty($id) ? null : App_Model_IedFinder::getBibliotecaObra($this->getBibliotecaId(), $id); | |
61 | + | |
62 | + return $obra; | |
63 | + } | |
64 | + | |
65 | + | |
66 | + public function bibliotecaPesquisaObra($options = array()) { | |
67 | + $defaultOptions = array('id' => null, 'options' => array(), 'hiddenInputOptions' => array()); | |
68 | + $options = $this->mergeOptions($options, $defaultOptions); | |
69 | + | |
70 | + $inputHint = "<img border='0' onclick='pesquisaObra();' id='lupa_pesquisa_obra' name='lupa_pesquisa_obra' src='imagens/lupa.png' />"; | |
71 | + | |
72 | + // se não recuperar obra, deixa titulo em branco | |
73 | + $obra = $this->getObra($options['id']); | |
74 | + $tituloObra = $obra ? $obra['titulo'] : ''; | |
75 | + | |
76 | + $defaultInputOptions = array('id' => 'titulo_obra', | |
77 | + 'label' => 'Obra', | |
78 | + 'value' => $tituloObra, | |
79 | + 'size' => '30', | |
80 | + 'max_length' => '255', | |
81 | + 'required' => true, | |
82 | + 'expressao' => false, | |
83 | + 'inline' => false, | |
84 | + 'label_hint' => '', | |
85 | + 'input_hint' => $inputHint, | |
86 | + 'callback' => '', | |
87 | + 'event' => 'onKeyUp', | |
88 | + 'disabled' => true); | |
89 | + | |
90 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
91 | + call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); | |
92 | + | |
93 | + // hidden input | |
94 | + $defaultHiddenInputOptions = array('id' => 'ref_cod_acervo', | |
95 | + 'value' => $this->getAcervoId($options['id'])); | |
96 | + | |
97 | + $hiddenInputOptions = $this->mergeOptions($options['hiddenInputOptions'], $defaultHiddenInputOptions); | |
98 | + call_user_func_array(array($this->viewInstance, 'campoOculto'), $hiddenInputOptions); | |
99 | + | |
100 | + // Ao selecionar obra, na pesquisa de obra é setado o value deste elemento | |
101 | + $this->viewInstance->campoOculto("cod_biblioteca", ""); | |
102 | + | |
103 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, ' | |
104 | + var resetObra = function(){ | |
105 | + $("#ref_cod_acervo").val(""); | |
106 | + $("#titulo_obra").val(""); | |
107 | + } | |
108 | + | |
109 | + $("#ref_cod_biblioteca").change(resetObra);', true); | |
110 | + | |
111 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, ' | |
112 | + function pesquisaObra() { | |
113 | + | |
114 | + var additionalFields = getElementFor("biblioteca"); | |
115 | + var exceptFields = getElementFor("titulo_obra"); | |
116 | + | |
117 | + if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) { | |
118 | + var bibliotecaId = getElementFor("biblioteca").val(); | |
119 | + | |
120 | + pesquisa_valores_popless("educar_pesquisa_obra_lst.php?campo1=ref_cod_acervo&campo2=titulo_obra&campo3="+bibliotecaId) | |
121 | + } | |
122 | + }'); | |
123 | + } | |
124 | +} | |
0 | 125 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaSituacao.php
0 → 100644
... | ... | @@ -0,0 +1,64 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaSituacao class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaSituacao extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_situacao'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $bibliotecaId = $this->getBibliotecaId(); | |
54 | + | |
55 | + if ($bibliotecaId and empty($resources)) | |
56 | + $resources = App_Model_IedFinder::getBibliotecaSituacoes($bibliotecaId); | |
57 | + | |
58 | + return $this->insertOption(null, "Selecione uma situação", $resources); | |
59 | + } | |
60 | + | |
61 | + public function bibliotecaSituacao($options = array()) { | |
62 | + parent::select($options); | |
63 | + } | |
64 | +} | |
0 | 65 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaTipoCliente.php
0 → 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaTipoCliente class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaTipoCliente extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_cliente_tipo'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $bibliotecaId = $this->getBibliotecaId(); | |
54 | + | |
55 | + if ($bibliotecaId and empty($resources)) | |
56 | + $resources = App_Model_IedFinder::getBibliotecaTiposCliente($bibliotecaId); | |
57 | + | |
58 | + return $this->insertOption(null, "Selecione um tipo de cliente", $resources); | |
59 | + } | |
60 | + | |
61 | + protected function defaultOptions(){ | |
62 | + return array('options' => array('label' => 'Tipo cliente')); | |
63 | + } | |
64 | + | |
65 | + public function bibliotecaTipoCliente($options = array()) { | |
66 | + parent::select($options); | |
67 | + } | |
68 | +} | |
0 | 69 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/BibliotecaTipoExemplar.php
0 → 100644
... | ... | @@ -0,0 +1,79 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_BibliotecaTipoExemplar class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_BibliotecaTipoExemplar extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_exemplar_tipo'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $bibliotecaId = $this->getBibliotecaId($bibliotecaId); | |
53 | + $resources = $options['resources']; | |
54 | + | |
55 | + if (empty($resources) && $bibliotecaId) { | |
56 | + $columns = array('cod_exemplar_tipo', 'nm_tipo'); | |
57 | + $where = array('ref_cod_biblioteca' => $bibliotecaId, 'ativo' => '1'); | |
58 | + $orderBy = array('nm_tipo' => 'ASC'); | |
59 | + | |
60 | + $resources = $this->getDataMapperFor('biblioteca', 'tipoExemplar')->findAll($columns, | |
61 | + $where, | |
62 | + $orderBy, | |
63 | + $addColumnIdIfNotSet = false); | |
64 | + | |
65 | + $resources = Portabilis_Object_Utils::asIdValue($resources, 'cod_exemplar_tipo', 'nm_tipo'); | |
66 | + } | |
67 | + | |
68 | + return $this->insertOption(null, "Selecione um tipo de exemplar", $resources); | |
69 | + } | |
70 | + | |
71 | + protected function defaultOptions(){ | |
72 | + return array('options' => array('label' => 'Tipo exemplar')); | |
73 | + } | |
74 | + | |
75 | + public function bibliotecaTipoExemplar($options = array()) { | |
76 | + parent::select($options); | |
77 | + } | |
78 | + | |
79 | +} | |
0 | 80 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/ComponenteCurricular.php
0 → 100644
... | ... | @@ -0,0 +1,82 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_ComponenteCurricular class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_ComponenteCurricular extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + | |
47 | + protected function getResourceId($id = null) { | |
48 | + if (! $id && $this->viewInstance->ref_cod_componente_curricular) | |
49 | + $id = $this->viewInstance->ref_cod_componente_curricular; | |
50 | + | |
51 | + return $id; | |
52 | + } | |
53 | + | |
54 | + protected function getOptions($turmaId, $resources) { | |
55 | + return $this->insertOption(null, "Selecione um componente curricular", array()); | |
56 | + } | |
57 | + | |
58 | + public function componenteCurricular($options = array()) { | |
59 | + $defaultOptions = array('id' => null, | |
60 | + 'turmaId' => null, | |
61 | + 'options' => array(), | |
62 | + 'resources' => array()); | |
63 | + | |
64 | + $options = $this->mergeOptions($options, $defaultOptions); | |
65 | + $resources = $this->getOptions($options['turmaId'], $options['resources']); | |
66 | + | |
67 | + $defaultSelectOptions = array('id' => 'ref_cod_componente_curricular', | |
68 | + 'label' => 'Componente Curricular', | |
69 | + 'componentes_curriculares' => $resources, | |
70 | + 'value' => $this->getResourceId($options['id']), | |
71 | + 'callback' => '', | |
72 | + 'inline' => false, | |
73 | + 'label_hint' => '', | |
74 | + 'input_hint' => '', | |
75 | + 'disabled' => false, | |
76 | + 'required' => true, | |
77 | + 'multiple' => false); | |
78 | + | |
79 | + $selectOptions = $this->mergeOptions($options['options'], $defaultSelectOptions); | |
80 | + call_user_func_array(array($this->viewInstance, 'campoLista'), $selectOptions); | |
81 | + } | |
82 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Core.php
0 → 100644
... | ... | @@ -0,0 +1,52 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_DynamicInput_Core class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_DynamicInput_Core extends Portabilis_View_Helper_Input_Core { | |
45 | + | |
46 | + protected function loadCoreAssets() { | |
47 | + parent::loadCoreAssets(); | |
48 | + | |
49 | + $dependencies = array('/modules/DynamicInput/Assets/Javascripts/DynamicInput.js'); | |
50 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $dependencies); | |
51 | + } | |
52 | +} | |
0 | 53 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php
0 → 100644
... | ... | @@ -0,0 +1,52 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_DynamicInput_CoreSelect class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_DynamicInput_CoreSelect extends Portabilis_View_Helper_Input_CoreSelect { | |
45 | + | |
46 | + protected function loadCoreAssets() { | |
47 | + parent::loadCoreAssets(); | |
48 | + | |
49 | + $dependencies = array('/modules/DynamicInput/Assets/Javascripts/DynamicInput.js'); | |
50 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $dependencies); | |
51 | + } | |
52 | +} | |
0 | 53 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Curso.php
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | +require_once 'Portabilis/Business/Professor.php'; | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Curso class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Curso extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_curso'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); | |
54 | + $escolaId = $this->getEscolaId($options['escolaId']); | |
55 | + $userId = $this->getCurrentUserId(); | |
56 | + $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); | |
57 | + | |
58 | + if ($instituicaoId and $escolaId and empty($resources) and $isProfessor) { | |
59 | + $cursos = Portabilis_Business_Professor::cursosAlocado($instituicaoId, $escolaId, $userId); | |
60 | + $resources = Portabilis_Array_Utils::setAsIdValue($cursos, 'id', 'nome'); | |
61 | + } | |
62 | + elseif ($escolaId && empty($resources)) | |
63 | + $resources = App_Model_IedFinder::getCursos($escolaId); | |
64 | + | |
65 | + return $this->insertOption(null, "Selecione um curso", $resources); | |
66 | + } | |
67 | + | |
68 | + public function curso($options = array()) { | |
69 | + parent::select($options); | |
70 | + } | |
71 | +} | |
0 | 72 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/DataFinal.php
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_DataFinal class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_DataFinal extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + protected function inputValue($value = null) { | |
47 | + if (! $value && $this->viewInstance->data_final) | |
48 | + $value = $this->viewInstance->data_final; | |
49 | + else | |
50 | + $value = date('t/m/Y'); | |
51 | + | |
52 | + return $value; | |
53 | + } | |
54 | + | |
55 | + public function dataFinal($options = array()) { | |
56 | + $defaultOptions = array('options' => array()); | |
57 | + $options = $this->mergeOptions($options, $defaultOptions); | |
58 | + | |
59 | + $defaultInputOptions = array('id' => 'data_final', | |
60 | + 'label' => 'Data final', | |
61 | + 'value' => $this->inputValue($options['options']['value']), | |
62 | + 'required' => true, | |
63 | + 'label_hint' => '', | |
64 | + 'inline' => false, | |
65 | + 'callback' => false, | |
66 | + 'disabled' => false); | |
67 | + | |
68 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
69 | + call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); | |
70 | + } | |
71 | +} | |
0 | 72 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/DataInicial.php
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_DataInicial class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_DataInicial extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + protected function inputValue($value = null) { | |
47 | + if (! $value && $this->viewInstance->data_inicial) | |
48 | + $value = $this->viewInstance->data_inicial; | |
49 | + else | |
50 | + $value = date('01/m/Y'); | |
51 | + | |
52 | + return $value; | |
53 | + } | |
54 | + | |
55 | + public function dataInicial($options = array()) { | |
56 | + $defaultOptions = array('options' => array()); | |
57 | + $options = $this->mergeOptions($options, $defaultOptions); | |
58 | + | |
59 | + $defaultInputOptions = array('id' => 'data_inicial', | |
60 | + 'label' => 'Data inicial', | |
61 | + 'value' => $this->inputValue($options['options']['value']), | |
62 | + 'required' => true, | |
63 | + 'label_hint' => '', | |
64 | + 'inline' => false, | |
65 | + 'callback' => false, | |
66 | + 'disabled' => false); | |
67 | + | |
68 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
69 | + call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); | |
70 | + } | |
71 | +} | |
0 | 72 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Escola.php
0 → 100644
... | ... | @@ -0,0 +1,121 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | +require_once 'Portabilis/Business/Professor.php'; | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Escola class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Escola extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputValue($value = null) { | |
48 | + return $this->getEscolaId($value); | |
49 | + } | |
50 | + | |
51 | + | |
52 | + protected function inputName() { | |
53 | + return 'ref_cod_escola'; | |
54 | + } | |
55 | + | |
56 | + | |
57 | + protected function inputOptions($options) { | |
58 | + $resources = $options['resources']; | |
59 | + $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); | |
60 | + $userId = $this->getCurrentUserId(); | |
61 | + $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); | |
62 | + | |
63 | + if ($instituicaoId and empty($resources) and $isProfessor) { | |
64 | + $escolas = Portabilis_Business_Professor::escolasAlocado($instituicaoId, $userId); | |
65 | + $resources = Portabilis_Array_Utils::setAsIdValue($escolas, 'id', 'nome'); | |
66 | + } | |
67 | + elseif ($instituicaoId and empty($resources)) | |
68 | + $resources = App_Model_IedFinder::getEscolas($instituicaoId); | |
69 | + | |
70 | + | |
71 | + return $this->insertOption(null, "Selecione uma escola", $resources); | |
72 | + } | |
73 | + | |
74 | + | |
75 | + public function selectInput($options = array()) { | |
76 | + parent::select($options); | |
77 | + } | |
78 | + | |
79 | + | |
80 | + public function stringInput($options = array()) { | |
81 | + $defaultOptions = array('options' => array()); | |
82 | + $options = $this->mergeOptions($options, $defaultOptions); | |
83 | + | |
84 | + // subescreve $options['options']['value'] com nome escola | |
85 | + if (isset($options['options']['value']) && $options['options']['value']) | |
86 | + $escolaId = $options['options']['value']; | |
87 | + else | |
88 | + $escolaId = $this->getEscolaId($options['id']); | |
89 | + | |
90 | + $escola = App_Model_IedFinder::getEscola($escolaId); | |
91 | + $options['options']['value'] = $escola['nome']; | |
92 | + | |
93 | + $defaultInputOptions = array('id' => 'ref_cod_escola', | |
94 | + 'label' => 'Escola', | |
95 | + 'value' => '', | |
96 | + 'inline' => false, | |
97 | + 'descricao' => '', | |
98 | + 'separador' => ':'); | |
99 | + | |
100 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
101 | + | |
102 | + $this->viewInstance->campoOculto($inputOptions['id'], $escolaId); | |
103 | + | |
104 | + $inputOptions['id'] = 'escola_nome'; | |
105 | + call_user_func_array(array($this->viewInstance, 'campoRotulo'), $inputOptions); | |
106 | + } | |
107 | + | |
108 | + | |
109 | + public function escola($options = array()) { | |
110 | + $isProfessor = Portabilis_Business_Professor::isProfessor($this->getInstituicaoId($options['instituicaoId']), | |
111 | + $this->getCurrentUserId()); | |
112 | + | |
113 | + if ($this->hasNivelAcesso('POLI_INSTITUCIONAL') || $this->hasNivelAcesso('INSTITUCIONAL') || $isProfessor) | |
114 | + $this->selectInput($options); | |
115 | + | |
116 | + elseif($this->hasNivelAcesso('SOMENTE_ESCOLA') || $this->hasNivelAcesso('SOMENTE_BIBLIOTECA')) | |
117 | + $this->stringInput($options); | |
118 | + | |
119 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, '/modules/DynamicInput/Assets/Javascripts/Escola.js'); | |
120 | + } | |
121 | +} | |
0 | 122 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Etapa.php
0 → 100644
... | ... | @@ -0,0 +1,60 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Etapa class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Etapa extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + // subscreve para não acrescentar '_id' no final | |
48 | + protected function inputName() { | |
49 | + return 'etapa'; | |
50 | + } | |
51 | + | |
52 | + protected function inputOptions($options) { | |
53 | + // não implementado load resources ainda, por enquanto busca somente com ajax. | |
54 | + return $this->insertOption(null, "Selecione uma etapa", $resources); | |
55 | + } | |
56 | + | |
57 | + public function etapa($options = array()) { | |
58 | + parent::select($options); | |
59 | + } | |
60 | +} | |
0 | 61 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Instituicao.php
0 → 100644
... | ... | @@ -0,0 +1,93 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Instituicao class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Instituicao extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputValue($value = null) { | |
48 | + return $this->getInstituicaoId($value); | |
49 | + } | |
50 | + | |
51 | + protected function inputName() { | |
52 | + return 'ref_cod_instituicao'; | |
53 | + } | |
54 | + | |
55 | + protected function inputOptions($options) { | |
56 | + $resources = $options['resources']; | |
57 | + | |
58 | + if (empty($resources)) | |
59 | + $resources = App_Model_IedFinder::getInstituicoes(); | |
60 | + | |
61 | + return $this->insertOption(null, "Selecione uma instituição", $resources); | |
62 | + } | |
63 | + | |
64 | + | |
65 | + protected function defaultOptions(){ | |
66 | + return array('options' => array('label' => 'Instituição')); | |
67 | + } | |
68 | + | |
69 | + | |
70 | + public function selectInput($options = array()) { | |
71 | + parent::select($options); | |
72 | + } | |
73 | + | |
74 | + | |
75 | + public function hiddenInput($options = array()) { | |
76 | + $defaultOptions = array('id' => null, 'options' => array()); | |
77 | + $options = $this->mergeOptions($options, $defaultOptions); | |
78 | + | |
79 | + $defaultInputOptions = array('id' => 'ref_cod_instituicao', | |
80 | + 'value' => $this->getInstituicaoId($options['id'])); | |
81 | + | |
82 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
83 | + call_user_func_array(array($this->viewInstance, 'campoOculto'), $inputOptions); | |
84 | + } | |
85 | + | |
86 | + | |
87 | + public function instituicao($options = array()) { | |
88 | + if ($this->hasNivelAcesso('POLI_INSTITUCIONAL')) | |
89 | + $this->selectInput($options); | |
90 | + else | |
91 | + $this->hiddenInput($options); | |
92 | + } | |
93 | +} | |
0 | 94 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Matricula.php
0 → 100644
... | ... | @@ -0,0 +1,59 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Matricula class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Matricula extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_matricula'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + // não implementado load resources ainda, por enquanto busca somente com ajax. | |
53 | + return $this->insertOption(null, "Selecione uma matricula", $resources); | |
54 | + } | |
55 | + | |
56 | + public function matricula($options = array()) { | |
57 | + parent::select($options); | |
58 | + } | |
59 | +} | |
0 | 60 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/PesquisaAluno.php
0 → 100644
... | ... | @@ -0,0 +1,128 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_PesquisaAluno class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_PesquisaAluno extends Portabilis_View_Helper_DynamicInput_Core { | |
46 | + | |
47 | + protected function inputValue($id = null) { | |
48 | + if (! $id && $this->viewInstance->ref_cod_aluno) | |
49 | + $id = $this->viewInstance->ref_cod_aluno; | |
50 | + | |
51 | + return $id; | |
52 | + } | |
53 | + | |
54 | + | |
55 | + protected function getResource($id) { | |
56 | + if (! $id) | |
57 | + $id = $this->inputValue($id); | |
58 | + | |
59 | + // chama finder somente se possuir id, senão ocorrerá exception | |
60 | + $resource = empty($id) ? null : App_Model_IedFinder::getAluno($this->getEscolaId(), $id); | |
61 | + | |
62 | + return $resource; | |
63 | + } | |
64 | + | |
65 | + | |
66 | + public function pesquisaAluno($options = array()) { | |
67 | + $defaultOptions = array('id' => null, 'options' => array(), 'filterByEscola' => false); | |
68 | + $options = $this->mergeOptions($options, $defaultOptions); | |
69 | + | |
70 | + $inputHint = "<img border='0' onclick='pesquisaAluno();' id='lupa_pesquisa_aluno' name='lupa_pesquisa_aluno' src='imagens/lupa.png' />"; | |
71 | + | |
72 | + // se não recuperar recurso, deixa resourceLabel em branco | |
73 | + $resource = $this->getResource($options['id']); | |
74 | + $resourceLabel = $resource ? $resource['nome_aluno'] : ''; | |
75 | + | |
76 | + $defaultInputOptions = array('id' => 'nm_aluno', | |
77 | + 'label' => 'Aluno', | |
78 | + 'value' => $resourceLabel, | |
79 | + 'size' => '30', | |
80 | + 'max_length' => '255', | |
81 | + 'required' => true, | |
82 | + 'expressao' => false, | |
83 | + 'inline' => false, | |
84 | + 'label_hint' => '', | |
85 | + 'input_hint' => $inputHint, | |
86 | + 'callback' => '', | |
87 | + 'event' => 'onKeyUp', | |
88 | + 'disabled' => true); | |
89 | + | |
90 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
91 | + call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); | |
92 | + | |
93 | + $this->viewInstance->campoOculto("ref_cod_aluno", $this->inputValue($options['id'])); | |
94 | + | |
95 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, ' | |
96 | + var resetAluno = function(){ | |
97 | + $("#ref_cod_aluno").val(""); | |
98 | + $("#nm_aluno").val(""); | |
99 | + } | |
100 | + | |
101 | + $("#ref_cod_escola").change(resetAluno);', true); | |
102 | + | |
103 | + if ($options['filterByEscola']) { | |
104 | + $js = 'function pesquisaAluno() { | |
105 | + var additionalFields = [document.getElementById("ref_cod_escola")]; | |
106 | + var exceptFields = [document.getElementById("nm_aluno")]; | |
107 | + | |
108 | + if (validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields)) { | |
109 | + | |
110 | + var escolaId = document.getElementById("ref_cod_escola").value; | |
111 | + pesquisa_valores_popless("/intranet/educar_pesquisa_aluno.php?ref_cod_escola="+escolaId); | |
112 | + } | |
113 | + }'; | |
114 | + } | |
115 | + | |
116 | + else { | |
117 | + $js = 'function pesquisaAluno() { | |
118 | + var exceptFields = [document.getElementById("nm_aluno")]; | |
119 | + | |
120 | + if (validatesPresenseOfValueInRequiredFields([], exceptFields)) { | |
121 | + pesquisa_valores_popless("/intranet/educar_pesquisa_aluno.php"); | |
122 | + } | |
123 | + }'; | |
124 | + } | |
125 | + | |
126 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js); | |
127 | + } | |
128 | +} | |
0 | 129 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Serie.php
0 → 100644
... | ... | @@ -0,0 +1,65 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Serie class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Serie extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_serie'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $escolaId = $this->getEscolaId($options['escolaId']); | |
54 | + $cursoId = $this->getCursoId($options['cursoId']); | |
55 | + | |
56 | + if ($escolaId && $cursoId && empty($resources)) | |
57 | + $resources = App_Model_IedFinder::getSeries($instituicaoId = null, $escolaId, $cursoId); | |
58 | + | |
59 | + return $this->insertOption(null, "Selecione uma série", $resources); | |
60 | + } | |
61 | + | |
62 | + public function serie($options = array()) { | |
63 | + parent::select($options); | |
64 | + } | |
65 | +} | |
0 | 66 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php
0 → 100644
... | ... | @@ -0,0 +1,73 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/DynamicInput/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Turma class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_DynamicInput_Turma extends Portabilis_View_Helper_DynamicInput_CoreSelect { | |
46 | + | |
47 | + protected function inputName() { | |
48 | + return 'ref_cod_turma'; | |
49 | + } | |
50 | + | |
51 | + protected function inputOptions($options) { | |
52 | + $resources = $options['resources']; | |
53 | + $instituicaoId = $this->getInstituicaoId($options['instituicaoId']); | |
54 | + $escolaId = $this->getEscolaId($options['escolaId']); | |
55 | + $serieId = $this->getSerieId($options['serieId']); | |
56 | + //$cursoId = $this->getCursoId($options['cursoId']); | |
57 | + $userId = $this->getCurrentUserId(); | |
58 | + $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId); | |
59 | + | |
60 | + if ($escolaId and $serieId and empty($resources) and $isProfessor) { | |
61 | + $turmas = Portabilis_Business_Professor::turmasAlocado($escolaId, $serieId, $userId); | |
62 | + $resources = Portabilis_Array_Utils::setAsIdValue($turmas, 'id', 'nome'); | |
63 | + } | |
64 | + elseif ($escolaId && $serieId && empty($resources)) | |
65 | + $resources = App_Model_IedFinder::getTurmas($escolaId, $serieId); | |
66 | + | |
67 | + return $this->insertOption(null, "Selecione uma turma", $resources); | |
68 | + } | |
69 | + | |
70 | + public function turma($options = array()) { | |
71 | + parent::select($options); | |
72 | + } | |
73 | +} | |
0 | 74 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,75 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_DynamicInput_Ano class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Ano extends Portabilis_View_Helper_Input_Core { | |
46 | + protected function inputValue($value = null) { | |
47 | + if (! $value && $this->viewInstance->ano) | |
48 | + $value = $this->viewInstance->ano; | |
49 | + else | |
50 | + $value = date('Y'); | |
51 | + | |
52 | + return $value; | |
53 | + } | |
54 | + | |
55 | + public function ano($options = array()) { | |
56 | + $defaultOptions = array('options' => array()); | |
57 | + $options = $this->mergeOptions($options, $defaultOptions); | |
58 | + | |
59 | + $defaultInputOptions = array('id' => 'ano', | |
60 | + 'label' => 'Ano', | |
61 | + 'value' => $this->inputValue($options['options']['value']), | |
62 | + 'size' => 4, | |
63 | + 'max_length' => 4, | |
64 | + 'required' => true, | |
65 | + 'label_hint' => '', | |
66 | + 'input_hint' => '', | |
67 | + 'script' => false, | |
68 | + 'callback' => false, | |
69 | + 'inline' => false, | |
70 | + 'disabled' => false); | |
71 | + | |
72 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
73 | + call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); | |
74 | + } | |
75 | +} | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Checkbox class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Checkbox extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function checkbox($attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), 'objectName' => ''); | |
49 | + $options = $this->mergeOptions($options, $defaultOptions); | |
50 | + | |
51 | + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; | |
52 | + | |
53 | + $defaultInputOptions = array( | |
54 | + 'id' => $options['objectName'] . $spacer . $attrName, | |
55 | + 'label' => ucwords($attrName), | |
56 | + 'value' => '', | |
57 | + 'label_hint' => '', | |
58 | + 'inline' => false, | |
59 | + 'script' => 'fixupCheckboxValue(this)', | |
60 | + 'disabled' => false | |
61 | + ); | |
62 | + | |
63 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
64 | + | |
65 | + // fixup para enviar um valor, junto ao param do checkbox. | |
66 | + $js = "var fixupCheckboxValue = function(input) { | |
67 | + var \$this = \$j(input); | |
68 | + \$this.val(\$this.is(':checked') ? 'on' : ''); | |
69 | + }"; | |
70 | + | |
71 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false); | |
72 | + call_user_func_array(array($this->viewInstance, 'campoCheck'), $inputOptions); | |
73 | + } | |
74 | +} | |
0 | 75 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,200 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'include/pmieducar/clsPermissoes.inc.php'; | |
33 | +require_once 'App/Model/IedFinder.php'; | |
34 | +require_once 'lib/Portabilis/View/Helper/Application.php'; | |
35 | +require_once 'lib/Portabilis/Array/Utils.php'; | |
36 | +require_once 'lib/Portabilis/String/Utils.php'; | |
37 | +require_once 'lib/Portabilis/Object/Utils.php'; | |
38 | +require_once 'lib/Portabilis/DataMapper/Utils.php'; | |
39 | + | |
40 | +/** | |
41 | + * Portabilis_View_Helper_Input_Core class. | |
42 | + * | |
43 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
44 | + * @category i-Educar | |
45 | + * @license @@license@@ | |
46 | + * @package Portabilis | |
47 | + * @since Classe disponível desde a versão 1.1.0 | |
48 | + * @version @@package_version@@ | |
49 | + */ | |
50 | +class Portabilis_View_Helper_Input_Core { | |
51 | + | |
52 | + public function __construct($viewInstance, $inputsHelper) { | |
53 | + $this->viewInstance = $viewInstance; | |
54 | + $this->_inputsHelper = $inputsHelper; | |
55 | + | |
56 | + $this->loadCoreAssets(); | |
57 | + $this->loadAssets(); | |
58 | + } | |
59 | + | |
60 | + | |
61 | + protected function inputsHelper() { | |
62 | + return $this->_inputsHelper; | |
63 | + } | |
64 | + | |
65 | + | |
66 | + protected function helperName() { | |
67 | + return end(explode('_', get_class($this))); | |
68 | + } | |
69 | + | |
70 | + | |
71 | + protected function inputName() { | |
72 | + return Portabilis_String_Utils::underscore($this->helperName()); | |
73 | + } | |
74 | + | |
75 | + | |
76 | + protected function inputValue($value = null) { | |
77 | + if (! $value && $this->viewInstance->{$this->inputName()}) | |
78 | + $value = $this->viewInstance->{$this->inputName()}; | |
79 | + | |
80 | + return $value; | |
81 | + } | |
82 | + | |
83 | + | |
84 | + protected function loadCoreAssets() { | |
85 | + Portabilis_View_Helper_Application::loadJQueryLib($this->viewInstance); | |
86 | + Portabilis_View_Helper_Application::loadJQueryUiLib($this->viewInstance); | |
87 | + | |
88 | + $dependencies = array('/modules/Portabilis/Assets/Javascripts/Utils.js', | |
89 | + '/modules/Portabilis/Assets/Javascripts/ClientApi.js', | |
90 | + '/modules/Portabilis/Assets/Javascripts/Validator.js'); | |
91 | + | |
92 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $dependencies); | |
93 | + } | |
94 | + | |
95 | + | |
96 | + protected function loadAssets() { | |
97 | + $rootPath = $_SERVER['DOCUMENT_ROOT']; | |
98 | + $style = "/modules/DynamicInput/Assets/Stylesheets/{$this->helperName()}.css"; | |
99 | + $script = "/modules/DynamicInput/Assets/Javascripts/{$this->helperName()}.js"; | |
100 | + | |
101 | + if (file_exists($rootPath . $style)) | |
102 | + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); | |
103 | + | |
104 | + if (file_exists($rootPath . $script)) | |
105 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $script); | |
106 | + } | |
107 | + | |
108 | + // wrappers | |
109 | + | |
110 | + protected function getCurrentUserId() { | |
111 | + return Portabilis_Utils_User::currentUserId(); | |
112 | + } | |
113 | + | |
114 | + protected function getPermissoes() { | |
115 | + return Portabilis_Utils_User::getClsPermissoes(); | |
116 | + } | |
117 | + | |
118 | + protected function hasNivelAcesso($nivelAcessoType) { | |
119 | + return Portabilis_Utils_User::hasNivelAcesso($nivelAcessoType); | |
120 | + } | |
121 | + | |
122 | + protected function getDataMapperFor($packageName, $modelName){ | |
123 | + return Portabilis_DataMapper_Utils::getDataMapperFor($packageName, $modelName); | |
124 | + } | |
125 | + | |
126 | + protected static function mergeOptions($options, $defaultOptions) { | |
127 | + return Portabilis_Array_Utils::merge($options, $defaultOptions); | |
128 | + } | |
129 | + | |
130 | + protected static function insertOption($key, $value, $array) { | |
131 | + return Portabilis_Array_Utils::insertIn($key, $value, $array); | |
132 | + } | |
133 | + | |
134 | + // ieducar helpers | |
135 | + | |
136 | + protected function getInstituicaoId($instituicaoId = null) { | |
137 | + if (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_instituicao)) | |
138 | + $instituicaoId = $this->viewInstance->ref_cod_instituicao; | |
139 | + | |
140 | + elseif (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_escola)) { | |
141 | + $escola = App_Model_IedFinder::getEscola($this->viewInstance->ref_cod_escola); | |
142 | + $instituicaoId = $escola['ref_cod_instituicao']; | |
143 | + } | |
144 | + | |
145 | + elseif (! $instituicaoId && is_numeric($this->viewInstance->ref_cod_biblioteca)) { | |
146 | + $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); | |
147 | + $instituicaoId = $biblioteca['ref_cod_instituicao']; | |
148 | + } | |
149 | + | |
150 | + elseif (! $instituicaoId) | |
151 | + $instituicaoId = $this->getPermissoes()->getInstituicao($this->getCurrentUserId()); | |
152 | + | |
153 | + return $instituicaoId; | |
154 | + } | |
155 | + | |
156 | + | |
157 | + protected function getEscolaId($escolaId = null) { | |
158 | + if (! $escolaId && $this->viewInstance->ref_cod_escola) | |
159 | + $escolaId = $this->viewInstance->ref_cod_escola; | |
160 | + | |
161 | + elseif (! $escolaId && is_numeric($this->viewInstance->ref_cod_biblioteca)) { | |
162 | + $biblioteca = App_Model_IedFinder::getBiblioteca($this->viewInstance->ref_cod_biblioteca); | |
163 | + $escolaId = $biblioteca['ref_cod_escola']; | |
164 | + } | |
165 | + | |
166 | + elseif (! $escolaId) | |
167 | + $escolaId = $this->getPermissoes()->getEscola($this->getCurrentUserId()); | |
168 | + | |
169 | + return $escolaId; | |
170 | + } | |
171 | + | |
172 | + | |
173 | + protected function getBibliotecaId($bibliotecaId = null) { | |
174 | + if (! $bibliotecaId && ! $this->viewInstance->ref_cod_biblioteca) { | |
175 | + $biblioteca = $this->getPermissoes()->getBiblioteca($this->getCurrentUserId()); | |
176 | + | |
177 | + if (is_array($biblioteca) && count($biblioteca) > 0) | |
178 | + $bibliotecaId = $biblioteca[0]['ref_cod_biblioteca']; | |
179 | + } | |
180 | + | |
181 | + elseif (! $bibliotecaId) | |
182 | + $bibliotecaId = $this->viewInstance->ref_cod_biblioteca; | |
183 | + | |
184 | + return $bibliotecaId; | |
185 | + } | |
186 | + | |
187 | + protected function getCursoId($cursoId = null) { | |
188 | + if (! $cursoId && $this->viewInstance->ref_cod_curso) | |
189 | + $cursoId = $this->viewInstance->ref_cod_curso; | |
190 | + | |
191 | + return $cursoId; | |
192 | + } | |
193 | + | |
194 | + protected function getSerieId($serieId = null) { | |
195 | + if (! $serieId && $this->viewInstance->ref_cod_serie) | |
196 | + $serieId = $this->viewInstance->ref_cod_serie; | |
197 | + | |
198 | + return $serieId; | |
199 | + } | |
200 | +} | |
0 | 201 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,88 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_DynamicInput_CoreSelect class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_Input_CoreSelect extends Portabilis_View_Helper_Input_Core { | |
45 | + | |
46 | + protected function inputName() { | |
47 | + return parent::inputName() . '_id'; | |
48 | + } | |
49 | + | |
50 | + public function select($options = array()) { | |
51 | + // this helper options | |
52 | + $defaultOptions = array('id' => null, | |
53 | + 'objectName' => '', | |
54 | + 'attrName' => $this->inputName(), | |
55 | + 'resources' => array(), | |
56 | + 'options' => array()); | |
57 | + | |
58 | + $defaultOptions = $this->mergeOptions($this->defaultOptions(), $defaultOptions); | |
59 | + $this->options = $this->mergeOptions($options, $defaultOptions); | |
60 | + $this->options['options'] = $this->mergeOptions($this->options['options'], $defaultOptions['options']); | |
61 | + | |
62 | + // select options | |
63 | + | |
64 | + $defaultInputOptions = array('label' => Portabilis_String_Utils::humanize($this->inputName()), | |
65 | + 'value' => $this->inputValue($this->options['id']), | |
66 | + 'resources' => $this->inputOptions($this->options)); | |
67 | + | |
68 | + $inputOptions = $this->mergeOptions($this->options['options'], $defaultInputOptions); | |
69 | + $helperOptions = array('objectName' => $this->options['objectName']); | |
70 | + | |
71 | + // input | |
72 | + $this->inputsHelper()->select($this->options['attrName'], $inputOptions, $helperOptions); | |
73 | + } | |
74 | + | |
75 | + // subscrever no child caso deseje carregar mais opções do banco de dados antes de carregar a página, | |
76 | + // ou deixar apenas com a opção padrão e carregar via ajax | |
77 | + protected function inputOptions($options) { | |
78 | + return $this->insertOption(null, | |
79 | + "Selecione um(a) " . Portabilis_String_Utils::humanize($this->inputName()), | |
80 | + $resources); | |
81 | + } | |
82 | + | |
83 | + // overwrite this method in childrens to set additional default options, to be merged with received options, | |
84 | + // and pass to select helper | |
85 | + protected function defaultOptions() { | |
86 | + return array(); | |
87 | + } | |
88 | +} | |
0 | 89 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Hidden class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Hidden extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function hidden($attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), 'objectName' => ''); | |
49 | + $options = $this->mergeOptions($options, $defaultOptions); | |
50 | + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; | |
51 | + | |
52 | + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, | |
53 | + 'value' => ''); | |
54 | + | |
55 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
56 | + | |
57 | + call_user_func_array(array($this->viewInstance, 'campoOculto'), $inputOptions); | |
58 | + } | |
59 | +} | |
0 | 60 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/MultipleSearch.php
0 → 100644
... | ... | @@ -0,0 +1,110 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_MultipleSearch class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_MultipleSearch extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function multipleSearch($objectName, $attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), | |
49 | + 'apiModule' => 'Api', | |
50 | + 'apiController' => ucwords($objectName), | |
51 | + 'apiResource' => $objectName . '-search', | |
52 | + 'searchPath' => ''); | |
53 | + | |
54 | + $options = $this->mergeOptions($options, $defaultOptions); | |
55 | + | |
56 | + if (empty($options['searchPath'])) | |
57 | + $options['searchPath'] = "/module/" . $options['apiModule'] . "/" . $options['apiController'] . | |
58 | + "?oper=get&resource=" . $options['apiResource']; | |
59 | + | |
60 | + // #TODO load resources value? | |
61 | + | |
62 | + /* | |
63 | + // load value if received an resource id | |
64 | + $resourceId = $options['hiddenInputOptions']['options']['value']; | |
65 | + | |
66 | + if ($resourceId && ! $options['options']['value']) | |
67 | + $options['options']['value'] = $resourceId . " - ". $this->resourcesValue($resourceId); | |
68 | + */ | |
69 | + | |
70 | + $this->selectInput($objectName, $attrName, $options); | |
71 | + | |
72 | + $this->loadAssets(); | |
73 | + $this->js($objectName, $attrName, $options); | |
74 | + } | |
75 | + | |
76 | + protected function selectInput($objectName, $attrName, $options) { | |
77 | + $textHelperOptions = array('objectName' => $objectName); | |
78 | + | |
79 | + $this->inputsHelper()->select($attrName, $options['options'], $textHelperOptions); | |
80 | + } | |
81 | + | |
82 | + | |
83 | + protected function loadAssets() { | |
84 | + $cssFile = '/modules/Portabilis/Assets/Plugins/Chosen/chosen.css'; | |
85 | + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $cssFile); | |
86 | + | |
87 | + $jsFiles = array('/modules/Portabilis/Assets/Plugins/Chosen/chosen.jquery.min.js', | |
88 | + '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearch.js'); | |
89 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFiles); | |
90 | + } | |
91 | + | |
92 | + | |
93 | + protected function js($objectName, $attrName, $options) { | |
94 | + // setup multiple search | |
95 | + | |
96 | + /* | |
97 | + all search options (including the option chosenOptions, that is passed for chosen plugin), | |
98 | + can be overwritten adding "var = multipleSearch<ObjectName>Options = { 'options' : 'val', option2 : '_' };" | |
99 | + in the script file for the resource controller. | |
100 | + */ | |
101 | + | |
102 | + $resourceOptions = "multipleSearch" . Portabilis_String_Utils::camelize($objectName) . "Options"; | |
103 | + | |
104 | + $js = "$resourceOptions = typeof $resourceOptions == 'undefined' ? {} : $resourceOptions; | |
105 | + multipleSearchHelper.setup('$objectName', '$attrName', '" . $options['searchPath'] . "', $resourceOptions);"; | |
106 | + | |
107 | + // this script will be executed after the script for the current controller (if it was loaded in the view); | |
108 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
109 | + } | |
110 | +} | |
0 | 111 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/MultipleSearchAjax.php
0 → 100644
... | ... | @@ -0,0 +1,116 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_MultipleSearchAjax class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_MultipleSearchAjax extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function multipleSearchAjax($objectName, $attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), | |
49 | + 'apiModule' => 'Api', | |
50 | + 'apiController' => ucwords($objectName), | |
51 | + 'apiResource' => $objectName . '-search', | |
52 | + 'searchPath' => ''); | |
53 | + | |
54 | + $options = $this->mergeOptions($options, $defaultOptions); | |
55 | + | |
56 | + if (empty($options['searchPath'])) | |
57 | + $options['searchPath'] = "/module/" . $options['apiModule'] . "/" . $options['apiController'] . | |
58 | + "?oper=get&resource=" . $options['apiResource']; | |
59 | + | |
60 | + // #TODO load resources value? | |
61 | + | |
62 | + /* | |
63 | + // load value if received an resource id | |
64 | + $resourceId = $options['hiddenInputOptions']['options']['value']; | |
65 | + | |
66 | + if ($resourceId && ! $options['options']['value']) | |
67 | + $options['options']['value'] = $resourceId . " - ". $this->resourcesValue($resourceId); | |
68 | + */ | |
69 | + | |
70 | + $this->selectInput($objectName, $attrName, $options); | |
71 | + | |
72 | + $this->loadAssets(); | |
73 | + $this->js($objectName, $attrName, $options); | |
74 | + } | |
75 | + | |
76 | + protected function selectInput($objectName, $attrName, $options) { | |
77 | + $textHelperOptions = array('objectName' => $objectName); | |
78 | + | |
79 | + $this->inputsHelper()->select($attrName, $options['options'], $textHelperOptions); | |
80 | + } | |
81 | + | |
82 | + | |
83 | + protected function loadAssets() { | |
84 | + $cssFile = '/modules/Portabilis/Assets/Plugins/Chosen/chosen.css'; | |
85 | + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $cssFile); | |
86 | + | |
87 | + // AjaxChosen requires this fixup, see https://github.com/meltingice/ajax-chosen | |
88 | + $fixupCss = ".chzn-container .chzn-results .group-result { display: list-item; }"; | |
89 | + Portabilis_View_Helper_Application::embedStylesheet($this->viewInstance, $fixupCss); | |
90 | + | |
91 | + | |
92 | + $jsFiles = array('/modules/Portabilis/Assets/Plugins/Chosen/chosen.jquery.min.js', | |
93 | + '/modules/Portabilis/Assets/Plugins/AjaxChosen/ajax-chosen.min.js', | |
94 | + '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/MultipleSearchAjax.js'); | |
95 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFiles); | |
96 | + } | |
97 | + | |
98 | + | |
99 | + protected function js($objectName, $attrName, $options) { | |
100 | + // setup multiple search | |
101 | + | |
102 | + /* | |
103 | + all search options (including the option ajaxChosenOptions, that is passed for ajaxChosen plugin), | |
104 | + can be overwritten adding "var = multipleSearchAjax<ObjectName>Options = { 'options' : 'val', option2 : '_' };" | |
105 | + in the script file for the resource controller. | |
106 | + */ | |
107 | + | |
108 | + $resourceOptions = "multipleSearchAjax" . Portabilis_String_Utils::camelize($objectName) . "Options"; | |
109 | + | |
110 | + $js = "$resourceOptions = typeof $resourceOptions == 'undefined' ? {} : $resourceOptions; | |
111 | + multipleSearchAjaxHelper.setup('$objectName', '$attrName', '" . $options['searchPath'] . "', $resourceOptions);"; | |
112 | + | |
113 | + // this script will be executed after the script for the current controller (if it was loaded in the view); | |
114 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
115 | + } | |
116 | +} | |
0 | 117 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,73 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Numeric class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function numeric($attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), 'objectName' => ''); | |
49 | + | |
50 | + $options = $this->mergeOptions($options, $defaultOptions); | |
51 | + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; | |
52 | + | |
53 | + $label = ! empty($attrName) ? $attrName : $options['objectName']; | |
54 | + $label = str_replace('_id', '', $label); | |
55 | + | |
56 | + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, | |
57 | + 'label' => ucwords($label), | |
58 | + 'value' => null, | |
59 | + 'size' => 15, | |
60 | + 'max_length' => 15, | |
61 | + 'required' => true, | |
62 | + 'label_hint' => '', | |
63 | + 'input_hint' => '', | |
64 | + 'script' => false, | |
65 | + 'event' => 'onKeyUp', | |
66 | + 'inline' => false, | |
67 | + 'disabled' => false); | |
68 | + | |
69 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
70 | + | |
71 | + call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); | |
72 | + } | |
73 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php
0 → 100644
... | ... | @@ -0,0 +1,62 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Resource_Beneficio class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Resource_Beneficio extends Portabilis_View_Helper_Input_CoreSelect { | |
46 | + | |
47 | + protected function inputOptions($options) { | |
48 | + $resources = $options['resources']; | |
49 | + | |
50 | + if (empty($resources)) { | |
51 | + $resources = new clsPmieducarAlunoBeneficio(); | |
52 | + $resources = $resources->lista(null, null, null, null, null, null, null, null, null, 1); | |
53 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_aluno_beneficio', 'nm_beneficio'); | |
54 | + } | |
55 | + | |
56 | + return $this->insertOption(null, "Selecione", $resources); | |
57 | + } | |
58 | + | |
59 | + public function beneficio($options = array()) { | |
60 | + parent::select($options); | |
61 | + } | |
62 | +} | |
0 | 63 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php
0 → 100644
... | ... | @@ -0,0 +1,62 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Resource_EstadoCivil class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Resource_EstadoCivil extends Portabilis_View_Helper_Input_CoreSelect { | |
46 | + | |
47 | + protected function inputOptions($options) { | |
48 | + $resources = $options['resources']; | |
49 | + | |
50 | + if (empty($resources)) { | |
51 | + $resources = new clsEstadoCivil(); | |
52 | + $resources = $resources->lista(); | |
53 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'ideciv', 'descricao'); | |
54 | + } | |
55 | + | |
56 | + return $this->insertOption(null, "Selecione", $resources); | |
57 | + } | |
58 | + | |
59 | + public function estadoCivil($options = array()) { | |
60 | + parent::select($options); | |
61 | + } | |
62 | +} | |
0 | 63 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchAjaxDeficiencias.php
0 → 100644
... | ... | @@ -0,0 +1,77 @@ |
1 | +<?php | |
2 | + | |
3 | +#error_reporting(E_ALL); | |
4 | +#ini_set("display_errors", 1); | |
5 | + | |
6 | +/** | |
7 | + * i-Educar - Sistema de gestão escolar | |
8 | + * | |
9 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
10 | + * <ctima@itajai.sc.gov.br> | |
11 | + * | |
12 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
13 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
14 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
15 | + * qualquer versão posterior. | |
16 | + * | |
17 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
18 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
19 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
20 | + * do GNU para mais detalhes. | |
21 | + * | |
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
23 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
24 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
25 | + * | |
26 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
27 | + * @category i-Educar | |
28 | + * @license @@license@@ | |
29 | + * @package Portabilis | |
30 | + * @since Arquivo disponível desde a versão 1.1.0 | |
31 | + * @version $Id$ | |
32 | + */ | |
33 | + | |
34 | +require_once 'lib/Portabilis/View/Helper/Input/MultipleSearchAjax.php'; | |
35 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
36 | +require_once 'lib/Portabilis/String/Utils.php'; | |
37 | + | |
38 | +/** | |
39 | + * Portabilis_View_Helper_Input_MultipleSearchDeficiencias class. | |
40 | + * | |
41 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
42 | + * @category i-Educar | |
43 | + * @license @@license@@ | |
44 | + * @package Portabilis | |
45 | + * @since Classe disponível desde a versão 1.1.0 | |
46 | + * @version @@package_version@@ | |
47 | + */ | |
48 | + | |
49 | + | |
50 | +/* | |
51 | + | |
52 | + Classe de modelo para MultipleSearchAjax<Resource> | |
53 | + | |
54 | + // para usar tal helper, adicionar a view: | |
55 | + | |
56 | + $helperOptions = array('objectName' => 'deficiencias'); | |
57 | + $options = array('label' => 'Deficiencias'); | |
58 | + | |
59 | + $this->inputsHelper()->multipleSearchDeficiencias('', $options, $helperOptions); | |
60 | + | |
61 | + // Esta classe assim com o javascript ainda não está concluida, | |
62 | + // pois o valor não é recuperado para exibição. | |
63 | + | |
64 | +*/ | |
65 | + | |
66 | +class Portabilis_View_Helper_Input_Resource_MultipleSearchDeficiencias extends Portabilis_View_Helper_Input_MultipleSearchAjax { | |
67 | + | |
68 | + public function multipleSearchDeficiencias($attrName, $options = array()) { | |
69 | + $defaultOptions = array('objectName' => 'deficiencias', | |
70 | + 'apiController' => 'Deficiencia', | |
71 | + 'apiResource' => 'deficiencia-search'); | |
72 | + | |
73 | + $options = $this->mergeOptions($options, $defaultOptions); | |
74 | + | |
75 | + parent::multipleSearchAjax($options['objectName'], $attrName, $options); | |
76 | + } | |
77 | +} | |
0 | 78 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/MultipleSearchDeficiencias.php
0 → 100644
... | ... | @@ -0,0 +1,90 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/MultipleSearch.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | +require_once 'lib/Portabilis/String/Utils.php'; | |
35 | + | |
36 | +/** | |
37 | + * Portabilis_View_Helper_Input_MultipleSearchDeficiencias class. | |
38 | + * | |
39 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
40 | + * @category i-Educar | |
41 | + * @license @@license@@ | |
42 | + * @package Portabilis | |
43 | + * @since Classe disponível desde a versão 1.1.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class Portabilis_View_Helper_Input_Resource_MultipleSearchDeficiencias extends Portabilis_View_Helper_Input_MultipleSearch { | |
47 | + | |
48 | + /*protected function resourceValue($id) { | |
49 | + if ($id) { | |
50 | + $sql = "select nm_deficiencia from cadastro.deficiencia where cod_deficiencia = $1"; | |
51 | + $options = array('params' => $id, 'return_only' => 'first-field'); | |
52 | + $nome = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
53 | + | |
54 | + return Portabilis_String_Utils::toLatin1($nome, array('transform' => true, 'escape' => false)); | |
55 | + } | |
56 | + }*/ | |
57 | + | |
58 | + protected function getOptions($resources) { | |
59 | + if (empty($resources)) { | |
60 | + $resources = new clsCadastroDeficiencia(); | |
61 | + $resources = $resources->lista(); | |
62 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_deficiencia', 'nm_deficiencia'); | |
63 | + } | |
64 | + | |
65 | + return $this->insertOption(null, '', $resources); | |
66 | + } | |
67 | + | |
68 | + public function multipleSearchDeficiencias($attrName, $options = array()) { | |
69 | + $defaultOptions = array('objectName' => 'deficiencias', | |
70 | + 'apiController' => 'Deficiencia', | |
71 | + 'apiResource' => 'deficiencia-search'); | |
72 | + | |
73 | + $options = $this->mergeOptions($options, $defaultOptions); | |
74 | + $options['options']['resources'] = $this->getOptions($options['options']['resources']); | |
75 | + | |
76 | + //var_dump($options['options']['options']); | |
77 | + | |
78 | + $this->placeholderJs($options); | |
79 | + | |
80 | + parent::multipleSearch($options['objectName'], $attrName, $options); | |
81 | + } | |
82 | + | |
83 | + protected function placeholderJs($options) { | |
84 | + $optionsVarName = "multipleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
85 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
86 | + $optionsVarName.placeholder = safeUtf8Decode('Selecione as deficiências');"; | |
87 | + | |
88 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
89 | + } | |
90 | +} | |
0 | 91 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php
0 → 100644
... | ... | @@ -0,0 +1,64 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Resource_Religiao class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | + | |
46 | +class Portabilis_View_Helper_Input_Resource_Religiao extends Portabilis_View_Helper_Input_CoreSelect { | |
47 | + | |
48 | + protected function inputOptions($options) { | |
49 | + $resources = $options['resources']; | |
50 | + | |
51 | + if (empty($options['resources'])) { | |
52 | + $resources = new clsPmieducarReligiao(); | |
53 | + $resources = $resources->lista(null, null, null, null, null, null, null, null, 1); | |
54 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_religiao', 'nm_religiao'); | |
55 | + } | |
56 | + | |
57 | + return $this->insertOption(null, "Selecione", $resources); | |
58 | + } | |
59 | + | |
60 | + | |
61 | + public function religiao($options = array()) { | |
62 | + parent::select($options); | |
63 | + } | |
64 | +} | |
0 | 65 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php
0 → 100644
... | ... | @@ -0,0 +1,70 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_Input_SimpleSearchAluno class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_Input_Resource_SimpleSearchAluno extends Portabilis_View_Helper_Input_SimpleSearch { | |
45 | + | |
46 | + public function simpleSearchAluno($attrName = '', $options = array()) { | |
47 | + $defaultOptions = array('objectName' => 'aluno', | |
48 | + 'apiController' => 'Aluno', | |
49 | + 'apiResource' => 'aluno-search'); | |
50 | + | |
51 | + $options = $this->mergeOptions($options, $defaultOptions); | |
52 | + | |
53 | + $this->placeholderJs($options); | |
54 | + | |
55 | + parent::simpleSearch($options['objectName'], $attrName, $options); | |
56 | + } | |
57 | + | |
58 | + protected function placeholderJs($options) { | |
59 | + $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
60 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
61 | + $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno ou código');"; | |
62 | + | |
63 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
64 | + } | |
65 | + | |
66 | + protected function loadAssets() { | |
67 | + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchAluno.js'; | |
68 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); | |
69 | + } | |
70 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php
0 → 100644
... | ... | @@ -0,0 +1,70 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php'; | |
33 | + | |
34 | +/** | |
35 | + * Portabilis_View_Helper_Input_SimpleSearchMatricula class. | |
36 | + * | |
37 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package Portabilis | |
41 | + * @since Classe disponível desde a versão 1.1.0 | |
42 | + * @version @@package_version@@ | |
43 | + */ | |
44 | +class Portabilis_View_Helper_Input_Resource_SimpleSearchMatricula extends Portabilis_View_Helper_Input_SimpleSearch { | |
45 | + | |
46 | + public function simpleSearchMatricula($attrName = '', $options = array()) { | |
47 | + $defaultOptions = array('objectName' => 'matricula', | |
48 | + 'apiController' => 'Matricula', | |
49 | + 'apiResource' => 'matricula-search'); | |
50 | + | |
51 | + $options = $this->mergeOptions($options, $defaultOptions); | |
52 | + | |
53 | + $this->placeholderJs($options); | |
54 | + | |
55 | + parent::simpleSearch($options['objectName'], $attrName, $options); | |
56 | + } | |
57 | + | |
58 | + protected function placeholderJs($options) { | |
59 | + $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
60 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
61 | + $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno, código ou código matricula');"; | |
62 | + | |
63 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
64 | + } | |
65 | + | |
66 | + protected function loadAssets() { | |
67 | + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchMatricula.js'; | |
68 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); | |
69 | + } | |
70 | +} | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php
0 → 100644
... | ... | @@ -0,0 +1,79 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | +require_once 'lib/Portabilis/String/Utils.php'; | |
35 | + | |
36 | +/** | |
37 | + * Portabilis_View_Helper_Input_SimpleSearchMunicipio class. | |
38 | + * | |
39 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
40 | + * @category i-Educar | |
41 | + * @license @@license@@ | |
42 | + * @package Portabilis | |
43 | + * @since Classe disponível desde a versão 1.1.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class Portabilis_View_Helper_Input_Resource_SimpleSearchMunicipio extends Portabilis_View_Helper_Input_SimpleSearch { | |
47 | + | |
48 | + protected function resourceValue($id) { | |
49 | + if ($id) { | |
50 | + $sql = "select nome, sigla_uf from public.municipio where idmun = $1"; | |
51 | + $options = array('params' => $id, 'return_only' => 'first-row'); | |
52 | + $municipio = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
53 | + $nome = $municipio['nome']; | |
54 | + $siglaUf = $municipio['sigla_uf']; | |
55 | + | |
56 | + return Portabilis_String_Utils::toLatin1($nome, array('transform' => true, 'escape' => false)) . " ($siglaUf)"; | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + public function simpleSearchMunicipio($attrName, $options = array()) { | |
61 | + $defaultOptions = array('objectName' => 'municipio', | |
62 | + 'apiController' => 'Municipio', | |
63 | + 'apiResource' => 'municipio-search'); | |
64 | + | |
65 | + $options = $this->mergeOptions($options, $defaultOptions); | |
66 | + | |
67 | + $this->placeholderJs($options); | |
68 | + | |
69 | + parent::simpleSearch($options['objectName'], $attrName, $options); | |
70 | + } | |
71 | + | |
72 | + protected function placeholderJs($options) { | |
73 | + $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
74 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
75 | + $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome da cidade');"; | |
76 | + | |
77 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
78 | + } | |
79 | +} | |
0 | 80 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php
0 → 100644
... | ... | @@ -0,0 +1,77 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | +require_once 'lib/Portabilis/String/Utils.php'; | |
35 | + | |
36 | +/** | |
37 | + * Portabilis_View_Helper_Input_SimpleSearchPais class. | |
38 | + * | |
39 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
40 | + * @category i-Educar | |
41 | + * @license @@license@@ | |
42 | + * @package Portabilis | |
43 | + * @since Classe disponível desde a versão 1.1.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class Portabilis_View_Helper_Input_Resource_SimpleSearchPais extends Portabilis_View_Helper_Input_SimpleSearch { | |
47 | + | |
48 | + protected function resourceValue($id) { | |
49 | + if ($id) { | |
50 | + $sql = "select nome from public.pais where idpais = $1"; | |
51 | + $options = array('params' => $id, 'return_only' => 'first-field'); | |
52 | + $nome = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
53 | + | |
54 | + return Portabilis_String_Utils::toLatin1($nome, array('transform' => true, 'escape' => false)); | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + public function simpleSearchPais($attrName, $options = array()) { | |
59 | + $defaultOptions = array('objectName' => 'pais', | |
60 | + 'apiController' => 'Pais', | |
61 | + 'apiResource' => 'pais-search'); | |
62 | + | |
63 | + $options = $this->mergeOptions($options, $defaultOptions); | |
64 | + | |
65 | + $this->placeholderJs($options); | |
66 | + | |
67 | + parent::simpleSearch($options['objectName'], $attrName, $options); | |
68 | + } | |
69 | + | |
70 | + protected function placeholderJs($options) { | |
71 | + $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
72 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
73 | + $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome do pais de origem');"; | |
74 | + | |
75 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
76 | + } | |
77 | +} | |
0 | 78 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php
0 → 100644
... | ... | @@ -0,0 +1,77 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php'; | |
33 | +require_once 'lib/Portabilis/Utils/Database.php'; | |
34 | +require_once 'lib/Portabilis/String/Utils.php'; | |
35 | + | |
36 | +/** | |
37 | + * Portabilis_View_Helper_Input_SimpleSearchPessoa class. | |
38 | + * | |
39 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
40 | + * @category i-Educar | |
41 | + * @license @@license@@ | |
42 | + * @package Portabilis | |
43 | + * @since Classe disponível desde a versão 1.1.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class Portabilis_View_Helper_Input_Resource_SimpleSearchPessoa extends Portabilis_View_Helper_Input_SimpleSearch { | |
47 | + | |
48 | + protected function resourceValue($id) { | |
49 | + if ($id) { | |
50 | + $sql = "select nome from cadastro.pessoa where idpes = $1"; | |
51 | + $options = array('params' => $id, 'return_only' => 'first-field'); | |
52 | + $nome = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options); | |
53 | + | |
54 | + return Portabilis_String_Utils::toLatin1($nome, array('transform' => true, 'escape' => false)); | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + public function simpleSearchPessoa($attrName, $options = array()) { | |
59 | + $defaultOptions = array('objectName' => 'pessoa', | |
60 | + 'apiController' => 'Pessoa', | |
61 | + 'apiResource' => 'pessoa-search'); | |
62 | + | |
63 | + $options = $this->mergeOptions($options, $defaultOptions); | |
64 | + | |
65 | + $this->placeholderJs($options); | |
66 | + | |
67 | + parent::simpleSearch($options['objectName'], $attrName, $options); | |
68 | + } | |
69 | + | |
70 | + protected function placeholderJs($options) { | |
71 | + $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; | |
72 | + $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; | |
73 | + $optionsVarName.placeholder = safeUtf8Decode('Informe o nome, código, CPF ou RG da pessoa');"; | |
74 | + | |
75 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
76 | + } | |
77 | +} | |
0 | 78 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Resource/TurmaTurno.php
0 → 100644
... | ... | @@ -0,0 +1,67 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Resource_TurmaTurno class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | + | |
46 | +class Portabilis_View_Helper_Input_Resource_TurmaTurno extends Portabilis_View_Helper_Input_CoreSelect { | |
47 | + | |
48 | + protected function inputOptions($options) { | |
49 | + $resources = $options['resources']; | |
50 | + | |
51 | + if (empty($options['resources'])) { | |
52 | + $sql = "select id, nome from pmieducar.turma_turno where ativo = 1 order by id DESC"; | |
53 | + $resources = Portabilis_Utils_Database::fetchPreparedQuery($sql); | |
54 | + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'id', 'nome'); | |
55 | + } | |
56 | + | |
57 | + return $this->insertOption(null, "Selecione", $resources); | |
58 | + } | |
59 | + | |
60 | + protected function defaultOptions() { | |
61 | + return array('options' => array('label' => 'Turno')); | |
62 | + } | |
63 | + | |
64 | + public function turmaTurno($options = array()) { | |
65 | + parent::select($options); | |
66 | + } | |
67 | +} | |
0 | 68 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,67 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Select class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Select extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function select($attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), 'objectName' => '', 'resources' => array()); | |
49 | + $options = $this->mergeOptions($options, $defaultOptions); | |
50 | + | |
51 | + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; | |
52 | + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, | |
53 | + 'label' => ucwords($attrName), | |
54 | + 'resources' => $options['resources'], | |
55 | + 'value' => '', | |
56 | + 'callback' => '', | |
57 | + 'inline' => false, | |
58 | + 'label_hint' => '', | |
59 | + 'input_hint' => '', | |
60 | + 'disabled' => false, | |
61 | + 'required' => true, | |
62 | + 'multiple' => false); | |
63 | + | |
64 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
65 | + call_user_func_array(array($this->viewInstance, 'campoLista'), $inputOptions); | |
66 | + } | |
67 | +} | |
0 | 68 | \ No newline at end of file | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php
0 → 100644
... | ... | @@ -0,0 +1,126 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_SimpleSearch class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + protected function resourceValue($id) { | |
48 | + throw new Exception("You are trying to get the resource value, but this is a generic class, " . | |
49 | + "please, define the method resourceValue in a resource subclass."); | |
50 | + } | |
51 | + | |
52 | + public function simpleSearch($objectName, $attrName, $options = array()) { | |
53 | + $defaultOptions = array('options' => array(), | |
54 | + 'apiModule' => 'Api', | |
55 | + 'apiController' => ucwords($objectName), | |
56 | + 'apiResource' => $objectName . '-search', | |
57 | + 'searchPath' => '', | |
58 | + 'addHiddenInput' => true, | |
59 | + 'hiddenInputOptions' => array()); | |
60 | + | |
61 | + $options = $this->mergeOptions($options, $defaultOptions); | |
62 | + | |
63 | + if (empty($options['searchPath'])) | |
64 | + $options['searchPath'] = "/module/" . $options['apiModule'] . "/" . $options['apiController'] . | |
65 | + "?oper=get&resource=" . $options['apiResource']; | |
66 | + | |
67 | + | |
68 | + // load value if received an resource id | |
69 | + $resourceId = $options['hiddenInputOptions']['options']['value']; | |
70 | + | |
71 | + if ($resourceId && ! $options['options']['value']) | |
72 | + $options['options']['value'] = $resourceId . " - ". $this->resourceValue($resourceId); | |
73 | + | |
74 | + $this->hiddenInput($objectName, $attrName, $options); | |
75 | + $this->textInput($objectName, $attrName, $options); | |
76 | + $this->js($objectName, $attrName, $options); | |
77 | + } | |
78 | + | |
79 | + | |
80 | + protected function hiddenInput($objectName, $attrName, $options) { | |
81 | + if ($options['addHiddenInput']) { | |
82 | + if ($attrName == 'id') { | |
83 | + throw new CoreExt_Exception("When \$addHiddenInput is true the \$attrName (of the visible input) " . | |
84 | + "must be different than 'id', because the hidden input will use it."); | |
85 | + } | |
86 | + | |
87 | + $defaultHiddenInputOptions = array('options' => array(), 'objectName' => $objectName); | |
88 | + $hiddenInputOptions = $this->mergeOptions($options['hiddenInputOptions'], $defaultHiddenInputOptions); | |
89 | + | |
90 | + $this->inputsHelper()->hidden('id', array(), $hiddenInputOptions); | |
91 | + } | |
92 | + } | |
93 | + | |
94 | + | |
95 | + protected function textInput($objectName, $attrName, $options) { | |
96 | + $textHelperOptions = array('objectName' => $objectName); | |
97 | + | |
98 | + $this->inputsHelper()->text($attrName, $options['options'], $textHelperOptions); | |
99 | + } | |
100 | + | |
101 | + | |
102 | + protected function js($objectName, $attrName, $options) { | |
103 | + // load simple search js | |
104 | + | |
105 | + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js'; | |
106 | + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile); | |
107 | + | |
108 | + | |
109 | + // setup simple search | |
110 | + | |
111 | + /* | |
112 | + all search options (including the option autocompleteOptions, that is passed for jquery autocomplete plugin), | |
113 | + can be overwritten adding "var = simpleSearch<ObjectName>Options = { placeholder : '...', optionName : '...' };" | |
114 | + in the script file for the resource controller. | |
115 | + */ | |
116 | + | |
117 | + $resourceOptions = "simpleSearch" . Portabilis_String_Utils::camelize($objectName) . "Options"; | |
118 | + | |
119 | + $js = "$resourceOptions = typeof $resourceOptions == 'undefined' ? {} : $resourceOptions; | |
120 | + simpleSearchHelper.setup('$objectName', '$attrName', '" . $options['searchPath'] . "', $resourceOptions);"; | |
121 | + | |
122 | + | |
123 | + // this script will be executed after the script for the current controller (if it was loaded in the view); | |
124 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); | |
125 | + } | |
126 | +} | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; | |
33 | + | |
34 | + | |
35 | +/** | |
36 | + * Portabilis_View_Helper_Input_Text class. | |
37 | + * | |
38 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package Portabilis | |
42 | + * @since Classe disponível desde a versão 1.1.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Core { | |
46 | + | |
47 | + public function text($attrName, $options = array()) { | |
48 | + $defaultOptions = array('options' => array(), 'objectName' => ''); | |
49 | + | |
50 | + $options = $this->mergeOptions($options, $defaultOptions); | |
51 | + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; | |
52 | + | |
53 | + $label = ! empty($attrName) ? $attrName : $options['objectName']; | |
54 | + $label = str_replace('_id', '', $label); | |
55 | + | |
56 | + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, | |
57 | + 'label' => ucwords($label), | |
58 | + 'value' => null, | |
59 | + 'size' => 50, | |
60 | + 'max_length' => 50, | |
61 | + 'required' => true, | |
62 | + 'script' => false, | |
63 | + 'inline' => false, | |
64 | + 'label_hint' => '', | |
65 | + 'input_hint' => '', | |
66 | + 'callback' => false, | |
67 | + 'event' => 'onKeyUp', | |
68 | + 'disabled' => false); | |
69 | + | |
70 | + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); | |
71 | + | |
72 | + call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); | |
73 | + } | |
74 | +} | ... | ... |
... | ... | @@ -0,0 +1,246 @@ |
1 | +<?php | |
2 | +#error_reporting(E_ALL); | |
3 | +#ini_set("display_errors", 1); | |
4 | +/** | |
5 | + * i-Educar - Sistema de gestão escolar | |
6 | + * | |
7 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
8 | + * <ctima@itajai.sc.gov.br> | |
9 | + * | |
10 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
11 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
12 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
13 | + * qualquer versão posterior. | |
14 | + * | |
15 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
16 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
17 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
18 | + * do GNU para mais detalhes. | |
19 | + * | |
20 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
21 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
22 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
23 | + * | |
24 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
25 | + * @category i-Educar | |
26 | + * @license @@license@@ | |
27 | + * @package Portabilis | |
28 | + * @since Arquivo disponível desde a versão 1.1.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +/** | |
33 | + * Portabilis_View_Helper_Inputs class. | |
34 | + * | |
35 | + * @author Lucas D'Avila <lucasdavila@portabilis.com.br> | |
36 | + * @category i-Educar | |
37 | + * @license @@license@@ | |
38 | + * @package Portabilis | |
39 | + * @since Classe disponível desde a versão 1.1.0 | |
40 | + * @version @@package_version@@ | |
41 | + */ | |
42 | + | |
43 | + | |
44 | +class Portabilis_View_Helper_Inputs { | |
45 | + | |
46 | + public function __construct($viewInstance) { | |
47 | + $this->viewInstance = $viewInstance; | |
48 | + } | |
49 | + | |
50 | + | |
51 | + // dynamic inputs helper | |
52 | + | |
53 | + /* adiciona inputs de seleção dinamica ao formulário, recebendo diretamente as opcoes do input, | |
54 | + sem necessidade de passar um array com um array de opções, ex: | |
55 | + | |
56 | + Ao invés de: | |
57 | + $this->inputsHelper()->dynamic('instituicao', array('options' => array(required' => false))); | |
58 | + | |
59 | + Pode-se usar: | |
60 | + $this->inputsHelper()->dynamic('instituicao', array(required' => false)); | |
61 | + | |
62 | + Ou | |
63 | + $this->inputsHelper()->dynamic('instituicao', array(), array('options' => array(required' => false))); | |
64 | + | |
65 | + Ou | |
66 | + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'pesquisaAluno')); | |
67 | + */ | |
68 | + | |
69 | + public function dynamic($helperNames, $inputOptions = array(), $helperOptions = array()) { | |
70 | + $options = $this->mergeInputOptions($inputOptions, $helperOptions); | |
71 | + | |
72 | + if (! is_array($helperNames)) | |
73 | + $helperNames = array($helperNames); | |
74 | + | |
75 | + foreach($helperNames as $helperName) { | |
76 | + $helperClassName = "Portabilis_View_Helper_DynamicInput_" . ucfirst($helperName); | |
77 | + $this->includeHelper($helperClassName); | |
78 | + | |
79 | + $helper = new $helperClassName($this->viewInstance, $this); | |
80 | + $helper->$helperName($options); | |
81 | + } | |
82 | + } | |
83 | + | |
84 | + | |
85 | + // input helpers | |
86 | + | |
87 | + public function text($attrNames, $inputOptions = array(), $helperOptions = array()) { | |
88 | + if (! is_array($attrNames)) | |
89 | + $attrNames = array($attrNames); | |
90 | + | |
91 | + foreach($attrNames as $attrName) { | |
92 | + $this->input('text', $attrName, $inputOptions, $helperOptions); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + public function numeric($attrNames, $inputOptions = array(), $helperOptions = array()) { | |
97 | + if (! is_array($attrNames)) | |
98 | + $attrNames = array($attrNames); | |
99 | + | |
100 | + foreach($attrNames as $attrName) { | |
101 | + $this->input('numeric', $attrName, $inputOptions, $helperOptions); | |
102 | + } | |
103 | + } | |
104 | + | |
105 | + | |
106 | + public function select($attrName, $inputOptions = array(), $helperOptions = array()) { | |
107 | + $this->input('select', $attrName, $inputOptions, $helperOptions); | |
108 | + } | |
109 | + | |
110 | + | |
111 | + public function search($attrName, $inputOptions = array(), $helperOptions = array()) { | |
112 | + $this->input('search', $attrName, $inputOptions, $helperOptions); | |
113 | + } | |
114 | + | |
115 | + | |
116 | + public function hidden($attrName, $inputOptions = array(), $helperOptions = array()) { | |
117 | + $this->input('hidden', $attrName, $inputOptions, $helperOptions); | |
118 | + } | |
119 | + | |
120 | + | |
121 | + public function checkbox($attrName, $inputOptions = array(), $helperOptions = array()) { | |
122 | + $this->input('checkbox', $attrName, $inputOptions, $helperOptions); | |
123 | + } | |
124 | + | |
125 | + | |
126 | + public function input($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) { | |
127 | + $helperClassName = "Portabilis_View_Helper_Input_" . ucfirst($helperName); | |
128 | + | |
129 | + $this->includeHelper($helperClassName); | |
130 | + $helper = new $helperClassName($this->viewInstance, $this); | |
131 | + $helper->$helperName($attrName, $this->mergeInputOptions($inputOptions, $helperOptions)); | |
132 | + } | |
133 | + | |
134 | + | |
135 | + // simple search input helper | |
136 | + | |
137 | + public function simpleSearch($objectName, $attrName, $inputOptions = array(), $helperOptions = array()) { | |
138 | + $options = $this->mergeInputOptions($inputOptions, $helperOptions); | |
139 | + | |
140 | + $helperClassName = 'Portabilis_View_Helper_Input_SimpleSearch'; | |
141 | + $this->includeHelper($helperClassName); | |
142 | + | |
143 | + $helper = new $helperClassName($this->viewInstance, $this); | |
144 | + $helper->simpleSearch($objectName, $attrName, $options); | |
145 | + } | |
146 | + | |
147 | + | |
148 | + // simple search resource input helper | |
149 | + | |
150 | + public function simpleSearchPessoa($attrName, $inputOptions = array(), $helperOptions = array()) { | |
151 | + $this->simpleSearchResourceInput('simpleSearchPessoa', $attrName, $inputOptions, $helperOptions); | |
152 | + } | |
153 | + | |
154 | + public function simpleSearchPais($attrName, $inputOptions = array(), $helperOptions = array()) { | |
155 | + $this->simpleSearchResourceInput('simpleSearchPais', $attrName, $inputOptions, $helperOptions); | |
156 | + } | |
157 | + | |
158 | + public function simpleSearchMunicipio($attrName, $inputOptions = array(), $helperOptions = array()) { | |
159 | + $this->simpleSearchResourceInput('simpleSearchMunicipio', $attrName, $inputOptions, $helperOptions); | |
160 | + } | |
161 | + | |
162 | + public function simpleSearchMatricula($attrName, $inputOptions = array(), $helperOptions = array()) { | |
163 | + $this->simpleSearchResourceInput('simpleSearchMatricula', $attrName, $inputOptions, $helperOptions); | |
164 | + } | |
165 | + | |
166 | + public function simpleSearchAluno($attrName, $inputOptions = array(), $helperOptions = array()) { | |
167 | + $this->simpleSearchResourceInput('simpleSearchAluno', $attrName, $inputOptions, $helperOptions); | |
168 | + } | |
169 | + | |
170 | + // multiple search resource input helper | |
171 | + | |
172 | + | |
173 | + /*public function multipleSearchDeficienciasAjax($attrName, $inputOptions = array(), $helperOptions = array()) { | |
174 | + $this->multipleSearchResourceInput('multipleSearchDeficiencias', $attrName, $inputOptions, $helperOptions); | |
175 | + }*/ | |
176 | + | |
177 | + public function multipleSearchDeficiencias($attrName, $inputOptions = array(), $helperOptions = array()) { | |
178 | + $this->multipleSearchResourceInput('multipleSearchDeficiencias', $attrName, $inputOptions, $helperOptions); | |
179 | + } | |
180 | + | |
181 | + // resource input helpers | |
182 | + | |
183 | + public function religiao($inputOptions = array(), $helperOptions = array()) { | |
184 | + $this->resourceInput('religiao', $this->mergeInputOptions($inputOptions, $helperOptions)); | |
185 | + } | |
186 | + | |
187 | + public function beneficio($inputOptions = array(), $helperOptions = array()) { | |
188 | + $this->resourceInput('beneficio', $this->mergeInputOptions($inputOptions, $helperOptions)); | |
189 | + } | |
190 | + | |
191 | + public function estadoCivil($inputOptions = array(), $helperOptions = array()) { | |
192 | + $this->resourceInput('estadoCivil', $this->mergeInputOptions($inputOptions, $helperOptions)); | |
193 | + } | |
194 | + | |
195 | + public function turmaTurno($inputOptions = array(), $helperOptions = array()) { | |
196 | + $this->resourceInput('turmaTurno', $this->mergeInputOptions($inputOptions, $helperOptions)); | |
197 | + } | |
198 | + | |
199 | + // protected methods | |
200 | + | |
201 | + protected function resourceInput($helperName, $options = array()) { | |
202 | + $helperClassName = "Portabilis_View_Helper_Input_Resource_" . ucfirst($helperName); | |
203 | + | |
204 | + $this->includeHelper($helperClassName); | |
205 | + $helper = new $helperClassName($this->viewInstance, $this); | |
206 | + $helper->$helperName($options); | |
207 | + } | |
208 | + | |
209 | + protected function simpleSearchResourceInput($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) { | |
210 | + $options = $this->mergeInputOptions($inputOptions, $helperOptions); | |
211 | + | |
212 | + $helperClassName = 'Portabilis_View_Helper_Input_Resource_' . ucfirst($helperName); | |
213 | + $this->includeHelper($helperClassName); | |
214 | + | |
215 | + $helper = new $helperClassName($this->viewInstance, $this); | |
216 | + $helper->$helperName($attrName, $options); | |
217 | + } | |
218 | + | |
219 | + protected function multipleSearchResourceInput($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) { | |
220 | + $this->simpleSearchResourceInput($helperName, $attrName, $inputOptions, $helperOptions); | |
221 | + } | |
222 | + | |
223 | + protected function includeHelper($helperClassName) { | |
224 | + $classPath = str_replace('_', '/', $helperClassName) . '.php'; | |
225 | + | |
226 | + // usado include_once para continuar execução script mesmo que o path inexista. | |
227 | + include_once $classPath; | |
228 | + | |
229 | + if (! class_exists($helperClassName)) | |
230 | + throw new CoreExt_Exception("Class '$helperClassName' not found in path '$classPath'"); | |
231 | + } | |
232 | + | |
233 | + protected function mergeInputOptions($inputOptions = array(), $helperOptions = array()) { | |
234 | + if (! empty($inputOptions) && isset($helperOptions['options'])) | |
235 | + throw new Exception("Don't send \$inputOptions and \$helperOptions['options'] at the same time!"); | |
236 | + | |
237 | + $defaultOptions = array('options' => $inputOptions); | |
238 | + $options = Portabilis_Array_Utils::merge($helperOptions, $defaultOptions); | |
239 | + | |
240 | + //foreach($helperOptions as $k => $v) { | |
241 | + // $options[$k] = $v; | |
242 | + //} | |
243 | + | |
244 | + return $options; | |
245 | + } | |
246 | +} | ... | ... |