Guest User

Untitled

a guest
Mar 27th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.02 KB | None | 0 0
  1. <?php
  2.  
  3. namespace ApplicationProviderSystemsConnection;
  4.  
  5. use ApplicationProviderSystemsAbstractView;
  6.  
  7. class View extends AbstractView
  8. {
  9.  
  10. public function init()
  11. {
  12.  
  13. $el = $this->div(array(
  14. 'childrens' => array(
  15. $this->h2(array(
  16. 'class' => 'sub-header',
  17. ),'Conexões'),
  18. $this->button(array(
  19. 'type' => 'link',
  20. 'text' => 'Adicionar Novo',
  21. 'request' => array(
  22. 'system','method',
  23. ),
  24. ), array(
  25. 'system' => $this->getParams()['system'],
  26. 'method' => 'add',
  27. )),
  28.  
  29. $this->grid(array(
  30. 'id' => 'grdConnections',
  31. 'store' => array(
  32. 'data' => $this->template->connections,
  33. ),
  34. 'columns' => array(
  35. array(
  36. 'type' => 'text',
  37. 'text' => '#',
  38. 'dataIndex' => 'id_connection',
  39. ),
  40. array(
  41. 'type' => 'text',
  42. 'text' => 'Nome',
  43. 'dataIndex' => 'name',
  44. ),
  45. array(
  46. 'type' => 'text',
  47. 'text' => 'Tipo Banco',
  48. 'dataIndex' => 'type_bd',
  49. ),
  50. array(
  51. 'type' => 'text',
  52. 'text' => 'Servidor',
  53. 'dataIndex' => 'host',
  54. ),
  55. array(
  56. 'type' => 'link',
  57. 'text' => 'Editar',
  58. 'icon' => 'pencil',
  59. 'request' => array(
  60. 'system','method','id_connection'
  61. ),
  62. 'params' => array(
  63. 'system' => $this->getParams()['system'],
  64. 'method' => 'edit',
  65. ),
  66. 'hiddenLabel' => true,
  67. ),
  68. array(
  69. 'type' => 'link',
  70. 'text' => 'Excluir',
  71. 'icon' => 'trash',
  72. 'request' => array(
  73. 'system','method','id_connection'
  74. ),
  75. 'params' => array(
  76. 'system' => $this->getParams()['system'],
  77. 'method' => 'remove',
  78. ),
  79. 'hiddenLabel' => true,
  80. 'confirm' => 'Deseja realmente excluir este registro?',
  81. ),
  82. array(
  83. 'type' => 'link',
  84. 'text' => 'Ler',
  85. 'icon' => 'cloud-upload',
  86. 'request' => array(
  87. 'system','method','id_connection'
  88. ),
  89. 'params' => array(
  90. 'system' => $this->getParams()['system'],
  91. 'method' => 'import',
  92. ),
  93. 'hiddenLabel' => true,
  94. 'confirm' => 'Deseja realmente ler este banco de dados?',
  95. ),
  96. array(
  97. 'type' => 'link',
  98. 'text' => 'Gravar',
  99. 'icon' => 'cloud-download',
  100. 'request' => array(
  101. 'system','method','id_connection'
  102. ),
  103. 'params' => array(
  104. 'system' => 'Funcionario',
  105. 'method' => 'deploy',
  106. ),
  107. 'hiddenLabel' => true,
  108. ),
  109. array(
  110. 'type' => 'link',
  111. 'text' => 'Detalhes',
  112. 'icon' => 'plus',
  113. 'request' => array(
  114. 'system','method','id_connection'
  115. ),
  116. 'params' => array(
  117. 'system' => 'Empresa',
  118. 'method' => 'refresh',
  119. ),
  120. 'hiddenLabel' => true,
  121. ),
  122. )
  123. )),
  124. ),
  125. ));
  126.  
  127. return $this->render($el);
  128. }
  129.  
  130. public function edit()
  131. {
  132.  
  133. return $this->add();
  134.  
  135. }
  136.  
  137. public function add()
  138. {
  139.  
  140. $el = $this->form(array(
  141. 'id' => 'connection',
  142. 'class' => 'form-horizontal',
  143. 'method' => 'post',
  144. 'childrens' => array(
  145. $this->h2(array(
  146. 'class' => 'sub-header',
  147. ),'Conexões'),
  148. $this->fieldSet(array(
  149. 'childrens' => array(
  150. $this->div(array(
  151. 'class' => 'row',
  152. 'childrens' => array(
  153. $this->field(array(
  154. 'name' => 'name',
  155. 'type' => 'text',
  156. 'label' => 'Nome da Conexão',
  157. 'maxLength' => 15,
  158. 'size' => 20,
  159. 'allowBlank' => false,
  160. 'readonly' => !empty($this->template->connection->name),
  161. 'value' => !empty($this->template->connection->name)? $this->template->connection->name : '',
  162. )),
  163. $this->field(array(
  164. 'name' => 'type',
  165. 'type' => 'hidden',
  166. 'value' => 'pgsql',
  167. )),
  168. $this->field(array(
  169. 'name' => 'host',
  170. 'type' => 'text',
  171. 'label' => 'Nome ou IP do Servidor',
  172. 'maxLength' => 40,
  173. 'size' => 55,
  174. 'allowBlank' => false,
  175. 'value' => !empty($this->template->connection->host)? $this->template->connection->host : '',
  176. )),
  177. $this->field(array(
  178. 'name' => 'port',
  179. 'type' => 'text',
  180. 'mask' => array(
  181. 'alias' => 'numeric',
  182. ),
  183. 'maxLength' => 8,
  184. 'size' => 8,
  185. 'allowBlank' => true,
  186. 'label' => 'Porta',
  187. 'value' => !empty($this->template->connection->port)? $this->template->connection->port : '5432',
  188. )),
  189. $this->field(array(
  190. 'name' => 'user',
  191. 'type' => 'text',
  192. 'label' => 'Usuário',
  193. 'allowBlank' => false,
  194. 'maxLength' => 40,
  195. 'size' => 50,
  196. 'value' => !empty($this->template->connection->user)? $this->template->connection->user : '',
  197. )),
  198. $this->field(array(
  199. 'name' => 'password',
  200. 'type' => 'password',
  201. 'label' => 'Senha',
  202. 'allowBlank' => true,
  203. 'value' => !empty($this->template->connection->password)? $this->template->connection->password : '',
  204. )),
  205. $this->field(array(
  206. 'name' => 'database',
  207. 'type' => 'select',
  208. 'label' => 'Nome do Banco de Dados',
  209. 'value' => !empty($this->template->connection->database)? $this->template->connection->database : '',
  210. 'valueField' => 'name',
  211. 'labelField' => 'name',
  212. 'allowBlank' => false,
  213. 'buttons' => array(
  214. $this->button(array(
  215. 'name' => 'databaseRefresh',
  216. 'formId' => 'connection',
  217. 'type' => 'ajax',
  218. 'text' => 'Refresh',
  219. 'icon' => 'refresh',
  220. 'response' => array(
  221. 'var options = $("#database")',
  222. 'options.find('option').remove().end()',
  223. 'console.log(options,result)',
  224. '$.each(result, function() {
  225. options.append($("<option />").val(this.name).text(this.name));
  226. })'
  227. ),
  228. 'hiddenLabel' => true,
  229. 'request' => array(
  230. 'service',
  231. 'method',
  232. 'type',
  233. 'host',
  234. 'port',
  235. 'user',
  236. 'password',
  237. ),
  238. ), array(
  239. 'service' => '"Connection"',
  240. 'method' => '"Databases"',
  241. 'type' => '%$("#type")%',
  242. 'host' => '%$("#host")%',
  243. 'port' => '%$("#port")%',
  244. 'user' => '%$("#user")%',
  245. 'password' => '%$("#password")%',
  246. )),
  247. ),
  248. 'data' => $this->template->databases,
  249. )),
  250. $this->button(array(
  251. 'name' => 'link',
  252. 'type' => 'link',
  253. 'text' => 'Voltar',
  254. 'icon' => 'chevron-left',
  255. 'request' => array(
  256. 'system','method',
  257. ),
  258. ), array(
  259. 'system' => 'Connection',
  260. 'method' => 'init',
  261. )),
  262. $this->button(array(
  263. 'name' => 'submit',
  264. 'type' => 'submit',
  265. 'text' => 'Salvar',
  266. 'request' => array(
  267. 'system','method','id_connection'
  268. ),
  269. ), array(
  270. 'system' => $this->getParams()['system'],
  271. 'method' => $this->getParams()['function'],
  272. 'id_connection' => !empty($this->template->connection->id_connection)? $this->template->connection->id_connection : '',
  273. )),
  274. ),
  275. )),
  276. ),
  277. )),
  278. ),
  279. ));
  280.  
  281. return $this->render($el);
  282. }
  283. }
Add Comment
Please, Sign In to add comment