Changes between Version 2 and Version 3 of WF/Tutorialdedesenvolvimentodeumprocessosimples
- Timestamp:
- 07/24/07 17:23:48 (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WF/Tutorialdedesenvolvimentodeumprocessosimples
v2 v3 238 238 239 239 {{{ 240 241 240 <?php 242 241 243 242 $application = new AvaliarController(new AvaliarModel($env), $env); 244 245 243 $application->run($_REQUEST['action']); 246 244 247 245 ?> 248 249 }}} 250 246 }}} 251 247 252 248 … … 258 254 259 255 $application = new ComporSolicitacaoController(new ComporSolicitacaoModel($env), $env); 260 261 256 $application->run($_REQUEST['action']); 262 257 … … 274 269 275 270 $application = new ExecutarController(new ExecutarModel($env), $env); 276 277 271 $application->run($_REQUEST['action']); 278 272 … … 290 284 291 285 $application = new InformarResultadoController(new InformarResultadoModel($env), $env); 292 293 286 $application->run($_REQUEST['action']); 294 287 … … 310 303 311 304 <br> 312 313 305 <input type="submit" name="action" value="Aprovar" /> 314 315 306 <input type="submit" name="action" value="Rejeitar" /> 316 307 … … 324 315 325 316 <table> 326 327 317 <tr> 328 329 318 <td><label>Título</label></td> 330 331 319 <td><input type="text" name="titulo" value="{$titulo}" /></td> 332 333 320 </tr> 334 335 321 <tr> 336 337 322 <td><label>Descrição</label></td> 338 339 323 <td><textarea name="descricao">{$descricao}</textarea></td> 340 341 324 </tr> 342 343 325 </table> 344 326 … … 358 340 359 341 <strong>Procedimento Executado:</strong><br/> 360 361 342 <textarea name="procedimento" cols="50" rows="7"></textarea><br/> 362 363 343 <input type="submit" name="action" value="Finalizar" /> 364 344 … … 372 352 373 353 {include file="info_solicitacao.tpl"} 374 375 354 <br/> 376 377 355 <table> 378 379 356 <tr> 380 381 357 <td><strong>Mensagem</strong></td> 382 383 358 <td>{$mensagem|nl2br}</td> 384 385 359 <tr> 386 387 360 </table> 388 361 … … 396 369 397 370 398 399 371 Por padrão, o Workflow cria um arquivo tpl para cada atividade interativa do processo. O arquivo info_solicitacao.tpl não corresponde a uma atividade, mas sim a um trecho de código que será incluído em outros arquivos tpl. Por isso, não estará na lista de arquivos já existentes, e deverá ser criado através da interface de código, aba templates, da seguinte maneira: 400 372 401 :1 - Clique no botão 'Novo template';402 403 :2 - Escolha a opção 'em_branco.tpl';404 405 :3 - Informe o nome do arquivo e clique em OK406 407 :4 - Inclua o código abaixo373 1 - Clique no botão 'Novo template'; 374 375 2 - Escolha a opção 'em_branco.tpl'; 376 377 3 - Informe o nome do arquivo e clique em OK 378 379 4 - Inclua o código abaixo 408 380 409 381 {{{ 410 382 411 383 <table> 412 413 384 <tr> 414 415 385 <td><strong>Solicitante</strong></td> 416 417 386 <td>{$solicitante_desc}</td> 418 419 387 </tr> 420 421 388 <tr> 422 423 389 <td><strong>Data</strong></td> 424 425 390 <td>{$data}</td> 426 427 391 </tr> 428 429 392 <tr> 430 431 393 <td><strong>Título</strong></td> 432 433 394 <td>{$titulo}</td> 434 435 395 </tr> 436 437 396 <tr> 438 439 397 <td><strong>Descrição</strong></td> 440 441 398 <td>{$descricao|nl2br}</td> 442 443 399 </tr> 444 445 400 </table> 446 401 … … 457 412 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: 458 413 459 :1 - Clique no botão 'Novo Include'; 460 461 :2 - Escolha a opção 'em_branco.php'; 462 463 :3 - Informe o nome do arquivo e clique em OK 464 465 :4 - Inclua o código correspondente 466 414 1 - Clique no botão 'Novo Include'; 415 2 - Escolha a opção 'em_branco.php'; 416 3 - Informe o nome do arquivo e clique em OK 417 4 - Inclua o código correspondente 467 418 468 419 … … 476 427 477 428 { 478 479 429 function __default () 480 481 { 482 430 { 483 431 $this->model->defaultAction(); 484 485 432 $this->loadViewVars(); 486 487 433 $this->showForm($this->AVALIAR); 488 489 } 490 491 434 } 492 435 493 436 function aprovar() 494 495 { 496 437 { 497 438 $this->model->aprovarAction(); 498 499 } 500 501 439 } 502 440 503 441 function rejeitar() 504 505 { 506 442 { 507 443 $this->model->rejeitarAction(); 508 509 } 510 444 } 445 446 function run($action) 447 { 448 $this->dispatch($action); 449 } 450 451 } 452 453 ?> 454 455 }}} 456 457 458 459 '''class.avaliar.model.inc.php''' 460 461 {{{ 462 <?php 463 class AvaliarModel extends Model 464 { 465 function defaultAction() 466 { 467 $this->updateAttributes(); 468 $this->addViewVar('titulo', $this->_titulo); 469 $this->addViewVar('descricao', $this->_descricao); 470 $this->addViewVar('data', $this->_data); 471 $this->addViewVar('solicitante_desc', $this->_solicitante_desc); 472 473 return true; 474 475 } 476 477 function aprovarAction() 478 { 479 $this->instance->setNextActivity('Executar'); 480 $this->commitInstance(); 481 482 return true; 483 484 } 485 486 function rejeitarAction() 487 { 488 $this->updateAttributes(); 489 $this->instance->setNextActivity('Informar Resultado'); 490 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ 491 $this->_mensagem = "Sua solicitação foi rejeitada"; 492 $this->updateInstance(); 493 $this->commitInstance(); 494 495 return true; 496 497 } 498 499 } 500 501 ?> 502 503 }}} 504 505 506 507 '''class.compor.solicitacao.controller.inc.php''' 508 {{{ 509 510 <?php 511 512 class ComporSolicitacaoController extends Controller 513 { 514 function __default () 515 { 516 $this->model->defaultAction(); 517 $this->loadViewVars(); 518 $this->showForm($this->COMPOR_SOLICITACAO); 519 } 520 521 function enviar() 522 { 523 $this->model->enviarAction(); 524 $this->loadViewVars(); 525 } 511 526 512 527 513 528 function run($action) 514 515 { 516 529 { 517 530 $this->dispatch($action); 518 519 } 520 521 } 522 523 ?> 524 525 }}} 526 527 528 529 '''class.avaliar.model.inc.php''' 530 531 {{{ 532 533 <?php 534 535 class AvaliarModel extends Model 536 537 { 538 531 } 532 533 } 534 535 ?> 536 537 }}} 538 539 540 541 '''class.compor.solicitacao.model.inc.php''' 542 543 {{{ 544 545 <?php 546 class ComporSolicitacaoModel extends Model 547 { 539 548 function defaultAction() 540 541 { 542 549 { 550 return true; 551 } 552 553 function inputValidate($form) 554 { 555 $msgerro = Array(); 556 557 /* título não pode ser vazio */ 558 559 if (isset($form['titulo']) && !empty($form['titulo'])) 560 $this->_titulo = $form['titulo']; 561 else 562 $msgerro[] = 'É necessário fornecer um título'; 563 564 565 if (isset($form['descricao']) && !empty($form['descricao'])) 566 $this->_descricao = $form['descricao']; 567 else 568 $msgerro[] = 'É necessário fornecer uma descrição'; 569 570 return $msgerro; 571 572 } 573 574 575 function enviarAction() 576 { 577 /* se não houve erros */ 578 if (count($this->activity->error = $this->inputValidate($this->request)) == 0) 579 { 580 581 $this->_solicitante = $this->getWfProperty('wf_user_id'); 582 $this->_solicitante_desc = $this->getWfProperty('wf_user_cnname'); 583 $this->_data = date('d/m/Y Hhi'); 584 $this->updateInstance(); 585 $this->commitInstance(); 586 587 return true; 588 } 589 else 590 591 { 592 $this->addViewVar('titulo', $this->_titulo); 593 $this->addViewVar('descricao', $this->_descricao); 594 return false; 595 596 } 597 598 } 599 600 } 601 602 ?> 603 604 }}} 605 606 607 608 '''class.controller.inc.php''' 609 610 {{{ 611 612 <?php 613 614 class Controller extends BaseController 615 616 { 617 618 var $COMPOR_SOLICITACAO = 'Compor_Solicitao.tpl'; 619 var $AVALIAR = 'Avaliar.tpl'; 620 var $EXECUTAR = 'Executar.tpl'; 621 var $INFORMAR_RESULTADO = 'Informar_Resultado.tpl'; 622 623 function Controller(&$model , &$env) 624 { 625 626 $this->super(&$model , &$env); 627 628 } 629 630 } 631 632 ?> 633 634 }}} 635 636 637 638 '''class.executar.controller.inc.php''' 639 {{{ 640 <?php 641 642 class ExecutarController extends Controller 643 { 644 function __default () 645 { 646 $this->model->defaultAction(); 647 $this->loadViewVars(); 648 $this->showForm($this->EXECUTAR); 649 650 } 651 652 653 654 function finalizar() 655 { 656 $this->model->finalizarAction(); 657 658 } 659 660 661 662 function run($action) 663 664 { 665 $this->dispatch($action); 666 667 } 668 669 } 670 671 ?> 672 673 }}} 674 675 676 677 '''class.executar.model.inc.php''' 678 679 {{{ 680 <?php 681 682 class ExecutarModel extends Model 683 684 { 685 function defaultAction() 686 { 543 687 $this->updateAttributes(); 544 545 688 $this->addViewVar('titulo', $this->_titulo); 546 547 689 $this->addViewVar('descricao', $this->_descricao); 548 549 690 $this->addViewVar('data', $this->_data); 550 551 691 $this->addViewVar('solicitante_desc', $this->_solicitante_desc); 552 692 553 693 554 555 694 return true; 556 695 … … 558 697 559 698 560 561 function aprovarAction() 562 563 { 564 565 $this->instance->setNextActivity('Executar'); 566 567 $this->commitInstance(); 568 569 570 571 return true; 572 573 } 574 575 576 577 function rejeitarAction() 578 579 { 580 699 function finalizarAction() 700 { 581 701 $this->updateAttributes(); 582 583 $this->instance->setNextActivity('Informar Resultado');584 585 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */586 587 $this->_mensagem = "Sua solicitação foi rejeitada";588 589 $this->updateInstance();590 591 $this->commitInstance();592 593 594 595 return true;596 597 }598 599 }600 601 ?>602 603 }}}604 605 606 607 '''class.compor.solicitacao.controller.inc.php'''608 609 {{{610 611 <?php612 613 class ComporSolicitacaoController extends Controller614 615 {616 617 function __default ()618 619 {620 621 $this->model->defaultAction();622 623 $this->loadViewVars();624 625 $this->showForm($this->COMPOR_SOLICITACAO);626 627 }628 629 630 631 function enviar()632 633 {634 635 $this->model->enviarAction();636 637 $this->loadViewVars();638 639 }640 641 642 643 function run($action)644 645 {646 647 $this->dispatch($action);648 649 }650 651 }652 653 ?>654 655 }}}656 657 658 659 '''class.compor.solicitacao.model.inc.php'''660 661 {{{662 663 <?php664 665 class ComporSolicitacaoModel extends Model666 667 {668 669 function defaultAction()670 671 {672 673 return true;674 675 }676 677 678 679 function inputValidate($form)680 681 {682 683 $msgerro = Array();684 685 686 687 /* título não pode ser vazio */688 689 if (isset($form['titulo']) && !empty($form['titulo']))690 691 $this->_titulo = $form['titulo'];692 693 else694 695 $msgerro[] = 'É necessário fornecer um título';696 697 698 699 if (isset($form['descricao']) && !empty($form['descricao']))700 701 $this->_descricao = $form['descricao'];702 703 else704 705 $msgerro[] = 'É necessário fornecer uma descrição';706 707 708 709 return $msgerro;710 711 }712 713 714 715 function enviarAction()716 717 {718 719 /* se não houve erros */720 721 if (count($this->activity->error = $this->inputValidate($this->request)) == 0)722 723 {724 725 $this->_solicitante = $this->getWfProperty('wf_user_id');726 727 $this->_solicitante_desc = $this->getWfProperty('wf_user_cnname');728 729 $this->_data = date('d/m/Y Hhi');730 731 $this->updateInstance();732 733 $this->commitInstance();734 735 return true;736 737 }738 739 else740 741 {742 743 $this->addViewVar('titulo', $this->_titulo);744 745 $this->addViewVar('descricao', $this->_descricao);746 747 return false;748 749 }750 751 }752 753 }754 755 ?>756 757 }}}758 759 760 761 '''class.controller.inc.php'''762 763 {{{764 765 <?php766 767 class Controller extends BaseController768 769 {770 771 var $COMPOR_SOLICITACAO = 'Compor_Solicitao.tpl';772 773 var $AVALIAR = 'Avaliar.tpl';774 775 var $EXECUTAR = 'Executar.tpl';776 777 var $INFORMAR_RESULTADO = 'Informar_Resultado.tpl';778 779 780 781 function Controller(&$model , &$env)782 783 {784 785 $this->super(&$model , &$env);786 787 }788 789 }790 791 ?>792 793 }}}794 795 796 797 '''class.executar.controller.inc.php'''798 799 {{{800 801 <?php802 803 class ExecutarController extends Controller804 805 {806 807 function __default ()808 809 {810 811 $this->model->defaultAction();812 813 $this->loadViewVars();814 815 $this->showForm($this->EXECUTAR);816 817 }818 819 820 821 function finalizar()822 823 {824 825 $this->model->finalizarAction();826 827 }828 829 830 831 function run($action)832 833 {834 835 $this->dispatch($action);836 837 }838 839 }840 841 ?>842 843 }}}844 845 846 847 '''class.executar.model.inc.php'''848 849 {{{850 851 <?php852 853 class ExecutarModel extends Model854 855 {856 857 function defaultAction()858 859 {860 861 $this->updateAttributes();862 863 $this->addViewVar('titulo', $this->_titulo);864 865 $this->addViewVar('descricao', $this->_descricao);866 867 $this->addViewVar('data', $this->_data);868 869 $this->addViewVar('solicitante_desc', $this->_solicitante_desc);870 871 872 873 return true;874 875 }876 877 878 879 function finalizarAction()880 881 {882 883 $this->updateAttributes();884 885 702 $this->_mensagem = "Sua solicitação foi atendida pelo técnico " 886 887 703 . $this->getWfProperty('wf_user_cnname') 888 889 704 . ". 890 705 <strong>Procedimento executado:</strong> 891 706 " . $this->request['procedimento']; 892 893 707 $this->updateInstance(); 894 895 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ 896 708 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ 897 709 $this->commitInstance(); 898 710 899 900 901 711 return true; 902 712 … … 912 722 913 723 '''class.informar.resultado.controller.inc.php''' 914 915 724 {{{ 916 725 … … 918 727 919 728 class InformarResultadoController extends Controller 920 921 { 922 729 { 923 730 function __default () 924 731 925 732 { 926 927 733 $this->model->defaultAction(); 928 929 734 $this->loadViewVars(); 930 931 735 $this->showForm($this->INFORMAR_RESULTADO); 932 933 } 934 935 736 } 936 737 937 738 function encerrar() 938 939 { 940 739 { 941 740 $this->model->encerrarAction(); 942 943 } 944 945 741 } 946 742 947 743 function run($action) 948 949 { 950 744 { 951 745 $this->dispatch($action); 952 953 746 } 954 747 … … 964 757 965 758 {{{ 966 967 <?php 968 759 <?php 969 760 class InformarResultadoModel extends Model 970 971 { 972 761 { 973 762 function defaultAction() 974 975 { 976 763 { 977 764 $this->updateAttributes(); 978 979 765 $this->addViewVar('titulo', $this->_titulo); 980 981 766 $this->addViewVar('descricao', $this->_descricao); 982 983 767 $this->addViewVar('data', $this->_data); 984 985 768 $this->addViewVar('solicitante_desc', $this->_solicitante_desc); 986 987 769 $this->addViewVar('mensagem', $this->_mensagem); 988 770 989 990 991 771 return true; 992 993 } 994 995 772 } 996 773 997 774 function encerrarAction() 998 999 { 1000 775 { 1001 776 $this->commitInstance(); 1002 1003 1004 1005 777 return true; 1006 1007 } 1008 1009 } 1010 1011 ?> 1012 1013 }}} 1014 778 } 779 780 } 781 782 ?> 783 784 }}} 1015 785 1016 786 … … 1020 790 1021 791 <?php 1022 1023 792 class Model extends BaseModel 1024 1025 { 1026 793 { 1027 794 var $_titulo; 1028 1029 795 var $_descricao; 1030 1031 796 var $_solicitante; 1032 1033 797 var $_solicitante_desc; 1034 1035 798 var $_data; 1036 1037 799 var $_mensagem; 1038 800 1039 1040 1041 801 function Model(&$env) 1042 1043 { 1044 802 { 1045 803 $this->super(&$env); 1046 804 … … 1058 816 1059 817 {{{ 1060 1061 818 <?php 1062 819 … … 1064 821 1065 822 wf_include('class.controller.inc.php'); 1066 1067 823 wf_include('class.compor.solicitacao.controller.inc.php'); 1068 1069 824 wf_include('class.avaliar.controller.inc.php'); 1070 1071 825 wf_include('class.executar.controller.inc.php'); 1072 1073 826 wf_include('class.informar.resultado.controller.inc.php'); 1074 827 … … 1078 831 1079 832 wf_include('class.model.inc.php'); 1080 1081 833 wf_include('class.compor.solicitacao.model.inc.php'); 1082 1083 834 wf_include('class.avaliar.model.inc.php'); 1084 1085 835 wf_include('class.executar.model.inc.php'); 1086 1087 836 wf_include('class.informar.resultado.model.inc.php'); 1088 837 … … 1092 841 1093 842 1094 1095 1096 1097 843 ==== Finalização ==== 1098 844 1099 Para finalizar o processo,é necessário compilá-lo e ativá-lo.Para isto,acessamos a interface de Administração de [wiki:WF _Processos Processos]845 Para finalizar o processo,é necessário compilá-lo e ativá-lo.Para isto,acessamos a interface de Administração de [wiki:WF/Processos Processos] 1100 846 ,abrimos o nosso processo e clicamos em "Compilação" e depoi sem "ativar".Uma vez feito isso,o processo estará disponível aquem tem direito(os que estão nos perfis do processo). 1101 847