Conheça  A Ferramenta LowCode mais moderna e veloz para desenvolvimento PHP: Adianti Creator
Carregando um THtmlEditor Estou tentando fazer um programa que gere requisições através de um mix entre um formulário e templetes, gostaria de poder editar estes templetes se necessario. Duvida : como colocar o conteudo de um arquivo html em appresourcestemplate1.html em um $html = new THtmlEditor('html_text'); Estou usando como base o TabularReportView onde acrescentei a linha $html = new THtmlEditor('html_...
LJ
Carregando um THtmlEditor  
Fechado
Estou tentando fazer um programa que gere requisições através de um mix entre um formulário e templetes, gostaria de poder editar estes templetes se necessario.
Duvida : como colocar o conteudo de um arquivo html em appresourcestemplate1.html em um $html = new THtmlEditor('html_text');

Estou usando como base o TabularReportView onde acrescentei a linha $html = new THtmlEditor('html_text');

$html->setValue(appresourcestemplate1.html)


Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (6)


PD

boa noite poderia explicar melhor, você quer gerar relatorio em pdf ou apenas views em html?
LJ

Tenho um template de envio de requisição de ferias, quero preencher com os dados do funcionario e depois imprimi-lo.
Já consegui mesclar com os dados dos funcionarios na variavel $html , agora só falta colocar esta variavel em nova pagina ou nova aba com um botao de imprimir .Linha 130 do codigo abaixo, esta comentada.
Obrigado a todos.


 
  1. <?php
  2. /**
  3. * Tabular report
  4. *
  5. * @version 1.0
  6. * @package samples
  7. * @subpackage tutor
  8. * @author Pablo Dall'Oglio
  9. * @copyright Copyright (c) 2006-2014 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10. * @license http://www.adianti.com.br/framework-license
  11. */
  12. class FeriasForm extends TPage
  13. {
  14. private $form; // form
  15. /**
  16. * Class constructor
  17. * Creates the page and the registration form
  18. */
  19. function __construct()
  20. {
  21. parent::__construct();
  22. // creates the form
  23. $this->form = new TForm('form_Customer_Report');
  24. $this->form->class = 'tform'; // CSS class
  25. // creates a table
  26. $table = new TTable;
  27. $table-> width = '100%';
  28. // add the table inside the form
  29. $this->form->add($table);
  30. // create the form fields
  31. $name_id = new ">TDBSeekButton('name_id', 'dsis', 'form_Customer_Report', 'Funcionario', 'nome', 'name_id', 'name');
  32. $name = new TEntry('name');
  33. $dias = new TRadioGroup('dias');
  34. $apartir = new TDate('apartir');
  35. // define the sizes
  36. $name->setSize(200);
  37. $name_id->setSize(50);
  38. $name->setEditable(FALSE);
  39. $apartir->setSize(100);
  40. $dias->setLayout('horizontal');
  41. $items=array();
  42. $items[15]='15';
  43. $items[30]='30';
  44. $dias->addItems($items);
  45. $dias->setValue('15');
  46. // add a row for the field name
  47. $row = $table->addRowSet(new TLabel('Pedido de Ferias'), '');
  48. $row->class = 'tformtitle'; // CSS class
  49. // add the fields into the table
  50. $table->addRowSet(new TLabel('Id' . ': '), array($name_id,$name));
  51. $table->addRowSet(new TLabel('A partir de' . ': '), $apartir);
  52. $table->addRowSet(new TLabel('Dura&ccedil;ao (dias)' . ': '), $dias);
  53. // create an action button (save)
  54. $save_button=new TButton('generate');
  55. $save_button->setAction(new TAction(array($this, 'onGenerate')), 'Generate');
  56. $save_button->setImage('ico_save.png');
  57. // add a row for the form action
  58. $row = $table->addRowSet($save_button, '');
  59. $row->class = 'tformaction';
  60. // define wich are the form fields
  61. $this->form->setFields(array($name,$name_id,$apartir,$dias,$save_button));
  62. // wrap the page content using vertical box
  63. $vbox = new TVBox;
  64. $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  65. $vbox->add($this->form);
  66. parent::add($vbox);
  67. }
  68. /* method onGenerate()
  69. Executed whenever the user clicks at the generate button
  70. */
  71. function onGenerate()
  72. {
  73. try
  74. {
  75. // open a transaction with database 'samples'
  76. TTransaction::open('dsis');
  77. // get the form data into an active record Customer
  78. $object = $this->form->getData();
  79. //salva ba tabela os dados das ferias
  80. //
  81. //programar
  82. //
  83. $funcionario =new Funcionario($object->name_id);
  84. if ($funcionario)
  85. {
  86. // substitui o html
  87. $html = new THtmlRenderer('app/resources/modeloferias.html');
  88. $replace = array();
  89. $replace['name'] = $object->name;
  90. $replace['dias'] = $object->dias;
  91. $replace['apartir'] = $object->apartir;
  92. $replace['matricula'] = $funcionario->matricula;
  93. $replace['cargo'] = $funcionario->cargo_id;
  94. // replace the main section variables
  95. $html->enableSection('main', $replace);
  96. // pega os dados do funcionario ex. matricula, cargo
  97. // apenas para debug
  98. new TMessage('info', $html->getContents());
  99. // preciso que abra o $html em nova Janela apenas com o botão imprimir.
  100. }
  101. else
  102. {
  103. new TMessage('error', 'No records found');
  104. }
  105. // fill the form with the active record data
  106. $this->form->setData($object);
  107. // close the transaction
  108. TTransaction::close();
  109. }
  110. catch (Exception $e) // in case of exception
  111. {
  112. // shows the exception error message
  113. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  114. // undo all pending operations
  115. TTransaction::rollback();
  116. }
  117. }
  118. }
  119. ?>

PD

boa tarde usa uma TWindow para mostrar os dados e coloca um botão de print nela, quando o user clicar ele chama o onGenerate da class FeriasForm, passando o id dofuncionario
LJ

Obrigado, vou tentar.
PD

Oi Luiz,

Para carregar um HTML dentro do THtmlEditor, tente:

 
  1. <?php
  2. $html = new THtmlEditor('nome_campo');
  3. $html->setValue(file_get_contents('app/resources/template1.html'));
  4. ?>


Att,
Pablo
LJ

Obrigado, deu certo.