SV
Permissão Negada TSeekButton
Boa Tarde Pessoal, tudo bem?
Configurei o TSeekButton, conforme alguns post no forum,, já cadastrei a rotina de Seek na rotina de programa concedendo para admin e user, porém aparece permissão negada.
Alguém poderia me ajudar?
Agradeço desde já
Obrigado!
Abaixo segue meu código.
Configurei o TSeekButton, conforme alguns post no forum,, já cadastrei a rotina de Seek na rotina de programa concedendo para admin e user, porém aparece permissão negada.
Alguém poderia me ajudar?
Agradeço desde já
Obrigado!
Abaixo segue meu código.
- <?php
- /**
- * SystemUnitForm Form
- * @author <your name here>
- */
- class SystemUnitForm extends TPage
- {
- protected $form; // form
- /**
- * Form constructor
- * @param $param Request
- */
- public function __construct( $param )
- {
- parent::__construct();
- // creates the form
- $this->form = new BootstrapFormBuilder('form_SystemUnit');
- $this->form->setFormTitle('Filial');
- $this->form->setFieldSizes('100%');
- $this->form->appendPage('Basic');
- // create the form fields
- $id = new TEntry('id');
- $name = new TEntry('name');
- $fantasia = new TEntry('fantasia');
- $tipopessoa = new TCombo('tipopessoa');
- $cnpj = new TEntry('cnpj');
- $rg = new TEntry('rg');
- $inscmunicipal = new TEntry('inscmunicipal');
- $cnaeprincipal = new TSeekButton('cnaeprincipal');
- $codigoregime = new TCombo('codigoregime');
- $cep = new TEntry('cep');
- $cidade = new TEntry('cidade');
- $uf = new TEntry('uf');
- $endereco = new TEntry('endereco');
- $numero = new TEntry('numero');
- $complemento = new TEntry('complemento');
- $bairro = new TEntry('bairro');
- $contato = new TEntry('contato');
- $fone = new TEntry('fone');
- $celular = new TEntry('celular');
- $email = new TEntry('email');
- $emailcobranca = new TEntry('emailcobranca');
- $site = new TEntry('site');
- $tipopessoa->addItems(['J'=>'Jurídica', 'F'=>'Física']);
- $codigoregime->addItems(['1'=>'1-Simples Nacional',
- '2'=>'2-Simples Nacional - excesso de sublimite da receita bruta',
- '3'=>'3-Regime Normal']);
- //acao do cep
- $action_cep = new TAction(array($this,'onCep'));
- $cep->setExitAction($action_cep);
- //*****************************************************
- //SEEK
- //*****************************************************
- $obj = new TabelaCnaeSeek;
- $action_cnae = new TAction( array( $obj, 'onreload' ) );
- $cnaeprincipal->setAction($action_cnae);
- // add the fields
- $row = $this->form->addFields([ new TLabel('Código') , $id ] );
- $row->layout = ['col-sm-2'];
- $row = $this->form->addFields([ new TLabel('Empresa') , $name ],
- [ new TLabel('Nome Fantasia') , $fantasia ],
- [ new TLabel('Tipo'), $tipopessoa ]);
- $row->layout = ['col-sm-5','col-sm-5','col-sm-2'];
- $row = $this->form->addFields([ new TLabel('CNPJ/CPF') , $cnpj ],
- [ new TLabel('IE/RG') , $rg ],
- [ new TLabel('Insc. Municipal') , $inscmunicipal ] );
- $row->layout = ['col-sm-3','col-sm-3','col-sm-3'];
- $row = $this->form->addFields( [ new TLabel('CNAE') , $cnaeprincipal ],
- [ new TLabel('Cód. Regime Tributário') , $codigoregime ] );
- $row->layout = ['col-sm-3','col-sm-3'];
- $label2 = new TLabel('Endereço', '#5A73DB', 12, '');
- $label2->style='text-align:left;border-bottom:1px solid #c0c0c0;width:100%';
- $this->form->addContent( [$label2] );
- $row = $this->form->addFields( [ new TLabel('CEP'), $cep ],
- [ new TLabel('Cidade'), $cidade ],
- [ new TLabel('UF'), $uf ],
- [ new TLabel('Endereço'), $endereco ],
- [ new TLabel('Nr'), $numero ]);
- $row->layout = ['col-sm-2','col-sm-2','col-sm-1','col-sm-6','col-sm-1' ];
- $this->form->addFields( );
- $this->form->addFields( [ new TLabel('Complemento') ], [ $complemento ] );
- $this->form->addFields( [ new TLabel('Bairro') ], [ $bairro ] );
- $this->form->addFields( [ new TLabel('Contato') ], [ $contato ] );
- $this->form->addFields( [ new TLabel('Fone') ], [ $fone ] );
- $this->form->addFields( [ new TLabel('Celular') ], [ $celular ] );
- $this->form->addFields( [ new TLabel('Email') ], [ $email ] );
- $this->form->addFields( [ new TLabel('Emailcobranca') ], [ $emailcobranca ] );
- $this->form->addFields( [ new TLabel('Site') ], [ $site ] );
- /*/ set sizes
- $id->setSize('100%');
- $name->setSize('100%');
- $fantasia->setSize('100%');
- $tipopessoa->setSize('100%');
- $cnpj->setSize('100%');
- $rg->setSize('100%');
- $inscmunicipal->setSize('100%');
- $cnaeprincipal->setSize('100%');
- $codigoregime->setSize('100%');
- $cep->setSize('100%');
- $cidade->setSize('100%');
- $uf->setSize('100%');
- $endereco->setSize('100%');
- $numero->setSize('100%');
- $complemento->setSize('100%');
- $bairro->setSize('100%');
- $contato->setSize('100%');
- $fone->setSize('100%');
- $celular->setSize('100%');
- $email->setSize('100%');
- $emailcobranca->setSize('100%');
- $site->setSize('100%');
- */
- if (!empty($id))
- {
- $id->setEditable(FALSE);
- }
- /** samples
- $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
- $fieldX->setSize( '100%' ); // set size
- **/
- // create the form actions
- $btn = $this->form->addAction(_t('Save'), new TAction([$this, 'onSave']), 'fa:floppy-o');
- $btn->class = 'btn btn-sm btn-primary';
- $this->form->addAction(_t('New'), new TAction([$this, 'onEdit']), 'fa:eraser red');
- // vertical box container
- $container = new TVBox;
- $container->style = 'width: 100%';
- //$container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $container->add($this->form);
- parent::add($container);
- }
- /**
- * Save form data
- * @param $param Request
- */
- public function onSave( $param )
- {
- try
- {
- TTransaction::open('empresa'); // open a transaction
- /**
- // Enable Debug logger for SQL operations inside the transaction
- TTransaction::setLogger(new TLoggerSTD); // standard output
- TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
- **/
- $this->form->validate(); // validate form data
- $data = $this->form->getData(); // get form data as array
- $object = new SystemUnit; // create an empty object
- $object->fromArray( (array) $data); // load the object with data
- $object->store(); // save the object
- // get the generated id
- $data->id = $object->id;
- $this->form->setData($data); // fill form data
- TTransaction::close(); // close the transaction
- new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- $this->form->setData( $this->form->getData() ); // keep form data
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * Clear form data
- * @param $param Request
- */
- public function onClear( $param )
- {
- $this->form->clear(TRUE);
- }
- /**
- * Load object to form data
- * @param $param Request
- */
- public function onEdit( $param )
- {
- try
- {
- if (isset($param['key']))
- {
- $key = $param['key']; // get the parameter $key
- TTransaction::open('empresa'); // open a transaction
- $object = new SystemUnit($key); // instantiates the Active Record
- $this->form->setData($object); // fill the form
- TTransaction::close(); // close the transaction
- }
- else
- {
- $this->form->clear(TRUE);
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- public static function onCep($param)
- {
- $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($param['cep']).'&formato=query_string');
- var_dump($resultado);
- if(!$resultado){
- $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
- }
- parse_str($resultado, $retorno);
- $obj = new StdClass;
- $obj->endereco = strtoupper($retorno['tipo_logradouro'].' '.$retorno['logradouro']);
- $obj->bairro = strtoupper($retorno['bairro']);
- $obj->cidade = strtoupper($retorno['cidade']);
- $obj->uf = strtoupper($retorno['uf']);
- TForm::sendData('form_SystemUnit', $obj);
- }
- }
- ?>
Nesses casos geralmente é algum detalhezinho, como nome da classe por exemplo. Confira se o programa cadastrado corresponde exatamente ao nome da classe. E você chegou a sair e entrar novamente do sistema para testar?
Estou com o mesmo erro.
a minha classe :