Class: ResultadosConsulta
- Inherits:
-
FXMainWindow
- Object
- FXMainWindow
- ResultadosConsulta
- Defined in:
- lib/parroquia/catecismo/resultado.rb,
lib/parroquia/sacramentos/resultados.rb
Instance Method Summary collapse
-
#cambiar_formato_fecha(fecha) ⇒ Object
Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY.
- #create ⇒ Object
- #imprimir_pdf ⇒ Object
-
#initialize(app, result_data) ⇒ ResultadosConsulta
constructor
A new instance of ResultadosConsulta.
- #listar_pdf ⇒ Object
-
#nombre_mes(mes) ⇒ Object
Nombre del mes.
- #registros_seleccionados ⇒ Object
- #seleccionar_columna ⇒ Object
- #seleccionar_directorio ⇒ Object
-
#seleccionar_fila ⇒ Object
Al hacer clic en una fila, se selecciona la fila completa para imprimir los datos.
Constructor Details
#initialize(app, result_data) ⇒ ResultadosConsulta
Returns a new instance of ResultadosConsulta.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/parroquia/catecismo/resultado.rb', line 7 def initialize(app, result_data) super(app, 'Resultados de la Consulta', width: 800, height: 480) @app = app @result_data = result_data # Los datos de resultados que se pasan a esta clase # Crea una tabla para mostrar los resultados @tabla = FXTable.new(self, opts: LAYOUT_EXPLICIT | TABLE_COL_SIZABLE | TABLE_ROW_SIZABLE, width: 800, height: 400, x: 0, y: 0) @tabla.visibleRows = 10 @tabla.visibleColumns = 10 # El tamaño de la tabla depende del número de columnas nombrada en poner nombre a las columnas y las filas al numero de registros encontrados @tabla.setTableSize(@result_data.length, 13) # Llena la tabla con los datos de resultados @result_data.each_with_index do |row, i| row.each_with_index do |col, j| @tabla.setItemText(i, j, col.to_s) end end # Poner nombre a las columnas @tabla.setColumnText(0, 'ID Alumnos') @tabla.setColumnText(1, 'Nombres') @tabla.setColumnText(2, 'Apellidos') @tabla.setColumnText(3, 'Lugar_nacimiento') @tabla.setColumnText(4, 'Fecha_nacimiento') @tabla.setColumnText(5, 'Cédula') @tabla.setColumnText(6, 'ID Niveles') @tabla.setColumnText(7, 'Nivel') @tabla.setColumnText(8, 'Sector') @tabla.setColumnText(9, 'Año lectivo') @tabla.setColumnText(10, 'ID Catequistas') @tabla.setColumnText(11, 'Nombres') @tabla.setColumnText(12, 'Apellidos') # Al hacer clic en una fila, se selecciona la fila completa para imprimir los datos def seleccionar_fila @tabla.each_row do |i| @tabla.selectRow(i.index) if @tabla.isRowSelected(i.index) end end def registros_seleccionados registros = [] (0...@tabla.numRows).each do |i| registros << @result_data[i] if @tabla.isRowSelected(i) end registros end def seleccionar_columna selected_columns = [] (0...@tabla.numColumns).each do |i| selected_columns << i if @tabla.isColumnSelected(i) end selected_columns end # Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY def cambiar_formato_fecha(fecha) # split "-" or "/" fecha = fecha.split(%r{-|/}) # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY if fecha[0].length == 4 "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}" else "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}" end end # Nombre del mes def nombre_mes(mes) meses = { '01' => 'enero', '02' => 'febrero', '03' => 'marzo', '04' => 'abril', '05' => 'mayo', '06' => 'junio', '07' => 'julio', '08' => 'agosto', '09' => 'septiembre', '10' => 'octubre', '11' => 'noviembre', '12' => 'diciembre' } meses[mes] end # Nombre de las filas @result_data.each_with_index do |_row, i| @tabla.setRowText(i, "Registro #{i + 1}") end # create buttons @btnlists = FXButton.new(self, 'Listar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30, x: 350, y: 430) @btnprint = FXButton.new(self, 'Exportar PDF', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30, x: 460, y: 430) @btnedit = FXButton.new(self, 'Editar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30, x: 570, y: 430) @btndelete = FXButton.new(self, 'Eliminar', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 100, height: 30, x: 680, y: 430) # connect buttons @btnprint.connect(SEL_COMMAND) do seleccionar_directorio imprimir_pdf end @btnlists.connect(SEL_COMMAND) do seleccionar_directorio listar_pdf end def listar_pdf selected_columns = seleccionar_columna registros_seleccionados = registros_seleccionados() # Obtén los registros seleccionados if selected_columns.empty? || registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'Debe seleccionar al menos una columna y registros') else # Genera el archivo PDF Prawn::Document.generate(@archivo_pdf, margin: [150, 100, 100, 100]) do |pdf| pdf.font 'Helvetica' pdf.font_size 12 pdf.image File.join(File.dirname(__FILE__), '../assets/images/arquidiocesisquito.png'), height: 100, position: :absolute, at: [-60, 680] pdf.text_box 'Arquidiócesis de Quito', align: :center, size: 16, style: :bold, at: [10, 670], width: pdf.bounds.width pdf.text_box 'Parroquia Eclesiástica "San Judas Tadeo"', align: :center, size: 14, style: :bold, at: [10, 650], width: pdf.bounds.width pdf.text_box "Jaime Roldós Aguilera, calle Oe13A y N82\nEl Condado, Quito - Ecuador\nTeléfono: 02496446", align: :center, size: 10, at: [10, 630], width: pdf.bounds.width pdf.image File.join(File.dirname(__FILE__), '../assets/images/sanjudastadeo.png'), height: 100, position: :absolute, at: [430, 680] # Título del certificado en color rojo pdf.text 'Lista de alumnos', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 # Recorre todos los registros seleccionados y agrega sus horarios de misas pdf.text "Año Lectivo #{registros_seleccionados[0][9]}" pdf.move_down 10 pdf.text "Catequista #{registros_seleccionados[0][11]} #{registros_seleccionados[0][12]}" pdf.move_down 10 pdf.text 'Número | Apellidos | Nombres | Nivel | Sector' pdf.move_down 10 contador = 1 registros_seleccionados.each do |registro| # Listar con numeros pdf.text "#{contador} | #{registro[selected_columns[2]]} #{registro[selected_columns[1]]} | #{registro[selected_columns[7]]} | #{registro[selected_columns[8]]}" pdf.move_down 10 contador += 1 end end # Abre el archivo PDF con el visor de PDF predeterminado del sistema system("xdg-open '#{@archivo_pdf}'") end # Mensaje de confirmación FXMessageBox.information(self, MBOX_OK, 'Información', 'El archivo PDF se ha generado correctamente') end def seleccionar_directorio dialog = FXDirDialog.new(self, 'Seleccionar directorio para guardar PDF') return unless dialog.execute != 0 directorio = dialog.getDirectory if registros_seleccionados.nil? || registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'No hay registros seleccionados') else @archivo_pdf = "#{directorio}/#{registros_seleccionados[0][19]} #{registros_seleccionados[0][20]} - #{registros_seleccionados[0][1]}.pdf" end end @btnedit.connect(SEL_COMMAND) do # Editar registros seleccionados y actualizar la basee de datos registros_seleccionados.each do |registro| sql = "SELECT * FROM alumnos INNER JOIN catequistas ON alumnos.id = catequistas.id INNER JOIN niveles ON alumnos.id = niveles.id WHERE alumnos.id = #{registro[0]}" $conn.exec(sql) do |result| @registros = result.values[0] require_relative 'actualizar_alumno' vtnactualizar_alumno = ActualizarAlumno.new(@app, @registros) vtnactualizar_alumno.create vtnactualizar_alumno.show(PLACEMENT_SCREEN) end end end @btndelete.connect(SEL_COMMAND) do # eliminar registros seleccionados if registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'Debe seleccionar al menos un registro') elsif FXMessageBox.question(self, MBOX_YES_NO, 'Confirmación', '¿Está seguro de eliminar los registros seleccionados?') == MBOX_CLICKED_YES # Mensaje de confirmación registros_seleccionados.each do |registro| # Eliminar registros de todas las tablas sql = 'DELETE FROM alumnos WHERE id = $1' $conn.exec_params(sql, [registro[0]]) sql = 'DELETE FROM catequistas WHERE id = $1' $conn.exec_params(sql, [registro[10]]) sql = 'DELETE FROM niveles WHERE id = $1' $conn.exec_params(sql, [registro[6]]) # Mensaje de confirmación FXMessageBox.information(self, MBOX_OK, 'Información', 'Los registros seleccionados se han eliminado correctamente') end end end Prawn::Fonts::AFM.hide_m17n_warning = true end |
Instance Method Details
#cambiar_formato_fecha(fecha) ⇒ Object
Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/parroquia/catecismo/resultado.rb', line 71 def cambiar_formato_fecha(fecha) # split "-" or "/" fecha = fecha.split(%r{-|/}) # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY if fecha[0].length == 4 "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}" else "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}" end end |
#create ⇒ Object
226 227 228 229 |
# File 'lib/parroquia/catecismo/resultado.rb', line 226 def create super show(PLACEMENT_SCREEN) end |
#imprimir_pdf ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/parroquia/sacramentos/resultados.rb', line 208 def imprimir_pdf if registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'Debe seleccionar al menos un registro') else # Genera el archivo PDF Prawn::Document.generate(@archivo_pdf, margin: [100, 100, 100, 100]) do |pdf| pdf.font 'Helvetica' pdf.font_size 12 # Definir tres casos en los que se puede imprimir el certificado y los distintos formatos para bautismo, confirmación y matrimonio # Bautismo # Encabezado pdf.image File.join(File.dirname(__FILE__), '../assets/images/arquidiocesisquito.png'), height: 80, position: :absolute, at: [-60, 680] pdf.text_box 'Arquidiócesis de Quito', align: :center, size: 16, style: :bold, at: [10, 670], width: pdf.bounds.width pdf.text_box 'Parroquia Eclesiástica "San Judas Tadeo"', align: :center, size: 14, style: :bold, at: [10, 650], width: pdf.bounds.width pdf.text_box "Jaime Roldós Aguilera, calle Oe13A y N82\nEl Condado, Quito - Ecuador\nTeléfono: 02496446", align: :center, size: 10, at: [10, 630], width: pdf.bounds.width pdf.image File.join(File.dirname(__FILE__), '../assets/images/sanjudastadeo.png'), height: 80, position: :absolute, at: [430, 680] case registros_seleccionados[0][1] when 'Bautismo' # Título del certificado en color rojo pdf.move_down 20 pdf.text 'CERTIFICADO DE BAUTISMO', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Añadir márgenes izquierdo y derecho # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Tomo, página y número justificado pdf.text "Yo, el infrascrito, certifico en legal forma a petición de la parte interesada que en el libro de bautismos de esta parroquia: Tomo #{registro[15]} - Página #{registro[16]} - Número #{registro[17]}, se halla inscrita la siguiente partida:", align: :justify pdf.move_down 10 # Fecha de bautismo pdf.text "FECHA DE BAUTISMO: #{cambiar_formato_fecha(registro[2])}.", align: :justify pdf.move_down 10 # Lugar de bautismo pdf.text "PARROQUIA: #{registro[25]}", align: :justify pdf.move_down 10 # Sector pdf.text "SECTOR: #{registro[26]}.", align: :justify pdf.move_down 10 # Celebrante pdf.text "MINISTRO: #{registro[3]}.", align: :justify pdf.move_down 10 # Nombres pdf.text "NOMBRES: #{registro[19]}.", align: :justify pdf.move_down 10 # Apellidos pdf.text "APELLIDOS: #{registro[20]}.", align: :justify pdf.move_down 10 # Fecha de nacimiento pdf.text "LUGAR DE NACIMIENTO #{registro[21]}. FECHA DE NACIMIENTO: #{cambiar_formato_fecha(registro[22])}.", align: :justify pdf.move_down 10 # Padres pdf.text "Hijo/ja de #{registro[9]} y de #{registro[10]}.", align: :justify pdf.move_down 10 # Padrinos pdf.text "Fueron sus padrinos: #{registro[5]} y #{registro[6]} a quienes se advirtió de sus obligaciones y parentezco espiritual.", align: :justify pdf.move_down 10 # Certifica pdf.text "CERTIFICA: #{registro[4]}.", align: :justify pdf.move_down 10 # Registro civil pdf.text 'REGISTRO CIVIL', align: :center, size: 14, style: :bold pdf.move_down 10 pdf.text "Provincia: #{registro[29]}, Cantón: #{registro[30]}, Parroquia: #{registro[31]}", align: :justify pdf.text "Año: #{registro[32]}, Tomo: #{registro[33]}, Página: #{registro[34]}, Acta: #{registro[35]}", align: :justify pdf.text "Fecha: #{cambiar_formato_fecha(registro[36])}", align: :justify pdf.move_down 10 # Datos tomados fielmente de original pdf.text 'Datos tomados fielmente del original', align: :center pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center # Nombre del párroco pdf.text (registro[27]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Comunión' pdf.move_down 20 pdf.text 'CERTIFICADO DE PRIMERA COMUNIÓN', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Tomo, página y número justificado pdf.text "Yo, el infrascrito, certifico en legal forma a petición de la parte interesada que en el libro de comuniones de esta parroquia: Tomo #{registro[15]} - Página #{registro[16]} - Número #{registro[17]}, se halla inscrita la siguiente partida:", align: :justify pdf.move_down 10 # Fecha de comunión pdf.text "FECHA DE COMUNIÓN: #{cambiar_formato_fecha(registro[2])}.", align: :justify pdf.move_down 10 # Lugar de comunión pdf.text "PARROQUIA: #{registro[25]}", align: :justify pdf.move_down 10 # Sector pdf.text "SECTOR: #{registro[26]}.", align: :justify pdf.move_down 10 # Celebrante pdf.text "CELEBRANTE: #{registro[3]}.", align: :justify pdf.move_down 10 # Nombres pdf.text "NOMBRES: #{registro[19]}.", align: :justify pdf.move_down 10 # Apellidos pdf.text "APELLIDOS: #{registro[20]}.", align: :justify pdf.move_down 10 # Cerifica pdf.text "CERTIFICA: #{registro[4]}.", align: :justify pdf.move_down 10 # Datos tomados fielmente de original pdf.text 'Datos tomados fielmente del original', align: :center pdf.move_down 40 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Confirmación' pdf.move_down 20 pdf.text 'CERTIFICADO DE CONFIRMACIÓN', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Tomo, página y número justificado pdf.text "Yo, el infrascrito, certifico en legal forma a petición de la parte interesada que en el libro de confirmaciones de esta parroquia: Tomo #{registro[15]} - Página #{registro[16]} - Número #{registro[17]}, se halla inscrita la siguiente partida:", align: :justify pdf.move_down 10 # Fecha de confirmación pdf.text "FECHA DE CONFIRMACIÓN: #{cambiar_formato_fecha(registro[2])}.", align: :justify pdf.move_down 10 # Celebrante pdf.text "CELEBRANTE: #{registro[3]}.", align: :justify pdf.move_down 10 # Padrinos pdf.text "Fue su padrino: #{registro[5]} a quien se advirtió de sus obligaciones y parentezco espiritual.", align: :justify pdf.move_down 10 # Certifica pdf.text "CERTIFICA: #{registro[4]}.", align: :justify pdf.move_down 10 # Datos tomados fielmente de original pdf.text 'Datos tomados fielmente del original', align: :center pdf.move_down 40 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Matrimonio' pdf.move_down 20 pdf.text 'CERTIFICADO DE MATRIMONIO', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Tomo, página y número justificado pdf.text "Yo, el infrascrito, certifico en legal forma a petición de la parte interesada que en el libro de matrimonios de esta parroquia: Tomo #{registro[15]} - Página #{registro[16]} - Número #{registro[17]}, se halla inscrita la siguiente partida:", align: :justify pdf.move_down 10 # Fecha de matrimonio pdf.text "FECHA DE MATRIMONIO: #{cambiar_formato_fecha(registro[2])}.", align: :justify pdf.move_down 10 # Datos del novio pdf.text "NOMBRES DEL NOVIO: #{registro[19]}.", align: :justify pdf.move_down 10 pdf.text "APELLIDOS DEL NOVIO: #{registro[20]}.", align: :justify pdf.move_down 10 # Datos de la novia pdf.text "NOMBRES DE LA NOVIA: #{registro[11]}.", align: :justify pdf.move_down 10 pdf.text "APELLIDOS DE LA NOVIA: #{registro[12]}.", align: :justify pdf.move_down 10 # Parroquia pdf.text "PARROQUIA: #{registro[25]}", align: :justify pdf.move_down 10 # Sector pdf.text "SECTOR: #{registro[26]}.", align: :justify pdf.move_down 10 # Celebrante pdf.text "CELEBRANTE: #{registro[3]}.", align: :justify # Feligreses de la parroquia pdf.text "Feligreses de la parroquia: #{registro[25]}.", align: :justify pdf.move_down 10 # Testigos pdf.text "TESTIGOS: #{registro[7]} y #{registro[8]}.", align: :justify pdf.move_down 10 # Cerifica pdf.text "CERTIFICA: #{registro[4]}.", align: :justify pdf.move_down 10 # Registro civil pdf.text 'REGISTRO CIVIL', align: :center, size: 14, style: :bold pdf.move_down 10 pdf.text "Provincia: #{registro[29]}, Cantón: #{registro[30]}, Parroquia: #{registro[31]}", align: :justify pdf.text "Año: #{registro[32]}, Tomo: #{registro[33]}, Página: #{registro[34]}, Acta: #{registro[35]}", align: :justify pdf.text "Fecha: #{cambiar_formato_fecha(registro[36])}", align: :justify pdf.move_down 10 # Datos tomados fielmente de original pdf.text 'Datos tomados fielmente del original', align: :center pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Partida Supletoria del Bautismo' pdf.move_down 20 pdf.text 'CERTIFICADO DE PARTIDA SUPLETORIA DEL BAUTISMO', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Fecha de bautismo pdf.text "FECHA DE BAUTISMO: #{cambiar_formato_fecha(registro[2])}.", align: :justify pdf.move_down 10 # Nombres pdf.text "NOMBRES: #{registro[19]}.", align: :justify pdf.move_down 10 # Apellidos pdf.text "APELLIDOS: #{registro[20]}.", align: :justify pdf.move_down 10 # Fecha de nacimiento pdf.text "LUGAR DE NACIMIENTO #{registro[21]}. FECHA DE NACIMIENTO: #{cambiar_formato_fecha(registro[22])}.", align: :justify pdf.move_down 10 # Padres pdf.text "Hijo/ja de #{registro[9]} y de #{registro[10]}.", align: :justify pdf.move_down 10 # Padrinos pdf.text "Fueron sus padrinos: #{registro[5]} y #{registro[6]}.", align: :justify pdf.move_down 10 # Registro civil pdf.text 'REGISTRO CIVIL', align: :center, size: 14, style: :bold pdf.move_down 10 pdf.text "Provincia: #{registro[29]}, Cantón: #{registro[30]}, Parroquia: #{registro[31]}", align: :justify pdf.text "Año: #{registro[32]}, Tomo: #{registro[33]}, Página: #{registro[34]}, Acta: #{registro[35]}", align: :justify pdf.text "Fecha: #{cambiar_formato_fecha(registro[36])}", align: :justify pdf.move_down 10 # Datos tomados fielmente de original pdf.text 'Datos tomados fielmente del original', align: :center pdf.move_down 40 # Firmas padres y testigos pdf.text "PADRE: #{registro[9]} FIRMA: __________________", align: :center pdf.move_down 10 pdf.text "MADRE: #{registro[10]} FIRMA: __________________", align: :center pdf.move_down 10 pdf.text 'TESTIGO 1): ................................... FIRMA: __________________', align: :center pdf.move_down 10 pdf.text 'TESTIGO 2): ................................... FIRMA: __________________', align: :center pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Curso Prebautismal' pdf.move_down 20 pdf.text 'CERTIFICADO DEL CURSO PREBAUTISMAL', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Título pdf.text 'Rvdo. Padre', align: :justify pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :justify pdf.move_down 10 # Parroquia pdf.text "Párroco de la Parroquia Eclesiástica \"#{registro[25]}\"", align: :justify pdf.move_down 10 # Saludo pdf.text 'De mis consideraciones:', align: :justify pdf.move_down 10 # Cuerpo pdf.text "Quien suscribe Padre #{registro[4]}, Párroco de la Parroquia Eclesiástica \"San Judas Tadeo\", CERTIFICA que #{registro[19]} #{registro[20]}, CI #{registro[23]} realizó la charla Pre - Bautismal en esta parroquia, para acompañar como padrino/madrina ............................. de ......................................................., bautizo que se realizará el #{cambiar_formato_fecha(registro[2])} en la parroquia antes mencionada.", align: :justify pdf.move_down 10 # Despedida pdf.text 'Es todo cuanto puedo certificar en honor a la verdad, pudiendo el peticionario hacer uso del presente certificado como ha bien tuviere', align: :justify pdf.move_down 10 pdf.text 'En Dios y María Santísima.', align: :justify pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[4]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Permiso de Bautismo' pdf.move_down 20 pdf.text 'PERMISO DE BAUTISMO', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Título pdf.text 'Rvdo. Padre', align: :justify pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :justify pdf.move_down 10 # Parroquia pdf.text "Párroco de la Parroquia Eclesiástica \"#{registro[25]}\"", align: :justify pdf.move_down 10 pdf.text 'Presente.', align: :justify pdf.move_down 10 # Saludo pdf.text 'Reciba un afectuoso saludo.', align: :justify pdf.move_down 10 # Cuerpo pdf.text "Por medio de la presente. Quien suscribe Padre #{registro[4]}, Párroco de la Parroquia Eclesiástica \"San Judas Tadeo\", AUTORIZO a #{registro[9]} CI .................. y a #{registro[10]} CI ...................., para que bauticen a su hijo/a #{registro[19]} #{registro[20]} CI #{registro[23]} y también a los padrinos #{registro[5]} y #{registro[6]}, bautizo que se realizará el #{cambiar_formato_fecha(registro[2])} en la parroquia antes mencionada.", align: :justify pdf.move_down 10 # Despedida pdf.text 'En Dios y María Santísima.', align: :justify pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[4]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end when 'Permiso de Matrimonio' pdf.move_down 20 pdf.text 'PERMISO DE MATRIMONIO', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 registros_seleccionados.each do |registro| # Fecha actual alineada a la derecha pdf.text "Quito, #{cambiar_formato_fecha(Time.now.strftime('%d/%m/%Y'))}", align: :right pdf.move_down 20 # Título pdf.text 'Rvdo. Padre', align: :justify pdf.move_down 10 # Nombre del párroco pdf.text (registro[27]).to_s, align: :justify pdf.move_down 10 # Parroquia pdf.text "Párroco de la Parroquia Eclesiástica \"#{registro[25]}\"", align: :justify pdf.move_down 10 pdf.text 'Presente.', align: :justify pdf.move_down 10 # Saludo pdf.text 'Reciba un afectuoso saludo.', align: :justify pdf.move_down 10 # Cuerpo pdf.text "Por medio de la presente. Quien suscribe Padre #{registro[4]}, Párroco de la Parroquia Eclesiástica \"San Judas Tadeo\", AUTORIZO y habiéndose realizado los trámites canónicos para celebrar ante la Iglesia Católica el matrimonio de #{registro[19]} #{registro[20]} CI #{registro[23]} y de #{registro[11]} #{registro[12]} CI #{registro[14]} y también los testigos #{registro[7]} y #{registro[8]} para que contraigan matrimonio el #{cambiar_formato_fecha(registro[2])} en la parroquia antes mencionada.", align: :justify pdf.move_down 10 # Despedida pdf.text 'Es todo cuanto puedo certificar en honor a la verdad.', align: :justify pdf.move_down 10 pdf.text 'En Dios y María Santísima.', align: :justify pdf.move_down 30 # Firma del párroco pdf.text '_______________________________', align: :center pdf.move_down 10 # Nombre del párroco pdf.text (registro[4]).to_s, align: :center # Parroco pdf.text 'Párroco', align: :center end end end # Abre el archivo PDF con el visor de PDF predeterminado del sistema system("xdg-open '#{@archivo_pdf}'") end # Mensaje de confirmación FXMessageBox.information(self, MBOX_OK, 'Información', 'El archivo PDF se ha generado correctamente') end |
#listar_pdf ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/parroquia/catecismo/resultado.rb', line 127 def listar_pdf selected_columns = seleccionar_columna registros_seleccionados = registros_seleccionados() # Obtén los registros seleccionados if selected_columns.empty? || registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'Debe seleccionar al menos una columna y registros') else # Genera el archivo PDF Prawn::Document.generate(@archivo_pdf, margin: [150, 100, 100, 100]) do |pdf| pdf.font 'Helvetica' pdf.font_size 12 pdf.image File.join(File.dirname(__FILE__), '../assets/images/arquidiocesisquito.png'), height: 100, position: :absolute, at: [-60, 680] pdf.text_box 'Arquidiócesis de Quito', align: :center, size: 16, style: :bold, at: [10, 670], width: pdf.bounds.width pdf.text_box 'Parroquia Eclesiástica "San Judas Tadeo"', align: :center, size: 14, style: :bold, at: [10, 650], width: pdf.bounds.width pdf.text_box "Jaime Roldós Aguilera, calle Oe13A y N82\nEl Condado, Quito - Ecuador\nTeléfono: 02496446", align: :center, size: 10, at: [10, 630], width: pdf.bounds.width pdf.image File.join(File.dirname(__FILE__), '../assets/images/sanjudastadeo.png'), height: 100, position: :absolute, at: [430, 680] # Título del certificado en color rojo pdf.text 'Lista de alumnos', align: :center, size: 20, style: :bold, color: 'FF0000' pdf.move_down 20 # Recorre todos los registros seleccionados y agrega sus horarios de misas pdf.text "Año Lectivo #{registros_seleccionados[0][9]}" pdf.move_down 10 pdf.text "Catequista #{registros_seleccionados[0][11]} #{registros_seleccionados[0][12]}" pdf.move_down 10 pdf.text 'Número | Apellidos | Nombres | Nivel | Sector' pdf.move_down 10 contador = 1 registros_seleccionados.each do |registro| # Listar con numeros pdf.text "#{contador} | #{registro[selected_columns[2]]} #{registro[selected_columns[1]]} | #{registro[selected_columns[7]]} | #{registro[selected_columns[8]]}" pdf.move_down 10 contador += 1 end end # Abre el archivo PDF con el visor de PDF predeterminado del sistema system("xdg-open '#{@archivo_pdf}'") end # Mensaje de confirmación FXMessageBox.information(self, MBOX_OK, 'Información', 'El archivo PDF se ha generado correctamente') end |
#nombre_mes(mes) ⇒ Object
Nombre del mes
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/parroquia/catecismo/resultado.rb', line 83 def nombre_mes(mes) meses = { '01' => 'enero', '02' => 'febrero', '03' => 'marzo', '04' => 'abril', '05' => 'mayo', '06' => 'junio', '07' => 'julio', '08' => 'agosto', '09' => 'septiembre', '10' => 'octubre', '11' => 'noviembre', '12' => 'diciembre' } meses[mes] end |
#registros_seleccionados ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/parroquia/catecismo/resultado.rb', line 52 def registros_seleccionados registros = [] (0...@tabla.numRows).each do |i| registros << @result_data[i] if @tabla.isRowSelected(i) end registros end |
#seleccionar_columna ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/parroquia/catecismo/resultado.rb', line 60 def seleccionar_columna selected_columns = [] (0...@tabla.numColumns).each do |i| selected_columns << i if @tabla.isColumnSelected(i) end selected_columns end |
#seleccionar_directorio ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/parroquia/catecismo/resultado.rb', line 174 def seleccionar_directorio dialog = FXDirDialog.new(self, 'Seleccionar directorio para guardar PDF') return unless dialog.execute != 0 directorio = dialog.getDirectory if registros_seleccionados.nil? || registros_seleccionados.empty? FXMessageBox.warning(self, MBOX_OK, 'Advertencia', 'No hay registros seleccionados') else @archivo_pdf = "#{directorio}/#{registros_seleccionados[0][19]} #{registros_seleccionados[0][20]} - #{registros_seleccionados[0][1]}.pdf" end end |
#seleccionar_fila ⇒ Object
Al hacer clic en una fila, se selecciona la fila completa para imprimir los datos
46 47 48 49 50 |
# File 'lib/parroquia/catecismo/resultado.rb', line 46 def seleccionar_fila @tabla.each_row do |i| @tabla.selectRow(i.index) if @tabla.isRowSelected(i.index) end end |