| 1 | = Tutorial de Desenvolvimento de um Processo Simples = |
| 2 | [[WikiInclude(WF/tableofcontents)]] |
| 3 | == Codificar os Includes == |
| 4 | Os próximos arquivos devem ser incluídos de forma semelhante como foi feito para o arquivo info_solicitação.tpl anteriormente, só que desta vez será usada a aba 'Includes', da interface de código. Para cada arquivo a ser incluído, execute: |
| 5 | |
| 6 | 1 - Clique no botão 'Novo Include'; |
| 7 | |
| 8 | 2 - Escolha a opção 'em_branco.php'; |
| 9 | |
| 10 | 3 - Informe o nome do arquivo e clique em OK |
| 11 | |
| 12 | 4 - Inclua o código correspondente |
| 13 | |
| 14 | '''class.avaliar.controller.inc.php''' |
| 15 | |
| 16 | {{{ |
| 17 | |
| 18 | <?php |
| 19 | |
| 20 | class AvaliarController extends Controller |
| 21 | |
| 22 | { |
| 23 | function __default () |
| 24 | { |
| 25 | $this->model->defaultAction(); |
| 26 | $this->loadViewVars(); |
| 27 | $this->showForm($this->AVALIAR); |
| 28 | } |
| 29 | |
| 30 | function aprovar() |
| 31 | { |
| 32 | $this->model->aprovarAction(); |
| 33 | } |
| 34 | |
| 35 | function rejeitar() |
| 36 | { |
| 37 | $this->model->rejeitarAction(); |
| 38 | } |
| 39 | |
| 40 | function run($action) |
| 41 | { |
| 42 | $this->dispatch($action); |
| 43 | } |
| 44 | |
| 45 | } |
| 46 | |
| 47 | ?> |
| 48 | |
| 49 | }}} |
| 50 | |
| 51 | '''class.avaliar.model.inc.php''' |
| 52 | |
| 53 | {{{ |
| 54 | |
| 55 | <?php |
| 56 | class AvaliarModel extends Model |
| 57 | { |
| 58 | function defaultAction() |
| 59 | { |
| 60 | $this->updateAttributes(); |
| 61 | $this->addViewVar('titulo', $this->_titulo); |
| 62 | $this->addViewVar('descricao', $this->_descricao); |
| 63 | $this->addViewVar('data', $this->_data); |
| 64 | $this->addViewVar('solicitante_desc', $this->_solicitante_desc); |
| 65 | |
| 66 | return true; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | function aprovarAction() |
| 71 | { |
| 72 | $this->instance->setNextActivity('Executar'); |
| 73 | $this->commitInstance(); |
| 74 | |
| 75 | return true; |
| 76 | |
| 77 | } |
| 78 | |
| 79 | function rejeitarAction() |
| 80 | { |
| 81 | $this->updateAttributes(); |
| 82 | $this->instance->setNextActivity('Informar Resultado'); |
| 83 | $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ |
| 84 | $this->_mensagem = "Sua solicitação foi rejeitada"; |
| 85 | $this->updateInstance(); |
| 86 | $this->commitInstance(); |
| 87 | |
| 88 | return true; |
| 89 | |
| 90 | } |
| 91 | |
| 92 | } |
| 93 | |
| 94 | ?> |
| 95 | |
| 96 | }}} |
| 97 | |
| 98 | '''class.compor.solicitacao.controller.inc.php''' |
| 99 | |
| 100 | {{{ |
| 101 | |
| 102 | <?php |
| 103 | |
| 104 | class ComporSolicitacaoController extends Controller |
| 105 | { |
| 106 | function __default () |
| 107 | { |
| 108 | $this->model->defaultAction(); |
| 109 | $this->loadViewVars(); |
| 110 | $this->showForm($this->COMPOR_SOLICITACAO); |
| 111 | } |
| 112 | |
| 113 | function enviar() |
| 114 | { |
| 115 | $this->model->enviarAction(); |
| 116 | $this->loadViewVars(); |
| 117 | } |
| 118 | |
| 119 | |
| 120 | function run($action) |
| 121 | { |
| 122 | $this->dispatch($action); |
| 123 | } |
| 124 | |
| 125 | } |
| 126 | |
| 127 | ?> |
| 128 | |
| 129 | }}} |
| 130 | |
| 131 | '''class.compor.solicitacao.model.inc.php''' |
| 132 | |
| 133 | {{{ |
| 134 | |
| 135 | <?php |
| 136 | class ComporSolicitacaoModel extends Model |
| 137 | { |
| 138 | function defaultAction() |
| 139 | { |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | function inputValidate($form) |
| 144 | { |
| 145 | $msgerro = Array(); |
| 146 | |
| 147 | /* título não pode ser vazio */ |
| 148 | |
| 149 | if (isset($form['titulo']) && !empty($form['titulo'])) |
| 150 | $this->_titulo = $form['titulo']; |
| 151 | else |
| 152 | $msgerro[] = 'É necessário fornecer um título'; |
| 153 | |
| 154 | |
| 155 | if (isset($form['descricao']) && !empty($form['descricao'])) |
| 156 | $this->_descricao = $form['descricao']; |
| 157 | else |
| 158 | $msgerro[] = 'É necessário fornecer uma descrição'; |
| 159 | |
| 160 | return $msgerro; |
| 161 | |
| 162 | } |
| 163 | |
| 164 | function enviarAction() |
| 165 | { |
| 166 | /* se não houve erros */ |
| 167 | if (count($this->activity->error = $this->inputValidate($this->request)) == 0) |
| 168 | { |
| 169 | |
| 170 | $this->_solicitante = $this->getWfProperty('wf_user_id'); |
| 171 | $this->_solicitante_desc = $this->getWfProperty('wf_user_cnname'); |
| 172 | $this->_data = date('d/m/Y H\hi'); |
| 173 | $this->updateInstance(); |
| 174 | $this->commitInstance(); |
| 175 | |
| 176 | return true; |
| 177 | } |
| 178 | else |
| 179 | |
| 180 | { |
| 181 | $this->addViewVar('titulo', $this->_titulo); |
| 182 | $this->addViewVar('descricao', $this->_descricao); |
| 183 | return false; |
| 184 | |
| 185 | } |
| 186 | |
| 187 | } |
| 188 | |
| 189 | } |
| 190 | |
| 191 | ?> |
| 192 | |
| 193 | }}} |
| 194 | |
| 195 | '''class.controller.inc.php''' |
| 196 | |
| 197 | {{{ |
| 198 | |
| 199 | <?php |
| 200 | |
| 201 | class Controller extends BaseController |
| 202 | |
| 203 | { |
| 204 | |
| 205 | var $COMPOR_SOLICITACAO = 'Compor_Solicitao.tpl'; |
| 206 | var $AVALIAR = 'Avaliar.tpl'; |
| 207 | var $EXECUTAR = 'Executar.tpl'; |
| 208 | var $INFORMAR_RESULTADO = 'Informar_Resultado.tpl'; |
| 209 | |
| 210 | function Controller(&$model , &$env) |
| 211 | { |
| 212 | |
| 213 | $this->super(&$model , &$env); |
| 214 | |
| 215 | } |
| 216 | |
| 217 | } |
| 218 | |
| 219 | ?> |
| 220 | |
| 221 | }}} |
| 222 | |
| 223 | '''class.executar.controller.inc.php''' |
| 224 | |
| 225 | {{{ |
| 226 | |
| 227 | <?php |
| 228 | |
| 229 | class ExecutarController extends Controller |
| 230 | { |
| 231 | function __default () |
| 232 | { |
| 233 | $this->model->defaultAction(); |
| 234 | $this->loadViewVars(); |
| 235 | $this->showForm($this->EXECUTAR); |
| 236 | |
| 237 | } |
| 238 | |
| 239 | function finalizar() |
| 240 | { |
| 241 | $this->model->finalizarAction(); |
| 242 | |
| 243 | } |
| 244 | |
| 245 | function run($action) |
| 246 | |
| 247 | { |
| 248 | $this->dispatch($action); |
| 249 | |
| 250 | } |
| 251 | |
| 252 | } |
| 253 | |
| 254 | ?> |
| 255 | |
| 256 | }}} |
| 257 | |
| 258 | '''class.executar.model.inc.php''' |
| 259 | |
| 260 | {{{ |
| 261 | |
| 262 | <?php |
| 263 | |
| 264 | class ExecutarModel extends Model |
| 265 | |
| 266 | { |
| 267 | function defaultAction() |
| 268 | { |
| 269 | $this->updateAttributes(); |
| 270 | $this->addViewVar('titulo', $this->_titulo); |
| 271 | $this->addViewVar('descricao', $this->_descricao); |
| 272 | $this->addViewVar('data', $this->_data); |
| 273 | $this->addViewVar('solicitante_desc', $this->_solicitante_desc); |
| 274 | |
| 275 | |
| 276 | return true; |
| 277 | |
| 278 | } |
| 279 | |
| 280 | function finalizarAction() |
| 281 | { |
| 282 | $this->updateAttributes(); |
| 283 | $this->_mensagem = "Sua solicitação foi atendida pelo técnico " |
| 284 | . $this->getWfProperty('wf_user_cnname') |
| 285 | . ".\n<strong>Procedimento executado:</strong>\n" . $this->request['procedimento']; |
| 286 | $this->updateInstance(); |
| 287 | $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ |
| 288 | $this->commitInstance(); |
| 289 | |
| 290 | return true; |
| 291 | |
| 292 | } |
| 293 | |
| 294 | } |
| 295 | |
| 296 | ?> |
| 297 | |
| 298 | }}} |
| 299 | |
| 300 | '''class.informar.resultado.controller.inc.php''' |
| 301 | |
| 302 | {{{ |
| 303 | |
| 304 | <?php |
| 305 | |
| 306 | class InformarResultadoController extends Controller |
| 307 | { |
| 308 | function __default () |
| 309 | |
| 310 | { |
| 311 | $this->model->defaultAction(); |
| 312 | $this->loadViewVars(); |
| 313 | $this->showForm($this->INFORMAR_RESULTADO); |
| 314 | } |
| 315 | |
| 316 | function encerrar() |
| 317 | { |
| 318 | $this->model->encerrarAction(); |
| 319 | } |
| 320 | |
| 321 | function run($action) |
| 322 | { |
| 323 | $this->dispatch($action); |
| 324 | } |
| 325 | |
| 326 | } |
| 327 | |
| 328 | ?> |
| 329 | |
| 330 | }}} |
| 331 | |
| 332 | '''class.informar.resultado.model.inc.php''' |
| 333 | |
| 334 | {{{ |
| 335 | |
| 336 | <?php |
| 337 | class InformarResultadoModel extends Model |
| 338 | { |
| 339 | function defaultAction() |
| 340 | { |
| 341 | $this->updateAttributes(); |
| 342 | $this->addViewVar('titulo', $this->_titulo); |
| 343 | $this->addViewVar('descricao', $this->_descricao); |
| 344 | $this->addViewVar('data', $this->_data); |
| 345 | $this->addViewVar('solicitante_desc', $this->_solicitante_desc); |
| 346 | $this->addViewVar('mensagem', $this->_mensagem); |
| 347 | |
| 348 | return true; |
| 349 | } |
| 350 | |
| 351 | function encerrarAction() |
| 352 | { |
| 353 | $this->commitInstance(); |
| 354 | return true; |
| 355 | } |
| 356 | |
| 357 | } |
| 358 | |
| 359 | ?> |
| 360 | |
| 361 | }}} |
| 362 | |
| 363 | '''class.model.inc.php''' |
| 364 | |
| 365 | {{{ |
| 366 | |
| 367 | <?php |
| 368 | class Model extends BaseModel |
| 369 | { |
| 370 | var $_titulo; |
| 371 | var $_descricao; |
| 372 | var $_solicitante; |
| 373 | var $_solicitante_desc; |
| 374 | var $_data; |
| 375 | var $_mensagem; |
| 376 | |
| 377 | function Model(&$env) |
| 378 | { |
| 379 | $this->super(&$env); |
| 380 | |
| 381 | } |
| 382 | |
| 383 | } |
| 384 | |
| 385 | ?> |
| 386 | |
| 387 | }}} |
| 388 | |
| 389 | '''shared.php''' |
| 390 | |
| 391 | {{{ |
| 392 | |
| 393 | <?php |
| 394 | |
| 395 | //camada de controle do processo |
| 396 | |
| 397 | wf_include('class.controller.inc.php'); |
| 398 | wf_include('class.compor.solicitacao.controller.inc.php'); |
| 399 | wf_include('class.avaliar.controller.inc.php'); |
| 400 | wf_include('class.executar.controller.inc.php'); |
| 401 | wf_include('class.informar.resultado.controller.inc.php'); |
| 402 | |
| 403 | //camada da lógica de negócios |
| 404 | |
| 405 | wf_include('class.model.inc.php'); |
| 406 | wf_include('class.compor.solicitacao.model.inc.php'); |
| 407 | wf_include('class.avaliar.model.inc.php'); |
| 408 | wf_include('class.executar.model.inc.php'); |
| 409 | wf_include('class.informar.resultado.model.inc.php'); |
| 410 | |
| 411 | ?> |
| 412 | |
| 413 | }}} |
| 414 | ---- |
| 415 | {{{ |
| 416 | #!html |
| 417 | <a href="http://www.expressolivre.org/dev/wiki/WF/Tutorialdedesenvolvimentodeumprocessosimples">1. Introdução</a><br> |
| 418 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialespecificacao">2. Especificação</a><br> |
| 419 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialprojeto">3. Projeto</a><br> |
| 420 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialfluxo">3.1. Criar o Fluxo</a><br> |
| 421 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialprocesso">3.2. Criar o Processo</a><br> |
| 422 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialativtrans">3.3. Criar as Atividades / Transições / Perfis</a><br> |
| 423 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialperfis">3.4. Mapear os Perfis</a><br> |
| 424 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialimplementação">4. Implementação</a><br> |
| 425 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialatividades">4.1. Codificar as Atividades</a><br> |
| 426 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialtemplates">4.2. Codificar os Templates</a><br> |
| 427 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialincludes">4.3. Codificar os Includes</a><br> |
| 428 | <a href="http://www.expressolivre.org/dev/wiki/WF/tutorialfinalizacao">5. Finalização</a> |
| 429 | }}} |