parroquia 1.1.13 → 1.1.14

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parroquia/catecismo/actualizar_alumno.rb +181 -0
  3. data/lib/parroquia/catecismo/alumno.rb +179 -0
  4. data/lib/parroquia/catecismo/catecismo.rb +119 -0
  5. data/lib/parroquia/catecismo/consulta.rb +177 -0
  6. data/lib/parroquia/catecismo/resultado.rb +230 -0
  7. data/lib/parroquia/main.rb +82 -91
  8. data/lib/parroquia/sacramentos/actualizar_bautismo.rb +313 -0
  9. data/lib/parroquia/sacramentos/actualizar_certificado_prebautismal.rb +184 -0
  10. data/lib/parroquia/sacramentos/actualizar_comunion.rb +239 -0
  11. data/lib/parroquia/sacramentos/actualizar_confirmacion.rb +239 -0
  12. data/lib/parroquia/sacramentos/actualizar_matrimonio.rb +298 -0
  13. data/lib/parroquia/sacramentos/actualizar_misa.rb +170 -0
  14. data/lib/parroquia/sacramentos/actualizar_permiso_prebautismal.rb +200 -0
  15. data/lib/parroquia/sacramentos/actualizar_permiso_prematrimonial.rb +205 -0
  16. data/lib/parroquia/sacramentos/actualizar_supletoria.rb +313 -0
  17. data/lib/parroquia/sacramentos/bautizo.rb +310 -0
  18. data/lib/parroquia/sacramentos/certificado_prebautismal.rb +195 -0
  19. data/lib/parroquia/sacramentos/comunion.rb +234 -0
  20. data/lib/parroquia/sacramentos/confirmacion.rb +239 -0
  21. data/lib/parroquia/sacramentos/consultas.rb +162 -0
  22. data/lib/parroquia/sacramentos/matrimonio.rb +297 -0
  23. data/lib/parroquia/sacramentos/misa.rb +171 -0
  24. data/lib/parroquia/sacramentos/permiso_bautismo.rb +207 -0
  25. data/lib/parroquia/sacramentos/permiso_prematrimonial.rb +219 -0
  26. data/lib/parroquia/sacramentos/resultados.rb +931 -0
  27. data/lib/parroquia/sacramentos/sacramentos.rb +182 -0
  28. data/lib/parroquia/sacramentos/supletoria.rb +309 -0
  29. metadata +30 -11
  30. data/lib/parroquia/actualizar_bautismo.rb +0 -245
  31. data/lib/parroquia/actualizar_confirmacion.rb +0 -194
  32. data/lib/parroquia/actualizar_matrimonio.rb +0 -235
  33. data/lib/parroquia/bautizo.rb +0 -239
  34. data/lib/parroquia/confirmacion.rb +0 -191
  35. data/lib/parroquia/consultas.rb +0 -144
  36. data/lib/parroquia/matrimonio.rb +0 -232
  37. data/lib/parroquia/resultados.rb +0 -414
@@ -0,0 +1,234 @@
1
+ require 'pg'
2
+ require 'fox16'
3
+ include Fox
4
+
5
+ class Comunion < FXMainWindow
6
+ def initialize(app)
7
+ @app = app
8
+ super(app, 'Parroquia San Judas Tadeo', width: 1050, height: 450)
9
+ self.backColor = FXRGB(3, 187, 133)
10
+ # Title
11
+ @lbltitle = FXLabel.new(self, 'Bienvenido a la Parroquia San Judas Tadeo',
12
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 1050, height: 20, x: 0, y: 20)
13
+ @lbltitle.font = FXFont.new(app, 'Geneva', 16, FONTWEIGHT_BOLD)
14
+ @lbltitle.backColor = FXRGB(3, 187, 133)
15
+ # Subtitle
16
+ @lblsubtitle = FXLabel.new(self, 'ARQUIDIOSESIS DE QUITO - SERVICIO PARROQUIAL DE SAN JUDAS TADEO',
17
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 1050, height: 20, x: 0, y: 40)
18
+ @lblsubtitle.font = FXFont.new(app, 'Geneva', 10, FONTWEIGHT_BOLD)
19
+ @lblsubtitle.backColor = FXRGB(3, 187, 133)
20
+ # Date
21
+ @date = Time.now.strftime('%d/%m/%Y')
22
+ @lbldate = FXLabel.new(self, "Fecha: #{cambiar_formato_fecha(@date)}", opts: LAYOUT_EXPLICIT | JUSTIFY_RIGHT,
23
+ width: 1050, height: 20, x: 0, y: 60, padRight: 20)
24
+ @lbldate.font = FXFont.new(app, 'Geneva', 12, FONTWEIGHT_BOLD)
25
+ @lbldate.backColor = FXRGB(3, 187, 133)
26
+ # section libros
27
+ @lbl_tomo = FXLabel.new(self, 'Tomo', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 50, y: 100)
28
+ @lbl_tomo.backColor = FXRGB(3, 187, 133)
29
+ @input_tomo = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 110, y: 100)
30
+ @lbl_page = FXLabel.new(self, 'Pagina', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 170, y: 100)
31
+ @lbl_page.backColor = FXRGB(3, 187, 133)
32
+ @input_page = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 230, y: 100)
33
+ @lbl_number = FXLabel.new(self, 'Numero', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 290,
34
+ y: 100)
35
+ @lbl_number.backColor = FXRGB(3, 187, 133)
36
+ @input_number = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 350,
37
+ y: 100)
38
+
39
+ # section datos
40
+ @lbl_fecha = FXLabel.new(self, 'Fecha de la 1ra comunión (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT, width: 250,
41
+ height: 20, x: 10, y: 150)
42
+ @lbl_fecha.backColor = FXRGB(3, 187, 133)
43
+ @input_fecha = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
44
+ y: 150)
45
+ @lbl_sacramento = FXLabel.new(self, 'Sacramento: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
46
+ x: 680, y: 150)
47
+ @lbl_sacramento.backColor = FXRGB(3, 187, 133)
48
+ @input_sacramento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
49
+ y: 150)
50
+ @input_sacramento.text = 'Comunión'
51
+ @input_sacramento.disable
52
+ @lbl_parroquia = FXLabel.new(self, 'Iglesia parroquial: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
53
+ x: 10, y: 180)
54
+ @lbl_parroquia.backColor = FXRGB(3, 187, 133)
55
+ @input_parroquia = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
56
+ y: 180)
57
+ @input_parroquia.text = 'San Judas Tadeo'
58
+ @input_parroquia.disable
59
+ @lbl_sector = FXLabel.new(self, 'Sector: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
60
+ y: 180)
61
+ @lbl_sector.backColor = FXRGB(3, 187, 133)
62
+ @input_sector = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 510,
63
+ y: 180)
64
+ @input_sector.text = 'Jaime Roldós'
65
+ @input_sector.disable
66
+ @lbl_parroco = FXLabel.new(self, 'Parroco: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 680,
67
+ y: 180)
68
+ @lbl_parroco.backColor = FXRGB(3, 187, 133)
69
+ @input_parroco = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
70
+ y: 180)
71
+ @lbl_celebrante = FXLabel.new(self, 'Celebrante: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
72
+ x: 10, y: 210)
73
+ @lbl_celebrante.backColor = FXRGB(3, 187, 133)
74
+ @input_celebrante = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
75
+ y: 210)
76
+ @lbl_name = FXLabel.new(self, 'Nombres: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
77
+ y: 240)
78
+ @lbl_name.backColor = FXRGB(3, 187, 133)
79
+ @input_name = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
80
+ y: 240)
81
+ @lbl_apellidos = FXLabel.new(self, 'Apellidos: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
82
+ y: 270)
83
+ @lbl_apellidos.backColor = FXRGB(3, 187, 133)
84
+ @input_apellidos = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
85
+ y: 270)
86
+ @lbl_lugar_nacimiento = FXLabel.new(self, 'Lugar de nacimiento: ', opts: LAYOUT_EXPLICIT, width: 150,
87
+ height: 20, x: 10, y: 300)
88
+ @lbl_lugar_nacimiento.backColor = FXRGB(3, 187, 133)
89
+ @input_lugar_nacimiento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20,
90
+ x: 170, y: 300)
91
+ @lbl_fecha_nacimiento = FXLabel.new(self, 'Fecha de nacimiento (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT,
92
+ width: 250, height: 20, x: 340, y: 300)
93
+ @lbl_fecha_nacimiento.backColor = FXRGB(3, 187, 133)
94
+ @input_fecha_nacimiento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20,
95
+ x: 590, y: 300)
96
+ @lbl_cedula = FXLabel.new(self, 'Cédula: ', opts: LAYOUT_EXPLICIT, width: 80, height: 20, x: 750,
97
+ y: 300)
98
+ @lbl_cedula.backColor = FXRGB(3, 187, 133)
99
+ @input_cedula = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
100
+ y: 300)
101
+ @lbl_certifica = FXLabel.new(self, 'Certifica: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
102
+ y: 360)
103
+ @lbl_certifica.backColor = FXRGB(3, 187, 133)
104
+ @input_certifica = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
105
+ y: 360)
106
+ # create buttons
107
+ @btnsave = FXButton.new(self, 'Guardar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
108
+ x: 790, y: 400)
109
+ @btncancel = FXButton.new(self, 'Cancelar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
110
+ x: 900, y: 400)
111
+
112
+ # connect buttons
113
+ @btnsave.connect(SEL_COMMAND) do
114
+ tomo = @input_tomo.text
115
+ page = @input_page.text
116
+ number = @input_number.text
117
+ fecha = @input_fecha.text
118
+ sacramento = @input_sacramento.text
119
+ parroquia = @input_parroquia.text
120
+ sector = @input_sector.text
121
+ parroco = @input_parroco.text
122
+ celebrante = @input_celebrante.text
123
+ name = @input_name.text
124
+ apellidos = @input_apellidos.text
125
+ lugar_nacimiento = @input_lugar_nacimiento.text
126
+ fecha_nacimiento = @input_fecha_nacimiento.text
127
+ cedula = @input_cedula.text.empty? ? nil : @input_cedula.text
128
+ padrino = @input_padrino.text.empty? ? nil : @input_padrino.text
129
+ certifica = @input_certifica.text
130
+
131
+
132
+ # tables
133
+ # tabla libros (id, tomo, pagina, numero)
134
+ # tabla creyentes (id, nombres, apellidos, lugar_nacimiento, fecha_nacimiento, cedula)
135
+ # tabla parroquias (id, nombre, sector, parroco)
136
+ # tabla sacramentos (id, nombre, fecha, celebrante, certifica, padrino, madrina, testigo_novio, testigo_novia, padre, madre, nombres_novia, apellidos_novia, cedula_novia, fk_creyentes, fk_parroquias, fk_registros_civiles, fk_libros)
137
+ # tabla registros_civiles (id, provincia_rc, canton_rc, parroquia_rc, anio_rc, tomo_rc, pagina_rc, acta_rc, fecha_rc)
138
+ # Iniciar una transacción
139
+ $conn.transaction do
140
+ # Insertar en la tabla libros
141
+ @registro_libros = $conn.exec('INSERT INTO libros (tomo, pagina, numero) VALUES ($1, $2, $3)',
142
+ [tomo, page, number])
143
+
144
+ # Insertar en la tabla creyentes
145
+ @registro_creyentes = $conn.exec(
146
+ 'INSERT INTO creyentes (nombres, apellidos, lugar_nacimiento, fecha_nacimiento, cedula) VALUES ($1, $2, $3, $4, $5)', [
147
+ name, apellidos, lugar_nacimiento, fecha_nacimiento, cedula
148
+ ]
149
+ )
150
+
151
+ # Insertar en la tabla parroquias
152
+ @registro_parroquias = $conn.exec('INSERT INTO parroquias (parroquia, sector, parroco) VALUES ($1, $2, $3)',
153
+ [parroquia, sector, parroco])
154
+
155
+ # Insertar en la tabla registros civiles, si no existen datos se crea un registro nuevo con id que corresponda y se llena los demaás datos con nil
156
+ @registro_registros_civiles = $conn.exec(
157
+ 'INSERT INTO registros_civiles (provincia_rc, canton_rc, parroquia_rc, anio_rc, tomo_rc, pagina_rc, acta_rc, fecha_rc) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)', [
158
+ nil, nil, nil, nil, nil, nil, nil, nil
159
+ ]
160
+ )
161
+
162
+ # Insertar en la tabla misas
163
+ @registro_misas = $conn.exec('INSERT INTO misas (intencion, fecha, hora) VALUES ($1, $2, $3)', [nil, nil, nil])
164
+
165
+ # Insertar en la tabla sacramentos
166
+ @registro_sacramentos = $conn.exec(
167
+ 'INSERT INTO sacramentos (sacramento, fecha, celebrante, certifica, padrino) VALUES ($1, $2, $3, $4, $5)', [sacramento,
168
+ fecha, celebrante, certifica, padrino]
169
+ )
170
+
171
+ # Confirmar la transacción
172
+ $conn.exec('COMMIT')
173
+ FXMessageBox.information(self, MBOX_OK, 'Información', 'Datos guardados correctamente')
174
+ clear_input_fields
175
+ end
176
+ end
177
+
178
+ @btncancel.connect(SEL_COMMAND) do
179
+ clear_input_fields
180
+ end
181
+
182
+ def clear_input_fields
183
+ @input_tomo.text = ''
184
+ @input_page.text = ''
185
+ @input_number.text = ''
186
+ @input_fecha.text = ''
187
+ @input_parroco.text = ''
188
+ @input_celebrante.text = ''
189
+ @input_name.text = ''
190
+ @input_apellidos.text = ''
191
+ @input_lugar_nacimiento.text = ''
192
+ @input_fecha_nacimiento.text = ''
193
+ @input_cedula.text = ''
194
+ @input_padrino.text = ''
195
+ @input_certifica.text = ''
196
+ end
197
+ end
198
+
199
+ # Nombre del mes
200
+ def nombre_mes(mes)
201
+ meses = {
202
+ '01' => 'enero',
203
+ '02' => 'febrero',
204
+ '03' => 'marzo',
205
+ '04' => 'abril',
206
+ '05' => 'mayo',
207
+ '06' => 'junio',
208
+ '07' => 'julio',
209
+ '08' => 'agosto',
210
+ '09' => 'septiembre',
211
+ '10' => 'octubre',
212
+ '11' => 'noviembre',
213
+ '12' => 'diciembre'
214
+ }
215
+ meses[mes]
216
+ end
217
+
218
+ # Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY
219
+ def cambiar_formato_fecha(fecha)
220
+ # split "-" or "/"
221
+ fecha = fecha.split(%r{-|/})
222
+ # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY
223
+ if fecha[0].length == 4
224
+ "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}"
225
+ else
226
+ "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}"
227
+ end
228
+ end
229
+
230
+ def create
231
+ super
232
+ show(PLACEMENT_SCREEN)
233
+ end
234
+ end
@@ -0,0 +1,239 @@
1
+ require 'pg'
2
+ require 'fox16'
3
+ include Fox
4
+
5
+ class Confirmacion < FXMainWindow
6
+ def initialize(app)
7
+ @app = app
8
+ super(app, 'Parroquia San Judas Tadeo', width: 1050, height: 450)
9
+ self.backColor = FXRGB(3, 187, 133)
10
+ # Title
11
+ @lbltitle = FXLabel.new(self, 'Bienvenido a la Parroquia San Judas Tadeo',
12
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 1050, height: 20, x: 0, y: 20)
13
+ @lbltitle.font = FXFont.new(app, 'Geneva', 16, FONTWEIGHT_BOLD)
14
+ @lbltitle.backColor = FXRGB(3, 187, 133)
15
+ # Subtitle
16
+ @lblsubtitle = FXLabel.new(self, 'ARQUIDIOSESIS DE QUITO - SERVICIO PARROQUIAL DE SAN JUDAS TADEO',
17
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 1050, height: 20, x: 0, y: 40)
18
+ @lblsubtitle.font = FXFont.new(app, 'Geneva', 10, FONTWEIGHT_BOLD)
19
+ @lblsubtitle.backColor = FXRGB(3, 187, 133)
20
+ # Date
21
+ @date = Time.now.strftime('%d/%m/%Y')
22
+ @lbldate = FXLabel.new(self, "Fecha: #{cambiar_formato_fecha(@date)}", opts: LAYOUT_EXPLICIT | JUSTIFY_RIGHT,
23
+ width: 1050, height: 20, x: 0, y: 60, padRight: 20)
24
+ @lbldate.font = FXFont.new(app, 'Geneva', 12, FONTWEIGHT_BOLD)
25
+ @lbldate.backColor = FXRGB(3, 187, 133)
26
+ # section libros
27
+ @lbl_tomo = FXLabel.new(self, 'Tomo', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 50, y: 100)
28
+ @lbl_tomo.backColor = FXRGB(3, 187, 133)
29
+ @input_tomo = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 110, y: 100)
30
+ @lbl_page = FXLabel.new(self, 'Pagina', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 170, y: 100)
31
+ @lbl_page.backColor = FXRGB(3, 187, 133)
32
+ @input_page = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 230, y: 100)
33
+ @lbl_number = FXLabel.new(self, 'Numero', opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 290,
34
+ y: 100)
35
+ @lbl_number.backColor = FXRGB(3, 187, 133)
36
+ @input_number = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 50, height: 20, x: 350,
37
+ y: 100)
38
+
39
+ # section datos
40
+ @lbl_fecha = FXLabel.new(self, 'Fecha de confirmación (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT, width: 250,
41
+ height: 20, x: 10, y: 150)
42
+ @lbl_fecha.backColor = FXRGB(3, 187, 133)
43
+ @input_fecha = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
44
+ y: 150)
45
+ @lbl_sacramento = FXLabel.new(self, 'Sacramento: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
46
+ x: 680, y: 150)
47
+ @lbl_sacramento.backColor = FXRGB(3, 187, 133)
48
+ @input_sacramento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
49
+ y: 150)
50
+ @input_sacramento.text = 'Confirmación'
51
+ @input_sacramento.disable
52
+ @lbl_parroquia = FXLabel.new(self, 'Iglesia parroquial: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
53
+ x: 10, y: 180)
54
+ @lbl_parroquia.backColor = FXRGB(3, 187, 133)
55
+ @input_parroquia = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
56
+ y: 180)
57
+ @input_parroquia.text = 'San Judas Tadeo'
58
+ @input_parroquia.disable
59
+ @lbl_sector = FXLabel.new(self, 'Sector: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
60
+ y: 180)
61
+ @lbl_sector.backColor = FXRGB(3, 187, 133)
62
+ @input_sector = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 510,
63
+ y: 180)
64
+ @input_sector.text = 'Jaime Roldós'
65
+ @input_sector.disable
66
+ @lbl_parroco = FXLabel.new(self, 'Parroco: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 680,
67
+ y: 180)
68
+ @lbl_parroco.backColor = FXRGB(3, 187, 133)
69
+ @input_parroco = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
70
+ y: 180)
71
+ @lbl_celebrante = FXLabel.new(self, 'Celebrante: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
72
+ x: 10, y: 210)
73
+ @lbl_celebrante.backColor = FXRGB(3, 187, 133)
74
+ @input_celebrante = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
75
+ y: 210)
76
+ @lbl_name = FXLabel.new(self, 'Nombres: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
77
+ y: 240)
78
+ @lbl_name.backColor = FXRGB(3, 187, 133)
79
+ @input_name = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
80
+ y: 240)
81
+ @lbl_apellidos = FXLabel.new(self, 'Apellidos: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
82
+ y: 270)
83
+ @lbl_apellidos.backColor = FXRGB(3, 187, 133)
84
+ @input_apellidos = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
85
+ y: 270)
86
+ @lbl_lugar_nacimiento = FXLabel.new(self, 'Lugar de nacimiento: ', opts: LAYOUT_EXPLICIT, width: 150,
87
+ height: 20, x: 10, y: 300)
88
+ @lbl_lugar_nacimiento.backColor = FXRGB(3, 187, 133)
89
+ @input_lugar_nacimiento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20,
90
+ x: 170, y: 300)
91
+ @lbl_fecha_nacimiento = FXLabel.new(self, 'Fecha de nacimiento (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT,
92
+ width: 250, height: 20, x: 340, y: 300)
93
+ @lbl_fecha_nacimiento.backColor = FXRGB(3, 187, 133)
94
+ @input_fecha_nacimiento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20,
95
+ x: 590, y: 300)
96
+ @lbl_cedula = FXLabel.new(self, 'Cédula: ', opts: LAYOUT_EXPLICIT, width: 80, height: 20, x: 750,
97
+ y: 300)
98
+ @lbl_cedula.backColor = FXRGB(3, 187, 133)
99
+ @input_cedula = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 850,
100
+ y: 300)
101
+ @lbl_padrino = FXLabel.new(self, 'Padrino: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
102
+ y: 330)
103
+ @lbl_padrino.backColor = FXRGB(3, 187, 133)
104
+ @input_padrino = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
105
+ y: 330)
106
+ @lbl_certifica = FXLabel.new(self, 'Certifica: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
107
+ y: 360)
108
+ @lbl_certifica.backColor = FXRGB(3, 187, 133)
109
+ @input_certifica = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
110
+ y: 360)
111
+ # create buttons
112
+ @btnsave = FXButton.new(self, 'Guardar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
113
+ x: 790, y: 400)
114
+ @btncancel = FXButton.new(self, 'Cancelar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
115
+ x: 900, y: 400)
116
+
117
+ # connect buttons
118
+ @btnsave.connect(SEL_COMMAND) do
119
+ tomo = @input_tomo.text
120
+ page = @input_page.text
121
+ number = @input_number.text
122
+ fecha = @input_fecha.text
123
+ sacramento = @input_sacramento.text
124
+ parroquia = @input_parroquia.text
125
+ sector = @input_sector.text
126
+ parroco = @input_parroco.text
127
+ celebrante = @input_celebrante.text
128
+ name = @input_name.text
129
+ apellidos = @input_apellidos.text
130
+ lugar_nacimiento = @input_lugar_nacimiento.text
131
+ fecha_nacimiento = @input_fecha_nacimiento.text
132
+ cedula = @input_cedula.text.empty? ? nil : @input_cedula.text
133
+ padrino = @input_padrino.text.empty? ? nil : @input_padrino.text
134
+ certifica = @input_certifica.text
135
+
136
+
137
+ # tables
138
+ # tabla libros (id, tomo, pagina, numero)
139
+ # tabla creyentes (id, nombres, apellidos, lugar_nacimiento, fecha_nacimiento, cedula)
140
+ # tabla parroquias (id, nombre, sector, parroco)
141
+ # tabla sacramentos (id, nombre, fecha, celebrante, certifica, padrino, madrina, testigo_novio, testigo_novia, padre, madre, nombres_novia, apellidos_novia, cedula_novia, fk_creyentes, fk_parroquias, fk_registros_civiles, fk_libros)
142
+ # tabla registros_civiles (id, provincia_rc, canton_rc, parroquia_rc, anio_rc, tomo_rc, pagina_rc, acta_rc, fecha_rc)
143
+ # Iniciar una transacción
144
+ $conn.transaction do
145
+ # Insertar en la tabla libros
146
+ @registro_libros = $conn.exec('INSERT INTO libros (tomo, pagina, numero) VALUES ($1, $2, $3)',
147
+ [tomo, page, number])
148
+
149
+ # Insertar en la tabla creyentes
150
+ @registro_creyentes = $conn.exec(
151
+ 'INSERT INTO creyentes (nombres, apellidos, lugar_nacimiento, fecha_nacimiento, cedula) VALUES ($1, $2, $3, $4, $5)', [
152
+ name, apellidos, lugar_nacimiento, fecha_nacimiento, cedula
153
+ ]
154
+ )
155
+
156
+ # Insertar en la tabla parroquias
157
+ @registro_parroquias = $conn.exec('INSERT INTO parroquias (parroquia, sector, parroco) VALUES ($1, $2, $3)',
158
+ [parroquia, sector, parroco])
159
+
160
+ # Insertar en la tabla registros civiles, si no existen datos se crea un registro nuevo con id que corresponda y se llena los demaás datos con nil
161
+ @registro_registros_civiles = $conn.exec(
162
+ 'INSERT INTO registros_civiles (provincia_rc, canton_rc, parroquia_rc, anio_rc, tomo_rc, pagina_rc, acta_rc, fecha_rc) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)', [
163
+ nil, nil, nil, nil, nil, nil, nil, nil
164
+ ]
165
+ )
166
+
167
+ # Insertar en la tabla misas
168
+ @registro_misas = $conn.exec('INSERT INTO misas (intencion, fecha, hora) VALUES ($1, $2, $3)', [nil, nil, nil])
169
+
170
+ # Insertar en la tabla sacramentos
171
+ @registro_sacramentos = $conn.exec(
172
+ 'INSERT INTO sacramentos (sacramento, fecha, celebrante, certifica, padrino) VALUES ($1, $2, $3, $4, $5)', [sacramento,
173
+ fecha, celebrante, certifica, padrino]
174
+ )
175
+
176
+ # Confirmar la transacción
177
+ $conn.exec('COMMIT')
178
+ FXMessageBox.information(self, MBOX_OK, 'Información', 'Datos guardados correctamente')
179
+ clear_input_fields
180
+ end
181
+ end
182
+
183
+ @btncancel.connect(SEL_COMMAND) do
184
+ clear_input_fields
185
+ end
186
+
187
+ def clear_input_fields
188
+ @input_tomo.text = ''
189
+ @input_page.text = ''
190
+ @input_number.text = ''
191
+ @input_fecha.text = ''
192
+ @input_parroco.text = ''
193
+ @input_celebrante.text = ''
194
+ @input_name.text = ''
195
+ @input_apellidos.text = ''
196
+ @input_lugar_nacimiento.text = ''
197
+ @input_fecha_nacimiento.text = ''
198
+ @input_cedula.text = ''
199
+ @input_padrino.text = ''
200
+ @input_certifica.text = ''
201
+ end
202
+ end
203
+
204
+ # Nombre del mes
205
+ def nombre_mes(mes)
206
+ meses = {
207
+ '01' => 'enero',
208
+ '02' => 'febrero',
209
+ '03' => 'marzo',
210
+ '04' => 'abril',
211
+ '05' => 'mayo',
212
+ '06' => 'junio',
213
+ '07' => 'julio',
214
+ '08' => 'agosto',
215
+ '09' => 'septiembre',
216
+ '10' => 'octubre',
217
+ '11' => 'noviembre',
218
+ '12' => 'diciembre'
219
+ }
220
+ meses[mes]
221
+ end
222
+
223
+ # Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY
224
+ def cambiar_formato_fecha(fecha)
225
+ # split "-" or "/"
226
+ fecha = fecha.split(%r{-|/})
227
+ # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY
228
+ if fecha[0].length == 4
229
+ "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}"
230
+ else
231
+ "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}"
232
+ end
233
+ end
234
+
235
+ def create
236
+ super
237
+ show(PLACEMENT_SCREEN)
238
+ end
239
+ end
@@ -0,0 +1,162 @@
1
+ require 'pg'
2
+ require 'fox16'
3
+ include Fox
4
+
5
+ class Consulta < FXMainWindow
6
+ def initialize(app)
7
+ super(app, 'Parroquia San Judas Tadeo', width: 700, height: 380)
8
+ @app = app
9
+ self.backColor = FXRGB(3, 187, 133)
10
+
11
+ # seccion encabezado
12
+ # create label
13
+ @lbltitle = FXLabel.new(self, 'Bienvenido a la Parroquia San Judas Tadeo',
14
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700, height: 20, x: 0, y: 20)
15
+ @lbltitle.font = FXFont.new(app, 'Geneva', 16, FONTWEIGHT_BOLD)
16
+ @lbltitle.backColor = FXRGB(3, 187, 133)
17
+ # create label
18
+ @lblsubtitle = FXLabel.new(self, 'ARQUIDIOSESIS DE QUITO - VICARIA NORTE SERVICIO PARROQUIAL DE SAN JUDAS TADEO',
19
+ opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700, height: 20, x: 0, y: 40)
20
+ @lblsubtitle.font = FXFont.new(app, 'Geneva', 10, FONTWEIGHT_BOLD)
21
+ @lblsubtitle.backColor = FXRGB(3, 187, 133)
22
+ # create label
23
+ @date = Time.now.strftime('%d/%m/%Y')
24
+ @lbldate = FXLabel.new(self, "Fecha: #{cambiar_formato_fecha(@date)} ", opts: LAYOUT_EXPLICIT | JUSTIFY_RIGHT,
25
+ width: 680, height: 20, x: 0, y: 60)
26
+ @lbldate.font = FXFont.new(app, 'Geneva', 12, FONTWEIGHT_BOLD)
27
+ @lbldate.backColor = FXRGB(3, 187, 133)
28
+ # seccioan consulta
29
+ @lbl_consulta = FXLabel.new(self, 'Consultar por: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
30
+ x: 10, y: 150)
31
+ @lbl_consulta.backColor = FXRGB(3, 187, 133)
32
+ @lbl_apellidos = FXLabel.new(self, 'Apellidos: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
33
+ y: 180)
34
+ @lbl_apellidos.backColor = FXRGB(3, 187, 133)
35
+ @input_apellidos = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
36
+ y: 180)
37
+ @lbl_nombres = FXLabel.new(self, 'Nombres: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
38
+ y: 180)
39
+ @lbl_nombres.backColor = FXRGB(3, 187, 133)
40
+ @input_nombres = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 510,
41
+ y: 180)
42
+ @lbl_cedula = FXLabel.new(self, 'Cédula: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 10,
43
+ y: 210)
44
+ @lbl_cedula.backColor = FXRGB(3, 187, 133)
45
+ @input_cedula = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
46
+ y: 210)
47
+ @lbl_fecha_desde = FXLabel.new(self, 'Fecha desde (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT, width: 250,
48
+ height: 20, x: 10, y: 240)
49
+ @lbl_fecha_desde.backColor = FXRGB(3, 187, 133)
50
+ @input_fecha_desde = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
51
+ y: 240)
52
+ @lbl_fecha_hasta = FXLabel.new(self, 'Fecha hasta (AAAA/MM/DD): ', opts: LAYOUT_EXPLICIT, width: 250,
53
+ height: 20, x: 10, y: 270)
54
+ @lbl_fecha_hasta.backColor = FXRGB(3, 187, 133)
55
+ @input_fecha_hasta = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 340,
56
+ y: 270)
57
+ @lbl_sacramento = FXLabel.new(self, 'Sacramento: ', opts: LAYOUT_EXPLICIT, width: 150, height: 20,
58
+ x: 10, y: 300)
59
+ @lbl_sacramento.backColor = FXRGB(3, 187, 133)
60
+ @input_sacramento = FXTextField.new(self, 10, opts: LAYOUT_EXPLICIT, width: 150, height: 20, x: 170,
61
+ y: 300)
62
+
63
+ # create buttons
64
+ @btnsearch = FXButton.new(self, 'Buscar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
65
+ x: 450, y: 330)
66
+ @btncancel = FXButton.new(self, 'Cancelar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30,
67
+ x: 560, y: 330)
68
+
69
+ # connect buttons
70
+ @btnsearch.connect(SEL_COMMAND) do
71
+ apellidos = @input_apellidos.text
72
+ nombres = @input_nombres.text
73
+ cedula = @input_cedula.text
74
+ fecha_desde = @input_fecha_desde.text
75
+ fecha_hasta = @input_fecha_hasta.text
76
+ sacramento = @input_sacramento.text
77
+
78
+ if apellidos.empty? && nombres.empty? && cedula.empty? && fecha_desde.empty? && fecha_hasta.empty? && sacramento.empty?
79
+ FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'Debe ingresar al menos un criterio de búsqueda')
80
+ else
81
+ # conectar a la base de datos
82
+ # tables
83
+ # tabla libros (id, tomo, pagina, numero)
84
+ # tabla creyentes (id, nombres, apellidos, lugar_nacimiento, fecha_nacimiento, cedula)
85
+ # tabla parroquias (id, nombre, sector, parroco)
86
+ # tabla sacramentos (id, nombre, fecha, celebrante, certifica, padrino, madrina, testigo_novio, testigo_novia, padre, madre, nombres_novia, apellidos_novia, cedula_novia, fk_creyentes, fk_parroquias, fk_registros_civiles, fk_libros)
87
+ # tabla registros_civiles (id, provincia_rc, canton_rc, parroquia_rc, anio_rc, tomo_rc, pagina_rc, acta_rc, fecha_rc)
88
+ # Join tables
89
+ sql = 'SELECT * FROM sacramentos INNER JOIN libros ON sacramentos.id = libros.id INNER JOIN creyentes ON sacramentos.id = creyentes.id INNER JOIN parroquias ON sacramentos.id = parroquias.id INNER JOIN registros_civiles ON sacramentos.id = registros_civiles.id INNER JOIN misas ON misas.id = parroquias.id'
90
+ sql += " WHERE creyentes.apellidos LIKE '%#{apellidos}%'" unless apellidos.empty?
91
+ sql += " AND creyentes.nombres LIKE '%#{nombres}%'" unless nombres.empty?
92
+ sql += " AND creyentes.cedula = '#{cedula}'" unless cedula.empty?
93
+ sql += " AND sacramentos.fecha >= '#{fecha_desde}'" unless fecha_desde.empty?
94
+ sql += " AND sacramentos.fecha <= '#{fecha_hasta}'" unless fecha_hasta.empty?
95
+ # Se hace una consulta desde una fecha hasta otra fecha
96
+ sql += " AND sacramentos.fecha BETWEEN '#{fecha_desde}' AND '#{fecha_hasta}'" unless fecha_desde.empty? || fecha_hasta.empty?
97
+ sql += " AND sacramentos.sacramento = '#{sacramento}'" unless sacramento.empty?
98
+ $conn.exec(sql) do |result|
99
+ if result.values.empty?
100
+ FXMessageBox.information(self, MBOX_OK, 'Información', 'No se encontraron registros')
101
+ else
102
+ # mostrar resultados
103
+ FXMessageBox.information(self, MBOX_OK, 'Información', "Se encontraron #{result.values.length} registros")
104
+ require_relative 'resultados'
105
+ vtnresultados = ResultadosConsulta.new(@app, result.values)
106
+ vtnresultados.create
107
+ vtnresultados.show(PLACEMENT_SCREEN)
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ @btncancel.connect(SEL_COMMAND) do
114
+ clear_input_fields
115
+ end
116
+
117
+ def clear_input_fields
118
+ @input_apellidos.text = ''
119
+ @input_nombres.text = ''
120
+ @input_cedula.text = ''
121
+ @input_fecha_desde.text = ''
122
+ @input_fecha_hasta.text = ''
123
+ @input_sacramento.text = ''
124
+ end
125
+ end
126
+
127
+ # Nombre del mes
128
+ def nombre_mes(mes)
129
+ meses = {
130
+ '01' => 'enero',
131
+ '02' => 'febrero',
132
+ '03' => 'marzo',
133
+ '04' => 'abril',
134
+ '05' => 'mayo',
135
+ '06' => 'junio',
136
+ '07' => 'julio',
137
+ '08' => 'agosto',
138
+ '09' => 'septiembre',
139
+ '10' => 'octubre',
140
+ '11' => 'noviembre',
141
+ '12' => 'diciembre'
142
+ }
143
+ meses[mes]
144
+ end
145
+
146
+ # Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY
147
+ def cambiar_formato_fecha(fecha)
148
+ # split "-" or "/"
149
+ fecha = fecha.split(%r{-|/})
150
+ # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY
151
+ if fecha[0].length == 4
152
+ "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}"
153
+ else
154
+ "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}"
155
+ end
156
+ end
157
+
158
+ def create
159
+ super
160
+ show(PLACEMENT_SCREEN)
161
+ end
162
+ end