Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ApplicationProviderSystemsConnection;
- use ApplicationProviderSystemsAbstractView;
- class View extends AbstractView
- {
- public function init()
- {
- $el = $this->div(array(
- 'childrens' => array(
- $this->h2(array(
- 'class' => 'sub-header',
- ),'Conexões'),
- $this->button(array(
- 'type' => 'link',
- 'text' => 'Adicionar Novo',
- 'request' => array(
- 'system','method',
- ),
- ), array(
- 'system' => $this->getParams()['system'],
- 'method' => 'add',
- )),
- $this->grid(array(
- 'id' => 'grdConnections',
- 'store' => array(
- 'data' => $this->template->connections,
- ),
- 'columns' => array(
- array(
- 'type' => 'text',
- 'text' => '#',
- 'dataIndex' => 'id_connection',
- ),
- array(
- 'type' => 'text',
- 'text' => 'Nome',
- 'dataIndex' => 'name',
- ),
- array(
- 'type' => 'text',
- 'text' => 'Tipo Banco',
- 'dataIndex' => 'type_bd',
- ),
- array(
- 'type' => 'text',
- 'text' => 'Servidor',
- 'dataIndex' => 'host',
- ),
- array(
- 'type' => 'link',
- 'text' => 'Editar',
- 'icon' => 'pencil',
- 'request' => array(
- 'system','method','id_connection'
- ),
- 'params' => array(
- 'system' => $this->getParams()['system'],
- 'method' => 'edit',
- ),
- 'hiddenLabel' => true,
- ),
- array(
- 'type' => 'link',
- 'text' => 'Excluir',
- 'icon' => 'trash',
- 'request' => array(
- 'system','method','id_connection'
- ),
- 'params' => array(
- 'system' => $this->getParams()['system'],
- 'method' => 'remove',
- ),
- 'hiddenLabel' => true,
- 'confirm' => 'Deseja realmente excluir este registro?',
- ),
- array(
- 'type' => 'link',
- 'text' => 'Ler',
- 'icon' => 'cloud-upload',
- 'request' => array(
- 'system','method','id_connection'
- ),
- 'params' => array(
- 'system' => $this->getParams()['system'],
- 'method' => 'import',
- ),
- 'hiddenLabel' => true,
- 'confirm' => 'Deseja realmente ler este banco de dados?',
- ),
- array(
- 'type' => 'link',
- 'text' => 'Gravar',
- 'icon' => 'cloud-download',
- 'request' => array(
- 'system','method','id_connection'
- ),
- 'params' => array(
- 'system' => 'Funcionario',
- 'method' => 'deploy',
- ),
- 'hiddenLabel' => true,
- ),
- array(
- 'type' => 'link',
- 'text' => 'Detalhes',
- 'icon' => 'plus',
- 'request' => array(
- 'system','method','id_connection'
- ),
- 'params' => array(
- 'system' => 'Empresa',
- 'method' => 'refresh',
- ),
- 'hiddenLabel' => true,
- ),
- )
- )),
- ),
- ));
- return $this->render($el);
- }
- public function edit()
- {
- return $this->add();
- }
- public function add()
- {
- $el = $this->form(array(
- 'id' => 'connection',
- 'class' => 'form-horizontal',
- 'method' => 'post',
- 'childrens' => array(
- $this->h2(array(
- 'class' => 'sub-header',
- ),'Conexões'),
- $this->fieldSet(array(
- 'childrens' => array(
- $this->div(array(
- 'class' => 'row',
- 'childrens' => array(
- $this->field(array(
- 'name' => 'name',
- 'type' => 'text',
- 'label' => 'Nome da Conexão',
- 'maxLength' => 15,
- 'size' => 20,
- 'allowBlank' => false,
- 'readonly' => !empty($this->template->connection->name),
- 'value' => !empty($this->template->connection->name)? $this->template->connection->name : '',
- )),
- $this->field(array(
- 'name' => 'type',
- 'type' => 'hidden',
- 'value' => 'pgsql',
- )),
- $this->field(array(
- 'name' => 'host',
- 'type' => 'text',
- 'label' => 'Nome ou IP do Servidor',
- 'maxLength' => 40,
- 'size' => 55,
- 'allowBlank' => false,
- 'value' => !empty($this->template->connection->host)? $this->template->connection->host : '',
- )),
- $this->field(array(
- 'name' => 'port',
- 'type' => 'text',
- 'mask' => array(
- 'alias' => 'numeric',
- ),
- 'maxLength' => 8,
- 'size' => 8,
- 'allowBlank' => true,
- 'label' => 'Porta',
- 'value' => !empty($this->template->connection->port)? $this->template->connection->port : '5432',
- )),
- $this->field(array(
- 'name' => 'user',
- 'type' => 'text',
- 'label' => 'Usuário',
- 'allowBlank' => false,
- 'maxLength' => 40,
- 'size' => 50,
- 'value' => !empty($this->template->connection->user)? $this->template->connection->user : '',
- )),
- $this->field(array(
- 'name' => 'password',
- 'type' => 'password',
- 'label' => 'Senha',
- 'allowBlank' => true,
- 'value' => !empty($this->template->connection->password)? $this->template->connection->password : '',
- )),
- $this->field(array(
- 'name' => 'database',
- 'type' => 'select',
- 'label' => 'Nome do Banco de Dados',
- 'value' => !empty($this->template->connection->database)? $this->template->connection->database : '',
- 'valueField' => 'name',
- 'labelField' => 'name',
- 'allowBlank' => false,
- 'buttons' => array(
- $this->button(array(
- 'name' => 'databaseRefresh',
- 'formId' => 'connection',
- 'type' => 'ajax',
- 'text' => 'Refresh',
- 'icon' => 'refresh',
- 'response' => array(
- 'var options = $("#database")',
- 'options.find('option').remove().end()',
- 'console.log(options,result)',
- '$.each(result, function() {
- options.append($("<option />").val(this.name).text(this.name));
- })'
- ),
- 'hiddenLabel' => true,
- 'request' => array(
- 'service',
- 'method',
- 'type',
- 'host',
- 'port',
- 'user',
- 'password',
- ),
- ), array(
- 'service' => '"Connection"',
- 'method' => '"Databases"',
- 'type' => '%$("#type")%',
- 'host' => '%$("#host")%',
- 'port' => '%$("#port")%',
- 'user' => '%$("#user")%',
- 'password' => '%$("#password")%',
- )),
- ),
- 'data' => $this->template->databases,
- )),
- $this->button(array(
- 'name' => 'link',
- 'type' => 'link',
- 'text' => 'Voltar',
- 'icon' => 'chevron-left',
- 'request' => array(
- 'system','method',
- ),
- ), array(
- 'system' => 'Connection',
- 'method' => 'init',
- )),
- $this->button(array(
- 'name' => 'submit',
- 'type' => 'submit',
- 'text' => 'Salvar',
- 'request' => array(
- 'system','method','id_connection'
- ),
- ), array(
- 'system' => $this->getParams()['system'],
- 'method' => $this->getParams()['function'],
- 'id_connection' => !empty($this->template->connection->id_connection)? $this->template->connection->id_connection : '',
- )),
- ),
- )),
- ),
- )),
- ),
- ));
- return $this->render($el);
- }
- }
Add Comment
Please, Sign In to add comment