Conheça as melhorias da versão 8.0, 8.1, 8.2!
Clique aqui para saber mais
TCOMBO pfoupf não exibe ou esconde campos Bom dia amigos, Preciso de uma ajuda... Quando seleciono um item na datagrid de consulta, o formulario abaixo é chamado e carrega todos os dados corretamente. Porém a função que esconde e existe os campos acionada pelo onchagePFouPJ no momento do carregamento do formulario não é executada. Quando é manipulada manualmente tudo funciona corretamente. O que é preciso ser realizado para ...
MP
TCOMBO pfoupf não exibe ou esconde campos  
Bom dia amigos,

Preciso de uma ajuda... Quando seleciono um item na datagrid de consulta, o formulario abaixo é chamado e carrega todos os dados corretamente. Porém a função que esconde e existe os campos acionada pelo onchagePFouPJ no momento do carregamento do formulario não é executada.

Quando é manipulada manualmente tudo funciona corretamente. O que é preciso ser realizado para que a funcao seja chamada no carregamento do form ?

Obrigado e aguardo uma dica!

 
  1. <?php
  2. /**
  3. * FormVerticalBuilderView
  4. *
  5. * @version 1.0
  6. * @package samples
  7. * @subpackage tutor
  8. * @author Pablo Dall'Oglio
  9. * @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10. * @license http://www.adianti.com.br/framework-license
  11. */
  12. class CadastroPessoasForm extends TPage
  13. {
  14. private $form;
  15. /**
  16. * Class constructor
  17. * Creates the page
  18. */
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->form = new BootstrapFormBuilder('form_cadastro_pessoas');
  23. $this->form->setFormTitle(('Cadastro de Pessoas Físicas e Juridicas'));
  24. $this->form->setFieldSizes('100%');
  25. $this->form->setClientValidation(true);
  26. // create the form fields
  27. $id = new TEntry('id');
  28. $datacadastro = new TEntry('datacadastro');
  29. $datacadastro->setValue(date("d/m/Y"));
  30. $novo = TSession::getValue('login');
  31. $statuscadastro = new TEntry('statuscadastro');
  32. $motivo = new TDBUniqueSearch('motivo', 'db_isis360', 'tb_CadastroPessoasMotivo', 'id', 'motivo');
  33. $relacionamento = new TDBUniqueSearch('relacionamento', 'db_isis360', 'tb_CadastroPessoasRelacionamento', 'id', 'relacionamento');
  34. $pfoupj = new TCombo('pfoupj');
  35. // $pfoupj = new TRadioGroup('pfoupj');
  36. $cpf = new TEntry('cpf');
  37. //$cpf->addValidation('cpf', new TCPFValidator);
  38. $rg = new TEntry('rg');
  39. $cnpj = new TEntry('cnpj');
  40. //$cnpj->addValidation('cpf', new TCNPJValidator);
  41. $cpfcnpj = new TEntry('cpfcnpj');
  42. $inscricaomunicipal = new TEntry('inscricaomunicipal');
  43. $inscricaoestadual = new TEntry('inscricaoestadual');
  44. $nome = new TEntry('nome');
  45. //$nome->addValidation('Nome', new TMinLengthValidator, array(3));
  46. $nomesocial = new TEntry('nomesocial');
  47. $razaosocial = new TEntry('razaosocial');
  48. $dataabertura = new TEntry('dataabertura');
  49. $situacaocnpj = new TEntry('situacaocnpj');
  50. $naturezajuridica = new TEntry('naturezajuridica');
  51. $porte = new TEntry('porte');
  52. //$razaosocial->addValidation('Razão Social', new TMinLengthValidator, array(3));
  53. $fantasia = new TEntry('fantasia');
  54. $genero = new TCombo('genero');
  55. $nascimento = new TDate('nascimento');
  56. $estadocivil = new TCombo('estadocivil');
  57. $nacionalidade = new TEntry('nacionalidade');
  58. $cep = new TEntry('cep');
  59. $logradouro = new TEntry('logradouro');
  60. $numero = new TEntry('numero');
  61. $bairro = new TEntry('bairro');
  62. $complemento = new TEntry('complemento');
  63. $cidade = new TEntry('cidade');
  64. $estado = new TEntry('estado');
  65. $telefonecnpj = new TEntry('telefonecnpj');
  66. $telefonefixo = new TEntry('telefonefixo');
  67. $telefonecelular = new TEntry('telefonecelular');
  68. $whatsapp = new TEntry('whatsapp');
  69. $email = new TEntry('email');
  70. $emailcnpj = new TEntry('emailcnpj');
  71. $email->addValidation('Email', new TEmailValidator);
  72. $site = new TEntry('site');
  73. $facebook = new TEntry('facebook');
  74. $linkedin = new TEntry('linkedin');
  75. $ieisento = new TCombo('ieisento');
  76. $suframa = new TEntry('suframa');
  77. $observacao = new TText('observacao');
  78. $grupo = new TDBUniqueSearch('grupo', 'db_isis360', 'tb_CadastroPessoasGrupo', 'id', 'grupo');
  79. $pfoupj->setChangeAction(new TAction(array($this, 'onChangePFouPJ')));
  80. $combo_items = array();
  81. $combo_items['f'] ='Física';
  82. $combo_items['j'] ='Jurídica';
  83. $pfoupj->addItems($combo_items);
  84. $pfoupj->setValue('f');
  85. //$pfoupj->setLayout('horizontal');
  86. self::onChangePFouPJ( ['pfoupj' => 'f'] );
  87. $ieisento->setChangeAction(new TAction(array($this, 'onChangeIEIsento')));
  88. $combo_items = array();
  89. $combo_items['i'] ='Isento';
  90. $combo_items['t'] ='Tributável';
  91. $ieisento->addItems($combo_items);
  92. $ieisento->setValue('t');
  93. // TEntry::disableField('form_cadastro_pessoas', 'cnpj');
  94. $motivo->setChangeAction(new TAction(array($this, 'onChangeMotivo')));
  95. $statuscadastro->setEditable(FALSE);
  96. // default value
  97. ;
  98. // fire change event
  99. // self::onChangePFouPJ( ['pfoupj' => 'Juridica'] );
  100. // add the combo options
  101. $estadocivil->addItems( [ 'S' => 'Solteiro(a)', 'U' => 'União Estável', 'C' => 'Casado(a)', 'E' => 'Separado(a)', 'D' => 'Divorciado(a)', 'V' => 'Viúvo(a)' ] );
  102. // $relacionamento->addItems( [ 'C' => 'Cliente', 'F' => 'Fornecedor', 'L' => 'Colaboador', 'T' => 'Transportador', 'Z' => 'Terceirizado' ] );
  103. $genero->addItems( [ 'M' => 'Masculino', 'F' => 'Feminino' ] );
  104. //$genero->setLayout('horizontal');
  105. // define some properties for the form fields
  106. $id->setEditable(FALSE);
  107. $id->setSize('100%');
  108. $cidade->setSize('100%');
  109. $observacao->setSize('300%', 100);
  110. $nascimento->setSize('100%');
  111. $logradouro->setSize('100%');
  112. $numero->setSize('30%');
  113. //$cidade->enableSearch();
  114. //$cidade->setMinLength(0);
  115. $relacionamento->setMinLength(0);
  116. $grupo->setMinLength(0);
  117. $motivo->setMinLength(0);
  118. //$estado->setMinLength(0);
  119. //$estado->setMask('{nome_estado} - <b>{uf}</b>');
  120. $nascimento->setMask('dd/mm/yyyy');
  121. $cnpj->setMask('99.999.999/9999-99');
  122. $cpf->setMask('999.999.999-99');
  123. $cep->setMask('99.999-999');
  124. $telefonefixo->setMask('(99) 9999.9999');
  125. $telefonecnpj->setMask('(99) 9999.9999');
  126. $telefonecelular->setMask('(99) 99999.9999');
  127. $whatsapp->setMask('(99) 99999.9999');
  128. // insert in form fields
  129. $this->form->appendPage('CADASTRO');
  130. $row = $this->form->addFields( [ new TLabel('Código'), $id ],
  131. [ new TLabel('Tipo de Pessoa'), $pfoupj ],
  132. [ new TLabel('Relacionamento'), $relacionamento ],
  133. [ new TLabel('Status'), $statuscadastro ]);
  134. $row->layout = ['col-sm-2','col-sm-4','col-sm-3','col-sm-3'];
  135. $row = $this->form->addFields( [ new TLabel('CPF'), $cpf ],
  136. [ new TLabel('RG'), $rg ]);
  137. $row->layout = ['col-sm-6','col-sm-6'];
  138. $row = $this->form->addFields( [ new TLabel('CNPJ'), $cnpj ],
  139. [ new TLabel('Razao Social'), $razaosocial ],
  140. [ new TLabel('Fantasia'), $fantasia ]);
  141. $row->layout = ['col-sm-2','col-sm-6','col-sm-4'];
  142. $row = $this->form->addFields( [ new TLabel('Nome'), $nome ],
  143. [ new TLabel('Nome Social'), $nomesocial ]);
  144. $row->layout = ['col-sm-6', 'col-sm-6'];
  145. $row = $this->form->addFields( [ new TLabel('Data Abertura'), $dataabertura ],
  146. [ new TLabel('Natureza Juridica'), $naturezajuridica ],
  147. [ new TLabel('Porte'), $porte ],
  148. [ new TLabel('Situação CNPJ'), $situacaocnpj ]);
  149. $row->layout = ['col-sm-2','col-sm-4','col-sm-4','col-sm-2'];
  150. $row = $this->form->addFields( [ new TLabel('Gênero'), $genero ],
  151. [ new TLabel('Estado Civil'), $estadocivil ],
  152. [ new TLabel('Nascimento'), $nascimento ] );
  153. $row->layout = ['col-sm-4', 'col-sm-4', 'col-sm-4'];
  154. $row = $this->form->addFields( [ new TLabel('Grupo / Categoria'), $grupo ],
  155. [ new TLabel('Motivo'), $motivo ],
  156. [ new TLabel('Data do Cadastro'), $datacadastro ]);
  157. $row->layout = ['col-sm-4','col-sm-4','col-sm-4'];
  158. $row = $this->form->addFields( [ new TLabel('Infomações Adicionai'), $observacao ]);
  159. $row->layout = ['col-sm-12'];
  160. $this->form->appendPage('ENDEREÇO');
  161. $row = $this->form->addFields( [ new TLabel('CEP'), $cep ],
  162. [ new TLabel('Logradouro'), $logradouro ],
  163. [ new TLabel('Número'), $numero ]);
  164. $row->layout = ['col-sm-2', 'col-sm-8', 'col-sm-2'];
  165. $row = $this->form->addFields( [ new TLabel('Complemento'),$complemento ],
  166. [ new TLabel('Bairro'), $bairro ],
  167. [ new TLabel('Cidade'), $cidade ],
  168. [ new TLabel('Estado'), $estado ] );
  169. $row->layout = ['col-sm-4', 'col-sm-3', 'col-sm-3','col-sm-2'];
  170. $this->form->appendPage('FISCAL');
  171. $row = $this->form->addFields( [ new TLabel('Inscrição Municipal'), $inscricaomunicipal ],
  172. [ new TLabel('I.E. Isento'), $ieisento ],
  173. [ new TLabel('Inscrição Estadual'), $inscricaoestadual ]);
  174. $row->layout = ['col-sm-4', 'col-sm-4','col-sm-4'];
  175. $row = $this->form->addFields( [ new TLabel('Suframa'), $suframa ]);
  176. $row->layout = ['col-sm-6'];
  177. $this->form->appendPage('CONTATOS');
  178. $row = $this->form->addFields( [ new TLabel('Fone Cadastro CNPJ'), $telefonecnpj ],
  179. [ new TLabel('Email Cadastro CNPJ'), $emailcnpj ]);
  180. $row->layout = ['col-sm-4', 'col-sm-8'];
  181. $row = $this->form->addFields( [ new TLabel('Telefone'), $telefonefixo ],
  182. [ new TLabel('Celular'), $telefonecelular ],
  183. [ new TLabel('WhatsApp'), $whatsapp ]);
  184. $row->layout = ['col-sm-4', 'col-sm-4','col-sm-4',];
  185. $row = $this->form->addFields( [ new TLabel('E-Mail'), $email ] );
  186. $row->layout = ['col-sm-6'];
  187. $row = $this->form->addFields( [ new TLabel('site'), $site ],
  188. [ new TLabel('facebook'), $facebook ],
  189. [ new TLabel('Linkedin'), $linkedin ] );
  190. $row->layout = ['col-sm-4', 'col-sm-4', 'col-sm-4'];
  191. $action_cep = new TAction(array($this,'onCep'));
  192. $cep->setExitAction($action_cep);
  193. $action_cnpj = new TAction(array($this,'onCNPJ'));
  194. $cnpj->setExitAction($action_cnpj);
  195. $btn = $this->form->addAction( 'Salvar', new TAction(array($this, 'onSave')), 'fa:save' );
  196. $btn->class = 'btn btn-sm btn-primary';
  197. $this->form->addActionLink(_t('Clear'), new TAction(array($this, 'onClear')), 'fa:eraser red');
  198. $this->form->addActionLink( _t('Back'), new TAction(array('CadastroPessoasListNew','onReload')), 'far:arrow-alt-circle-left blue' );
  199. //$this->form->addAction('BUSCAR CEP', new TAction([$this, 'onCep']), 'fa:search');
  200. //$this->form->addAction('BUSCAR CNPJ', new TAction([$this, 'onCNPJ']), 'fa:search');
  201. //$action_cep = new TAction(array($this,'onCep'));
  202. //$cep->setExitAction($action_cep);
  203. // wrap the page content
  204. $vbox = new TVBox;
  205. $vbox->style = 'width: 100%';
  206. $vbox->add(new TXMLBreadCrumb('menu.xml', 'CadastroPessoasList'));
  207. $vbox->add($this->form);
  208. // add the form inside the page
  209. parent::add($vbox);
  210. }
  211. public function validate()
  212. {
  213. // assign post data before validation
  214. // validation exception would prevent
  215. // the user code to execute setData()
  216. $this->setData($this->getData());
  217. foreach ($this->fields as $fieldObject)
  218. {
  219. $fieldObject->validate();
  220. }
  221. }
  222. public function onSave()
  223. {
  224. try
  225. {
  226. TTransaction::open('db_isis360');
  227. $object = $this->form->getData('tb_CadastroPessoas');
  228. $this->form->validate();
  229. //$object = new Testedois; // create an empty object
  230. $data = $this->form->getData(); // get form data as array
  231. $object->fromArray( (array) $data); // load the object with data
  232. // Valida o CPF
  233. if($data->pfoupj == 'f')
  234. {
  235. $cpf = new TCPFValidator;
  236. $cpf->validate('CPF', $data->cpf);
  237. }
  238. // Valida o CNPJ
  239. if($data->pfoupj == 'j' )
  240. {
  241. $cnpj = new TCNPJValidator;
  242. $cnpj->validate('CNPJ', $data->cnpj);
  243. }
  244. //var_dump($object);
  245. $object->store();
  246. $this->form->setData( $object );
  247. //new TMessage('info', 'Registro salvo com sucesso!');
  248. TToast::show('success', 'Registro SALVO com Sucesso!', 'top right', 'far:check-circle' );
  249. TTransaction::close();
  250. }
  251. catch (exception $e)
  252. {
  253. new TMessage('error', $e->getMessage());
  254. TTransaction::rollback();
  255. }
  256. }
  257. public function onEdit($param)
  258. {
  259. try
  260. {
  261. TTransaction::open('db_isis360');
  262. $key = $param['id'];
  263. $object = new tb_CadastroPessoas($key);
  264. $this->form->setData( $object );
  265. TTransaction::close();
  266. }
  267. catch (exception $e)
  268. {
  269. new TMessage('error', $e->getMessage());
  270. TTransaction::rollback();
  271. }
  272. }
  273. /**
  274. * Clear form
  275. */
  276. public function onClear($param)
  277. {
  278. $this->form->clear();
  279. // $this->contacts->addHeader();
  280. // $this->contacts->addDetail( new stdClass );
  281. // $this->contacts->addCloneAction();
  282. }
  283. public static function onChangePFouPJ($param)
  284. {
  285. if ($param['pfoupj'] == 'f' )
  286. {
  287. TQuickForm::showField('form_cadastro_pessoas', 'cpf');
  288. TQuickForm::showField('form_cadastro_pessoas', 'rg');
  289. TQuickForm::showField('form_cadastro_pessoas', 'nome');
  290. TQuickForm::showField('form_cadastro_pessoas', 'nomesocial');
  291. TQuickForm::showField('form_cadastro_pessoas', 'genero');
  292. TQuickForm::showField('form_cadastro_pessoas', 'estadocivil');
  293. TQuickForm::showField('form_cadastro_pessoas', 'nascimento');
  294. TQuickForm::hideField('form_cadastro_pessoas', 'cnpj');
  295. TQuickForm::hideField('form_cadastro_pessoas', 'inscricaomunicipal');
  296. TQuickForm::hideField('form_cadastro_pessoas', 'inscricaoestadual');
  297. TQuickForm::hideField('form_cadastro_pessoas', 'suframa');
  298. TQuickForm::hideField('form_cadastro_pessoas', 'razaosocial');
  299. TQuickForm::hideField('form_cadastro_pessoas', 'fantasia');
  300. TQuickForm::hideField('form_cadastro_pessoas', 'dataabertura');
  301. TQuickForm::hideField('form_cadastro_pessoas', 'naturezajuridica');
  302. TQuickForm::hideField('form_cadastro_pessoas', 'porte');
  303. TQuickForm::hideField('form_cadastro_pessoas', 'situacaocnpj');
  304. TQuickForm::hideField('form_cadastro_pessoas', 'observacao');
  305. TEntry::disableField('form_cadastro_pessoas', 'telefonecnpj');
  306. TEntry::disableField('form_cadastro_pessoas', 'emailcnpj');
  307. }
  308. else
  309. {
  310. TQuickForm::hideField('form_cadastro_pessoas', 'cpf');
  311. TQuickForm::hideField('form_cadastro_pessoas', 'rg');
  312. TQuickForm::hideField('form_cadastro_pessoas', 'nome');
  313. TQuickForm::hideField('form_cadastro_pessoas', 'nomesocial');
  314. TQuickForm::hideField('form_cadastro_pessoas', 'genero');
  315. TQuickForm::hideField('form_cadastro_pessoas', 'estadocivil');
  316. TQuickForm::hideField('form_cadastro_pessoas', 'nascimento');
  317. TQuickForm::showField('form_cadastro_pessoas', 'cnpj');
  318. TQuickForm::showField('form_cadastro_pessoas', 'inscricaomunicipal');
  319. TQuickForm::showField('form_cadastro_pessoas', 'inscricaoestadual');
  320. TQuickForm::showField('form_cadastro_pessoas', 'suframa');
  321. TQuickForm::showField('form_cadastro_pessoas', 'razaosocial');
  322. TQuickForm::showField('form_cadastro_pessoas', 'fantasia');
  323. TQuickForm::showField('form_cadastro_pessoas', 'dataabertura');
  324. TQuickForm::showField('form_cadastro_pessoas', 'naturezajuridica');
  325. TQuickForm::showField('form_cadastro_pessoas', 'porte');
  326. TQuickForm::showField('form_cadastro_pessoas', 'situacaocnpj');
  327. TQuickForm::showField('form_cadastro_pessoas', 'observacao');
  328. TEntry::disableField('form_cadastro_pessoas', 'telefonecnpj');
  329. }
  330. }
  331. public static function onChangeIEIsento($param)
  332. {
  333. if ($param['ieisento'] == 'i' )
  334. {
  335. TEntry::disableField('form_cadastro_pessoas', 'inscricaoestadual');
  336. }
  337. else
  338. {
  339. TEntry::enableField('form_cadastro_pessoas', 'inscricaoestadual');
  340. }
  341. }
  342. static function onChangeMotivo($param)
  343. {
  344. $motivo = $param['motivo'];
  345. if ($motivo == NULL)
  346. {
  347. $statuscadastro = "NOVO";
  348. }
  349. else
  350. {
  351. $statuscadastro = "ATIVO";
  352. }
  353. $obj = new StdClass;
  354. $obj->statuscadastro = $statuscadastro;
  355. TForm::sendData('form_cadastro_pessoas', $obj);
  356. }
  357. public static function onCep($param)
  358. {
  359. $cep = $param['cep'];
  360. if (!empty($cep))
  361. {
  362. try
  363. {
  364. $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($param['cep']).'&formato=query_string');
  365. if(!$resultado){
  366. $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  367. //var_dump($resultado);
  368. }
  369. parse_str($resultado, $retorno);
  370. $obj = new StdClass;
  371. //$obj->cep = $param['cep'];
  372. $obj->logradouro = strtoupper( $retorno['tipo_logradouro'].' '.$retorno['logradouro']);
  373. $obj->bairro = strtoupper( $retorno['bairro']);
  374. $obj->cidade = strtoupper( $retorno['cidade']);
  375. $obj->estado = strtoupper( $retorno['uf']);
  376. TForm::sendData('form_cadastro_pessoas', $obj);
  377. //var_dump($obj);
  378. }
  379. catch (Exception $e)
  380. {
  381. new TMessage('error','CEP não encontrado');
  382. }
  383. }
  384. else
  385. {
  386. new TMessage('alert', 'Por favor, Informe o CEP');
  387. }
  388. }
  389. public static function onCNPJ($param)
  390. {
  391. try {
  392. if (isset($param['cnpj']) and $param['cnpj'])
  393. {
  394. //Joga o valor informado para uma variavel
  395. $cnpj = $param['cnpj'];
  396. //Deixa apenas numeros usando expressão regular
  397. $cnpj = preg_replace("/\D/","", $cnpj);
  398. //efetua a consulta e joga o resultado na variavel retorno
  399. $retorno = @file_get_contents('https://www.receitaws.com.br/v1/cnpj/'.urlencode($cnpj));
  400. $objeto = json_decode($retorno);
  401. if (isset($objeto->logradouro)){
  402. $obj = new stdClass();
  403. $obj->razaosocial = $objeto->nome;
  404. $obj->fantasia = $objeto->fantasia;
  405. //$obj->tipo_pessoa = 'J';
  406. $obj->logradouro = $objeto->logradouro;
  407. $obj->numero = $objeto->numero;
  408. $obj->complemento = $objeto->complemento;
  409. $obj->bairro = $objeto->bairro;
  410. $obj->cidade = $objeto->municipio;
  411. $obj->estado = $objeto->uf;
  412. $obj->dataabertura = $objeto->abertura;
  413. $obj->porte = $objeto->porte;
  414. $obj->naturezajuridica = $objeto->natureza_juridica;
  415. $obj->situacaocnpj = $objeto->situacao;
  416. $obj->cep = $objeto->cep;
  417. $obj->telefonecnpj = $objeto->telefone;
  418. $obj->emailcnpj = $objeto->email;
  419. $obj->observacao = "";
  420. for ($i = 0; $i < count($objeto->qsa); $i++)
  421. {
  422. $obj->observacao .= $objeto->qsa[$i]->qual." - ";
  423. $obj->observacao .= $objeto->qsa[$i]->nome."\n";
  424. }
  425. for ($i = 0; $i < count($objeto->atividade_principal); $i++)
  426. {
  427. $obj->observacao .= "Atividade Principal ".$objeto->atividade_principal[$i]->code." - ";
  428. $obj->observacao .= $objeto->atividade_principal[$i]->text."\n";
  429. }
  430. for ($i = 0; $i < count($objeto->atividades_secundarias); $i++)
  431. {
  432. $obj->observacao .= "Atividade Secundaria ".$objeto->atividades_secundarias[$i]->code." - ";
  433. $obj->observacao .= $objeto->atividades_secundarias[$i]->text."\n";
  434. }
  435. $obj->observacao .= "Natureza Juridica - ".$objeto->natureza_juridica."\n";
  436. $obj->observacao .= "Capital Social - R$-".number_format($objeto->capital_social,2,',','.')."\n";
  437. TToast::show('info', 'CNPJ Localizado na Receita Federal', 'top right', 'far:check-circle' );
  438. TEntry::disableField('form_cadastro_pessoas', 'observacao');
  439. TForm::sendData('form_cadastro_pessoas',$obj);
  440. unset($obj);
  441. }else{
  442. //new TMessage('info', 'CNPJ não localizado na Receita Federal.');
  443. TToast::show('error', 'CNPJ não localizado na base da Receita Federal', 'top right', 'far:check-circle' );
  444. }
  445. }
  446. }catch (Exception $e){
  447. new TMessage('error', '<b>Error:</b> ' . $e->getMessage());
  448. }
  449. }
  450. }

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 (2)


NR

Você precisa "ativar o gatilho" na função onEdit:
 
  1. <?php
  2. public function onEdit($param)
  3. {
  4. try
  5. {
  6. TTransaction::open('db_isis360');
  7. $key = $param['id'];
  8. $object = new tb_CadastroPessoas($key);
  9. $this->form->setData( $object );
  10. self::onChangePFouPJ( ['pfoupj' => $object->pfoupj] ); // modo 1
  11. TForm::sendData('form_cadastro_pessoas',(object)['pfoupj'=>$object->pfoup]); // modo 2
  12. TTransaction::close();
  13. }
  14. catch (exception $e)
  15. {
  16. new TMessage('error', $e->getMessage());
  17. TTransaction::rollback();
  18. }
  19. }
  20. ?>
MP

Funcionou perfeitamente!!! muito grato pela ajuda!!! logo mais estarei também contribuindo aqui...