Lançado Adianti Framework 7.6!
Clique aqui para saber mais
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)


Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


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

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.