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 H\hi'); 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 699 function finalizarAction() 700 { 701 $this->updateAttributes(); 702 $this->_mensagem = "Sua solicitação foi atendida pelo técnico " 703 . $this->getWfProperty('wf_user_cnname') 704 . ".\n<strong>Procedimento executado:</strong>\n" . $this->request['procedimento']; 705 $this->updateInstance(); 706 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ 567 707 $this->commitInstance(); 568 708 569 570 571 709 return true; 572 710 573 711 } 574 712 575 576 577 function rejeitarAction() 578 579 { 580 713 } 714 715 ?> 716 717 }}} 718 719 720 721 '''class.informar.resultado.controller.inc.php''' 722 {{{ 723 724 <?php 725 726 class InformarResultadoController extends Controller 727 { 728 function __default () 729 730 { 731 $this->model->defaultAction(); 732 $this->loadViewVars(); 733 $this->showForm($this->INFORMAR_RESULTADO); 734 } 735 736 function encerrar() 737 { 738 $this->model->encerrarAction(); 739 } 740 741 function run($action) 742 { 743 $this->dispatch($action); 744 } 745 746 } 747 748 ?> 749 750 }}} 751 752 753 754 '''class.informar.resultado.model.inc.php''' 755 756 {{{ 757 <?php 758 class InformarResultadoModel extends Model 759 { 760 function defaultAction() 761 { 581 762 $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 763 $this->addViewVar('titulo', $this->_titulo); 764 $this->addViewVar('descricao', $this->_descricao); 765 $this->addViewVar('data', $this->_data); 766 $this->addViewVar('solicitante_desc', $this->_solicitante_desc); 767 $this->addViewVar('mensagem', $this->_mensagem); 768 769 return true; 770 } 771 772 function encerrarAction() 773 { 591 774 $this->commitInstance(); 592 593 594 595 775 return true; 596 597 } 598 599 } 600 601 ?> 602 603 }}} 604 605 606 607 '''class.compor.solicitacao.controller.inc.php''' 608 609 {{{ 610 611 <?php 612 613 class ComporSolicitacaoController extends Controller 614 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 <?php 664 665 class ComporSolicitacaoModel extends Model 666 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 else 694 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 else 704 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 H\hi'); 730 731 $this->updateInstance(); 732 733 $this->commitInstance(); 734 735 return true; 736 737 } 738 739 else 740 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 <?php 766 767 class Controller extends BaseController 768 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 <?php 802 803 class ExecutarController extends Controller 804 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 <?php 852 853 class ExecutarModel extends Model 854 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 $this->_mensagem = "Sua solicitação foi atendida pelo técnico " 886 887 . $this->getWfProperty('wf_user_cnname') 888 889 . ".\n<strong>Procedimento executado:</strong>\n" . $this->request['procedimento']; 890 891 $this->updateInstance(); 892 893 $this->instance->setNextUser($this->_solicitante); /* devolve a instância para o solicitante */ 894 895 $this->commitInstance(); 896 897 898 899 return true; 900 901 } 902 903 } 904 905 ?> 906 907 }}} 908 909 910 911 '''class.informar.resultado.controller.inc.php''' 912 913 {{{ 914 915 <?php 916 917 class InformarResultadoController extends Controller 918 919 { 920 921 function __default () 922 923 { 924 925 $this->model->defaultAction(); 926 927 $this->loadViewVars(); 928 929 $this->showForm($this->INFORMAR_RESULTADO); 930 931 } 932 933 934 935 function encerrar() 936 937 { 938 939 $this->model->encerrarAction(); 940 941 } 942 943 944 945 function run($action) 946 947 { 948 949 $this->dispatch($action); 950 951 } 952 953 } 954 955 ?> 956 957 }}} 958 959 960 961 '''class.informar.resultado.model.inc.php''' 962 963 {{{ 964 965 <?php 966 967 class InformarResultadoModel extends Model 968 969 { 970 971 function defaultAction() 972 973 { 974 975 $this->updateAttributes(); 976 977 $this->addViewVar('titulo', $this->_titulo); 978 979 $this->addViewVar('descricao', $this->_descricao); 980 981 $this->addViewVar('data', $this->_data); 982 983 $this->addViewVar('solicitante_desc', $this->_solicitante_desc); 984 985 $this->addViewVar('mensagem', $this->_mensagem); 986 987 988 989 return true; 990 991 } 992 993 994 995 function encerrarAction() 996 997 { 998 999 $this->commitInstance(); 1000 1001 1002 1003 return true; 1004 1005 } 1006 1007 } 1008 1009 ?> 1010 1011 }}} 1012 776 } 777 778 } 779 780 ?> 781 782 }}} 1013 783 1014 784 … … 1018 788 1019 789 <?php 1020 1021 790 class Model extends BaseModel 1022 1023 { 1024 791 { 1025 792 var $_titulo; 1026 1027 793 var $_descricao; 1028 1029 794 var $_solicitante; 1030 1031 795 var $_solicitante_desc; 1032 1033 796 var $_data; 1034 1035 797 var $_mensagem; 1036 798 1037 1038 1039 799 function Model(&$env) 1040 1041 { 1042 800 { 1043 801 $this->super(&$env); 1044 802 … … 1056 814 1057 815 {{{ 1058 1059 816 <?php 1060 817 … … 1062 819 1063 820 wf_include('class.controller.inc.php'); 1064 1065 821 wf_include('class.compor.solicitacao.controller.inc.php'); 1066 1067 822 wf_include('class.avaliar.controller.inc.php'); 1068 1069 823 wf_include('class.executar.controller.inc.php'); 1070 1071 824 wf_include('class.informar.resultado.controller.inc.php'); 1072 825 … … 1076 829 1077 830 wf_include('class.model.inc.php'); 1078 1079 831 wf_include('class.compor.solicitacao.model.inc.php'); 1080 1081 832 wf_include('class.avaliar.model.inc.php'); 1082 1083 833 wf_include('class.executar.model.inc.php'); 1084 1085 834 wf_include('class.informar.resultado.model.inc.php'); 1086 835 … … 1090 839 1091 840 1092 1093 1094 1095 841 ==== Finalização ==== 1096 842 1097 Para finalizar o processo,é necessário compilá-lo e ativá-lo.Para isto,acessamos a interface de Administração de [wiki:WF _Processos Processos]843 Para finalizar o processo,é necessário compilá-lo e ativá-lo.Para isto,acessamos a interface de Administração de [wiki:WF/Processos Processos] 1098 844 ,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). 1099 845