kamila 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. data/doc/classes/Array2D.html +221 -0
  2. data/doc/classes/Array2D.src/M000001.html +19 -0
  3. data/doc/classes/Array2D.src/M000002.html +18 -0
  4. data/doc/classes/Array2D.src/M000003.html +18 -0
  5. data/doc/classes/Array2D.src/M000004.html +23 -0
  6. data/doc/classes/CfYiyi.html +172 -0
  7. data/doc/classes/CfYiyi.src/M000011.html +17 -0
  8. data/doc/classes/CfYiyi.src/M000012.html +26 -0
  9. data/doc/classes/EscapeShellCmd.html +157 -0
  10. data/doc/classes/EscapeShellCmd.src/M000013.html +18 -0
  11. data/doc/classes/Example.html +184 -0
  12. data/doc/classes/Example.src/M000005.html +17 -0
  13. data/doc/classes/Example.src/M000006.html +19 -0
  14. data/doc/classes/Example.src/M000007.html +19 -0
  15. data/doc/classes/Example.src/M000008.html +20 -0
  16. data/doc/classes/Method/Overload.html +123 -0
  17. data/doc/classes/Method/Signature.html +315 -0
  18. data/doc/classes/Method/Signature.src/M000015.html +20 -0
  19. data/doc/classes/Method/Signature.src/M000016.html +18 -0
  20. data/doc/classes/Method/Signature.src/M000017.html +18 -0
  21. data/doc/classes/Method/Signature.src/M000018.html +18 -0
  22. data/doc/classes/Method/Signature.src/M000019.html +22 -0
  23. data/doc/classes/Method/Signature.src/M000020.html +18 -0
  24. data/doc/classes/Method/Signature.src/M000021.html +21 -0
  25. data/doc/classes/Method/Signature.src/M000022.html +26 -0
  26. data/doc/classes/Method/Signature.src/M000023.html +36 -0
  27. data/doc/classes/Method/Signature.src/M000024.html +18 -0
  28. data/doc/classes/Method/Signature.src/M000025.html +24 -0
  29. data/doc/classes/Method/Signature.src/M000026.html +18 -0
  30. data/doc/classes/Method.html +144 -0
  31. data/doc/classes/Method.src/M000014.html +33 -0
  32. data/doc/classes/Module.html +111 -0
  33. data/doc/classes/MyCGI.html +137 -0
  34. data/doc/classes/MyCGI.src/M000034.html +18 -0
  35. data/doc/classes/ScanearDisco.html +251 -0
  36. data/doc/classes/ScanearDisco.src/M000027.html +24 -0
  37. data/doc/classes/ScanearDisco.src/M000028.html +28 -0
  38. data/doc/classes/ScanearDisco.src/M000029.html +52 -0
  39. data/doc/classes/ScanearDisco.src/M000030.html +19 -0
  40. data/doc/classes/ScanearDisco.src/M000031.html +48 -0
  41. data/doc/classes/ScanearDisco.src/M000032.html +40 -0
  42. data/doc/classes/TestEscapeShellCmd.html +137 -0
  43. data/doc/classes/TestEscapeShellCmd.src/M000033.html +19 -0
  44. data/doc/classes/Utilidades.html +173 -0
  45. data/doc/classes/Utilidades.src/M000009.html +17 -0
  46. data/doc/classes/Utilidades.src/M000010.html +28 -0
  47. data/doc/created.rid +1 -0
  48. data/doc/files/lib/Array2D_rb.html +120 -0
  49. data/doc/files/lib/cf_yiyi_rb.html +120 -0
  50. data/doc/files/lib/escape_shell_cmd_rb.html +121 -0
  51. data/doc/files/lib/mycgi_rb.html +127 -0
  52. data/doc/files/lib/overload_rb.html +101 -0
  53. data/doc/files/lib/scanear_disco_rb.html +140 -0
  54. data/doc/files/lib/utilidades_rb.html +120 -0
  55. data/doc/files/test/testEscapeShellCmd_rb.html +116 -0
  56. data/doc/files/test/testmycgi_rb.html +109 -0
  57. data/doc/files/test/testoverload_rb.html +101 -0
  58. data/doc/fr_class_index.html +38 -0
  59. data/doc/fr_file_index.html +36 -0
  60. data/doc/fr_method_index.html +60 -0
  61. data/doc/index.html +24 -0
  62. data/lib/Array2D.rb +33 -0
  63. data/lib/application.rb +3509 -0
  64. data/lib/cerrar.sh +2 -0
  65. data/lib/cf_yiyi.rb +26 -0
  66. data/lib/escape_shell_cmd.rb +24 -0
  67. data/lib/kamila.rb +452 -0
  68. data/lib/mycgi.rb +41 -0
  69. data/lib/mypdf.rb +215 -0
  70. data/lib/overload.rb +197 -0
  71. data/lib/scanear_disco.rb +169 -0
  72. data/lib/smtp_tls.rb +66 -0
  73. data/lib/utilidades.rb +29 -0
  74. data/test/testEscapeShellCmd.rb +12 -0
  75. metadata +133 -0
@@ -0,0 +1,3509 @@
1
+ # ******************** kamila version 1.0.1 - Framework *********************
2
+ #
3
+ # Copyright (C) 2008 Edgar Gonzalez (egonzale.wordpress.com)
4
+ #
5
+ # This framework is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This framework is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this framework; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+ #
19
+ # Este framework es software libre; puedes redistribuirlo y/o modificarlo
20
+ # bajo los terminos de la licencia publica general GNU tal y como fue publicada
21
+ # por la Fundacion del Software Libre; desde la version 2.1 o cualquier
22
+ # versión superior.
23
+ #
24
+ # Este framework es distribuido con la esperanza de ser util pero SIN NINGUN
25
+ # TIPO DE GARANTIA; sin dejar atras su LADO MERCANTIL o PARA FAVORECER ALGUN
26
+ # FIN EN PARTICULAR. Lee la licencia publica general para mas detalles.
27
+ #
28
+ # Debes recibir una copia de la Licencia Publica General GNU junto con este
29
+ # framework, si no es asi, escribe a Fundacion del Software Libre Inc.,
30
+ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
+ # ***************************************************************************
32
+ =begin
33
+ Classes : Application
34
+ Source : application.rb
35
+ Autor : Edgar Gonzalez
36
+ Email : edgargonzalezmunoz@gmail.com
37
+ Blog : egonzale.wordpress.com
38
+ Website : www.myjavaserver.com/~egonzale
39
+ Framework : kamila versión 1.0.1
40
+ Fecha : 18 de Julio del 2008
41
+ =end
42
+
43
+ require "rubygems" # Libreria de gems rubyforge
44
+ require $kamila_lib+"utilidades" # Libreria 1.0.1 del autor.
45
+ require "fileutils" # Libreria de ruby
46
+ #require "erb" # Libreria de ruby
47
+ require "erubis" # Libreria de gems rubyforge: http://www.kuwata-lab.com/erubis/ es mas rapido
48
+ require $kamila_lib+"overload" # Libreria dcyt-1.0.0 del autor.
49
+ require 'mycgi' # Libreria de cgi con ruby.
50
+ require "cgi" # Libreria de cgi con ruby.
51
+ require 'cgi/session' # Libreria de cgi con ruby.
52
+ require 'cgi/session/pstore' # Libreria de cgi con ruby.
53
+ require 'pstore' # Libreria de cgi con ruby.
54
+ require "digest/md5" # Libreria de cgi con ruby.
55
+
56
+ class Application
57
+ @kamila_array_views_dir = nil
58
+ @kamila_array_views_file = nil
59
+ @kamila_array_models = nil
60
+ @kamila_views_dir_exist = false
61
+ @kamila_views_file_exist = false
62
+ @kamila_model_exist = false
63
+ $kamila_view = nil
64
+ def initialize()
65
+ end
66
+ private
67
+ def verifyviews(page)
68
+ # Cargar las vistas existentes en kamila/views
69
+ @kamila_views_dir_exist = false
70
+ @kamila_views_file_exist = false
71
+ Dir.chdir($kamila_home+"/views/")
72
+ archivosDir = Dir.glob('*')
73
+ objUtilidades = Utilidades.new()
74
+ @kamila_array_views_dir = Array.new()
75
+ if (archivosDir.size()-1>=0)
76
+ j = archivosDir.size()-1
77
+ for i in 0..j
78
+ @kamila_array_views_dir[i] = objUtilidades.getNombreArchivo(archivosDir[i].to_s)
79
+ if @kamila_array_views_dir[i] == $kamila_controller
80
+ @kamila_views_dir_exist = true
81
+ Dir.chdir($kamila_home+"/views/"+$kamila_controller+"/")
82
+ archivosViews = Dir.glob('*')
83
+ @kamila_array_views_file = Array.new()
84
+ if (archivosViews.size()-1>=0)
85
+ kj = archivosViews.size()-1
86
+ for ki in 0..kj
87
+ @kamila_array_views_file[ki] = objUtilidades.getNombreArchivo(archivosViews[ki].to_s)
88
+ if @kamila_array_views_file[ki] == page+".rhtml"
89
+ @kamila_views_file_exist = true
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ Dir.chdir($kamila_home+"/views/")
97
+ end
98
+ def get_binding()
99
+ binding
100
+ end
101
+ public
102
+ def loadmodel(model)
103
+ # Cargar los modelos existentes en kamila/models
104
+ @kamila_model_exist = false
105
+ Dir.chdir("../models/")
106
+ archivos = Dir.glob('*')
107
+ objUtilidades = Utilidades.new()
108
+ @kamila_array_models = Array.new()
109
+ if (archivos.size()-1>=0)
110
+ j = archivos.size()-1
111
+ for i in 0..j
112
+ @kamila_array_models[i] = objUtilidades.getNombreArchivo(archivos[i].to_s)
113
+ if @kamila_array_models[i] == model+".rb"
114
+ salida=false
115
+ existeBDD = false
116
+ File.open($kamila_home+"/models/"+model+".rb", "r") do |infile|
117
+ while (line = infile.gets and salida==false and $kamila_MVCPlusPlus)
118
+ if line.index("puts")!=nil or line.index("print")!=nil or line.index("render")!=nil or line.index("insert_text")!=nil
119
+ salida=true
120
+ end
121
+ if line.index("ActiveRecord::Base.establish_connection")!=nil
122
+ existeBDD = true
123
+ end
124
+ end
125
+ end
126
+ if salida==true
127
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
128
+ $kamila_titulo = "Error"
129
+ $kamila_mensaje = $kamila_defaultMessages["message009"] + " " + $kamila_home+"/models/"+model+".rb" + " " + $kamila_defaultMessages["message010"]
130
+ #$kamila_mensaje = "#{ e } (#{ e.class })!"
131
+ $kamila_linkto = $kamila_site
132
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
133
+ else
134
+ @kamila_model_exist = true
135
+ if existeBDD == false
136
+ require "active_record"
137
+ ActiveRecord::Base.establish_connection(
138
+ :adapter => $kamila_DatabaseAdapter,
139
+ :host => $kamila_DatabaseHost,
140
+ :port => $kamila_DatabasePort.to_i,
141
+ :database => $kamila_DatabaseName,
142
+ :username => $kamila_DatabaseUsername,
143
+ :password => $kamila_DatabasePassword
144
+ )
145
+ end
146
+ require model
147
+ end
148
+ end
149
+ end
150
+ end
151
+ return @kamila_model_exist
152
+ end
153
+ def render(page)
154
+ if page == "" or page == nil
155
+ page = "index"
156
+ end
157
+ verifyviews(page)
158
+ if @kamila_views_dir_exist and @kamila_views_file_exist
159
+ ##############################################################################################
160
+ # Antes era con redireccionamiento basado en el .htaccess #
161
+ # $kamila_cgi.redirect($kamila_site+"/views/"+$kamila_controller+"/"+page+".rhtml") #
162
+ # Solucion: http://www.hiveminds.co.uk/node/3189 #
163
+ ##############################################################################################
164
+ $kamila_view = $kamila_home+"/views/"+$kamila_controller+"/"+page+".rhtml"
165
+ input = File.read($kamila_view)
166
+
167
+ ##############################################################################################
168
+ # Explicacion del metodo binding() en ruby #
169
+ # http://onestepback.org/index.cgi/Tech/Ruby/RubyBindings.rdoc/style/print #
170
+ ##############################################################################################
171
+ # usando ERB con eruby
172
+ #begin
173
+ # eruby = ERB.new(input)
174
+ # eruby.result(get_binding())
175
+ # eruby.run(get_binding())
176
+ #rescue
177
+ # $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
178
+ # $kamila_titulo = "Error"
179
+ # $kamila_mensaje = $!
180
+ # #$kamila_mensaje = "#{ e } (#{ e.class })!"
181
+ # $kamila_linkto = $kamila_site
182
+ # $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
183
+ #end
184
+
185
+ ##############################################################################################
186
+ # Usando erubis: http://www.kuwata-lab.com/erubis/ más rápido que ERB #
187
+ ##############################################################################################
188
+ #eruby = Erubis::Eruby.new(input)
189
+ #eruby.result(get_binding())
190
+
191
+ # Otra Forma
192
+
193
+ begin
194
+ if $kamila_MVCPlusPlus
195
+ if input.index("loadmodel")==nil and
196
+ input.index(".find")==nil and
197
+ input.index(".save")==nil and
198
+ input.index(".create")==nil and
199
+ input.index(".delete")==nil and
200
+ input.index("by_sql")==nil and
201
+ input.index("<html>")==nil and
202
+ input.index("</html>")==nil and
203
+ input.index("<title>")==nil and
204
+ input.index("</title>")==nil and
205
+ input.index("<head>")==nil and
206
+ input.index("</head>")==nil and
207
+ input.index("<script>")==nil and
208
+ input.index("</script>")==nil and
209
+ input.index("<body>")==nil and
210
+ input.index("</body>")==nil and
211
+ input.index("<input>")==nil and
212
+ input.index("<textarea>")==nil and
213
+ input.index("</textarea>")==nil and
214
+ input.index("<select>")==nil and
215
+ input.index("</select>")==nil and
216
+ input.index("<link>")==nil and
217
+ input.index("<frame>")==nil and
218
+ input.index("</frame>")==nil and
219
+ input.index("<frameset>")==nil and
220
+ input.index("</frameset>")==nil and
221
+ input.index("<iframe>")==nil and
222
+ input.index("</iframe>")==nil and
223
+ input.index("<table>")==nil and
224
+ input.index("</table>")==nil and
225
+ input.index("<tr>")==nil and
226
+ input.index("</tr>")==nil and
227
+ input.index("<td>")==nil and
228
+ input.index("</td>")==nil and
229
+ input.index("<div>")==nil and
230
+ input.index("</div>")==nil and
231
+ input.index("<span>")==nil and
232
+ input.index("</span>")==nil and
233
+ input.index("<p>")==nil and
234
+ input.index("</p>")==nil and
235
+ input.index("<link>")==nil and
236
+ input.index("<a>")==nil and
237
+ input.index("</a>")==nil and
238
+ input.index("<img>")==nil and
239
+ input.index("<font>")==nil and
240
+ input.index("</font>")==nil and
241
+ input.index("<center>")==nil and
242
+ input.index("</center>")==nil
243
+ ejecutarEval = true
244
+ else
245
+ ejecutarEval = false
246
+ end
247
+ else
248
+ ejecutarEval = true
249
+ end
250
+ if ejecutarEval
251
+ eruby = Erubis::Eruby.new
252
+ src = eruby.convert(input)
253
+ begin
254
+ print eval(src)
255
+ #rescue SyntaxError
256
+ rescue Exception => e
257
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
258
+ $kamila_titulo = "Error"
259
+ if $kamila_defaultMessagesType.upcase=="RUBY"
260
+ $kamila_mensaje = $!.to_s
261
+ if $kamila_mensaje != ""
262
+ $kamila_mensaje = $kamila_mensaje.gsub(/</,"")
263
+ $kamila_mensaje = $kamila_mensaje.gsub(/>/,"")
264
+ $kamila_mensaje = $kamila_mensaje.gsub(/"/,"'")
265
+ else
266
+ $kamila_mensaje = $kamila_defaultMessages["message018"] + " " + $kamila_view
267
+ end
268
+ else
269
+ $kamila_mensaje = $kamila_defaultMessages["message018"] + " " + $kamila_view
270
+ end
271
+ $kamila_linkto = $kamila_site
272
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
273
+ end
274
+ else
275
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
276
+ $kamila_titulo = "Error"
277
+ if $kamila_defaultMessagesType.upcase=="RUBY"
278
+ $kamila_mensaje = $!.to_s
279
+ if $kamila_mensaje != ""
280
+ $kamila_mensaje = $kamila_mensaje.gsub(/</,"")
281
+ $kamila_mensaje = $kamila_mensaje.gsub(/>/,"")
282
+ $kamila_mensaje = $kamila_mensaje.gsub(/"/,"'")
283
+ else
284
+ $kamila_mensaje = $kamila_defaultMessages["message009"] + " " + $kamila_view + " " + $kamila_defaultMessages["message011"]
285
+ end
286
+ else
287
+ $kamila_mensaje = $kamila_defaultMessages["message009"] + " " + $kamila_view + " " + $kamila_defaultMessages["message011"]
288
+ end
289
+ $kamila_linkto = $kamila_site
290
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
291
+ end
292
+ rescue
293
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
294
+ $kamila_titulo = "Error"
295
+ if $kamila_defaultMessagesType.upcase=="RUBY"
296
+ $kamila_mensaje = $!.to_s
297
+ if $kamila_mensaje != ""
298
+ $kamila_mensaje = $kamila_mensaje.gsub(/</,"")
299
+ $kamila_mensaje = $kamila_mensaje.gsub(/>/,"")
300
+ $kamila_mensaje = $kamila_mensaje.gsub(/"/,"'")
301
+ else
302
+ $kamila_mensaje = $kamila_defaultMessages["message012"] + " " + $kamila_view
303
+ end
304
+ else
305
+ $kamila_mensaje = $kamila_defaultMessages["message012"] + " " + $kamila_view
306
+ end
307
+ $kamila_linkto = $kamila_site
308
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
309
+ end
310
+
311
+ else
312
+ if @kamila_views_dir_exist == false
313
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
314
+ $kamila_titulo = "Error"
315
+ if $kamila_defaultMessagesType.upcase=="RUBY"
316
+ $kamila_mensaje = $!.to_s
317
+ if $kamila_mensaje != ""
318
+ $kamila_mensaje = $kamila_mensaje.gsub(/</,"")
319
+ $kamila_mensaje = $kamila_mensaje.gsub(/>/,"")
320
+ $kamila_mensaje = $kamila_mensaje.gsub(/"/,"'")
321
+ else
322
+ $kamila_mensaje = $kamila_defaultMessages["message019"] + " " + $kamila_controller
323
+ end
324
+ else
325
+ $kamila_mensaje = $kamila_defaultMessages["message019"] + " " + $kamila_controller
326
+ end
327
+ $kamila_linkto = $kamila_site
328
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
329
+ else
330
+ if @kamila_views_file_exist == false
331
+ $kamila_icon_mensaje = "Ext.MessageBox.ERROR"
332
+ $kamila_titulo = "Error"
333
+ if $kamila_defaultMessagesType.upcase=="RUBY"
334
+ $kamila_mensaje = $!.to_s
335
+ if $kamila_mensaje != ""
336
+ $kamila_mensaje = $kamila_mensaje.gsub(/</,"")
337
+ $kamila_mensaje = $kamila_mensaje.gsub(/>/,"")
338
+ $kamila_mensaje = $kamila_mensaje.gsub(/"/,"'")
339
+ else
340
+ $kamila_mensaje = $kamila_defaultMessages["message013"] + " " + page.to_s + ".rhtml"
341
+ end
342
+ else
343
+ $kamila_mensaje = $kamila_defaultMessages["message013"] + " " + page.to_s + ".rhtml"
344
+ end
345
+ $kamila_linkto = $kamila_site
346
+ $kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
347
+ end
348
+ end
349
+ end
350
+ end
351
+ # Funciones de HTML
352
+ def create_html()
353
+ return '<html>'
354
+ end
355
+ def close_html()
356
+ return '</html>'
357
+ end
358
+ def create_head()
359
+ return '<head>'
360
+ end
361
+ def close_head()
362
+ return '</head>'
363
+ end
364
+ def create_title(title)
365
+ return '<title>'+title.to_s+'</title>'
366
+ end
367
+ def create_center()
368
+ return '<center>'
369
+ end
370
+ def close_center()
371
+ return '</center>'
372
+ end
373
+ def create_meta()
374
+ return '<meta name="GENERATOR" content="kamila version 1.0.1">'
375
+ end
376
+ overload(:create_meta)
377
+ def create_meta(httpequiv,content,charset)
378
+ return '<meta http-equiv="'+httpequiv.to_s+'" content="'+content.to_s+'; charset='+charset.to_s+'">'
379
+ end
380
+ overload(:create_meta,String,String,String)
381
+ def create_body()
382
+ return '<body>'
383
+ end
384
+ overload(:create_body)
385
+ def create_body(background,bgcolor,css,js)
386
+ return '<body background="' + background.to_s + '" bgcolor="' + bgcolor.to_s + '" class="' + css.to_s + '" ' + js.to_s + '>'
387
+ end
388
+ overload(:create_body,String,String,String,String)
389
+ def create_body(marginheight,marginwidth,topmargin,leftmargin,bgcolor)
390
+ return '<body marginheight="' + marginheight.to_s + '" marginwidth="' + marginwidth.to_s + '" topmargin="' + topmargin.to_s + '" leftmargin= "' + leftmargin.to_s + '" bgcolor="' + bgcolor.to_s + '" >'
391
+ end
392
+ overload(:create_body,String,String,String,String,String)
393
+ def close_body()
394
+ return '</body>'
395
+ end
396
+ def create_css(css)
397
+ return '<link rel="stylesheet" type="text/css" href="'+ $kamila_site + '/public/css/' + css.to_s+'">'
398
+ end
399
+ def create_javascript()
400
+ return '<script language="javascript">'
401
+ end
402
+ overload(:create_javascript)
403
+ def create_javascript(js)
404
+ return '<script type="text/javascript" src="'+ $kamila_site + '/public/js/' + js.to_s+'">'
405
+ end
406
+ overload(:create_javascript,String)
407
+ def create_javascript(js,flag)
408
+ if flag.upcase=='TRUE'
409
+ return '<script type="text/javascript" src="'+ js.to_s + '">'
410
+ else
411
+ return ''
412
+ end
413
+ end
414
+ overload(:create_javascript,String,String)
415
+ def close_javascript()
416
+ return '</script>'
417
+ end
418
+ def create_javascript_view_file(left,top,width,height,file)
419
+ return '<script language="javascript">
420
+ var opciones="left='+left.to_s+',top='+top.to_s+',width='+width.to_s+',height='+height.to_s+'";
421
+ mi_ventana = window.open("'+file.to_s+'","",opciones);
422
+ </script>'
423
+ end
424
+ def create_javascript_md5()
425
+ return '<script type="text/javascript" src="'+$kamila_site+'/public/js/md5.js"></script>'
426
+ end
427
+ def create_javascript_livevalidation(idiom)
428
+ if idiom=="es"
429
+ return '<link rel="stylesheet" type="text/css" href="'+$kamila_site+'/public/css/validacion.css"><script type="text/javascript" src="'+$kamila_site+'/public/js/livevalidation_es.js"></script>'
430
+ else
431
+ return '<link rel="stylesheet" type="text/css" href="'+$kamila_site+'/public/css/validacion.css"><script type="text/javascript" src="'+$kamila_site+'/public/js/livevalidation_en.js"></script>'
432
+ end
433
+ end
434
+ def create_javascript_extjs()
435
+ return '<link rel="stylesheet" type="text/css" href="'+$kamila_site+'/public/css/resources/css/ext-all.css"><link rel="stylesheet" type="text/css" href="'+$kamila_site+'/public/css/resources/css/file-upload.css"><script type="text/javascript" src="'+$kamila_site+'/public/js/extjs/adapter/ext/ext-base.js"></script><script type="text/javascript" src="'+$kamila_site+'/public/js/extjs/ext-all.js"></script><script type="text/javascript" src="'+$kamila_site+'/public/js/extjs/build/widgets/form/FileUploadField.js"></script><script>Ext.QuickTips.init();</script>'
436
+ end
437
+ def create_javascript_rialto(theme)
438
+ return '<link rel="stylesheet" type="text/css" href="'+ $kamila_site + '/public/css/rialto/style/rialto.css"/>' +
439
+ '<link rel="stylesheet" type="text/css" href="'+ $kamila_site + '/public/css/rialto/style/formatGrid.css"/>' +
440
+ '<link rel="stylesheet" type="text/css" href="'+ $kamila_site + '/public/css/rialto/style/behavior.css"/>' +
441
+ '<link rel="stylesheet" href="'+ $kamila_site + '/public/css/rialto/style/' + theme.to_s+'" type="text/css">' +
442
+ '<SCRIPT SRC="'+ $kamila_site + '/public/js/rialto/config.js" language="JavaScript1.2"></SCRIPT>' +
443
+ '<SCRIPT SRC="'+ $kamila_site + '/public/js/rialto/rialto.js" language="JavaScript1.2"></SCRIPT>'
444
+ end
445
+ def create_javascript_language_extjs(language,charset)
446
+ return '<script type="text/javascript">
447
+ var s = document.createElement("script");
448
+ s.type = "text/javascript";
449
+ s.src = "' + $kamila_site.to_s + '/public/js/extjs/locale/ext-lang-' + language.to_s + '.js";
450
+ s.charset = "' + charset.to_s + '";
451
+ document.getElementsByTagName("head")[0].appendChild(s);
452
+ </script>'
453
+ end
454
+ def create_javascript_validate_rangedate_extjs(funcion)
455
+ return '<script type="text/javascript">
456
+ Ext.apply(Ext.form.VTypes, {
457
+ ' + funcion.to_s + ': function(val, field) {
458
+ var date = field.parseDate(val);
459
+ var dispUpd = function(picker) {
460
+ var ad = picker.activeDate;
461
+ picker.activeDate = null;
462
+ picker.update(ad);
463
+ };
464
+ if (field.startDateField) {
465
+ var sd = Ext.getCmp(field.startDateField);
466
+ sd.maxValue = date;
467
+ if (sd.menu && sd.menu.picker) {
468
+ sd.menu.picker.maxDate = date;
469
+ dispUpd(sd.menu.picker);
470
+ }
471
+ } else if (field.endDateField) {
472
+ var ed = Ext.getCmp(field.endDateField);
473
+ ed.minValue = date;
474
+ if (ed.menu && ed.menu.picker) {
475
+ ed.menu.picker.minDate = date;
476
+ dispUpd(ed.menu.picker);
477
+ }
478
+ }
479
+ return true;
480
+ }
481
+ });
482
+ </script>'
483
+ end
484
+ def create_javascript_lightbox2()
485
+ return '<link rel="stylesheet" type="text/css" href="'+$kamila_site+'/public/css/lightbox2/lightbox.css" media="screen"><script type="text/javascript" src="'+$kamila_site+'/public/js/lightbox2/prototype.js"></script><script type="text/javascript" src="'+$kamila_site+'/public/js/lightbox2/scriptaculous.js?load=effects,builder"></script><script type="text/javascript" src="'+$kamila_site+'/public/js/lightbox2/lightbox.js"></script>'
486
+ end
487
+ def create_heading(h)
488
+ return '<' + h.to_s + '>'
489
+ end
490
+ overload(:create_heading,String)
491
+ def create_heading(h,texto)
492
+ return '<' + h.to_s + '>' + texto.to_s
493
+ end
494
+ overload(:create_heading,String,String)
495
+ def create_heading(h,id,texto)
496
+ return '<' + h.to_s + ' id="'+id.to_s+'">' + texto.to_s
497
+ end
498
+ overload(:create_heading,String,String,String)
499
+ def close_heading(h)
500
+ return '</' + h.to_s + '>'
501
+ end
502
+ def create_paragraphs()
503
+ return '<p>'
504
+ end
505
+ overload(:create_paragraphs)
506
+ def create_paragraphs(id)
507
+ return '<p id="' + id.to_s + '">'
508
+ end
509
+ overload(:create_paragraphs,String)
510
+ def create_paragraphs(id,texto)
511
+ return '<p id="' + id.to_s + '">'+texto.to_s
512
+ end
513
+ overload(:create_paragraphs,String,String)
514
+ def create_paragraphs(id,text,css)
515
+ return '<p id="' + id.to_s + '" class="' + css.to_s + '">'+text.to_s
516
+ end
517
+ overload(:create_paragraphs,String,String,String)
518
+ def close_paragraphs()
519
+ return '</p>'
520
+ end
521
+ def insert_linebreaks(top)
522
+ br = '<br/>'
523
+ linebreak = ''
524
+ 1.upto(top) do
525
+ linebreak = linebreak + br
526
+ end
527
+ return linebreak
528
+ end
529
+ def insert_text(text)
530
+ return text.to_s
531
+ end
532
+ def create_span(text)
533
+ return '<span>'+text.to_s
534
+ end
535
+ overload(:create_span,String)
536
+ def create_span(text,id)
537
+ return '<span id="' + id.to_s + '" >'+text.to_s
538
+ end
539
+ overload(:create_span,String,String)
540
+ def create_span(text,id,css)
541
+ return '<span id="' + id.to_s + '" class="' + css.to_s + '" >'+text.to_s
542
+ end
543
+ overload(:create_span,String,String,String)
544
+ def close_span()
545
+ return '</span>'
546
+ end
547
+ def create_ul()
548
+ return '<ul>'
549
+ end
550
+ overload(:create_ul)
551
+ def create_ul(id)
552
+ return '<ul id='+id.to_s+'>'
553
+ end
554
+ overload(:create_ul,String)
555
+ def close_ul()
556
+ return '</ul>'
557
+ end
558
+ def create_ol()
559
+ return '<ol>'
560
+ end
561
+ overload(:create_ol)
562
+ def create_ol(id)
563
+ return '<ol id="'+id.to_s+'" >'
564
+ end
565
+ overload(:create_ol,String)
566
+ def create_ol(id,css)
567
+ return '<ol id="'+id.to_s+'" class="' + css.to_s + '" >'
568
+ end
569
+ overload(:create_ol,String,String)
570
+ def close_ol()
571
+ return '</ol>'
572
+ end
573
+ def create_li()
574
+ return '<li>'
575
+ end
576
+ overload(:create_li)
577
+ def create_li(id)
578
+ return '<li id="'+id.to_s+'" >'
579
+ end
580
+ overload(:create_li,String)
581
+ def create_li(id,css)
582
+ return '<li id="'+id.to_s+'" class="' + css.to_s + '" >'
583
+ end
584
+ overload(:create_li,String,String)
585
+ def close_li()
586
+ return '</li>'
587
+ end
588
+ def create_div()
589
+ return '<div>'
590
+ end
591
+ overload(:create_div)
592
+ def create_div(id)
593
+ return '<div id="' + id.to_s + '">'
594
+ end
595
+ overload(:create_div,String)
596
+ def create_div(id,css)
597
+ return '<div class="' + css.to_s + '">'
598
+ end
599
+ overload(:create_div,String,String)
600
+ def create_div(id,css,text)
601
+ return '<div id="'+id.to_s+'" class="'+css.to_s+'">'+text.to_s
602
+ end
603
+ overload(:create_div,String,String,String)
604
+ def create_div(id,css,align,text)
605
+ return '<div id="'+id.to_s+'" class="'+css.to_s+'" align="' +align.to_s + '" >'+text.to_s
606
+ end
607
+ overload(:create_div,String,String,String,String)
608
+ def close_div()
609
+ return '</div>'
610
+ end
611
+ def create_font(face,size,color,css)
612
+ return '<font face="'+face.to_s+'" size="'+size.to_s+'" color="' +color.to_s + '" class="' + css.to_s + '" >'
613
+ end
614
+ def close_font()
615
+ return '</font>'
616
+ end
617
+ def create_href(url)
618
+ return '<a href="' + url.to_s + '">'
619
+ end
620
+ overload(:create_href,String)
621
+ def create_href(url,texto)
622
+ return '<a href="' + url.to_s + '">'+texto.to_s+'</a>'
623
+ end
624
+ overload(:create_href,String,String)
625
+ def create_href(url,texto,target)
626
+ return '<a href="' + url.to_s + '" target="' + target.to_s + '" >'+texto.to_s
627
+ end
628
+ overload(:create_href,String,String,String)
629
+ def close_href()
630
+ return '</a>'
631
+ end
632
+ def create_table(border)
633
+ return '<table border="' + border.to_s + '">'
634
+ end
635
+ overload(:create_table,String)
636
+ def create_table(border,width)
637
+ return '<table border="' + border.to_s + '" width="' + width.to_s + '" >'
638
+ end
639
+ overload(:create_table,String,String)
640
+ def create_table(cellpadding,cellspacing,border,align,width,height,background)
641
+ return '<table cellpadding="' + cellpadding.to_s + '"cellspacing="' + cellspacing.to_s + '" border="' + border.to_s + '" align="' + align.to_s + '" width="' + width.to_s + '" height="' + height.to_s + '" background="' + $kamila_site + '/public/' + background.to_s + '" >'
642
+ end
643
+ overload(:create_table,String,String,String,String,String,String,String)
644
+ def close_table()
645
+ return '</table>'
646
+ end
647
+ def create_tr()
648
+ return '<tr>'
649
+ end
650
+ def close_tr()
651
+ return '</tr>'
652
+ end
653
+ def create_td()
654
+ return '<td>'
655
+ end
656
+ overload(:create_td)
657
+ def create_td(width)
658
+ return '<td width="' + width.to_s + '" >'
659
+ end
660
+ overload(:create_td,String)
661
+ def create_td(width,css)
662
+ return '<td width="' + width.to_s + '" class="' + css.to_s + '" >'
663
+ end
664
+ overload(:create_td,String,String)
665
+ def create_td(width,height,css)
666
+ return '<td width="' + width.to_s + '" height="' + height.to_s + '" class="' + css.to_s + '" >'
667
+ end
668
+ overload(:create_td,String,String,String)
669
+ def create_td(valign,align,height,css)
670
+ return '<td valign="' + valign.to_s + '" align="' + align.to_s + '" height="' + height.to_s + '" class="' + css.to_s + '" >'
671
+ end
672
+ overload(:create_td,String,String,String,String)
673
+ def create_td(width,height,align,border,css)
674
+ return '<td width="' + width.to_s + '" height="' + height.to_s + '" align="' + align.to_s + '" border="' + border.to_s + '" class="' + css.to_s + '" >'
675
+ end
676
+ overload(:create_td,String,String,String,String,String)
677
+ def close_td()
678
+ return '</td>'
679
+ end
680
+ def create_img(src)
681
+ return '<img src="'+$kamila_site+'/public/'+src.to_s+'" />'
682
+ end
683
+ overload(:create_img,String)
684
+ def create_img(src,alt)
685
+ return '<img src="'+$kamila_site+'/public/'+src.to_s+'" alt="'+alt.to_s+'" />'
686
+ end
687
+ overload(:create_img,String,String)
688
+ def create_img(id,src,alt)
689
+ return '<img id="'+id.to_s+'" alt="'+alt.to_s+'" src="'+$kamila_site+'/public/'+src.to_s+'" />'
690
+ end
691
+ overload(:create_img,String,String,String)
692
+ def create_img(id,src,alt,border)
693
+ return '<img id="'+id.to_s+'" border="'+border.to_s+'" src="'+$kamila_site+'/public/'+src.to_s+'" alt="'+alt.to_s+'" />'
694
+ end
695
+ overload(:create_img,String,String,String,String)
696
+ def create_img(id,src,alt,border,height)
697
+ return '<img id="'+id.to_s+'" border="'+border.to_s+'" src="'+$kamila_site+'/public/'+src.to_s+'" alt="'+alt.to_s+'" height="' + height.to_s + '" />'
698
+ end
699
+ overload(:create_img,String,String,String,String,String)
700
+ def create_img(id,src,alt,border,height,width)
701
+ return '<img id="'+id.to_s+'" border="'+border.to_s+'" src="'+$kamila_site+'/public/'+src.to_s+'" alt="'+alt.to_s+'" height="' + height.to_s + '" width="' + width.to_s + '" />'
702
+ end
703
+ overload(:create_img,String,String,String,String,String,String)
704
+ def create_text_lightbox2(url,text)
705
+ src = Array.new
706
+ description = Array.new
707
+ src = url.split("|")
708
+ description = text.split("|")
709
+ itemsImages = ''
710
+ for i in 0..src.length-1
711
+ itemsImages = itemsImages+'<a href="'+$kamila_site+'/public/'+src[i].to_s+'" rel="lightbox[roadtrip]" >'+description[i].to_s+'</a><br/>'
712
+ end
713
+ return itemsImages
714
+ end
715
+ overload(:create_text_lightbox2,String,String)
716
+ def create_text_lightbox2(src,title,description)
717
+ return '<a href="'+$kamila_site+'/public/'+src.to_s+'" rel="lightbox" title="'+title.to_s+'">'+description+'</a>'
718
+ end
719
+ overload(:create_text_lightbox2,String,String,String)
720
+ def create_img_lightbox2(src,title,alt,height,width)
721
+ return '<a href="'+$kamila_site+'/public/'+src.to_s+'" rel="lightbox" title="'+title.to_s+'"><img border="0" src="'+$kamila_site+'/public/'+src.to_s+'" alt="'+alt.to_s+'" height="' + height.to_s + '" width="' + width.to_s + '" /><br/>'+alt.to_s+'</a>'
722
+ end
723
+ overload(:create_img_lightbox2,String,String,String,String,String)
724
+ def create_img_lightbox2(url,text,altura,amplitud)
725
+ src = Array.new
726
+ description = Array.new
727
+ height = Array.new
728
+ width = Array.new
729
+ src = url.split("|")
730
+ description = text.split("|")
731
+ height = altura.split("|")
732
+ width = amplitud.split("|")
733
+ itemsImages = ''
734
+ for i in 0..src.length-1
735
+ itemsImages = itemsImages+'<a href="'+$kamila_site+'/public/'+src[i].to_s+'" rel="lightbox[roadtrip]" ><img border="0" src="'+$kamila_site+'/public/'+src[i].to_s+'" height="' + height[i].to_s + '" width="' + width[i].to_s + '" /><br/>'+description[i].to_s+'</a><br/>'
736
+ end
737
+ return itemsImages
738
+ end
739
+ overload(:create_img_lightbox2,String,String,String,String)
740
+ def create_form(id,name,method,action)
741
+ return '<form id="'+id.to_s+'" name="'+name.to_s+'" method="'+method.to_s+'" action="' + $kamila_site + '/' + action.to_s + '">'
742
+ end
743
+ overload(:create_form,String,String,String,String)
744
+ def create_form(id,name,method,action,multipart)
745
+ if multipart.upcase=="TRUE"
746
+ return '<form id="'+id.to_s+'" name="'+name.to_s+'" method="'+method.to_s+'" action="' + $kamila_site + '/' + action.to_s + '" enctype="multipart/form-data" >'
747
+ else
748
+ return '<form id="'+id.to_s+'" name="'+name.to_s+'" method="'+method.to_s+'" action="' + $kamila_site + '/' + action.to_s + '">'
749
+ end
750
+ end
751
+ overload(:create_form,String,String,String,String,String)
752
+ def close_form()
753
+ return '</form>'
754
+ end
755
+ def select_focus(form,name)
756
+ return '<script language="JavaScript">
757
+ document.' + form.to_s + '.' + name.to_s + '.select();
758
+ document.' + form.to_s + '.' + name.to_s + '.focus();
759
+ </script> '
760
+ end
761
+ def input_button(id,name,value,css,js)
762
+ return '<input type="button" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" ' + js.to_s + '>'
763
+ end
764
+ def input_submit(id,name,value,css)
765
+ return '<input type="submit" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" >'
766
+ end
767
+ def input_reset(id,name,value,css)
768
+ return '<input type="reset" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" >'
769
+ end
770
+ def input_hidden(id,name,value)
771
+ return '<input type="hidden" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'">'
772
+ end
773
+ # Funciones usando Live Validation
774
+ def input_reset_lv(id,name,value,css)
775
+ return '<input type="reset" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" >'
776
+ end
777
+ def input_submit_lv(id,name,value,css,form,fieldsHidden)
778
+ registros = Array.new
779
+ campos = Array.new
780
+ theitems = ''
781
+ registros = fieldsHidden.split('|')
782
+ for i in 0..registros.length-1
783
+ campos = registros[i].split(',')
784
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
785
+ end
786
+ return '<script>
787
+ function '+id.to_s+'Click()
788
+ {
789
+ '+theitems+'
790
+ }
791
+ </script>
792
+ <input type="submit" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" onclick="javascript: { '+id.to_s+'Click() }">'
793
+ end
794
+ overload(:input_submit_lv,String,String,String,String,String,String)
795
+ def input_submit_lv(id,name,value,css,form,fieldsHidden,ids,messageError)
796
+ registros = Array.new
797
+ campos = Array.new
798
+ idsArray = Array.new
799
+ if ids==''
800
+ idsitems = 'var exito = true; '
801
+ else
802
+ idsitems = 'var exito = false; '
803
+ end
804
+ theitems = ''
805
+ registros = fieldsHidden.split('|')
806
+ for i in 0..registros.length-1
807
+ campos = registros[i].split(',')
808
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
809
+ end
810
+ idsArray = ids.split(',')
811
+ for i in 0..idsArray.length-1
812
+ if i==0 and i==idsArray.length-1
813
+ idsitems = idsitems + 'if ('+idsArray[i]+'.validate() ) { exito=true; } '
814
+ else
815
+ if i==0
816
+ idsitems = idsitems + 'if ('+idsArray[i]+'.validate() && '
817
+ else
818
+ if i==idsArray.length-1
819
+ idsitems = idsitems + idsArray[i]+'.validate() ) { exito=true; } '
820
+ else
821
+ idsitems = idsitems + idsArray[i]+'.validate() && '
822
+ end
823
+ end
824
+ end
825
+ end
826
+ return '<script>
827
+ function '+id.to_s+'Click()
828
+ {
829
+ '+theitems+'
830
+ '+form+'.onsubmit = function(e){
831
+ '+idsitems+'
832
+ if (exito==true)
833
+ {
834
+ '+form+'.submit();
835
+ return true;
836
+ }
837
+ else
838
+ {
839
+ Ext.onReady(function(){
840
+ Ext.MessageBox.show({
841
+ title: "Error",
842
+ msg: "' + messageError.to_s + '" ,
843
+ width:400,
844
+ buttons: Ext.MessageBox.OK,
845
+ icon: Ext.MessageBox.ERROR
846
+ });
847
+ });
848
+ }
849
+ return false;
850
+ }
851
+ }
852
+ </script>
853
+ <input type="submit" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" onclick="javascript: { '+id.to_s+'Click() }">'
854
+ end
855
+ overload(:input_submit_lv,String,String,String,String,String,String,String,String)
856
+ def input_text_key_validate_lv(nameform,range,type,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
857
+ istype = 0
858
+ if readonly.upcase=='TRUE'
859
+ readonly = 'readonly'
860
+ else
861
+ readonly = ''
862
+ end
863
+ if disabled.upcase=='TRUE'
864
+ disabled = 'disabled'
865
+ else
866
+ disabled = ''
867
+ end
868
+ if range=='a..z' or range=='A..Z' or range=='a..Z' or range=='A..z'
869
+ jsRange = 'a-z A-Z'
870
+ istype = 0
871
+ end
872
+ if range=='0..9'
873
+ jsRange = '0-90-9'
874
+ istype = 1
875
+ end
876
+ if range=='0.0..0.9'
877
+ jsRange = '0-90-9'
878
+ istype = 2
879
+ end
880
+ if range=='0..Z' or range=='A..9' or range=='a..9' or range=='0..z'
881
+ jsRange = 'a-z A-Z 0-90-9'
882
+ istype = 3
883
+ end
884
+ if type.upcase=='MD5'
885
+ type = 'password'
886
+ inputText = '<script>function '+id.to_s+'encriptar_md5(idElement) { if ('+id.to_s+'old_clave_md5!=idElement.value) { idElement.value = hex_md5(idElement.value ); '+id.to_s+'old_clave_md5 = idElement.value; } }</script><input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" onKeyDown="return '+id.to_s+'keyLock(event)" onChange="'+id.to_s+'encriptar_md5(document.'+nameform.to_s+'.'+name.to_s+');"><script>var '+id.to_s+'old_clave_md5 = document.'+nameform.to_s+'.'+name.to_s+'.value ; </script> '
887
+ else
888
+ inputText = '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" onKeyDown="return '+id.to_s+'keyLock(event)">'
889
+ end
890
+ if istype==0
891
+ return inputText + '
892
+ <script type="text/javascript">
893
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
894
+ '+id.to_s+'.add(Validate.Presence);
895
+ function '+id.to_s+'keyLock(e)
896
+ {
897
+ kc=e.keyCode?e.keyCode:e.which;
898
+ if(kc<32 || kc==190 || kc==59) return true;
899
+ kc=String.fromCharCode(kc);
900
+ if(/[^' + jsRange.to_s + ']/.test(kc)) return false;
901
+ }
902
+ </script>'
903
+ end
904
+ if istype==1
905
+ return inputText + '
906
+ <script type="text/javascript">
907
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
908
+ '+id.to_s+'.add(Validate.Presence);
909
+ function '+id.to_s+'keyLock(e)
910
+ {
911
+ kc=e.keyCode?e.keyCode:e.which;
912
+ if (kc<32) return true;
913
+ kc=String.fromCharCode(kc);
914
+ if(/[^' + jsRange.to_s + ']/.test(kc)) return false;
915
+ }
916
+ </script>'
917
+ end
918
+ if istype==2
919
+ return inputText + '
920
+ <script type="text/javascript">
921
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
922
+ '+id.to_s+'.add(Validate.Presence);
923
+ function '+id.to_s+'keyLock(e)
924
+ {
925
+ kc=e.keyCode?e.keyCode:e.which;
926
+ if(kc<32 || (kc==190 && Ext.get("'+id.to_s+'").dom.value.indexOf(".")==-1)) return true;
927
+ kc=String.fromCharCode(kc);
928
+ if(/[^' + jsRange.to_s + ']/.test(kc)) return false;
929
+ }
930
+ </script>'
931
+ end
932
+ if istype==3
933
+ return inputText + '
934
+ <script type="text/javascript">
935
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
936
+ '+id.to_s+'.add(Validate.Presence);
937
+ function '+id.to_s+'keyLock(e)
938
+ {
939
+ kc=e.keyCode?e.keyCode:e.which;
940
+ if(kc<32 || kc==190 || kc==59) return true;
941
+ kc=String.fromCharCode(kc);
942
+ if(/[^' + jsRange.to_s + ']/.test(kc)) return false;
943
+ }
944
+ </script>'
945
+ end
946
+ end
947
+ def input_text_presence_lv(type,nameform,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
948
+ if readonly.upcase=='TRUE'
949
+ readonly = 'readonly'
950
+ else
951
+ readonly = ''
952
+ end
953
+ if disabled.upcase=='TRUE'
954
+ disabled = 'disabled'
955
+ else
956
+ disabled = ''
957
+ end
958
+ if type.to_s == 'md5'
959
+ type = 'password'
960
+ inputText = '<script>function '+id.to_s+'encriptar_md5(idElement) { if ('+id.to_s+'old_clave_md5!=idElement.value) { idElement.value = hex_md5(idElement.value ); '+id.to_s+'old_clave_md5 = idElement.value; } }</script><input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" onChange="'+id.to_s+'encriptar_md5(document.'+nameform.to_s+'.'+name.to_s+');"> <script>var '+id.to_s+'old_clave_md5 = document.'+nameform.to_s+'.'+name.to_s+'.value ; </script>'
961
+ else
962
+ inputText = '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">'
963
+ end
964
+ return inputText + '
965
+ <script type="text/javascript">
966
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
967
+ '+id.to_s+'.add(Validate.Presence);
968
+ </script>'
969
+ end
970
+ def input_textarea_key_validate_lv(range,id,name,value,readonly,disabled,alt,tabindex,css,rows,cols)
971
+ if readonly.upcase=='TRUE'
972
+ readonly = 'readonly'
973
+ else
974
+ readonly = ''
975
+ end
976
+ if disabled.upcase=='TRUE'
977
+ disabled = 'disabled'
978
+ else
979
+ disabled = ''
980
+ end
981
+ if range=='a..z' or range=='A..Z' or range=='a..Z' or range=='A..z'
982
+ jsRange = 'a-z A-Z'
983
+ end
984
+ if range=='0..9'
985
+ jsRange = '0-90-9'
986
+ end
987
+ return '<textarea id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s + '" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" rows="' + rows.to_s + '" cols="' + cols.to_s + '" onKeyDown="return '+id.to_s+'keyLock(event)"></textarea>
988
+ <script type="text/javascript">
989
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
990
+ '+id.to_s+'.add(Validate.Presence);
991
+ function '+id.to_s+'keyLock(e)
992
+ {
993
+ kc=e.keyCode?e.keyCode:e.which;
994
+ if(kc<32 || kc==190 || kc==59) return true;
995
+ kc=String.fromCharCode(kc);
996
+ if(/[^' + jsRange.to_s + ']/.test(kc)) return false;
997
+ }
998
+ </script>'
999
+ end
1000
+ def input_file_presence_lv(id,name,value,readonly,disabled,alt,tabindex,css)
1001
+ if readonly.upcase=='TRUE'
1002
+ readonly = 'readonly'
1003
+ else
1004
+ readonly = ''
1005
+ end
1006
+ if disabled.upcase=='TRUE'
1007
+ disabled = 'disabled'
1008
+ else
1009
+ disabled = ''
1010
+ end
1011
+ return '<input id="'+id.to_s+'" type="file" name="'+name.to_s+'" value="'+value.to_s + '" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" >
1012
+ <script type="text/javascript">
1013
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1014
+ '+id.to_s+'.add(Validate.Presence);
1015
+ </script>'
1016
+ end
1017
+ def input_textarea_presence_lv(id,name,value,readonly,disabled,alt,tabindex,css,rows,cols)
1018
+ if readonly.upcase=='TRUE'
1019
+ readonly = 'readonly'
1020
+ else
1021
+ readonly = ''
1022
+ end
1023
+ if disabled.upcase=='TRUE'
1024
+ disabled = 'disabled'
1025
+ else
1026
+ disabled = ''
1027
+ end
1028
+ return '<textarea id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s + '" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '" rows="' + rows.to_s + '" cols="' + cols.to_s + '"></textarea>
1029
+ <script type="text/javascript">
1030
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1031
+ '+id.to_s+'.add(Validate.Presence);
1032
+ </script>'
1033
+ end
1034
+ def input_numericality_lv(typeinteger,type,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
1035
+ if readonly.upcase=='TRUE'
1036
+ readonly = 'readonly'
1037
+ else
1038
+ readonly = ''
1039
+ end
1040
+ if disabled.upcase=='TRUE'
1041
+ disabled = 'disabled'
1042
+ else
1043
+ disabled = ''
1044
+ end
1045
+ return '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1046
+ <script type="text/javascript">
1047
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1048
+ '+id.to_s+'.add(Validate.Presence);
1049
+ '+id.to_s+'.add(Validate.Numericality, { onlyInteger: ' + typeinteger.to_s + ' });
1050
+ </script>'
1051
+ end
1052
+ def input_length_lv(typelength,typesize,type,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
1053
+ if readonly.upcase=='TRUE'
1054
+ readonly = 'readonly'
1055
+ else
1056
+ readonly = ''
1057
+ end
1058
+ if disabled.upcase=='TRUE'
1059
+ disabled = 'disabled'
1060
+ else
1061
+ disabled = ''
1062
+ end
1063
+ return '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1064
+ <script type="text/javascript">
1065
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1066
+ '+id.to_s+'.add(Validate.Presence);
1067
+ '+id.to_s+'.add(Validate.Length, { ' + typelength.to_s + ': ' + typesize.to_s + ' });
1068
+ </script>'
1069
+ end
1070
+ def input_checkbox_lv(id,name,value,readonly,disabled,alt,tabindex,css)
1071
+ if readonly.upcase=='TRUE'
1072
+ readonly = 'readonly'
1073
+ else
1074
+ readonly = ''
1075
+ end
1076
+ if disabled.upcase=='TRUE'
1077
+ disabled = 'disabled'
1078
+ else
1079
+ disabled = ''
1080
+ end
1081
+ return '<input type="checkbox" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1082
+ <script type="text/javascript">
1083
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1084
+ '+id.to_s+'.add(Validate.Acceptance);
1085
+ </script>'
1086
+ end
1087
+ overload(:input_checkbox_lv,String,String,String,String,String,String,Integer,String)
1088
+ def input_checkbox_lv(id,name,value,readonly,disabled,alt,tabindex)
1089
+ if readonly.upcase=='TRUE'
1090
+ readonly = 'readonly'
1091
+ else
1092
+ readonly = ''
1093
+ end
1094
+ if disabled.upcase=='TRUE'
1095
+ disabled = 'disabled'
1096
+ else
1097
+ disabled = ''
1098
+ end
1099
+ return '<input type="checkbox" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '">
1100
+ <script type="text/javascript">
1101
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1102
+ '+id.to_s+'.add(Validate.Acceptance);
1103
+ </script>'
1104
+ end
1105
+ overload(:input_checkbox_lv,String,String,String,String,String,String,Integer)
1106
+ def input_radio_button_lv(id,name,value,readonly,disabled,alt,tabindex,css)
1107
+ if readonly.upcase=='TRUE'
1108
+ readonly = 'readonly'
1109
+ else
1110
+ readonly = ''
1111
+ end
1112
+ if disabled.upcase=='TRUE'
1113
+ disabled = 'disabled'
1114
+ else
1115
+ disabled = ''
1116
+ end
1117
+ return '<input type="radio" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">'+value.to_s
1118
+ end
1119
+ overload(:input_radio_button_lv,String,String,String,String,String,String,Integer,String)
1120
+ def input_radio_button_lv(id,name,value,readonly,disabled,alt,tabindex)
1121
+ if readonly.upcase=='TRUE'
1122
+ readonly = 'readonly'
1123
+ else
1124
+ readonly = ''
1125
+ end
1126
+ if disabled.upcase=='TRUE'
1127
+ disabled = 'disabled'
1128
+ else
1129
+ disabled = ''
1130
+ end
1131
+ return '<input selected type="radio" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '">'+value.to_s
1132
+ end
1133
+ overload(:input_radio_button_lv,String,String,String,String,String,String,Integer)
1134
+ def input_combobox_lv(id,name,range,readonly,disabled,alt,tabindex,css)
1135
+ if readonly.upcase=='TRUE'
1136
+ readonly = 'readonly'
1137
+ else
1138
+ readonly = ''
1139
+ end
1140
+ if disabled.upcase=='TRUE'
1141
+ disabled = 'disabled'
1142
+ else
1143
+ disabled = ''
1144
+ end
1145
+ texto = '<select id="'+id.to_s+'" name="'+name.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">'
1146
+ itemsRange = Array.new()
1147
+ itemsRange = range.split(',')
1148
+ tamanoitemsRange = itemsRange.length - 1
1149
+ for i in 0..tamanoitemsRange
1150
+ if i==0
1151
+ texto = texto + '<option selected value="' + itemsRange[i].to_s + '">' + itemsRange[i].to_s + '</option>'
1152
+ else
1153
+ texto = texto + '<option value="' + itemsRange[i].to_s + '">' + itemsRange[i].to_s + '</option>'
1154
+ end
1155
+ end
1156
+ texto = texto + '</select>'
1157
+ return texto
1158
+ end
1159
+ overload(:input_combobox_lv,String,String,String,String,String,String,Integer,String)
1160
+ def input_combobox_lv(id,name,range,readonly,disabled,alt,tabindex)
1161
+ if readonly.upcase=='TRUE'
1162
+ readonly = 'readonly'
1163
+ else
1164
+ readonly = ''
1165
+ end
1166
+ if disabled.upcase=='TRUE'
1167
+ disabled = 'disabled'
1168
+ else
1169
+ disabled = ''
1170
+ end
1171
+ texto = '<select id="'+id.to_s+'" name="'+name.to_s+'" ' + readonly.to_s + ' ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '">'
1172
+ itemsRange = Array.new()
1173
+ itemsRange = range.split(',')
1174
+ tamanoitemsRange = itemsRange.length - 1
1175
+ for i in 0..tamanoitemsRange
1176
+ if i==0
1177
+ texto = texto + '<option selected value="' + itemsRange[i].to_s + '">' + itemsRange[i].to_s + '</option>'
1178
+ else
1179
+ texto = texto + '<option value="' + itemsRange[i].to_s + '">' + itemsRange[i].to_s + '</option>'
1180
+ end
1181
+ end
1182
+ texto = texto + '</select>'
1183
+ return texto
1184
+ end
1185
+ overload(:input_combobox_lv,String,String,String,String,String,String,Integer)
1186
+ def input_inclusion_lv(range,partial,type,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
1187
+ if readonly.upcase=='TRUE'
1188
+ readonly = 'readonly'
1189
+ else
1190
+ readonly = ''
1191
+ end
1192
+ if disabled.upcase=='TRUE'
1193
+ disabled = 'disabled'
1194
+ else
1195
+ disabled = ''
1196
+ end
1197
+ itemsRange = Array.new()
1198
+ itemsRange = range.split(',')
1199
+ tamanoitemsRange = itemsRange.length - 1
1200
+ jsRange = '["'
1201
+ for i in 0..tamanoitemsRange
1202
+ if i<tamanoitemsRange
1203
+ jsRange = jsRange.to_s + itemsRange[i].to_s + '","'
1204
+ else
1205
+ jsRange = jsRange.to_s + itemsRange[i].to_s + '"]'
1206
+ end
1207
+ end
1208
+ return '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1209
+ <script type="text/javascript">
1210
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1211
+ '+id.to_s+'.add(Validate.Presence);
1212
+ '+id.to_s+'.add(Validate.Inclusion, { within: ' + jsRange.to_s + ', partialMatch: ' + partial.to_s + ' });
1213
+ </script>'
1214
+ end
1215
+ def input_exclusion_lv(range,partial,type,id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
1216
+ if readonly.upcase=='TRUE'
1217
+ readonly = 'readonly'
1218
+ else
1219
+ readonly = ''
1220
+ end
1221
+ if disabled.upcase=='TRUE'
1222
+ disabled = 'disabled'
1223
+ else
1224
+ disabled = ''
1225
+ end
1226
+ itemsRange = Array.new()
1227
+ itemsRange = range.split(',')
1228
+ jsRange = '["'
1229
+ if range=='A..9'
1230
+ jsRange = jsRange.to_s + 'A","B","C","D","E","F","G","H","I","J","K","L","M","N","Ñ","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9' + '"]'
1231
+ else
1232
+ if range=='A..Z'
1233
+ jsRange = jsRange.to_s + 'A","B","C","D","E","F","G","H","I","J","K","L","M","N","Ñ","O","P","Q","R","S","T","U","V","W","X","Y","Z' + '"]'
1234
+ else
1235
+ if range=='a..9'
1236
+ jsRange = jsRange.to_s + 'a","b","c","d","e","f","g","h","i","j","k","l","m","n","ñ","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9' + '"]'
1237
+ else
1238
+ if range=='a..z'
1239
+ jsRange = jsRange.to_s + 'a","b","c","d","e","f","g","h","i","j","k","l","m","n","ñ","o","p","q","r","s","t","u","v","w","x","y","z' + '"]'
1240
+ else
1241
+ if range=='0..9'
1242
+ jsRange = jsRange.to_s + '0","1","2","3","4","5","6","7","8","9' + '"]'
1243
+ else
1244
+ tamanoitemsRange = itemsRange.length - 1
1245
+ for i in 0..tamanoitemsRange
1246
+ if i<tamanoitemsRange
1247
+ jsRange = jsRange.to_s + itemsRange[i].to_s + '","'
1248
+ else
1249
+ jsRange = jsRange.to_s + itemsRange[i].to_s + '"]'
1250
+ end
1251
+ end
1252
+ end
1253
+ end
1254
+ end
1255
+ end
1256
+ end
1257
+ return '<input type="' + type.to_s + '" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1258
+ <script type="text/javascript">
1259
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1260
+ '+id.to_s+'.add(Validate.Presence);
1261
+ '+id.to_s+'.add(Validate.Exclusion, { within: ' + jsRange.to_s + ', partialMatch: ' + partial.to_s + ' });
1262
+ </script>'
1263
+ end
1264
+ def create_massValidate_lv(ids,messageError)
1265
+ return '<script type="text/javascript">
1266
+ form.onsubmit = function(e){
1267
+ var exito = LiveValidation.massValidate(['+ids.to_s+']);
1268
+ if (exito==true)
1269
+ {
1270
+ form.submit();
1271
+ return true;
1272
+ }
1273
+ else
1274
+ {
1275
+ Ext.onReady(function(){
1276
+ Ext.MessageBox.show({
1277
+ title: "Error",
1278
+ msg: "' + messageError.to_s + '" ,
1279
+ width:400,
1280
+ buttons: Ext.MessageBox.OK,
1281
+ icon: Ext.MessageBox.ERROR
1282
+ });
1283
+
1284
+ });
1285
+ }
1286
+ return false;
1287
+ }
1288
+ </script>'
1289
+ end
1290
+ def input_validate_email_lv(id,name,value,readonly,size,maxlength,disabled,alt,tabindex,css)
1291
+ return '<input type="text" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" ' + readonly.to_s + ' size="'+ size.to_s + '" maxlength="' + maxlength.to_s + '" ' + disabled.to_s + ' alt="' + alt.to_s + '" tabindex="' + tabindex.to_s + '" class="' + css.to_s + '">
1292
+ <script type="text/javascript">
1293
+ var '+id.to_s+' = new LiveValidation("'+id.to_s+'");
1294
+ '+id.to_s+'.add(Validate.Presence);
1295
+ '+id.to_s+'.add(Validate.Email);
1296
+ </script>'
1297
+ end
1298
+ # Funciones usando Extjs
1299
+ def input_button_extjs(id,name,value,css,form,fieldNames,messageError,js)
1300
+ theitems = 'var exito = true; '
1301
+ if fieldNames==''
1302
+ condicion1 = 'exito==true'
1303
+ condicion2 = ''
1304
+ else
1305
+ itemsids = Array.new()
1306
+ itemsids = fieldNames.split(",")
1307
+ condicion1 = ''
1308
+ condicion2 = ''
1309
+ for i in 0..itemsids.length-1
1310
+ if i == itemsids.length-1
1311
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() '
1312
+ else
1313
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() && '
1314
+ end
1315
+ condicion2 = condicion2.to_s + itemsids[i].to_s + '.clearInvalid(); '
1316
+ end
1317
+ end
1318
+ return '<script>
1319
+ function '+id.to_s+name.to_s+'()
1320
+ {
1321
+ '+theitems+'
1322
+ if ('+condicion1.to_s+')
1323
+ {
1324
+ '+js+';
1325
+ return true;
1326
+ }
1327
+ else
1328
+ {
1329
+ Ext.MessageBox.show({
1330
+ title: "Error",
1331
+ msg: "' + messageError.to_s + '",
1332
+ width:400,
1333
+ buttons: Ext.MessageBox.OK,
1334
+ icon: Ext.MessageBox.ERROR
1335
+ });
1336
+ '+condicion2.to_s+'
1337
+ return false;
1338
+ }
1339
+ }
1340
+ </script>
1341
+ <input type="button" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" onclick="return '+id.to_s+name.to_s+'()">'
1342
+ end
1343
+ def input_submit_extjs(id,name,value,css,form,fieldsHidden,js)
1344
+ registros = Array.new
1345
+ campos = Array.new
1346
+ theitems = ''
1347
+ registros = fieldsHidden.split('|')
1348
+ for i in 0..registros.length-1
1349
+ campos = registros[i].split(',')
1350
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
1351
+ end
1352
+ return '<script>
1353
+ function '+id.to_s+js.to_s+'
1354
+ {
1355
+ '+theitems+' if ('+js.to_s+') { return true; } else { return false; };
1356
+ }
1357
+ </script>
1358
+ <input type="submit" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" onclick="return '+id.to_s+js.to_s+'">'
1359
+ end
1360
+ overload(:input_submit_extjs,String,String,String,String,String,String,String)
1361
+ def input_submit_extjs(id,name,value,css,form,fieldsHidden,fieldNames,messageError)
1362
+ registros = Array.new
1363
+ campos = Array.new
1364
+ theitems = 'var exito = true; '
1365
+ registros = fieldsHidden.split('|')
1366
+ for i in 0..registros.length-1
1367
+ campos = registros[i].split(',')
1368
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
1369
+ end
1370
+ if fieldNames==''
1371
+ condicion1 = 'exito==true'
1372
+ condicion2 = ''
1373
+ else
1374
+ itemsids = Array.new()
1375
+ itemsids = fieldNames.split(",")
1376
+ condicion1 = ''
1377
+ condicion2 = ''
1378
+ for i in 0..itemsids.length-1
1379
+ if i == itemsids.length-1
1380
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() '
1381
+ else
1382
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() && '
1383
+ end
1384
+ condicion2 = condicion2.to_s + itemsids[i].to_s + '.clearInvalid(); '
1385
+ end
1386
+ end
1387
+ return '<script>
1388
+ function '+id.to_s+name.to_s+'()
1389
+ {
1390
+ '+theitems+'
1391
+ if ('+condicion1.to_s+')
1392
+ {
1393
+ return true;
1394
+ }
1395
+ else
1396
+ {
1397
+ Ext.MessageBox.show({
1398
+ title: "Error",
1399
+ msg: "' + messageError.to_s + '",
1400
+ width:400,
1401
+ buttons: Ext.MessageBox.OK,
1402
+ icon: Ext.MessageBox.ERROR
1403
+ });
1404
+ '+condicion2.to_s+'
1405
+ return false;
1406
+ }
1407
+ }
1408
+ </script>
1409
+ <input type="submit" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" onclick="return '+id.to_s+name.to_s+'()">'
1410
+ end
1411
+ overload(:input_submit_extjs,String,String,String,String,String,String,String,String)
1412
+ def input_reset_extjs(id,name,value,css)
1413
+ return '<input type="reset" id="'+id.to_s+'" name="'+name.to_s+'" value="'+value.to_s+'" class="' + css.to_s + '" >'
1414
+ end
1415
+ def create_massValidate_extjs(name,ids,mensaje)
1416
+ itemsids = Array.new()
1417
+ itemsids = ids.split(",")
1418
+ condicion1 = ''
1419
+ condicion2 = ''
1420
+ for i in 0..itemsids.length-1
1421
+ if i == itemsids.length-1
1422
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() '
1423
+ else
1424
+ condicion1 = condicion1.to_s + itemsids[i].to_s + '.isValid() && '
1425
+ end
1426
+ condicion2 = condicion2.to_s + itemsids[i].to_s + '.clearInvalid(); '
1427
+ end
1428
+ return '<script>
1429
+ function '+name.to_s+'
1430
+ {
1431
+ if ('+condicion1.to_s+')
1432
+ {
1433
+ return true;
1434
+ }
1435
+ else
1436
+ {
1437
+ Ext.MessageBox.show({
1438
+ title: "Error",
1439
+ msg: "' + mensaje.to_s + '",
1440
+ width:400,
1441
+ buttons: Ext.MessageBox.OK,
1442
+ icon: Ext.MessageBox.ERROR
1443
+ });
1444
+ '+condicion2.to_s+'
1445
+ return false;
1446
+ }
1447
+ }
1448
+ </script>'
1449
+ end
1450
+ def create_label_extjs(id,width,text,disabled,cls)
1451
+ return '<div id="k'+id.to_s+'"></div>
1452
+ <script>
1453
+ var k'+id.to_s+' = new Ext.form.Label({
1454
+ id: "'+id.to_s+'",
1455
+ width: '+width.to_s+',
1456
+ text: "'+text.to_s+'",
1457
+ disabled: '+disabled.to_s+',
1458
+ cls: "'+cls.to_s+'"
1459
+ });
1460
+ k'+id.to_s+'.render("k'+id.to_s+'");
1461
+ </script>'
1462
+ end
1463
+ overload(:create_label_extjs,String,String,String,String,String)
1464
+ def create_label_extjs(id,width,text,disabled,cls,x,y)
1465
+ return '<div id="k'+id.to_s+'"></div>
1466
+ <script>
1467
+ var k'+id.to_s+' = new Ext.form.Label({
1468
+ renderTo: document.body,
1469
+ floating: true,
1470
+ id: "'+id.to_s+'",
1471
+ width: '+width.to_s+',
1472
+ text: "'+text.to_s+'",
1473
+ disabled: '+disabled.to_s+',
1474
+ cls: "'+cls.to_s+'"
1475
+ });
1476
+ k'+id.to_s+'.setPagePosition('+x.to_s+','+y.to_s+');
1477
+ k'+id.to_s+'.render("k'+id.to_s+'");
1478
+ </script>'
1479
+ end
1480
+ overload(:create_label_extjs,String,String,String,String,String,String,String)
1481
+ def input_datefield_extjs(id,name,value,readonly,blankText,disabled,invalidText)
1482
+ return '<span id="k' + id.to_s + '"></span>
1483
+ <script>
1484
+ var '+name.to_s+' = new Ext.form.DateField({
1485
+ name: "' + name.to_s + '",
1486
+ id: "' + id.to_s + '",
1487
+ value: "' + value.to_s + '",
1488
+ readOnly: ' + readonly.to_s + ',
1489
+ blankText: "' + blankText.to_s + '",
1490
+ disabled: '+disabled.to_s+',
1491
+ invalidText: "' + invalidText.to_s + '"
1492
+ });
1493
+ '+name.to_s+'.render("k'+id.to_s+'");
1494
+ </script>'
1495
+ end
1496
+ overload(:input_datefield_extjs,String,String,String,String,String,String,String)
1497
+ def input_datefield_extjs(id,name,value,readonly,blankText,invalidText,type,vtype,disabled,dateField)
1498
+ if type=='1'
1499
+ startendDateField = 'endDateField: "' + dateField.to_s + '" '
1500
+ else
1501
+ startendDateField = 'startDateField: "' + dateField.to_s + '" '
1502
+ end
1503
+ return '<span id="k' + id.to_s + '"></span>
1504
+ <script>
1505
+ var '+name.to_s+' = new Ext.form.DateField({
1506
+ name: "' + name.to_s + '",
1507
+ id: "' + id.to_s + '",
1508
+ value: "' + value.to_s + '",
1509
+ readOnly: ' + readonly.to_s + ',
1510
+ blankText: "' + blankText.to_s + '",
1511
+ invalidText: "' + invalidText.to_s + '",
1512
+ disabled: '+disabled.to_s+',
1513
+ vtype: "' + vtype.to_s + '", ' + startendDateField + '
1514
+ });
1515
+ '+name.to_s+'.render("k'+id.to_s+'");
1516
+ </script>'
1517
+ end
1518
+ overload(:input_datefield_extjs,String,String,String,String,String,String,String,String,String,String)
1519
+ def input_textField_extjs(id,name,inputType,width,allowBlank,value,disabled,cls)
1520
+ if inputType.upcase=='MD5'
1521
+ inputType='password'
1522
+ return '<div id="k'+id.to_s+'"></div>
1523
+ <script>
1524
+ function '+id.to_s+'encriptar_id_md5(idEl)
1525
+ {
1526
+ if ('+id.to_s+'old_clave_md5!=document.getElementById(idEl).value)
1527
+ {
1528
+ document.getElementById(idEl).value = hex_md5(document.getElementById(idEl).value);
1529
+ '+id.to_s+'old_clave_md5 = document.getElementById(idEl).value;
1530
+ }
1531
+ }
1532
+ var '+name.to_s+' = new Ext.form.TextField({
1533
+ id: "'+id.to_s+'",
1534
+ name: "'+name.to_s+'",
1535
+ inputType: "'+inputType.to_s+'",
1536
+ width: '+width.to_s+',
1537
+ allowBlank: '+allowBlank.to_s+',
1538
+ value: "'+value.to_s+'",
1539
+ disabled: '+disabled.to_s+',
1540
+ cls: "'+cls.to_s+'"
1541
+ });
1542
+ '+id.to_s+'El = Ext.get("k'+id.to_s+'");
1543
+ '+id.to_s+'El.addKeyListener([10,13,32], function(){
1544
+ '+id.to_s+'encriptar_id_md5('+name.to_s+'.getId());
1545
+ });
1546
+ '+name.to_s+'.on("change", function() { '+id.to_s+'encriptar_id_md5('+name.to_s+'.getId()); });
1547
+ '+name.to_s+'.render("k'+id.to_s+'");
1548
+ var '+id.to_s+'old_clave_md5 = document.getElementById('+name.to_s+'.getId()).value;
1549
+ </script>'
1550
+ else
1551
+ return '<div id="k'+id.to_s+'"></div>
1552
+ <script>
1553
+ var '+name.to_s+' = new Ext.form.TextField({
1554
+ id: "'+id.to_s+'",
1555
+ name: "'+name.to_s+'",
1556
+ inputType: "'+inputType.to_s+'",
1557
+ width: '+width.to_s+',
1558
+ allowBlank: '+allowBlank.to_s+',
1559
+ value: "'+value.to_s+'",
1560
+ disabled: '+disabled.to_s+',
1561
+ cls: "'+cls.to_s+'"
1562
+ });
1563
+ '+name.to_s+'.render("k'+id.to_s+'");
1564
+ </script>'
1565
+ end
1566
+ end
1567
+ def input_file_extjs(id,name,width,allowBlank,value,disabled,cls)
1568
+ return '<div id="k'+id.to_s+'"></div>
1569
+ <script>
1570
+ var '+name.to_s+' = new Ext.form.FileUploadField({
1571
+ id: "'+id.to_s+'",
1572
+ name: "'+name.to_s+'",
1573
+ renderTo: "k'+id.to_s+'",
1574
+ width: '+width.to_s+',
1575
+ allowBlank: '+allowBlank.to_s+',
1576
+ value: "'+value.to_s+'",
1577
+ disabled: '+disabled.to_s+',
1578
+ cls: "'+cls.to_s+'"
1579
+ });
1580
+ </script>'
1581
+ end
1582
+ def input_textArea_extjs(id,name,width,height,allowBlank,value,disabled,cls)
1583
+ return '<div id="k'+id.to_s+'"></div>
1584
+ <script>
1585
+ var '+name.to_s+' = new Ext.form.TextArea({
1586
+ id: "'+id.to_s+'",
1587
+ name: "'+name.to_s+'",
1588
+ height: '+height.to_s+',
1589
+ width: '+width.to_s+',
1590
+ allowBlank: '+allowBlank.to_s+',
1591
+ value: "'+value.to_s+'",
1592
+ disabled: '+disabled.to_s+',
1593
+ cls: "'+cls.to_s+'"
1594
+ });
1595
+ '+name.to_s+'.render("k'+id.to_s+'");
1596
+ </script>'
1597
+ end
1598
+ def input_timeField_extjs(id,name,width,minValue,maxValue,increment,allowBlank,value,disabled,cls)
1599
+ return '<div id="k'+id.to_s+'"></div>
1600
+ <script>
1601
+ var '+name.to_s+' = new Ext.form.TimeField({
1602
+ id: "'+id.to_s+'",
1603
+ name: "'+name.to_s+'",
1604
+ minValue: "'+minValue.to_s+'",
1605
+ maxValue: "'+maxValue.to_s+'",
1606
+ increment: '+increment.to_s+',
1607
+ width: '+width.to_s+',
1608
+ allowBlank: '+allowBlank.to_s+',
1609
+ value: "'+value.to_s+'",
1610
+ disabled: '+disabled.to_s+',
1611
+ cls: "'+cls.to_s+'"
1612
+ });
1613
+ '+name.to_s+'.render("k'+id.to_s+'");
1614
+ </script>'
1615
+ end
1616
+ def input_numberField_extjs(id,name,inputType,width,allowBlank,value,disabled,cls)
1617
+ if inputType.upcase=='INTEGER'
1618
+ return '<div id="k'+id.to_s+'"></div>
1619
+ <script>
1620
+ var '+name.to_s+' = new Ext.form.NumberField({
1621
+ id: "'+id.to_s+'",
1622
+ name: "'+name.to_s+'",
1623
+ width: '+width.to_s+',
1624
+ allowDecimals: false,
1625
+ allowBlank: '+allowBlank.to_s+',
1626
+ value: "'+value.to_s+'",
1627
+ disabled: '+disabled.to_s+',
1628
+ cls: "'+cls.to_s+'"
1629
+ });
1630
+ '+name.to_s+'.render("k'+id.to_s+'");
1631
+ </script>'
1632
+ else
1633
+ return '<div id="k'+id.to_s+'"></div>
1634
+ <script>
1635
+ var '+name.to_s+' = new Ext.form.NumberField({
1636
+ id: "'+id.to_s+'",
1637
+ name: "'+name.to_s+'",
1638
+ width: '+width.to_s+',
1639
+ allowDecimals: true,
1640
+ allowBlank: '+allowBlank.to_s+',
1641
+ value: "'+value.to_s+'",
1642
+ disabled: '+disabled.to_s+',
1643
+ cls: "'+cls.to_s+'"
1644
+ });
1645
+ '+name.to_s+'.render("k'+id.to_s+'");
1646
+ </script>'
1647
+ end
1648
+ end
1649
+ =begin
1650
+ def input_numberField_extjs(id,name,inputType,width,allowBlank,value,disabled,cls)
1651
+ if inputType.upcase=='INTEGER'
1652
+ return '<div id="k'+id.to_s+'"></div>
1653
+ <script>
1654
+ var '+name.to_s+' = new Ext.form.TextField({
1655
+ id: "'+id.to_s+'",
1656
+ name: "'+name.to_s+'",
1657
+ width: '+width.to_s+',
1658
+ allowBlank: '+allowBlank.to_s+',
1659
+ value: "'+value.to_s+'",
1660
+ cls: "'+cls.to_s+'",
1661
+ disabled: '+disabled.to_s+',
1662
+ vtype: "'+id.to_s+'validNumber"
1663
+ });
1664
+ '+name.to_s+'.render("k'+id.to_s+'");
1665
+ Ext.apply(Ext.form.VTypes, {
1666
+ '+id.to_s+'validNumber: function(value, field)
1667
+ {
1668
+ var lon = value.length-1;
1669
+ var x=value.substr(lon,1);
1670
+ if(/[^0-90-9]/.test(x)) return false;
1671
+ return true;
1672
+ }
1673
+ });
1674
+ </script>'
1675
+ else
1676
+ return '<div id="k'+id.to_s+'"></div>
1677
+ <script>
1678
+ var '+name.to_s+' = new Ext.form.NumberField({
1679
+ id: "'+id.to_s+'",
1680
+ name: "'+name.to_s+'",
1681
+ width: '+width.to_s+',
1682
+ allowBlank: '+allowBlank.to_s+',
1683
+ value: "'+value.to_s+'",
1684
+ disabled: '+disabled.to_s+',
1685
+ cls: "'+cls.to_s+'"
1686
+ });
1687
+ '+name.to_s+'.render("k'+id.to_s+'");
1688
+ </script>'
1689
+ end
1690
+ end
1691
+ =end
1692
+ =begin
1693
+ #NO FUNCIONA, acceder las propiedades al arreglo items, para cambiarlas
1694
+ #/*if (rg.getXType()=="radiogroup")
1695
+ #{
1696
+ # alert("Es Radio Group");
1697
+ # var item0 = rg.items[0];
1698
+ # alert(rg.items[0].checked); // ESTO NO FUNCIONA hasta la version Extjs 2.2
1699
+ #}*/
1700
+ def input_radioGroup_extjs(id,name,columns,items,disabled,cls)
1701
+ theitems = ''
1702
+ registros = items.split('|')
1703
+ for i in 0..registros.length-1
1704
+ campos = registros[i].split(',')
1705
+ if i==registros.length-1
1706
+ theitems = theitems + '{boxLabel: "'+campos[0].to_s+'", name: "'+name.to_s+'", inputValue: "'+campos[1].to_s+'", checked: '+campos[2].to_s+'}'
1707
+ else
1708
+ theitems = theitems + '{boxLabel: "'+campos[0].to_s+'", name: "'+name.to_s+'", inputValue: "'+campos[1].to_s+'", checked: '+campos[2].to_s+'}, '
1709
+ end
1710
+ end
1711
+ return '<div id="k'+id.to_s+'"></div>
1712
+ <script>
1713
+ var '+name.to_s+' = new Ext.form.RadioGroup({
1714
+ id: "'+id.to_s+'",
1715
+ name: "'+name.to_s+'",
1716
+ columns: ['+columns.to_s+'],
1717
+ items: [ '+theitems.to_s+' ],
1718
+ disabled: '+disabled.to_s+',
1719
+ cls: "'+cls.to_s+'"
1720
+ });
1721
+ '+name.to_s+'.render("k'+id.to_s+'");
1722
+ </script>'
1723
+ end
1724
+ =end
1725
+ def input_radioGroup_extjs(id,name,columns,items,disabled,cls)
1726
+ theRadio = ''
1727
+ theRadio0 = ''
1728
+ xy = Array.new
1729
+ xy = columns.split(",")
1730
+ registros = Array.new
1731
+ registros = items.split('|')
1732
+ theRadio0 = theRadio0+name.to_s+' = new Ext.form.Hidden(); '
1733
+ for i in 0..registros.length-1
1734
+ campos = registros[i].split(',')
1735
+ theitems = 'boxLabel: "'+campos[0].to_s+'", name: "'+name.to_s+'", inputValue: "'+campos[1].to_s+'", checked: '+campos[2].to_s+','
1736
+ if campos[2].to_s=='true'
1737
+ theRadio0 = theRadio0+name.to_s+'.setValue("'+campos[1].to_s+'"); '
1738
+ theRadio0 = theRadio0+name.to_s+'.render("k'+id.to_s+'"); '
1739
+ end
1740
+ theRadio = theRadio+name.to_s+i.to_s+' = new Ext.form.Radio({
1741
+ id: "'+id.to_s+i.to_s+'",
1742
+ name: "'+name.to_s+'",
1743
+ '+theitems+'
1744
+ disabled: '+disabled.to_s+',
1745
+ cls: "'+cls.to_s+'"
1746
+ }); '
1747
+ theRadio = theRadio+name.to_s+i.to_s+'.setSize('+xy[0].to_s+','+xy[1].to_s+'); '
1748
+ #theRadio = theRadio+name.to_s+i.to_s+'.on("click", function(){ '
1749
+ #for j in 0..registros.length-1
1750
+ # if j==i
1751
+ # theRadio = theRadio+name.to_s+j.to_s+'.checked=true; '+name.to_s+'.setValue('+name.to_s+j.to_s+'.getValue()); alert('+name.to_s+'.getValue()); '
1752
+ # else
1753
+ # theRadio = theRadio+name.to_s+j.to_s+'.checked=false; '
1754
+ # end
1755
+ #end
1756
+ #theRadio = theRadio+' }); '
1757
+ theRadio = theRadio+name.to_s+i.to_s+'.render("k'+id.to_s+'"); '
1758
+ end
1759
+ return '<div id="k'+id.to_s+'"></div>
1760
+ <script>
1761
+ '+theRadio0+'
1762
+ '+theRadio+'
1763
+ </script>'
1764
+ end
1765
+ def input_comboBox_extjs(id,name,width,store,emptyText,disabled,cls)
1766
+ thestore = ''
1767
+ campos = store.split(',')
1768
+ for i in 0..campos.length-1
1769
+ if i==campos.length-1
1770
+ thestore = thestore + '["'+campos[i].to_s+'"]'
1771
+ else
1772
+ thestore = thestore + '["'+campos[i].to_s+'"],'
1773
+ end
1774
+ end
1775
+ if store.index(emptyText) != nil
1776
+ thevalue = 'value: "'+emptyText.to_s+'"'
1777
+ else
1778
+ thevalue = 'emptyText: "'+emptyText.to_s+'"'
1779
+ end
1780
+ return '<div id="k'+id.to_s+'"></div>
1781
+ <script>
1782
+ var '+id.to_s+'store = new Ext.data.SimpleStore({
1783
+ fields: [ "'+name.to_s+'" ],
1784
+ data : [ '+thestore.to_s+' ]
1785
+ });
1786
+ var '+name.to_s+' = new Ext.form.ComboBox({
1787
+ id: "'+id.to_s+'",
1788
+ name: "'+name.to_s+'",
1789
+ store: '+id.to_s+'store,
1790
+ width: '+width.to_s+',
1791
+ displayField: "'+name.to_s+'",
1792
+ typeAhead: true,
1793
+ mode: "local",
1794
+ triggerAction: "all",
1795
+ '+thevalue.to_s+',
1796
+ disabled: '+disabled.to_s+',
1797
+ cls: "'+cls.to_s+'"
1798
+ });
1799
+ '+name.to_s+'.render("k'+id.to_s+'");
1800
+ </script>'
1801
+ end
1802
+ =begin
1803
+ # NO FUNCIONA, acceder las propiedades al arreglo items, para cambiarlas
1804
+ # /*if (cg.getXType()=="checkboxgroup")
1805
+ # {
1806
+ # alert("Es Checkbox Group");
1807
+ # var item0 = rg.items[0];
1808
+ # alert(cg.items[0].checked); // ESTO NO FUNCIONA hasta la version Extjs 2.2
1809
+ # }*/
1810
+ def input_checkboxGroup_extjs(id,name,columns,items,disabled,cls)
1811
+ theitems = ''
1812
+ registros = items.split('|')
1813
+ for i in 0..registros.length-1
1814
+ campos = registros[i].split(',')
1815
+ if i==registros.length-1
1816
+ theitems = theitems + '{boxLabel: "'+campos[0].to_s+'", inputValue: "'+campos[1].to_s+'", name: "'+campos[2].to_s+'", checked: '+campos[3].to_s+'}'
1817
+ else
1818
+ theitems = theitems + '{boxLabel: "'+campos[0].to_s+'", inputValue: "'+campos[1].to_s+'", name: "'+campos[2].to_s+'", checked: '+campos[3].to_s+'}, '
1819
+ end
1820
+ end
1821
+ return '<div id="k'+id.to_s+'"></div>
1822
+ <script>
1823
+ var '+name.to_s+' = new Ext.form.CheckboxGroup({
1824
+ id: "'+id.to_s+'",
1825
+ name: "'+name.to_s+'",
1826
+ columns: ['+columns.to_s+'],
1827
+ items: [ '+theitems.to_s+' ],
1828
+ disabled: '+disabled.to_s+',
1829
+ cls: "'+cls.to_s+'"
1830
+ });
1831
+ '+name.to_s+'.render("k'+id.to_s+'");
1832
+ </script>'
1833
+ end
1834
+ =end
1835
+ def input_checkboxGroup_extjs(id,name,columns,items,disabled,cls)
1836
+ theCheckbox = ''
1837
+ xy = Array.new
1838
+ xy = columns.split(",")
1839
+ registros = Array.new
1840
+ registros = items.split('|')
1841
+ for i in 0..registros.length-1
1842
+ campos = registros[i].split(',')
1843
+ theitems = 'boxLabel: "'+campos[0].to_s+'", inputValue: "'+campos[1].to_s+'", name: "'+campos[2].to_s+'", checked: '+campos[3].to_s+','
1844
+ theCheckbox = theCheckbox+name.to_s+i.to_s+' = new Ext.form.Checkbox({
1845
+ id: "'+id.to_s+i.to_s+'",
1846
+ '+theitems+'
1847
+ disabled: '+disabled.to_s+',
1848
+ cls: "'+cls.to_s+'"
1849
+ }); '
1850
+ theCheckbox = theCheckbox+name.to_s+i.to_s+'.setSize('+xy[0].to_s+','+xy[1].to_s+'); '
1851
+ theCheckbox = theCheckbox+name.to_s+i.to_s+'.render("k'+id.to_s+'"); '
1852
+ end
1853
+ return '<div id="k'+id.to_s+'"></div>
1854
+ <script>
1855
+ '+theCheckbox+'
1856
+ </script>'
1857
+ end
1858
+ def input_emailField_extjs(id,name,width,allowBlank,value,disabled,cls)
1859
+ return '<div id="k'+id.to_s+'"></div>
1860
+ <script>
1861
+ var '+name.to_s+' = new Ext.form.TextField({
1862
+ id: "'+id.to_s+'",
1863
+ name: "'+name.to_s+'",
1864
+ vtype: "email",
1865
+ width: '+width.to_s+',
1866
+ allowBlank: '+allowBlank.to_s+',
1867
+ value: "'+value.to_s+'",
1868
+ disabled: '+disabled.to_s+',
1869
+ cls: "'+cls.to_s+'"
1870
+ });
1871
+ '+name.to_s+'.render("k'+id.to_s+'");
1872
+ </script>'
1873
+ end
1874
+ def input_htmlEditor_extjs(id,name,value,width,height,allowBlank,disabled,cls)
1875
+ return '<div id="k'+id.to_s+'"></div>
1876
+ <script>
1877
+ var '+name.to_s+' = new Ext.form.HtmlEditor({
1878
+ id: "'+id.to_s+'",
1879
+ name: "'+name.to_s+'",
1880
+ value: "'+value.to_s+'",
1881
+ width: '+width.to_s+',
1882
+ height: '+height.to_s+',
1883
+ allowBlank: '+allowBlank.to_s+',
1884
+ disabled: '+disabled.to_s+',
1885
+ cls: "'+cls.to_s+'",
1886
+ layout: "fit"
1887
+ });
1888
+ '+name.to_s+'.render("k'+id.to_s+'");
1889
+ </script>'
1890
+ end
1891
+ def show_Message_extjs(icon,title,message)
1892
+ if icon.to_s=="ERROR"
1893
+ $kamila_icon_mensaje = 'Ext.MessageBox.ERROR'
1894
+ end
1895
+ if icon.to_s=="QUESTION"
1896
+ $kamila_icon_mensaje = 'Ext.MessageBox.QUESTION'
1897
+ end
1898
+ if icon.to_s=="INFO"
1899
+ $kamila_icon_mensaje = 'Ext.MessageBox.INFO'
1900
+ end
1901
+ return '<script>
1902
+ Ext.MessageBox.show({
1903
+ title: "' + title.to_s + '",
1904
+ msg: "' + message.to_s + '",
1905
+ width:400,
1906
+ buttons: Ext.MessageBox.OK,
1907
+ icon: ' + $kamila_icon_mensaje + '
1908
+ });
1909
+ </script>'
1910
+ end
1911
+ overload(:show_Message_extjs,String,String,String)
1912
+ def show_Message_extjs(icon,title,message,linkto)
1913
+ if icon.to_s=="ERROR"
1914
+ $kamila_icon_mensaje = 'Ext.MessageBox.ERROR'
1915
+ end
1916
+ if icon.to_s=="QUESTION"
1917
+ $kamila_icon_mensaje = 'Ext.MessageBox.QUESTION'
1918
+ end
1919
+ if icon.to_s=="INFO"
1920
+ $kamila_icon_mensaje = 'Ext.MessageBox.INFO'
1921
+ end
1922
+ #$kamila_titulo = title.to_s
1923
+ #$kamila_mensaje = message.to_s
1924
+ #$kamila_linkto = $kamila_site + '/' + linkto.to_s
1925
+ #$kamila_cgi.redirect($kamila_site+"/public/message/message.rhtml")
1926
+ return '<script>
1927
+ Ext.MessageBox.show({
1928
+ title: "' + title.to_s + '",
1929
+ msg: "' + message.to_s + '",
1930
+ width:400,
1931
+ fn: exit,
1932
+ buttons: Ext.MessageBox.OK,
1933
+ icon: ' + $kamila_icon_mensaje + '
1934
+ });
1935
+ function exit()
1936
+ {
1937
+ location.href = "' + $kamila_site + '/' + linkto.to_s + '";
1938
+ }
1939
+ </script>'
1940
+ end
1941
+ overload(:show_Message_extjs,String,String,String,String)
1942
+ def create_tabpanel_extjs(id,active,collapsible,floating,width,height,plain,titles,icons,tabtips,urls,closeable,col,row)
1943
+ itemsTitles = Array.new()
1944
+ itemsIcons = Array.new()
1945
+ itemsTabtips = Array.new()
1946
+ itemsUrls = Array.new()
1947
+ itemsCloseable = Array.new()
1948
+ itemsTitles = titles.split(',')
1949
+ itemsIcons = icons.split(',')
1950
+ itemsTabtips = tabtips.split(',')
1951
+ itemsUrls = urls.split(',')
1952
+ itemsCloseable = closeable.split(',')
1953
+ tamanoitemsRange = itemsTitles.length - 1
1954
+ itemsTab = '['
1955
+ for i in 0..tamanoitemsRange
1956
+ if i==tamanoitemsRange
1957
+ itemsTab = itemsTab + '{
1958
+ title: "' +itemsTitles[i].to_s+'",
1959
+ iconCls: "'+itemsIcons[i].to_s+'",
1960
+ tabTip: "'+itemsTabtips[i].to_s+'",
1961
+ autoLoad: "'+itemsUrls[i].to_s+'",
1962
+ closable: '+itemsCloseable[i].to_s+'
1963
+ }]'
1964
+ else
1965
+ itemsTab = itemsTab + '{
1966
+ title: "' +itemsTitles[i].to_s+'",
1967
+ iconCls: "'+itemsIcons[i].to_s+'",
1968
+ tabTip: "'+itemsTabtips[i].to_s+'",
1969
+ autoLoad: "'+itemsUrls[i].to_s+'",
1970
+ closable: '+itemsCloseable[i].to_s+'
1971
+ },'
1972
+ end
1973
+ end
1974
+ return '<script>
1975
+ var '+id.to_s+'tabs = new Ext.TabPanel({
1976
+ renderTo: document.body,
1977
+ id: "k'+id.to_s+'",
1978
+ activeTab: '+active.to_s+',
1979
+ collapsible: '+collapsible.to_s+',
1980
+ floating: '+floating.to_s+',
1981
+ width:'+width.to_s+',
1982
+ height:'+height.to_s+',
1983
+ plain:'+plain.to_s+',
1984
+ defaults:{autoScroll: true},
1985
+ draggable: {
1986
+ insertProxy: false,
1987
+ onDrag : function(e){
1988
+ var pel = this.proxy.getEl();
1989
+ this.x = pel.getLeft(true);
1990
+ this.y = pel.getTop(true);
1991
+ var s = this.panel.getEl().shadow;
1992
+ if (s) {
1993
+ s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
1994
+ }
1995
+ },
1996
+ endDrag : function(e){
1997
+ this.panel.setPosition(this.x, this.y);
1998
+ }
1999
+ },
2000
+ items: '+itemsTab.to_s+'
2001
+ });
2002
+ '+id.to_s+'tabs.setPagePosition('+col.to_s+','+row.to_s+');
2003
+ '+id.to_s+'tabs.render("k'+id.to_s+'");
2004
+ </script>'
2005
+ end
2006
+ def create_gridView_extjs(nameFunction,title,idCatalogo,ids,ds,cm,widthcm,data)
2007
+ itemsDs = Array.new
2008
+ itemsDs = ds.split(',')
2009
+ itemsds = ''
2010
+ for i in 0..itemsDs.length-1
2011
+ if i==itemsDs.length-1
2012
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"}'
2013
+ else
2014
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"},'
2015
+ end
2016
+ end
2017
+ itemsCm = Array.new
2018
+ itemsWidthcm = Array.new
2019
+ itemsCm = cm.split(',')
2020
+ itemswidthcm = widthcm.split(',')
2021
+ itemscm = ''
2022
+ for i in 0..itemsCm.length-1
2023
+ if i==itemsCm.length-1
2024
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"}'
2025
+ else
2026
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"},'
2027
+ end
2028
+ end
2029
+ if ids!=''
2030
+ itemsIds = Array.new
2031
+ itemsIds = ids.split(',')
2032
+ itemsids = ''
2033
+ for i in 0..itemsIds.length-1
2034
+ itemsids = itemsids + 'Ext.get("'+itemsIds[i].to_s+'").dom.value = '+idCatalogo+'grid.getSelectionModel().getSelected().get("'+itemsDs[i].to_s+'");'
2035
+ end
2036
+ itemsids = itemsids + 'document.getElementById("'+itemsIds[0].to_s+'").select();document.getElementById("'+itemsIds[0].to_s+'").focus();'
2037
+ botonAceptar = '{
2038
+ text:"Aceptar",
2039
+ handler: function()
2040
+ {
2041
+ '+itemsids+'
2042
+ '+idCatalogo+'onoff_clave = true;
2043
+ '+idCatalogo+'win.hide();
2044
+ }
2045
+ },'
2046
+ else
2047
+ botonAceptar = ''
2048
+ end
2049
+ return '<div id="'+idCatalogo+'"></div><div id="'+idCatalogo+'Grid"></div>
2050
+ <script>
2051
+ var '+idCatalogo+'gridOnOff = false;
2052
+ var '+idCatalogo+'winOnOff = false;
2053
+ var '+idCatalogo+'grid = null;
2054
+ var '+idCatalogo+'win = null;
2055
+ function '+nameFunction.to_s+'()
2056
+ {
2057
+ var datos = "'+data.to_s+'";
2058
+ var Registros = datos.split("|");
2059
+ if (Registros.length-1==0)
2060
+ {
2061
+ Ext.MessageBox.alert("Error", "Inesperado, posible error en la vista o modelo");
2062
+ return;
2063
+ }
2064
+ var Datos2 = new Array();
2065
+ var j=0;
2066
+ var k=0;
2067
+ while (j<Registros.length)
2068
+ {
2069
+ var Campos = Registros[j].split(",");
2070
+ var Datos1 = new Array();
2071
+ for (i=0;i<Campos.length; i++)
2072
+ {
2073
+ Datos1[i] = Campos[i];
2074
+ }
2075
+ if (j>0)
2076
+ {
2077
+ Datos2[k] = Datos1;
2078
+ k++
2079
+ }
2080
+ j++;
2081
+ }
2082
+ Ext.grid.Datos = Datos2;
2083
+ if (!'+idCatalogo+'gridOnOff)
2084
+ {
2085
+ '+idCatalogo+'grid = new Ext.grid.GridPanel({
2086
+ border:false,
2087
+ ds: new Ext.data.Store({
2088
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2089
+ data: Ext.grid.Datos
2090
+ }),
2091
+ cm: new Ext.grid.ColumnModel([
2092
+ new Ext.grid.RowNumberer(), '+itemscm+' ]),
2093
+
2094
+ viewConfig: {
2095
+ forceFit:true
2096
+ }
2097
+ });
2098
+ '+idCatalogo+'gridOnOff = true;
2099
+ }
2100
+ else
2101
+ {
2102
+ var storeDatos = new Ext.data.Store({
2103
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2104
+ data: Ext.grid.Datos
2105
+ });
2106
+ '+idCatalogo+'grid.reconfigure(storeDatos,'+idCatalogo+'grid.getColumnModel());
2107
+ }
2108
+ if(!'+idCatalogo+'winOnOff)
2109
+ {
2110
+ '+idCatalogo+'win = new Ext.Window(
2111
+ {
2112
+ el:"'+idCatalogo+'",
2113
+ layout:"fit",
2114
+ title: "'+title.to_s+'",
2115
+ width:500,
2116
+ height:300,
2117
+ modal: true,
2118
+ closeAction:"hide",
2119
+ plain: true,
2120
+ items: '+idCatalogo+'grid,
2121
+ buttons: ['+botonAceptar+'
2122
+ {
2123
+ text: "Salir",
2124
+ handler: function()
2125
+ {
2126
+ '+idCatalogo+'win.hide();
2127
+ }
2128
+ }]
2129
+ });
2130
+ '+idCatalogo+'winOnOff = true;
2131
+ }
2132
+ '+idCatalogo+'win.show(this);
2133
+ '+idCatalogo+'grid.render("'+idCatalogo.to_s+'Grid");
2134
+ '+idCatalogo+'grid.getSelectionModel().selectFirstRow();
2135
+ }
2136
+ </script>'
2137
+ end
2138
+ def create_gridAjaxView_extjs(nameFunction,title,idCatalogo,ids,ds,cm,widthcm,pageserver)
2139
+ itemsDs = Array.new
2140
+ itemsDs = ds.split(',')
2141
+ itemsds = ''
2142
+ for i in 0..itemsDs.length-1
2143
+ if i==itemsDs.length-1
2144
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"}'
2145
+ else
2146
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"},'
2147
+ end
2148
+ end
2149
+ itemsCm = Array.new
2150
+ itemsWidthcm = Array.new
2151
+ itemsCm = cm.split(',')
2152
+ itemswidthcm = widthcm.split(',')
2153
+ itemscm = ''
2154
+ for i in 0..itemsCm.length-1
2155
+ if i==itemsCm.length-1
2156
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"}'
2157
+ else
2158
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"},'
2159
+ end
2160
+ end
2161
+ if ids!=''
2162
+ itemsIds = Array.new
2163
+ itemsIds = ids.split(',')
2164
+ itemsids = ''
2165
+ for i in 0..itemsIds.length-1
2166
+ itemsids = itemsids + 'Ext.get("'+itemsIds[i].to_s+'").dom.value = '+idCatalogo+'grid.getSelectionModel().getSelected().get("'+itemsDs[i].to_s+'");'
2167
+ end
2168
+ itemsids = itemsids + 'document.getElementById("'+itemsIds[0].to_s+'").select();document.getElementById("'+itemsIds[0].to_s+'").focus();'
2169
+ botonAceptar = '{
2170
+ text:"Aceptar",
2171
+ handler: function()
2172
+ {
2173
+ '+itemsids+'
2174
+ '+idCatalogo+'onoff_clave = true;
2175
+ '+idCatalogo+'win.hide();
2176
+ }
2177
+ },'
2178
+ else
2179
+ botonAceptar = ''
2180
+ end
2181
+ return '<div id="'+idCatalogo+'"></div><div id="'+idCatalogo+'Grid"></div>
2182
+ <script>
2183
+ var '+idCatalogo+'gridOnOff = false;
2184
+ var '+idCatalogo+'winOnOff = false;
2185
+ var '+idCatalogo+'grid = null;
2186
+ var '+idCatalogo+'win = null;
2187
+ function '+nameFunction.to_s+'()
2188
+ {
2189
+ Ext.Ajax.request({
2190
+ url : "'+$kamila_site+'/'+pageserver+'",
2191
+ method: "POST",
2192
+ waitMsg: "Cargando...",
2193
+ success: function ( resultado, request ) {
2194
+ var datos = resultado.responseText;
2195
+ var Registros = datos.split("|");
2196
+ if (Registros.length-1==0)
2197
+ {
2198
+ Ext.MessageBox.alert("Error", "Inesperado, posible error en la vista o modelo");
2199
+ return;
2200
+ }
2201
+ var Datos2 = new Array();
2202
+ var j=0;
2203
+ var k=0;
2204
+ while (j<Registros.length)
2205
+ {
2206
+ var Campos = Registros[j].split(",");
2207
+ var Datos1 = new Array();
2208
+ for (i=0;i<Campos.length; i++)
2209
+ {
2210
+ Datos1[i] = Campos[i];
2211
+ }
2212
+ if (j>0)
2213
+ {
2214
+ Datos2[k] = Datos1;
2215
+ k++
2216
+ }
2217
+ j++;
2218
+ }
2219
+ Ext.grid.Datos = Datos2;
2220
+ if (!'+idCatalogo+'gridOnOff)
2221
+ {
2222
+ '+idCatalogo+'grid = new Ext.grid.GridPanel({
2223
+ border:false,
2224
+ ds: new Ext.data.Store({
2225
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2226
+ data: Ext.grid.Datos
2227
+ }),
2228
+ cm: new Ext.grid.ColumnModel([
2229
+ new Ext.grid.RowNumberer(), '+itemscm+' ]),
2230
+
2231
+ viewConfig: {
2232
+ forceFit:true
2233
+ }
2234
+ });
2235
+ '+idCatalogo+'gridOnOff = true;
2236
+ }
2237
+ else
2238
+ {
2239
+ var storeDatos = new Ext.data.Store({
2240
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2241
+ data: Ext.grid.Datos
2242
+ });
2243
+ '+idCatalogo+'grid.reconfigure(storeDatos,'+idCatalogo+'grid.getColumnModel());
2244
+ }
2245
+ if(!'+idCatalogo+'winOnOff)
2246
+ {
2247
+ '+idCatalogo+'win = new Ext.Window(
2248
+ {
2249
+ el:"'+idCatalogo+'",
2250
+ layout:"fit",
2251
+ title: "'+title.to_s+'",
2252
+ width:500,
2253
+ height:300,
2254
+ modal: true,
2255
+ closeAction:"hide",
2256
+ plain: true,
2257
+ items: '+idCatalogo+'grid,
2258
+ buttons: ['+botonAceptar+'
2259
+ {
2260
+ text: "Salir",
2261
+ handler: function()
2262
+ {
2263
+ '+idCatalogo+'win.hide();
2264
+ }
2265
+ }]
2266
+ });
2267
+ '+idCatalogo+'winOnOff = true;
2268
+ }
2269
+ '+idCatalogo+'win.show(this);
2270
+ '+idCatalogo+'grid.render("'+idCatalogo.to_s+'Grid");
2271
+ '+idCatalogo+'grid.getSelectionModel().selectFirstRow();
2272
+ },
2273
+ failure: function ( resultado, request) {
2274
+ Ext.MessageBox.alert("Error", resultado.responseText);
2275
+ }
2276
+ });
2277
+ }
2278
+ </script>'
2279
+ end
2280
+ overload(:create_gridAjaxView_extjs,String,String,String,String,String,String,String,String)
2281
+ def create_gridAjaxView_extjs(nameFunction,width,height,title,idCatalogo,ds,cm,widthcm,pageserver)
2282
+ itemsDs = Array.new
2283
+ itemsDs = ds.split(',')
2284
+ itemsds = ''
2285
+ for i in 0..itemsDs.length-1
2286
+ if i==itemsDs.length-1
2287
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"}'
2288
+ else
2289
+ itemsds = itemsds + '{name: "' + itemsDs[i].to_s + '"},'
2290
+ end
2291
+ end
2292
+ itemsCm = Array.new
2293
+ itemsWidthcm = Array.new
2294
+ itemsCm = cm.split(',')
2295
+ itemswidthcm = widthcm.split(',')
2296
+ itemscm = ''
2297
+ for i in 0..itemsCm.length-1
2298
+ if i==itemsCm.length-1
2299
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"}'
2300
+ else
2301
+ itemscm = itemscm + '{header: "'+itemsCm[i].to_s + '", width: '+itemswidthcm[i].to_s+', sortable: true, dataIndex: "'+itemsDs[i].to_s+'"},'
2302
+ end
2303
+ end
2304
+ if ds!=''
2305
+ itemsIds = Array.new
2306
+ itemsIds = ds.split(',')
2307
+ itemsids = ''
2308
+ for i in 0..itemsIds.length-1
2309
+ itemsids = itemsids + 'if (typeof('+itemsIds[i].to_s+'0)!="undefined") { '
2310
+ itemsids = itemsids + 'if ('+itemsIds[i].to_s+'0.getXType()=="radio") { '
2311
+ itemsids = itemsids + itemsIds[i].to_s+'0.setValue('+idCatalogo+'grid.getSelectionModel().getSelected().get("'+itemsDs[i].to_s+'"));'
2312
+ itemsids = itemsids + ' } }'
2313
+ itemsids = itemsids + 'if (typeof('+itemsIds[i].to_s+')!="undefined") { '
2314
+ itemsids = itemsids + itemsIds[i].to_s+'.setValue('+idCatalogo+'grid.getSelectionModel().getSelected().get("'+itemsDs[i].to_s+'"));'
2315
+ itemsids = itemsids + ' } '
2316
+ end
2317
+ botonAceptar = '{
2318
+ text:"Aceptar",
2319
+ handler: function()
2320
+ {
2321
+ '+itemsids+'
2322
+ '+idCatalogo+'onoff_clave = true;
2323
+ '+idCatalogo+'win.hide();
2324
+ }
2325
+ },'
2326
+ else
2327
+ botonAceptar = ''
2328
+ end
2329
+ return '<div id="'+idCatalogo+'"></div><div id="'+idCatalogo+'Grid"></div>
2330
+ <script>
2331
+ var '+idCatalogo+'gridOnOff = false;
2332
+ var '+idCatalogo+'winOnOff = false;
2333
+ var '+idCatalogo+'grid = null;
2334
+ var '+idCatalogo+'win = null;
2335
+ function '+nameFunction.to_s+'()
2336
+ {
2337
+ Ext.Ajax.request({
2338
+ url : "'+$kamila_site+'/'+pageserver+'",
2339
+ method: "POST",
2340
+ waitMsg: "Cargando...",
2341
+ success: function ( resultado, request ) {
2342
+ var datos = resultado.responseText;
2343
+ var Registros = datos.split("|");
2344
+ if (Registros.length-1==0)
2345
+ {
2346
+ Ext.MessageBox.alert("Error", "Inesperado, posible error en la vista o modelo");
2347
+ return;
2348
+ }
2349
+ var Datos2 = new Array();
2350
+ var j=0;
2351
+ var k=0;
2352
+ while (j<Registros.length-1)
2353
+ {
2354
+ var Campos = Registros[j].split(",");
2355
+ var otroCampos = null;
2356
+ var jj = 0;
2357
+ var exitSalida = false;
2358
+ while (jj<Campos.length && exitSalida==false)
2359
+ {
2360
+ if (Campos[jj].indexOf("$")!=-1)
2361
+ {
2362
+ otrosCampos = Campos[jj].split("$");
2363
+ otrosCampos = otrosCampos[1].split(";")
2364
+ kk=0;
2365
+ m=jj;
2366
+ while (kk<otrosCampos.length)
2367
+ {
2368
+ Campos[m] = otrosCampos[kk];
2369
+ kk++;
2370
+ m++;
2371
+ }
2372
+ exitSalida = true;
2373
+ }
2374
+ jj++;
2375
+ }
2376
+ var Datos1 = new Array();
2377
+ for (i=0;i<Campos.length; i++)
2378
+ {
2379
+ Datos1[i] = Campos[i];
2380
+ }
2381
+ if (j>0)
2382
+ {
2383
+ Datos2[k] = Datos1;
2384
+ k++
2385
+ }
2386
+ j++;
2387
+ }
2388
+ Ext.grid.Datos = Datos2;
2389
+ if (!'+idCatalogo+'gridOnOff)
2390
+ {
2391
+ '+idCatalogo+'grid = new Ext.grid.GridPanel({
2392
+ border:false,
2393
+ ds: new Ext.data.Store({
2394
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2395
+ data: Ext.grid.Datos
2396
+ }),
2397
+ cm: new Ext.grid.ColumnModel([
2398
+ new Ext.grid.RowNumberer(), '+itemscm+' ]),
2399
+
2400
+ viewConfig: {
2401
+ forceFit:true
2402
+ }
2403
+ });
2404
+ '+idCatalogo+'gridOnOff = true;
2405
+ }
2406
+ else
2407
+ {
2408
+ var storeDatos = new Ext.data.Store({
2409
+ reader: new Ext.data.ArrayReader({}, [ '+itemsds+' ]),
2410
+ data: Ext.grid.Datos
2411
+ });
2412
+ '+idCatalogo+'grid.reconfigure(storeDatos,'+idCatalogo+'grid.getColumnModel());
2413
+ }
2414
+ if(!'+idCatalogo+'winOnOff)
2415
+ {
2416
+ '+idCatalogo+'win = new Ext.Window(
2417
+ {
2418
+ el:"'+idCatalogo+'",
2419
+ layout:"fit",
2420
+ title: "'+title.to_s+'",
2421
+ width: '+width.to_s+',
2422
+ height: '+height.to_s+',
2423
+ modal: true,
2424
+ closeAction:"hide",
2425
+ plain: true,
2426
+ items: '+idCatalogo+'grid,
2427
+ buttons: ['+botonAceptar+'
2428
+ {
2429
+ text: "Salir",
2430
+ handler: function()
2431
+ {
2432
+ '+idCatalogo+'win.hide();
2433
+ }
2434
+ }]
2435
+ });
2436
+ '+idCatalogo+'winOnOff = true;
2437
+ }
2438
+ '+idCatalogo+'win.show(this);
2439
+ '+idCatalogo+'grid.render("'+idCatalogo.to_s+'Grid");
2440
+ '+idCatalogo+'grid.getSelectionModel().selectFirstRow();
2441
+ },
2442
+ failure: function ( resultado, request) {
2443
+ Ext.MessageBox.alert("Error", resultado.responseText);
2444
+ }
2445
+ });
2446
+ }
2447
+ </script>'
2448
+ end
2449
+ overload(:create_gridAjaxView_extjs,String,String,String,String,String,String,String,String,String)
2450
+ def create_AjaxFind_extjs(nameFunction,action,params,ids,pageserver)
2451
+ theAction = Array.new
2452
+ theAction = action.split(",")
2453
+ campos = Array.new
2454
+ theParams = ''
2455
+ campos = params.split(',')
2456
+ for i in 0..campos.length-1
2457
+ if i==campos.length-1
2458
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue() '
2459
+ else
2460
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue(), '
2461
+ end
2462
+ end
2463
+ theFields = Array.new
2464
+ theIds = ''
2465
+ theFields = ids.split(",")
2466
+ j=1
2467
+ for i in 0..theFields.length-1
2468
+ theIds = theIds + 'if (typeof('+theFields[i].to_s+')!="undefined") { '
2469
+ theIds = theIds + 'if ('+theFields[i].to_s+'.getXType()=="textfield") { '
2470
+ theIds = theIds + theFields[i].to_s+'.setValue(Campos['+j.to_s+']); '
2471
+ theIds = theIds + ' } } '
2472
+ theIds = theIds + 'if (typeof('+theFields[i].to_s+'0)!="undefined") { '
2473
+ theIds = theIds + 'if ('+theFields[i].to_s+'0.getXType()=="radio") { '
2474
+ #theIds = theIds + ' Campos1 = Registros[1].split("$!"); Campos2 = Campos1[1].split(";"); alert('+theFields[i].to_s+'0.inputValue); alert(Campos2[0]); if ('+theFields[i].to_s+'0.inputValue==Campos2[0]) { '+theFields[i].to_s+'0.checked = true; '+theFields[i].to_s+'1.checked = false; } else { '+theFields[i].to_s+'1.checked = true; '+theFields[i].to_s+'0.checked = false; } '
2475
+ #theIds = theIds + ' Campos1 = Registros[1].split("$!"); Campos2 = Campos1[1].split(";"); if ('+theFields[i].to_s+'0.inputValue==Campos2[0]) { '+theFields[i].to_s+'0.setValue(true); '+theFields[i].to_s+'1.setValue(false); } else { '+theFields[i].to_s+'1.setValue(true); '+theFields[i].to_s+'0.setValue(false); } '
2476
+ theIds = theIds + theFields[i].to_s+'0.setValue(Campos['+j.to_s+']); '
2477
+ theIds = theIds + ' } }'
2478
+ theIds = theIds + 'if (typeof('+theFields[i].to_s+')!="undefined") { '
2479
+ theIds = theIds + 'if ('+theFields[i].to_s+'.getXType()=="checkbox") { '
2480
+ theIds = theIds + theFields[i].to_s+'.setValue(Campos['+j.to_s+']); '
2481
+ theIds = theIds + ' } } '
2482
+ theIds = theIds + 'if (typeof('+theFields[i].to_s+')!="undefined") { '
2483
+ theIds = theIds + 'if ('+theFields[i].to_s+'.getXType()!="textfield") { '
2484
+ theIds = theIds + theFields[i].to_s+'.setValue(Campos['+j.to_s+']); '
2485
+ theIds = theIds + ' } } '
2486
+ j=j+1
2487
+ end
2488
+ return '<script>
2489
+ function '+nameFunction+'()
2490
+ {
2491
+ Ext.Ajax.request({
2492
+ url : "'+$kamila_site+'/'+pageserver+'",
2493
+ params : { '+theAction[0].to_s+': "'+theAction[1].to_s+'", '+theParams+' },
2494
+ method: "POST",
2495
+ success: function ( resultado, request ) {
2496
+ datos = resultado.responseText;
2497
+ var Registros = datos.split("|");
2498
+ if (Registros.length-1==0)
2499
+ {
2500
+ Ext.MessageBox.alert("Error", "Inesperado, posible error en la vista o modelo");
2501
+ return;
2502
+ }
2503
+ var Campos = Registros[1].split(",");
2504
+ var otroCampos = null;
2505
+ var j = 0;
2506
+ var exitSalida = false;
2507
+ while (j<Campos.length && exitSalida==false)
2508
+ {
2509
+ if (Campos[j].indexOf("$")!=-1)
2510
+ {
2511
+ otrosCampos = Campos[j].split("$");
2512
+ otrosCampos = otrosCampos[1].split(";")
2513
+ k=0;
2514
+ m=j;
2515
+ while (k<otrosCampos.length)
2516
+ {
2517
+ Campos[m] = otrosCampos[k];
2518
+ k++;
2519
+ m++;
2520
+ }
2521
+ exitSalida = true;
2522
+ }
2523
+ j++;
2524
+ }
2525
+ if (Campos[0] == 1)
2526
+ {
2527
+ '+theIds+'
2528
+ }
2529
+ else
2530
+ {
2531
+ Ext.MessageBox.alert("Error", Campos[1]);
2532
+ }
2533
+ },
2534
+ failure: function ( result, request) {
2535
+ Ext.MessageBox.alert("Error", result.responseText);
2536
+ }
2537
+ });
2538
+ }
2539
+ </script>'
2540
+ end
2541
+ def create_AjaxSave_extjs(nameFunction,action,params,pageserver)
2542
+ theAction = Array.new
2543
+ theAction = action.split(",")
2544
+ campos = Array.new
2545
+ theParams = ''
2546
+ campos = params.split(',')
2547
+ for i in 0..campos.length-1
2548
+ if i==campos.length-1
2549
+ if campos[i].to_s.index("&")!=nil
2550
+ bb = campos[i].to_s.split("&")
2551
+ campos[i] = bb[1]
2552
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'0.getGroupValue() '
2553
+ else
2554
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue() '
2555
+ end
2556
+ else
2557
+ if campos[i].to_s.index("&")!=nil
2558
+ bb = campos[i].to_s.split("&")
2559
+ campos[i] = bb[1]
2560
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'0.getGroupValue(), '
2561
+ else
2562
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue(), '
2563
+ end
2564
+ end
2565
+ end
2566
+ return '<script>
2567
+ function '+nameFunction+'()
2568
+ {
2569
+ Ext.Ajax.request({
2570
+ url : "'+$kamila_site+'/'+pageserver+'",
2571
+ params : { '+theAction[0].to_s+': "'+theAction[1].to_s+'", '+theParams+' },
2572
+ method: "POST",
2573
+ success: function ( resultado, request ) {
2574
+ mensaje = resultado.responseText;
2575
+ Ext.MessageBox.alert("Informaci&oacute;n", mensaje);
2576
+ },
2577
+ failure: function ( result, request) {
2578
+ Ext.MessageBox.alert("Error", result.responseText);
2579
+ }
2580
+ });
2581
+ }
2582
+ </script>'
2583
+ end
2584
+ def create_AjaxCancel_extjs(nameFunction,action,ids,pageserver)
2585
+ theAction = Array.new
2586
+ theAction = action.split(",")
2587
+ theFields = Array.new
2588
+ theIds = ''
2589
+ theFields = ids.split(",")
2590
+ j=1
2591
+ for i in 0..theFields.length-1
2592
+ theIds = theIds +theFields[i].to_s+'.setValue("");'
2593
+ theIds = theIds +theFields[i].to_s+'.clearInvalid();'
2594
+ j=j+1
2595
+ end
2596
+ return '<script>
2597
+ function '+nameFunction+'()
2598
+ {
2599
+ Ext.Ajax.request({
2600
+ url : "'+$kamila_site+'/'+pageserver+'",
2601
+ params : { '+theAction[0].to_s+': "'+theAction[1].to_s+'" },
2602
+ method: "POST",
2603
+ success: function ( resultado, request ) {
2604
+ '+theIds+'
2605
+ },
2606
+ failure: function ( result, request) {
2607
+ Ext.MessageBox.alert("Error", result.responseText);
2608
+ }
2609
+ });
2610
+ }
2611
+ </script>'
2612
+ end
2613
+ def create_AjaxDelete_extjs(nameFunction,action,params,ids,pageserver)
2614
+ theAction = Array.new
2615
+ theAction = action.split(",")
2616
+ campos = Array.new
2617
+ theParams = ''
2618
+ campos = params.split(',')
2619
+ for i in 0..campos.length-1
2620
+ if i==campos.length-1
2621
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue() '
2622
+ else
2623
+ theParams = theParams.to_s + campos[i].to_s+' : '+campos[i].to_s+'.getValue(), '
2624
+ end
2625
+ end
2626
+ theFields = Array.new
2627
+ theIds = ''
2628
+ theFields = ids.split(",")
2629
+ j=1
2630
+ for i in 0..theFields.length-1
2631
+ theIds = theIds +theFields[i].to_s+'.setValue("");'
2632
+ theIds = theIds +theFields[i].to_s+'.clearInvalid();'
2633
+ j=j+1
2634
+ end
2635
+ return '<script>
2636
+ function '+nameFunction+'()
2637
+ {
2638
+ Ext.Ajax.request({
2639
+ url : "'+$kamila_site+'/'+pageserver+'",
2640
+ params : { '+theAction[0].to_s+': "'+theAction[1].to_s+'", '+theParams+' },
2641
+ method: "POST",
2642
+ success: function ( resultado, request ) {
2643
+ mensaje = resultado.responseText;
2644
+ Ext.MessageBox.alert("Informaci&oacute;n", mensaje);
2645
+ '+theIds+'
2646
+ },
2647
+ failure: function ( result, request) {
2648
+ Ext.MessageBox.alert("Error", result.responseText);
2649
+ }
2650
+ });
2651
+ }
2652
+ </script>'
2653
+ end
2654
+ def create_AjaxPrint_extjs(nameFunction,action,pageserver)
2655
+ theAction = Array.new
2656
+ theAction = action.split(",")
2657
+ return '<script>
2658
+ function '+nameFunction+'()
2659
+ {
2660
+ Ext.Ajax.request({
2661
+ url : "'+$kamila_site+'/'+pageserver+'",
2662
+ params : { '+theAction[0].to_s+': "'+theAction[1].to_s+'" },
2663
+ method: "POST",
2664
+ success: function ( resultado, request ) {
2665
+ datos = resultado.responseText;
2666
+ var Registros = datos.split("|");
2667
+ if (Registros.length-1==0)
2668
+ {
2669
+ Ext.MessageBox.alert("Error", "Inesperado, posible error en la vista o modelo");
2670
+ return;
2671
+ }
2672
+ var Campos = Registros[1].split(",");
2673
+ if (Campos[0] == 1)
2674
+ {
2675
+ var opciones="left=200,top=100,width=550,height=450";
2676
+ mi_ventana = window.open(Campos[1],"",opciones);
2677
+ }
2678
+ else
2679
+ {
2680
+ Ext.MessageBox.alert("Error", Campos[1]);
2681
+ }
2682
+ },
2683
+ failure: function ( result, request) {
2684
+ Ext.MessageBox.alert("Error", result.responseText);
2685
+ }
2686
+ });
2687
+ }
2688
+ </script>'
2689
+ end
2690
+ =begin
2691
+ def create_AjaxFormTabPanel_extjs(panel,tabs,fields,actionsbutton)
2692
+ itemsPanel = Array.new
2693
+ itemsPanel = panel.split(',')
2694
+ itemsTabs = Array.new
2695
+ itemsFields = Array.new
2696
+ tiraItems = 'items: {
2697
+ xtype:"tabpanel",
2698
+ activeTab: 0,
2699
+ defaults:{autoHeight:true, bodyStyle:"padding:10px"},
2700
+ items:[{ '
2701
+ for i in 0..tabs.length-1
2702
+ if i==tabs.length-1
2703
+ else
2704
+ itemsTabs = tabs[i]
2705
+ tiraItems = tiraItems + 'title:"'+itemsTabs[0]+'",'
2706
+ tiraItems = tiraItems + 'layout:"form",'
2707
+ tiraItems = tiraItems + 'labelWidth:'+itemsTabs[1]+','
2708
+ if i==0
2709
+ tiraItems = tiraItems + 'items: [{ '
2710
+ else
2711
+ tiraItems = tiraItems + '},{''
2712
+ end
2713
+ itemsFields = fields[i]
2714
+ tiraItems = tiraItems + 'fieldLabel: "'+itemsFields[0]+'",'
2715
+ tiraItems = tiraItems + 'id: "'+itemsFields[1]+'",'
2716
+ tiraItems = tiraItems + 'name: "'+itemsFields[2]+'",'
2717
+ if itemsFields[3] == 'email'
2718
+ tiraItems = tiraItems + 'vtype: "'+itemsFields[3]+'" '
2719
+ else
2720
+ if itemsFields[3] == 'doublefield'
2721
+ tiraItems = tiraItems + 'xtype: "numberfield" '
2722
+ else
2723
+ if itemsFields[3] == 'integerfield'
2724
+ tiraItems = tiraItems + 'vtype: "validNumber" '
2725
+ else
2726
+ tiraItems = tiraItems + 'xtype: "'+itemsFields[3]+'" '
2727
+ end
2728
+ end
2729
+ end
2730
+ end
2731
+ end
2732
+ return '<script>
2733
+ var '+itemsPanel[0]+'tabs = new Ext.FormPanel({
2734
+ id: "'+itemsPanel[0]+'",
2735
+ border:'+itemsPanel[1]+',
2736
+ width: '+itemsPanel[2]+',
2737
+ floating: true,
2738
+
2739
+ items: {
2740
+ xtype:"tabpanel",
2741
+ activeTab: 0,
2742
+ defaults:{autoHeight:true, bodyStyle:"padding:10px"},
2743
+ items:[{
2744
+ title:"Personal Details",
2745
+ layout:"form",
2746
+ labelWidth: 75,
2747
+ defaults: {width: 230},
2748
+ defaultType: "textfield",
2749
+
2750
+ items: [{
2751
+ fieldLabel: "First Name",
2752
+ name: "first",
2753
+ xtype: "numberfield"
2754
+ },{
2755
+ fieldLabel: "Last Name",
2756
+ name: "last",
2757
+ value: "Slocum"
2758
+ },{
2759
+ fieldLabel: "Company",
2760
+ name: "company",
2761
+ value: "Ext JS"
2762
+ },{
2763
+ fieldLabel: "Email",
2764
+ name: "email",
2765
+ vtype:"email"
2766
+ }]
2767
+ },{
2768
+ title:"Phone Numbers",
2769
+ layout:"form",
2770
+ labelWidth: 75,
2771
+ defaults: {width: 230},
2772
+ defaultType: "textfield",
2773
+
2774
+ items: [{
2775
+ fieldLabel: "Home",
2776
+ name: "home",
2777
+ value: "(888) 555-1212"
2778
+ },{
2779
+ fieldLabel: 'Business',
2780
+ name: 'business'
2781
+ },{
2782
+ fieldLabel: 'Mobile',
2783
+ name: 'mobile'
2784
+ },{
2785
+ fieldLabel: 'Fax',
2786
+ name: 'fax'
2787
+ }]
2788
+ }]
2789
+ },
2790
+
2791
+ buttons: [{
2792
+ text: 'Save'
2793
+ },{
2794
+ text: 'Cancel'
2795
+ }]
2796
+ });
2797
+ '+itemsPanel[0]+'tabs.setPagePosition('+itemsPanel[3]+'+,'+itemsPanel[4]+');
2798
+ '+itemsPanel[0]+'tabs.render(document.body);
2799
+ </script>'
2800
+ end
2801
+ =end
2802
+ # Funciones para rialto
2803
+ def show_Message_rialto(top,left,width,height,title,message,gray)
2804
+ if gray.upcase=='GRAY'
2805
+ fondo = 'gray'
2806
+ else
2807
+ fondo = 'transparent'
2808
+ end
2809
+ return '<script>
2810
+ var sPopup = new rialto.widget.PopUp("popupRialto",'+top+','+left+',"'+width+'","'+height+'","'+message.to_s+'","'+title.to_s+'","'+fondo.to_s+'");
2811
+ var btn2pop = new rialto.widget.Button(30,65,"Aceptar","Aceptar",sPopup);
2812
+ btn2pop.onclick=function () { sPopup.closeWindow(); }
2813
+ </script>'
2814
+ end
2815
+ overload(:show_Message_rialto,String,String,String,String,String,String,String)
2816
+ def show_Message_rialto(top,left,width,height,title,message,gray,linkto)
2817
+ if gray.upcase=='GRAY'
2818
+ fondo = 'gray'
2819
+ else
2820
+ fondo = 'transparent'
2821
+ end
2822
+ return '<script>
2823
+ var sPopup = new rialto.widget.PopUp("popupRialto",'+top+','+left+',"'+width+'","'+height+'","'+message.to_s+'","'+title.to_s+'","'+fondo.to_s+'");
2824
+ var btn2pop = new rialto.widget.Button(30,65,"Aceptar","Aceptar",sPopup);
2825
+ btn2pop.onclick=function () { sPopup.closeWindow(); location.href = "' + $kamila_site + '/' + linkto.to_s + '"; }
2826
+ </script>'
2827
+ end
2828
+ overload(:show_Message_rialto,String,String,String,String,String,String,String,String)
2829
+ def create_label_rialto(name,top,left,parent,text,className)
2830
+ if parent.upcase=='DOCUMENT.BODY' or parent==''
2831
+ parent='document.body'
2832
+ return '<script>
2833
+ var '+name.to_s+' = new rialto.widget.Label("'+name.to_s+'",'+top.to_s+','+left.to_s+','+parent.to_s+',"'+text.to_s+'","'+className.to_s+'");
2834
+ </script>'
2835
+ else
2836
+ return '<div id="'+parent.to_s+'"></div>
2837
+ <script>
2838
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2839
+ var '+name.to_s+' = new rialto.widget.Label("'+name.to_s+'",'+top.to_s+','+left.to_s+','+parent.to_s+',"'+text.to_s+'","'+className.to_s+'");
2840
+ </script>'
2841
+ end
2842
+ end
2843
+ def input_text_rialto(name,top,left,width,type,parent,value,options)
2844
+ property = Array.new
2845
+ property = options.split(",")
2846
+ if type.upcase == 'MD5'
2847
+ type='P'
2848
+ if parent=='document.body' or parent==''
2849
+ parent='document.body'
2850
+ return '<script>
2851
+ function '+name.to_s+'encriptarMd5()
2852
+ {
2853
+ var valorMD5 = hex_md5('+name.to_s+'.getValue());
2854
+ '+name.to_s+'.setValue(valorMD5);
2855
+ '+name.to_s+'old_clave_md5 = '+name.to_s+'.getValue();
2856
+ }
2857
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2858
+ var '+name.to_s+' = new rialto.widget.Text("'+name.to_s+'",'+top.to_s+','+left.to_s+','+width.to_s+',"'+type.to_s+'",'+parent.to_s+',{initValue:"'+value.to_s+'",autoUp:'+property[0].to_s+',isRequired:'+property[1].to_s+',disable:'+property[2].to_s+',alt:"'+property[3].to_s+'",accessKey:"'+property[4].to_s+'",rows:'+property[5].to_s+',tabIndex:'+property[6].to_s+'});
2859
+ var '+name.to_s+'old_clave_md5 = '+name.to_s+'.getValue();
2860
+ '+name.to_s+'.onblur = function () { if ( '+name.to_s+'old_clave_md5 !='+name.to_s+'.getValue() ) { '+name.to_s+'encriptarMd5(); } }
2861
+ </script>'
2862
+ else
2863
+ return '<div id="'+parent.to_s+'"></div>
2864
+ <script>
2865
+ function '+name.to_s+'encriptarMd5()
2866
+ {
2867
+ var valorMD5 = hex_md5('+name.to_s+'.getValue());
2868
+ '+name.to_s+'.setValue(valorMD5);
2869
+ '+name.to_s+'old_clave_md5 = '+name.to_s+'.getValue();
2870
+ '+name.to_s+'onoff_clave_md5 = false;
2871
+ }
2872
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2873
+ var '+name.to_s+' = new rialto.widget.Text("'+name.to_s+'",'+top.to_s+','+left.to_s+','+width.to_s+',"'+type.to_s+'",'+parent.to_s+',{initValue:"'+value.to_s+'",autoUp:'+property[0].to_s+',isRequired:'+property[1].to_s+',disable:'+property[2].to_s+',alt:"'+property[3].to_s+'",accessKey:"'+property[4].to_s+'",rows:'+property[5].to_s+',tabIndex:'+property[6].to_s+'});
2874
+ var '+name.to_s+'old_clave_md5 = '+name.to_s+'.getValue();
2875
+ '+name.to_s+'.onblur = function () { if ( '+name.to_s+'old_clave_md5 !='+name.to_s+'.getValue() ) { '+name.to_s+'encriptarMd5(); } }
2876
+ </script>'
2877
+ end
2878
+ else
2879
+ if parent=='document.body' or parent==''
2880
+ parent='document.body'
2881
+ return '<script>
2882
+ var '+name.to_s+' = new rialto.widget.Text("'+name.to_s+'",'+top.to_s+','+left.to_s+','+width.to_s+',"'+type.to_s+'",'+parent.to_s+',{initValue:"'+value.to_s+'",autoUp:'+property[0].to_s+',isRequired:'+property[1].to_s+',disable:'+property[2].to_s+',alt:"'+property[3].to_s+'",accessKey:"'+property[4].to_s+'",rows:'+property[5].to_s+',tabIndex:'+property[6].to_s+'});
2883
+ </script>'
2884
+ else
2885
+ return '<div id="'+parent.to_s+'"></div>
2886
+ <script>
2887
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2888
+ var '+name.to_s+' = new rialto.widget.Text("'+name.to_s+'",'+top.to_s+','+left.to_s+','+width.to_s+',"'+type.to_s+'",'+parent.to_s+',{initValue:"'+value.to_s+'",autoUp:'+property[0].to_s+',isRequired:'+property[1].to_s+',disable:'+property[2].to_s+',alt:"'+property[3].to_s+'",accessKey:"'+property[4].to_s+'",rows:'+property[5].to_s+',tabIndex:'+property[6].to_s+'});
2889
+ </script>'
2890
+ end
2891
+ end
2892
+ end
2893
+ def input_button_rialto(name,top,left,text,alt,parent,options,form,js)
2894
+ property = Array.new
2895
+ property = options.split(",")
2896
+ if parent=='document.body' or parent==''
2897
+ parent='document.body'
2898
+ return '<script>
2899
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2900
+ '+name.to_s+'.onclick= function () { '+js.to_s+'(); }
2901
+ </script>'
2902
+ else
2903
+ return '<div id="'+parent.to_s+'"></div>
2904
+ <script>
2905
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2906
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2907
+ '+name.to_s+'.onclick= function () { '+js.to_s+'(); }
2908
+ </script>'
2909
+ end
2910
+ end
2911
+ def input_reset_rialto(name,top,left,text,alt,parent,options,form)
2912
+ property = Array.new
2913
+ property = options.split(",")
2914
+ if parent=='document.body' or parent==''
2915
+ parent='document.body'
2916
+ return '<script>
2917
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2918
+ '+name.to_s+'.onclick= function () { '+form.to_s+'.reset(); return false; }
2919
+ </script>'
2920
+ else
2921
+ return '<div id="'+parent.to_s+'"></div>
2922
+ <script>
2923
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2924
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2925
+ '+name.to_s+'.onclick= function () { '+form.to_s+'.reset(); return false; }
2926
+ </script>'
2927
+ end
2928
+ end
2929
+ def input_submit_rialto(name,top,left,text,alt,parent,options,form,fieldsHidden,rialtoMassValidate)
2930
+ registros = Array.new
2931
+ campos = Array.new
2932
+ theitems = ''
2933
+ registros = fieldsHidden.split('|')
2934
+ for i in 0..registros.length-1
2935
+ campos = registros[i].split(',')
2936
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
2937
+ end
2938
+ property = Array.new
2939
+ property = options.split(",")
2940
+ if parent=='document.body' or parent==''
2941
+ parent='document.body'
2942
+ return '<script>
2943
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2944
+ '+name.to_s+'.onclick= function () { '+theitems + ' '+rialtoMassValidate.to_s+'; }
2945
+ </script>'
2946
+ else
2947
+ return '<div id="'+parent.to_s+'"></div>
2948
+ <script>
2949
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
2950
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2951
+ '+name.to_s+'.onclick= function () { '+theitems +' '+rialtoMassValidate.to_s+'; }
2952
+ </script>'
2953
+ end
2954
+ end
2955
+ overload(:input_submit_rialto,String,String,String,String,String,String,String,String,String,String)
2956
+ def input_submit_rialto(name,top,left,text,alt,parent,options,form,fieldsHidden,fieldsName,messageError)
2957
+ if fieldsName==''
2958
+ itemsValidateisRequired = ''
2959
+ itemsValidate = ''
2960
+ itemsExecution = ' '+form.to_s+'.submit(); return true; '
2961
+ else
2962
+ itemsValidate = ''
2963
+ itemsValidateisRequired = 'var '+form.to_s+'_formatter = new rialto.utils.Formatter({type:"string"}); var '+form.to_s+'_Validate=true; '
2964
+ itemsExecution = ' '
2965
+ itemsids = Array.new()
2966
+ itemsids = fieldsName.split(",")
2967
+ nrodeItems = itemsids.length-1
2968
+ for i in 0..nrodeItems
2969
+ if i == 0
2970
+ itemsValidateisRequired = itemsValidateisRequired + 'for (i=0; i<'+nrodeItems.to_s+'; i++) { '
2971
+ end
2972
+ if i !=0 and i!=nrodeItems
2973
+ itemsValidateisRequired = itemsValidateisRequired + ' if ('+itemsids[i].to_s+'.isRequired==true && '+itemsids[i].to_s+'.getValue()=="") {'+form.to_s+'_Validate=false; }'
2974
+ end
2975
+ if i == nrodeItems
2976
+ itemsValidateisRequired = itemsValidateisRequired + ' if ('+itemsids[i].to_s+'.isRequired==true && '+itemsids[i].to_s+'.getValue()=="") {'+form.to_s+'_Validate=false; } }'
2977
+ end
2978
+ itemsValidate = itemsValidate + 'if (' + form.to_s + '_formatter.validate('+itemsids[i].to_s+'.getValue(),false)!=true && '+form.to_s+'_Validate==true ) { '+form.to_s+'_Validate=false; } '
2979
+ end
2980
+ itemsExecution = itemsExecution + 'if ('+form.to_s+'_Validate==true) { '+form.to_s+'.submit(); return true; } else { var sPopup = new rialto.widget.PopUp("popupRialto",150,420,"260","80","'+messageError.to_s+'","Informacion","gray"); var btn2pop = new rialto.widget.Button(30,65,"Aceptar","Aceptar",sPopup); btn2pop.onclick=function () { sPopup.closeWindow(); }; return false;}'
2981
+ end
2982
+ registros = Array.new
2983
+ campos = Array.new
2984
+ theitems = ''
2985
+ registros = fieldsHidden.split('|')
2986
+ for i in 0..registros.length-1
2987
+ campos = registros[i].split(',')
2988
+ theitems = theitems.to_s + form.to_s + '.' + campos[0].to_s+'.value="'+campos[1].to_s+'";'
2989
+ end
2990
+ property = Array.new
2991
+ property = options.split(",")
2992
+ if parent=='document.body' or parent==''
2993
+ parent='document.body'
2994
+ return '<script>
2995
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
2996
+ '+name.to_s+'.onclick= function () { '+theitems + ' ' + itemsValidateisRequired+' '+itemsValidate+' '+itemsExecution+' }
2997
+ </script>'
2998
+ else
2999
+ return '<div id="'+parent.to_s+'"></div>
3000
+ <script>
3001
+ var '+parent.to_s+'=document.getElementById("'+parent.to_s+'");
3002
+ var '+name.to_s+' = new rialto.widget.Button('+top.to_s+','+left.to_s+',"'+text.to_s+'","'+alt.to_s+'",'+parent.to_s+',{adaptToText:'+property[0].to_s+',widthMin:'+property[1].to_s+'});
3003
+ '+name.to_s+'.onclick= function () { '+theitems + ' ' + itemsValidateisRequired+' '+itemsValidate+' '+itemsExecution+' }
3004
+ </script>'
3005
+ end
3006
+ end
3007
+ overload(:input_submit_rialto,String,String,String,String,String,String,String,String,String,String,String)
3008
+ def create_massValidate_rialto(form,name,ids,mensaje)
3009
+ itemsValidate = ''
3010
+ itemsValidateisRequired = 'var '+form.to_s+'_formatter = new rialto.utils.Formatter({type:"string"}); var '+form.to_s+'_Validate=true; '
3011
+ itemsExecution = ' '
3012
+ itemsids = Array.new()
3013
+ itemsids = ids.split(",")
3014
+ nrodeItems = itemsids.length-1
3015
+ for i in 0..nrodeItems
3016
+ if i == 0
3017
+ itemsValidateisRequired = itemsValidateisRequired + 'for (i=0; i<'+nrodeItems.to_s+'; i++) { '
3018
+ end
3019
+ if i !=0 and i!=nrodeItems
3020
+ itemsValidateisRequired = itemsValidateisRequired + ' if ('+itemsids[i].to_s+'.isRequired==true && '+itemsids[i].to_s+'.getValue()=="") {'+form.to_s+'_Validate=false; }'
3021
+ end
3022
+ if i == nrodeItems
3023
+ itemsValidateisRequired = itemsValidateisRequired + ' if ('+itemsids[i].to_s+'.isRequired==true && '+itemsids[i].to_s+'.getValue()=="") {'+form.to_s+'_Validate=false; } }'
3024
+ end
3025
+ itemsValidate = itemsValidate + 'if (' + form.to_s + '_formatter.validate('+itemsids[i].to_s+'.getValue(),false)!=true && '+form.to_s+'_Validate==true ) { '+form.to_s+'_Validate=false; } '
3026
+ end
3027
+ itemsExecution = itemsExecution + 'if ('+form.to_s+'_Validate==true) { '+form.to_s+'.submit(); return true; } else { var sPopup = new rialto.widget.PopUp("popupRialto",150,420,"260","80","'+mensaje.to_s+'","Informacion","gray"); var btn2pop = new rialto.widget.Button(30,65,"Aceptar","Aceptar",sPopup); btn2pop.onclick=function () { sPopup.closeWindow(); }; return false;}'
3028
+ return '<script>
3029
+ function '+name.to_s+'
3030
+ {
3031
+ '+itemsValidateisRequired+' '+itemsValidate+' '+itemsExecution+'
3032
+ }
3033
+ </script>'
3034
+ end
3035
+ def input_checkbox_rialto(name,top,left,parent,text,isChecked,className)
3036
+ return '<div id="'+parent+'"></div>
3037
+ <script>
3038
+ var '+name+' = new rialto.widget.Checkbox("'+name+'",'+top+','+left+','+parent+',"'+text+'",'+isChecked+',"'+className+'");
3039
+ </script>'
3040
+ end
3041
+ def input_combo_rialto(name,top,left,width,items,selWithText,parent,enable,heightItem)
3042
+ itemsvalue = Array.new
3043
+ itemsvalue = items.split(",")
3044
+ theitems = ''
3045
+ for i in 0..itemsvalue.length-1
3046
+ theitems = theitems + name + '.addItem("'+itemsvalue[i].to_s+'","'+itemsvalue[i].to_s+'"); '
3047
+ end
3048
+ if selWithText == ''
3049
+ theitems = theitems + name + '.selFirst();'
3050
+ else
3051
+ theitems = theitems + name + '.selWithText("'+selWithText+'"); '
3052
+ end
3053
+ theitems = theitems + name + '.onclick = function() { '+ name + '.getSelText(); }'
3054
+ return '<div id="'+parent+'"></div>
3055
+ <script>
3056
+ var '+name+' = new rialto.widget.Combo("","'+name+'",'+top+','+left+','+width+','+parent+',{suggest:true,enable:'+enable+',heightItem:'+heightItem+'});
3057
+ '+theitems+'
3058
+ </script>'
3059
+ end
3060
+ def create_gridView_rialto(top,left,width,height,nameFunction,title,nameCatalogo,nameFields,cn,widthc,typec,data)
3061
+ # Estaba despues de cargar el grid: '+nameCatalogo+'oGrid.deleteOneLine(0);
3062
+ itemsc = Array.new()
3063
+ itemsw = Array.new()
3064
+ itemst = Array.new()
3065
+ itemsf = Array.new()
3066
+ itemsc = cn.split(",")
3067
+ itemsw = widthc.split(",")
3068
+ itemst = typec.split(",")
3069
+ itemsf = nameFields.split(",")
3070
+ itemsHeader = " "
3071
+ ciclo = " "
3072
+ for i in 0..itemsc.length-1
3073
+ if i==itemsc.length-1
3074
+ itemsHeader = itemsHeader + '{title:"'+itemsc[i]+'",width:'+itemsw[i]+',type:"'+itemst[i]+'"} '
3075
+ else
3076
+ itemsHeader = itemsHeader + '{title:"'+itemsc[i]+'",width:'+itemsw[i]+',type:"'+itemst[i]+'"},'
3077
+ end
3078
+ ciclo = ciclo+itemsf[i].to_s+'.setValue('+nameCatalogo+'oGrid.getCellData('+nameCatalogo+'oGrid.getIndLineClic(),'+i.to_s+'));'
3079
+ end
3080
+ return '<script>
3081
+ var '+nameCatalogo+'sPopup = null;
3082
+ var '+nameCatalogo+'oGrid = null;
3083
+ function '+nameCatalogo+'LoadData()
3084
+ {
3085
+ var Datos2 = new Array();
3086
+ var j=0;
3087
+ var k=0;
3088
+ datos = "'+data.to_s+'";
3089
+ Registros = datos.split("|");
3090
+ while (j<Registros.length)
3091
+ {
3092
+ var Campos = Registros[j].split(",");
3093
+ var Datos1 = new Array();
3094
+ for (i=0;i<Campos.length; i++)
3095
+ {
3096
+ Datos1[i] = Campos[i];
3097
+ }
3098
+ if (j>0)
3099
+ {
3100
+ Datos2[k] = Datos1;
3101
+ k++
3102
+ }
3103
+ j++;
3104
+ }
3105
+ '+nameCatalogo+'oGrid.fillGrid(Datos2);
3106
+ '+nameCatalogo+'oGrid.clickLine(0,0);
3107
+ var aceptar = new rialto.widget.Button(parseInt(screen.height * 0.40),parseInt(screen.width * 0.15),
3108
+ "Aceptar","Seleccionar usuario",'+nameCatalogo+'sPopup,{adaptToText:true,widthMin:70});
3109
+ aceptar.onclick= function() { '+ciclo+nameCatalogo+'sPopup.closeWindow(); }
3110
+ var salir = new rialto.widget.Button(parseInt(screen.height * 0.40),parseInt(screen.width * 0.25),
3111
+ "Salir","Salir",'+nameCatalogo+'sPopup,{adaptToText:true,widthMin:70});
3112
+ salir.onclick= function() { '+nameCatalogo+'sPopup.closeWindow(); }
3113
+ }
3114
+ function '+nameFunction+'()
3115
+ {
3116
+ '+nameCatalogo+'sPopup = new rialto.widget.PopUp("'+nameCatalogo+'",'+top+','+left+',"'+width+'","'+height+'","'+title+'","","gray");
3117
+ '+nameCatalogo+'oGrid = new rialto.widget.Grid({top:30,left:5,height:220,witdh:200,
3118
+ arrHeader:[ '+itemsHeader+' ],
3119
+ name:"'+nameCatalogo+'oTable",parent:'+nameCatalogo+'sPopup,row:10,
3120
+ cellActive:false,sortable:true,multiSelect:false,
3121
+ lineHeight:26,boolPrint:true,switchable:true,
3122
+ clickable:true,autoResizableW:true,autoResizableH:false,
3123
+ writable:false});
3124
+ '+nameCatalogo+'LoadData();
3125
+ }
3126
+ </script>'
3127
+ end
3128
+ def create_gridAjaxView_rialto(top,left,width,height,nameFunction,title,nameCatalogo,nameFields,cn,widthc,typec,pageserver)
3129
+ # Estaba despues de cargar el grid: '+nameCatalogo+'oGrid.deleteOneLine(0);
3130
+ itemsc = Array.new()
3131
+ itemsw = Array.new()
3132
+ itemst = Array.new()
3133
+ itemsf = Array.new()
3134
+ itemsc = cn.split(",")
3135
+ itemsw = widthc.split(",")
3136
+ itemst = typec.split(",")
3137
+ itemsf = nameFields.split(",")
3138
+ itemsHeader = " "
3139
+ ciclo = " "
3140
+ for i in 0..itemsc.length-1
3141
+ if i==itemsc.length-1
3142
+ itemsHeader = itemsHeader + '{title:"'+itemsc[i]+'",width:'+itemsw[i]+',type:"'+itemst[i]+'"} '
3143
+ else
3144
+ itemsHeader = itemsHeader + '{title:"'+itemsc[i]+'",width:'+itemsw[i]+',type:"'+itemst[i]+'"},'
3145
+ end
3146
+ ciclo = ciclo+itemsf[i].to_s+'.setValue('+nameCatalogo+'oGrid.getCellData('+nameCatalogo+'oGrid.getIndLineClic(),'+i.to_s+'));'
3147
+ end
3148
+ return '<script>
3149
+ var '+nameCatalogo+'sPopup = null;
3150
+ var '+nameCatalogo+'oGrid = null;
3151
+ function '+nameCatalogo+'Repuesta(response)
3152
+ {
3153
+ var Datos2 = new Array();
3154
+ var j=0;
3155
+ var k=0;
3156
+ datos = response.responseText;
3157
+ Registros = datos.split("|");
3158
+ while (j<Registros.length)
3159
+ {
3160
+ var Campos = Registros[j].split(",");
3161
+ var Datos1 = new Array();
3162
+ for (i=0;i<Campos.length; i++)
3163
+ {
3164
+ Datos1[i] = Campos[i];
3165
+ }
3166
+ if (j>0)
3167
+ {
3168
+ Datos2[k] = Datos1;
3169
+ k++
3170
+ }
3171
+ j++;
3172
+ }
3173
+ '+nameCatalogo+'oGrid.fillGrid(Datos2);
3174
+ '+nameCatalogo+'oGrid.clickLine(0,0);
3175
+ var aceptar = new rialto.widget.Button(parseInt(screen.height * 0.40),parseInt(screen.width * 0.15),
3176
+ "Aceptar","Seleccionar usuario",'+nameCatalogo+'sPopup,{adaptToText:true,widthMin:70});
3177
+ aceptar.onclick= function() { '+ciclo+nameCatalogo+'sPopup.closeWindow(); }
3178
+ var salir = new rialto.widget.Button(parseInt(screen.height * 0.40),parseInt(screen.width * 0.25),
3179
+ "Salir","Salir",'+nameCatalogo+'sPopup,{adaptToText:true,widthMin:70});
3180
+ salir.onclick= function() { '+nameCatalogo+'sPopup.closeWindow(); }
3181
+ }
3182
+ function '+nameFunction+'()
3183
+ {
3184
+ '+nameCatalogo+'sPopup = new rialto.widget.PopUp("'+nameCatalogo+'",'+top+','+left+',"'+width+'","'+height+'","'+title+'","","gray");
3185
+ '+nameCatalogo+'oGrid = new rialto.widget.Grid({top:30,left:5,height:220,witdh:200,
3186
+ arrHeader:[ '+itemsHeader+' ],
3187
+ name:"'+nameCatalogo+'oTable",parent:'+nameCatalogo+'sPopup,row:10,
3188
+ cellActive:false,sortable:true,multiSelect:false,
3189
+ lineHeight:26,boolPrint:true,switchable:true,
3190
+ clickable:true,autoResizableW:true,autoResizableH:false,
3191
+ writable:false});
3192
+ //Ajax para los datos
3193
+ var '+nameCatalogo+'ajaxReq=new rialto.io.AjaxRequest({
3194
+ url:"'+$kamila_site+'/'+pageserver+'",
3195
+ method: "post",
3196
+ withWaitWindow:true,
3197
+ callBackObjectOnSuccess:this,
3198
+ onSuccess: '+nameCatalogo+'Repuesta,
3199
+ onFailure: function(){ alert("Error Ajax conexion"); }
3200
+ });
3201
+ '+nameCatalogo+'ajaxReq.load("");
3202
+ }
3203
+ </script>'
3204
+ end
3205
+ # Formato a un numero
3206
+ def format_number(number, separator)
3207
+ return number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1"+separator)
3208
+ end
3209
+ # Funciones basadas en Gruff
3210
+ def create_graph_gruff(type,theme,font,fontsize,title,x_axis_label,y_axis_label,titlearray,dataarray,xlabels,xvalue,file)
3211
+ require 'rubygems'
3212
+ require 'gruff'
3213
+ case type.upcase
3214
+ when 'LINE'
3215
+ g = Gruff::Line.new
3216
+ when 'PIE'
3217
+ g = Gruff::Pie.new
3218
+ when 'BAR'
3219
+ g = Gruff::Bar.new
3220
+ when 'AREA'
3221
+ g = Gruff::Area.new
3222
+ when 'SIDEBAR'
3223
+ g = Gruff::SideBar.new
3224
+ when 'STACKEDBAR'
3225
+ g = Gruff::StackedBar.new
3226
+ when 'SIDESTACKEDBAR'
3227
+ g = Gruff::SideStackedBar.new
3228
+ else
3229
+ g = Gruff::Line.new
3230
+ end
3231
+ case theme[0].upcase
3232
+ when 'BLACK'
3233
+ g.theme_keynote
3234
+ when 'BLUELIGHT'
3235
+ g.theme_37signals
3236
+ when 'PINK'
3237
+ g.theme_odeo
3238
+ when 'BLUE'
3239
+ g.theme_rails_keynote
3240
+ else
3241
+ g.theme = theme[1]
3242
+ end
3243
+ g.title = title
3244
+ # Tipo de Letra
3245
+ if font!=""
3246
+ g.font = font
3247
+ end
3248
+ if fontsize[0]!=''
3249
+ g.title_font_size = fontsize[0]
3250
+ else
3251
+ g.title_font_size = 14
3252
+ end
3253
+ if fontsize[1]!=''
3254
+ g.legend_font_size = fontsize[1]
3255
+ else
3256
+ g.legend_font_size = 12
3257
+ end
3258
+ if fontsize[2]!=''
3259
+ g.marker_font_size = fontsize[2]
3260
+ else
3261
+ g.marker_font_size = 12
3262
+ end
3263
+ g.x_axis_label = x_axis_label
3264
+ g.y_axis_label = y_axis_label
3265
+ for i in 0..titlearray.length-1
3266
+ g.data(titlearray[i], dataarray[i])
3267
+ end
3268
+ for i in 0..xlabels.length-1
3269
+ g.labels[xlabels[i]] = xvalue[i]
3270
+ end
3271
+ g.write(file)
3272
+ end
3273
+ # Content Slider 2.4 fuente: http://www.dynamicdrive.com
3274
+ def create_css_contentslider(borderline,bordercolor,width,height,ctp,btp,sctp,sbtp)
3275
+ widthSW = width.to_i - 10
3276
+ return '<style>
3277
+ .sliderwrapper{
3278
+ position: relative;
3279
+ overflow: hidden;
3280
+ border: '+borderline+'px solid '+bordercolor+';
3281
+ border-bottom-width: 6px;
3282
+ width: '+width+'px;
3283
+ height: '+height+'px;
3284
+ }
3285
+ .sliderwrapper .contentdiv{
3286
+ visibility: hidden;
3287
+ position: absolute;
3288
+ left: 0;
3289
+ top: 0;
3290
+ padding: 5px;
3291
+ background: white;
3292
+ width: '+widthSW.to_s+'px;
3293
+ height: 100%;
3294
+ filter:progid:DXImageTransform.Microsoft.alpha(opacity=100);
3295
+ -moz-opacity: 1;
3296
+ opacity: 1;
3297
+ }
3298
+ .pagination{
3299
+ width: '+width+'px;
3300
+ text-align: right;
3301
+ background-color: '+bordercolor+';
3302
+ padding: 5px 10px;
3303
+ }
3304
+ .pagination a{
3305
+ padding: 0 5px;
3306
+ text-decoration: none;
3307
+ color: '+ctp+';
3308
+ background: '+btp+';
3309
+ }
3310
+ .pagination a:hover, .pagination a.selected{
3311
+ color: '+sctp+';
3312
+ background-color: '+sbtp+';
3313
+ }
3314
+ </style>'
3315
+ end
3316
+ def create_ContentSlider_text(id,content,link,label1,label2)
3317
+ contentdiv = ''
3318
+ for i in 0..content.length-1
3319
+ contentdiv = contentdiv + '<div class="contentdiv"><a href="'+link[i]+'">'+content[i]+'</a></div>'
3320
+ end
3321
+ return '<div id="'+id+'" class="sliderwrapper">
3322
+ '+contentdiv+'
3323
+ </div>
3324
+ <div id="paginate-slider1" class="pagination">
3325
+ </div>
3326
+ <script type="text/javascript">
3327
+ featuredcontentslider.init({
3328
+ id: "'+id+'",
3329
+ contentsource: ["inline", ""],
3330
+ toc: "#increment",
3331
+ nextprev: ["'+label1+'", "'+label2+'"],
3332
+ revealtype: "click",
3333
+ enablefade: [true, 0.2],
3334
+ autorotate: [true, 3000],
3335
+ onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
3336
+ //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
3337
+ //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
3338
+ }
3339
+ })
3340
+ </script>'
3341
+ end
3342
+ def create_ContentSlider_image(id,content,link,label1,label2,isTable)
3343
+ contentdiv = ''
3344
+ for i in 0..content.length-1
3345
+ image = Array.new
3346
+ image = content[i]
3347
+ if isTable.upcase=='TRUE'
3348
+ contentdiv = contentdiv + '<div class="contentdiv"><table border="0"><tr><td><a href="'+link[i]+'"><img id="'+image[0].to_s+'" border="'+image[1].to_s+'" src="'+image[2].to_s+'" alt="'+image[3].to_s+'" height="' + image[4].to_s + '" width="' + image[5].to_s + '" /></a><td align="top"><a href="'+link[i]+'">'+image[6].to_s+'</a></td></tr></table></div>'
3349
+ else
3350
+ contentdiv = contentdiv + '<div class="contentdiv"><a href="'+link[i]+'"><img id="'+image[0].to_s+'" border="'+image[1].to_s+'" src="'+image[2].to_s+'" alt="'+image[3].to_s+'" height="' + image[4].to_s + '" width="' + image[5].to_s + '" /><p>'+image[6].to_s+'</p></a></div>'
3351
+ end
3352
+ end
3353
+ return '<div id="'+id+'" class="sliderwrapper">
3354
+ '+contentdiv+'
3355
+ </div>
3356
+ <div id="paginate-slider1" class="pagination">
3357
+ </div>
3358
+ <script type="text/javascript">
3359
+ featuredcontentslider.init({
3360
+ id: "'+id+'",
3361
+ contentsource: ["inline", ""],
3362
+ toc: "#increment",
3363
+ nextprev: ["'+label1+'", "'+label2+'"],
3364
+ revealtype: "click",
3365
+ enablefade: [true, 0.2],
3366
+ autorotate: [true, 3000],
3367
+ onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
3368
+ //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
3369
+ //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
3370
+ }
3371
+ })
3372
+ </script>'
3373
+ end
3374
+ def create_showVideo_wmv(id,width,height,url)
3375
+ return '<OBJECT ID="'+id+'" width="'+width+'" height="+height+" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
3376
+ codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,70" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
3377
+ <PARAM name="URL" value="'+url+'">
3378
+ <PARAM name="DisplaySize" value=0>
3379
+ <PARAM name="AllowChangeDisplaySize" value="True">
3380
+ <PARAM NAME=ShowControls VALUE=1>
3381
+ <PARAM NAME="WindowlessVideo" Value="0">
3382
+ <PARAM NAME=ShowDisplay VALUE=1>
3383
+ <PARAM NAME=ShowStatusBar VALUE=1>
3384
+ <PARAM NAME=AutoStart VALUE=TRUE>
3385
+ <PARAM NAME=InvokeURLS Value=False>
3386
+ <embed name="'+id+'" width="'+width+'" height="'+height+'" type="application/x-mplayer2"
3387
+ pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"
3388
+ src="'+url+'" Name="Video File" AllowChangeDisplaySize="True" ShowControls="1" AutoStart=True ShowDisplay="0" ShowStatusBar="1">
3389
+ </embed>
3390
+ </OBJECT>'
3391
+ end
3392
+ def create_showVideo_flash(id,width,height,url)
3393
+ return '<object ID="'+id+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="+height+">
3394
+ <param name="movie" value="'+url+'">
3395
+ <param name="quality" value="high">
3396
+ <embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="+height+"></embed>
3397
+ </object>'
3398
+ end
3399
+ def create_showVideo_jwplayer(id,width,height,url)
3400
+ # Basado del Proyecto: http://www.jeroenwijering.com/?item=JW_FLV_Media_Player
3401
+ return '<div id="'+id+'"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
3402
+ <script type="text/javascript" src="'+$kamila_site+'/public/js/kamila/swfobject.js'+'"></script>
3403
+ <script type="text/javascript">
3404
+ var s1 = new SWFObject("'+$kamila_site+'/public/js/kamila/player.swf'+'","ply","'+width+'","'+height+'","9","#FFFFFF");
3405
+ s1.addParam("allowfullscreen","true");
3406
+ s1.addParam("allowscriptaccess","always");
3407
+ s1.addParam("flashvars","file='+url+'&image='+$kamila_site+'/public/img/kamila/preview.jpg'+'");
3408
+ s1.write("'+id+'");
3409
+ </script>'
3410
+ end
3411
+ # Llamada a un controlador desde otro controlador
3412
+ def callController(controller)
3413
+ objetoMyCgi = MyCGI.new
3414
+ objetoMyCgi.redirect($kamila_site+"/"+controller.to_s)
3415
+ end
3416
+ overload(:callController,String)
3417
+ def callController(controller,message,link)
3418
+ objetoMyCgi = MyCGI.new
3419
+ objetoMyCgi.redirect($kamila_site+"/"+controller.to_s+"/index/message="+message.to_s+"&link="+link.to_s)
3420
+ end
3421
+ overload(:callController,String,String,String)
3422
+ # Manejo de Sesiones por Kamila
3423
+ def initSession()
3424
+ minutos = 30
3425
+ begin
3426
+ valor = true
3427
+ prefix = String.new()
3428
+ prefix = Digest::MD5.hexdigest($kamila_remoteaddr.to_s)
3429
+ #prefix = $kamila_remoteaddr.to_s
3430
+ db = PStore.new("/tmp/kamila_session."+prefix.to_s)
3431
+ db.transaction do
3432
+ db[prefix] = Time.now
3433
+ db['kamilasession_framework'] = minutos
3434
+ db.commit
3435
+ end
3436
+ rescue
3437
+ valor = false
3438
+ end
3439
+ return valor
3440
+ end
3441
+ overload(:initSession)
3442
+ def initSession(minutes)
3443
+ minutos = minutes.to_i
3444
+ begin
3445
+ valor = true
3446
+ prefix = String.new()
3447
+ prefix = Digest::MD5.hexdigest($kamila_remoteaddr.to_s)
3448
+ #prefix = $kamila_remoteaddr.to_s
3449
+ db = PStore.new("/tmp/kamila_session."+prefix.to_s)
3450
+ db.transaction do
3451
+ db[prefix] = Time.now
3452
+ db['kamilasession_framework'] = minutos
3453
+ db.commit
3454
+ end
3455
+ rescue
3456
+ valor = false
3457
+ end
3458
+ return valor
3459
+ end
3460
+ overload(:initSession,String)
3461
+ def deleteSession()
3462
+ prefix = String.new()
3463
+ prefix = Digest::MD5.hexdigest($kamila_remoteaddr.to_s)
3464
+ #prefix = $kamila_remoteaddr.to_s
3465
+ if File.exist?("/tmp/kamila_session."+prefix.to_s)
3466
+ File.unlink("/tmp/kamila_session."+prefix.to_s)
3467
+ end
3468
+ end
3469
+ def setValueSession(variable,value)
3470
+ prefix = String.new()
3471
+ prefix = Digest::MD5.hexdigest($kamila_remoteaddr.to_s)
3472
+ #prefix = $kamila_remoteaddr.to_s
3473
+ db = PStore.new("/tmp/kamila_session."+prefix.to_s)
3474
+ db.transaction do
3475
+ db[prefix] = Time.now
3476
+ db[variable.to_s] = value.to_s
3477
+ db.commit
3478
+ end
3479
+ end
3480
+ def getValueSession(variable)
3481
+ prefix = String.new()
3482
+ prefix = Digest::MD5.hexdigest($kamila_remoteaddr.to_s)
3483
+ #prefix = $kamila_remoteaddr.to_s
3484
+ value = String.new
3485
+ inicio = 0
3486
+ minutos = 0
3487
+ if File.exist?("/tmp/kamila_session."+prefix.to_s)
3488
+ db = PStore.new("/tmp/kamila_session."+prefix.to_s)
3489
+ db.transaction do
3490
+ inicio = db[prefix]
3491
+ minutos = db['kamilasession_framework']
3492
+ end
3493
+ ahora = Time.now
3494
+ tiempo = ahora - inicio
3495
+ transcurrido = tiempo.to_i/60
3496
+ if transcurrido.to_i < minutos
3497
+ db.transaction do
3498
+ value = db[variable.to_s]
3499
+ end
3500
+ else
3501
+ deleteSession()
3502
+ value = ""
3503
+ end
3504
+ else
3505
+ value = ""
3506
+ end
3507
+ return value.to_s
3508
+ end
3509
+ end