Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.75 KB | None | 0 0
  1.  
  2.  
  3. #
  4. #
  5. #
  6. class Alumno < ActiveRecord::Base
  7. establish_connection 'sega_' + Rails.env
  8.  
  9. self.table_name = 'movcInscripciones'
  10. self.primary_key = 'IdInscripcion'
  11.  
  12. # datos de prueba
  13. # 242633
  14. # matricula 206829
  15.  
  16. def self.por_matricula(matricula)
  17. Alumno.where(Matricula: matricula, IdEstatus: [2, 4, 11,17])
  18. end
  19.  
  20. def horario
  21. config = Rails.configuration.database_configuration
  22. enviroment = 'sega_' + Rails.env
  23. @connection = ActiveRecord::Base.establish_connection(
  24. :adapter => config[enviroment]['adapter'],
  25. :url => config[enviroment]['url'],
  26. :database => config[enviroment]['database'],
  27. :username => config[enviroment]['username'],
  28. :password => config[enviroment]['password']
  29. )
  30.  
  31. sql_query = "
  32. Declare @IdInscripcion As Int
  33. Declare @IdCicloEscolar As Int
  34. Set @IdInscripcion = #{self.IdInscripcion}
  35. Set @IdCicloEscolar = #{self.IdCicloEscolar}
  36.  
  37.  
  38. Select Distinct @IdInscripcion as IdInscripcion, i.Ciclo, j.Materia as Clave,
  39. i.Descripcion as Materia,
  40. isnull(k.Descripcion,'') as Opcion, aa.Grupo, aa.IdGrupo,
  41. l.Descripcion as Tipo,
  42. isnull(HLunes,'') as HLunes, isnull(L_SalonGrupo,'') as SLunes,
  43. isnull(HMartes,'') as HMartes, isnull(M_SalonGrupo,'') as sMartes,
  44. isnull(HMiercoles,'') as HMiercoles, isnull(MM_SalonGrupo,'') as SMiercoles,
  45. isnull(HJueves,'') as HJueves, isnull(J_SalonGrupo,'') as SJueves,
  46. isnull(HViernes,'') as HViernes, isnull(V_SalonGrupo,'') as SViernes,
  47. isnull(HSabado,'') as HSabado, isnull(S_SalonGrupo,'') as SSabado,
  48. --isnull(HViernes,'') as HDomingo, isnull(V_SalonGrupo,'') as SDomingo,
  49. isnull(HDomingo,'') As HDomingo, isNull(D_SalonGrupo,'') As SDomingo,
  50. '' as Maestro, Fechas
  51. From (
  52.  
  53. Select Distinct h.IdMateriaPlanEstudios, a.IdOpcionMateria, a.IdTipoGrupo, a.Grupo,
  54. row_number() over(Partition by a.IdGrupo order by a.IdGrupo) as Ren, a.IdGrupo,
  55. Convert(char(5), b.HoraEntrada, 108) + ' - ' + Convert(char(5), b.HoraSalida, 108) as HLunes,
  56. b.SalonGrupo as L_SalonGrupo, b.Ren as RLunes,
  57. Convert(char(5), c.HoraEntrada, 108) + ' - ' + Convert(char(5), c.HoraSalida, 108) as HMartes,
  58. c.SalonGrupo as M_SalonGrupo, c.Ren as RMartes,
  59. Convert(char(5), d.HoraEntrada, 108) + ' - ' + Convert(char(5), d.HoraSalida, 108) as HMiercoles,
  60. d.SalonGrupo as MM_SalonGrupo, d.Ren as RMiercoles,
  61. Convert(char(5), e.HoraEntrada, 108) + ' - ' + Convert(char(5), e.HoraSalida, 108) as HJueves,
  62. e.SalonGrupo as J_SalonGrupo, e.Ren as RJueves,
  63. Convert(char(5), f.HoraEntrada, 108) + ' - ' + Convert(char(5), f.HoraSalida, 108) as HViernes,
  64. f.SalonGrupo as V_SalonGrupo, f.Ren as RViernes,
  65. Convert(char(5), g.HoraEntrada, 108) + ' - ' + Convert(char(5), g.HoraSalida, 108) as HSabado,
  66. g.SalonGrupo as S_SalonGrupo, g.Ren as RSabado,
  67. Convert(char(5), m.HoraEntrada, 108) + ' - ' + Convert(char(5), m.HoraSalida, 108) as HDomingo,
  68. m.SalonGrupo as D_SalonGrupo, m.Ren as RDomingo,
  69.  
  70. Convert(char(10), a.FechaInicio, 103) /*+ ' - ' + Convert(char(10), a.FechaFin, 103)*/ as Fechas
  71. From movdInscripciones h with (nolock)
  72. Inner Join movcGrupos a with (nolock)
  73. On h.IdGrupo = a.IdGrupo
  74. --And a.IdTipoGrupo = 1
  75. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  76. From movdGrupos ab with (nolock)
  77. Inner Join catcSalonesGrupos bb with (nolock)
  78. On ab.IdSalonGrupo = bb.IdSalonGrupo
  79. Where ab.IdDia = 1) as b
  80. On a.IdGrupo = b.IdGrupo
  81. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  82. From movdGrupos ab with (nolock)
  83. Inner Join catcSalonesGrupos bb with (nolock)
  84. On ab.IdSalonGrupo = bb.IdSalonGrupo
  85. Where ab.IdDia = 2) as c
  86. On a.IdGrupo = c.IdGrupo
  87. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  88. From movdGrupos ab with (nolock)
  89. Inner Join catcSalonesGrupos bb with (nolock)
  90. On ab.IdSalonGrupo = bb.IdSalonGrupo
  91. Where ab.IdDia = 3) as d
  92. On a.IdGrupo = d.IdGrupo
  93. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  94. From movdGrupos ab with (nolock)
  95. Inner Join catcSalonesGrupos bb with (nolock)
  96. On ab.IdSalonGrupo = bb.IdSalonGrupo
  97. Where ab.IdDia = 4) as e
  98. On a.IdGrupo = e.IdGrupo
  99. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  100. From movdGrupos ab with (nolock)
  101. Inner Join catcSalonesGrupos bb with (nolock)
  102. On ab.IdSalonGrupo = bb.IdSalonGrupo
  103. Where ab.IdDia = 5) as f
  104. On a.IdGrupo = f.IdGrupo
  105. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  106. From movdGrupos ab with (nolock)
  107. Inner Join catcSalonesGrupos bb with (nolock)
  108. On ab.IdSalonGrupo = bb.IdSalonGrupo
  109. Where ab.IdDia = 6) as g
  110. On a.IdGrupo = g.IdGrupo
  111. Left Join (Select ab.*,bb.SalonGrupo, row_number() over(partition by IdGrupo order By IdGrupo) as Ren
  112. From movdGrupos ab with (nolock)
  113. Inner Join catcSalonesGrupos bb with (nolock)
  114. On ab.IdSalonGrupo = bb.IdSalonGrupo
  115. Where ab.IdDia = 7) as m
  116. On a.IdGrupo = m.IdGrupo
  117. Where IdInscripcion = @IdInscripcion
  118. And a.IdCicloEscolar = @IdCicloEscolar) as aa
  119. Inner Join catdMateriasPlanesEstudio i
  120. On aa.IdMateriaPlanEstudios = i.IdMateriaPlanEstudios
  121. Inner Join catcMaterias j
  122. On i.IdMateria = j.IdMateria
  123. Left Join catcOpcionesMaterias k
  124. On (aa.IdOpcionMateria = k.IdOpcionMateria )
  125. Inner Join catcTiposGrupos l
  126. On aa.IdTipoGrupo = l.IdTipoGrupo
  127. Order By i.Ciclo, j.Materia
  128. "
  129.  
  130. @resultado = @connection.connection.exec_query(sql_query, :skip_logging)
  131.  
  132. end
  133.  
  134.  
  135. def horario_juan
  136.  
  137. config = Rails.configuration.database_configuration
  138. enviroment = 'sega_' + Rails.env
  139. @connection = ActiveRecord::Base.establish_connection(
  140. :adapter => config[enviroment]['adapter'],
  141. :url => config[enviroment]['url'],
  142. :database => config[enviroment]['database'],
  143. :username => config[enviroment]['username'],
  144. :password => config[enviroment]['password']
  145. )
  146.  
  147. sql_query = ""
  148. end
  149.  
  150. def self.info_matricula_odonto(matricula)
  151. #Alumno.where(Matricula: matricula, IdEstatus: [2, 4, 17])
  152. #Alumno.joins("INNER JOIN catdDetalleCampus on movcInscripciones.iddcampus = catdDetalleCampus.IddCampus INNER JOIN ").where(Matricula: matricula, IdEstatus: [2, 4, 11,17])
  153.  
  154. config = Rails.configuration.database_configuration
  155. enviroment = 'sega_' + Rails.env
  156. @connection = ActiveRecord::Base.establish_connection(
  157. :adapter => config[enviroment]['adapter'],
  158. :url => config[enviroment]['url'],
  159. :database => config[enviroment]['database'],
  160. :username => config[enviroment]['username'],
  161. :password => config[enviroment]['password']
  162. )
  163.  
  164. sql_query = "Select b.nombre+' '+ b.primerapellido +' '+b.Segundoapellido AS Nombre, d.Descripcion AS Estatus,c.DescProgramaEducativo AS 'Programa', c.DescModalidad As Modalidad,
  165. c.campus,
  166. a.IdInscripcion ,a.Matricula
  167. From
  168. movcInscripciones a
  169. INNER JOIN catcPersonas b ON a.idPersona = b.idPersona
  170. INNER JOIN catdDetalleCampus c ON a.iddCampus = c.iddCampus
  171. INNER JOIN catcEstatus d ON a.idEstatus = d.idEstatus
  172. WHERE a.Matricula ="+ matricula +
  173. " AND a.IdEstatus in (2, 4, 11,17)"
  174.  
  175. @resultado = @connection.connection.exec_query(sql_query, :skip_logging)
  176.  
  177. end
  178.  
  179.  
  180. #Método que nos sirve para saber el horario del alumno con su idinscripcion respecto a un ciclo escolar
  181. def self.programas_educativos_x_matricula(matricula)
  182. config = Rails.configuration.database_configuration
  183. enviroment = 'sega_movil_' + Rails.env
  184. @connection = ActiveRecord::Base.establish_connection(
  185. :adapter => config[enviroment]['adapter'],
  186. :url => config[enviroment]['url'],
  187. :database => config[enviroment]['database'],
  188. :username => config[enviroment]['username'],
  189. :password => config[enviroment]['password']
  190. )
  191.  
  192. sentencia_sql = "sp_ConsultasAlumno14 14,#{matricula}"
  193.  
  194. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  195. end
  196.  
  197.  
  198. #Método que nos sirve para saber el horario del alumno con su idinscripcion respecto a un ciclo escolar
  199. def self.horario_x_idInscripcion_idCicloEscolar(idInscripcion,idCicloEscolar)
  200.  
  201. config = Rails.configuration.database_configuration
  202. enviroment = 'sega_movil_' + Rails.env
  203. @connection = ActiveRecord::Base.establish_connection(
  204. :adapter => config[enviroment]['adapter'],
  205. :url => config[enviroment]['url'],
  206. :database => config[enviroment]['database'],
  207. :username => config[enviroment]['username'],
  208. :password => config[enviroment]['password']
  209. )
  210.  
  211. sentencia_sql = "sp_SEGAMovilHorarioAlumno 5,#{idInscripcion},#{idCicloEscolar}"
  212.  
  213. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  214. end
  215.  
  216.  
  217.  
  218. #Método que nos sirve para saber las faltas del alumno con su idinscripcion respecto a un ciclo escolar
  219. def self.faltas_x_idInscripcion_idCicloEscolar(idInscripcion,idCicloEscolar)
  220.  
  221. config = Rails.configuration.database_configuration
  222. enviroment = 'sega_movil_' + Rails.env
  223. @connection = ActiveRecord::Base.establish_connection(
  224. :adapter => config[enviroment]['adapter'],
  225. :url => config[enviroment]['url'],
  226. :database => config[enviroment]['database'],
  227. :username => config[enviroment]['username'],
  228. :password => config[enviroment]['password']
  229. )
  230.  
  231. sentencia_sql = "sp_SEGAMovilHorarioAlumno 6,#{idInscripcion},#{idCicloEscolar}"
  232.  
  233. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  234.  
  235. end
  236.  
  237.  
  238. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  239. def self.titulacion_x_idInscripcion(idInscripcion)
  240. config = Rails.configuration.database_configuration
  241. enviroment = 'sega_movil_' + Rails.env
  242. @connection = ActiveRecord::Base.establish_connection(
  243. :adapter => config[enviroment]['adapter'],
  244. :url => config[enviroment]['url'],
  245. :database => config[enviroment]['database'],
  246. :username => config[enviroment]['username'],
  247. :password => config[enviroment]['password']
  248. )
  249.  
  250. sentencia_sql = "sp_CONTitulaciones 5,#{idInscripcion}"
  251. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  252.  
  253. end
  254.  
  255.  
  256.  
  257. #Método que nos sirve para consultar la fotografia del alumno
  258. def self.fotografia_alumno matricula
  259.  
  260. config = Rails.configuration.database_configuration
  261. enviroment = 'sega_' + Rails.env
  262.  
  263. @connection = ActiveRecord::Base.establish_connection(
  264. :adapter => config[enviroment]['adapter'],
  265. :url => config[enviroment]['url'],
  266. :database => config[enviroment]['database'],
  267. :username => config[enviroment]['username'],
  268. :password => config[enviroment]['password']
  269. )
  270.  
  271.  
  272. #TODO Eliminar esta funcion cuando pasaemos a producción y que esta quede fija en la BD.
  273. =begin
  274. CREATE FUNCTION dbo.f_BinaryToBase64(@bin VARBINARY(MAX))
  275. RETURNS VARCHAR(MAX)
  276. AS
  277. BEGIN
  278. DECLARE @Base64 VARCHAR(MAX)
  279.  
  280. SET @Base64 = CAST(N'' AS XML).value('xs:base64Binary(xs:hexBinary(sql:variable("@bin")))','VARCHAR(MAX)')
  281.  
  282. RETURN @Base64
  283. END
  284. =end
  285.  
  286. sql_query =
  287. "
  288. Declare @matricula As Int
  289. Set @matricula = #{matricula.strip}
  290.  
  291. Select top 1 dbo.f_BinaryToBase64(b.Fotografia) As fotografia
  292. From credenciales..movcCredenciales a
  293. Inner Join credenciales..catdFotografias b
  294. On a.IdFoto = b.IdFoto
  295. where a.clave = @matricula And b.tipo = 'A'
  296. Order by a.IdCredencial desc
  297. "
  298.  
  299. @resultado = @connection.connection.exec_query(sql_query, :skip_logging)
  300.  
  301. end
  302.  
  303.  
  304.  
  305. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  306. def self.kardex_alumno(idInscripcion)
  307. config = Rails.configuration.database_configuration
  308. enviroment = 'sega_movil_' + Rails.env
  309. @connection = ActiveRecord::Base.establish_connection(
  310. :adapter => config[enviroment]['adapter'],
  311. :url => config[enviroment]['url'],
  312. :database => config[enviroment]['database'],
  313. :username => config[enviroment]['username'],
  314. :password => config[enviroment]['password']
  315. )
  316.  
  317. sentencia_sql = " sp_movdKardex9 9,0,#{idInscripcion},0,0,0,0,0,0,'',0,0,'',0,0,'',0,0,'',0,0,'','','','','','',0,0,0,0"
  318. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  319.  
  320. end
  321.  
  322.  
  323. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  324. def self.bloqueo_alumno(matricula)
  325. config = Rails.configuration.database_configuration
  326. enviroment = 'sega_movil_' + Rails.env
  327. @connection = ActiveRecord::Base.establish_connection(
  328. :adapter => config[enviroment]['adapter'],
  329. :url => config[enviroment]['url'],
  330. :database => config[enviroment]['database'],
  331. :username => config[enviroment]['username'],
  332. :password => config[enviroment]['password']
  333. )
  334. sentencia_sql = "sp_CONValidarBloqueoAlumno 3,#{matricula},'',0"
  335. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  336. end
  337.  
  338. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  339. def self.carnet_alumno(matricula)
  340. config = Rails.configuration.database_configuration
  341. enviroment = 'sega_movil_' + Rails.env
  342. @connection = ActiveRecord::Base.establish_connection(
  343. :adapter => config[enviroment]['adapter'],
  344. :url => config[enviroment]['url'],
  345. :database => config[enviroment]['database'],
  346. :username => config[enviroment]['username'],
  347. :password => config[enviroment]['password']
  348. )
  349. sentencia_sql = "sp_CONCarnetCultural #{matricula},1"
  350. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  351. end
  352.  
  353.  
  354.  
  355. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  356. def self.calificaciones_alumno(idInscripcion)
  357. config = Rails.configuration.database_configuration
  358. enviroment = 'sega_codafyr_' + Rails.env
  359. @connection = ActiveRecord::Base.establish_connection(
  360. :adapter => config[enviroment]['adapter'],
  361. :url => config[enviroment]['url'],
  362. :database => config[enviroment]['database'],
  363. :username => config[enviroment]['username'],
  364. :password => config[enviroment]['password']
  365. )
  366. sentencia_sql = " sp_CONConsultaCalificacionesAlumnos #{idInscripcion}"
  367. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  368. end
  369.  
  370.  
  371.  
  372. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  373. def self.informacion_gral_alumno(matricula)
  374. config = Rails.configuration.database_configuration
  375. enviroment = 'sega_' + Rails.env
  376. @connection = ActiveRecord::Base.establish_connection(
  377. :adapter => config[enviroment]['adapter'],
  378. :url => config[enviroment]['url'],
  379. :database => config[enviroment]['database'],
  380. :username => config[enviroment]['username'],
  381. :password => config[enviroment]['password']
  382. )
  383. sentencia_sql =
  384. "
  385. Select c.PrimerApellido,c.SegundoApellido,c.Nombre,c.Genero,a.promedio,b.UnidadAcademica,b.DescProgramaEducativo,b.DescNivelAcademico,b.DescModalidad,b.Campus
  386. From movcInscripciones a
  387. Inner Join catdDetalleCampus b
  388. On a.IddCampus = b.IddCampus
  389. Inner Join catcPersonas c
  390. On a.IdPersona = c.IdPersona
  391. Where a.Matricula = #{matricula.strip}
  392. And a.IdEstatus in (4)
  393. "
  394.  
  395.  
  396.  
  397. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  398. end
  399.  
  400. #Método que nos regresa los datos academicos y los datos personales del alumno por su matricula
  401. def self.datos_academicos_personales_alumno(matricula)
  402. config = Rails.configuration.database_configuration
  403. enviroment = 'sega_' + Rails.env
  404. @connection = ActiveRecord::Base.establish_connection(
  405. :adapter => config[enviroment]['adapter'],
  406. :url => config[enviroment]['url'],
  407. :database => config[enviroment]['database'],
  408. :username => config[enviroment]['username'],
  409. :password => config[enviroment]['password']
  410. )
  411. sentencia_sql = "sp_CONDatosAlumnoBECA 5, #{matricula.strip}"
  412.  
  413. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  414. end
  415.  
  416. def self.datos_documentos_tutorias (matricula)
  417. #sp_movcDocumentosAlumnos 5, 0,[Matricula], 3, 0, '', 0, 0, 0, '', 0, 0, '', '', 0, 0, 0, '', '', '', '', '', '', '', 0
  418. config = Rails.configuration.database_configuration
  419. enviroment = 'sega_' + Rails.env
  420. @connection = ActiveRecord::Base.establish_connection(
  421. :adapter => config[enviroment]['adapter'],
  422. :url => config[enviroment]['url'],
  423. :database => config[enviroment]['database'],
  424. :username => config[enviroment]['username'],
  425. :password => config[enviroment]['password']
  426. )
  427. sentencia_sql = "sp_movcDocumentosAlumnos 5, 0,#{matricula}, 3, 0, '', 0, 0, 0, '', 0, 0, '', '', 0, 0, 0, '', '', '', '', '', '', '', 0"
  428.  
  429. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  430. end
  431.  
  432. def self.datos_academicos_personales_tutorias(matricula)
  433. #sp_TutoriasConsultaDatosEscolares 8,'','',235129, 0,'','',0
  434. config = Rails.configuration.database_configuration
  435. enviroment = 'sega_' + Rails.env
  436. @connection = ActiveRecord::Base.establish_connection(
  437. :adapter => config[enviroment]['adapter'],
  438. :url => config[enviroment]['url'],
  439. :database => config[enviroment]['database'],
  440. :username => config[enviroment]['username'],
  441. :password => config[enviroment]['password']
  442. )
  443. sentencia_sql = "sp_TutoriasConsultaDatosEscolares 8,'','',#{matricula}, 0,'','',0"
  444.  
  445. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  446. end
  447.  
  448. def self.datos_inscripcion_tutorias(id_unidad, matricula)
  449. config = Rails.configuration.database_configuration
  450. enviroment = 'sega_' + Rails.env
  451. @connection = ActiveRecord::Base.establish_connection(
  452. :adapter => config[enviroment]['adapter'],
  453. :url => config[enviroment]['url'],
  454. :database => config[enviroment]['database'],
  455. :username => config[enviroment]['username'],
  456. :password => config[enviroment]['password']
  457. )
  458. sentencia_sql = "sp_TutoriasConsultaDatosEscolares 11,#{id_unidad},'',#{matricula}, 0,'','',0"
  459.  
  460. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  461. end
  462.  
  463. def self.datos_calificaciones_alumno_tutorias(id_inscripcion)
  464. config = Rails.configuration.database_configuration
  465. enviroment = 'sega_' + Rails.env
  466. @connection = ActiveRecord::Base.establish_connection(
  467. :adapter => config[enviroment]['adapter'],
  468. :url => config[enviroment]['url'],
  469. :database => config[enviroment]['database'],
  470. :username => config[enviroment]['username'],
  471. :password => config[enviroment]['password']
  472. )
  473. sentencia_sql = "sp_CONConsultaCalificacionesAlumnos #{id_inscripcion}"
  474.  
  475. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  476. end
  477.  
  478. def self.datos_faltas_alumno_tutorias(id_inscripcion)
  479. config = Rails.configuration.database_configuration
  480. enviroment = 'sega_' + Rails.env
  481. @connection = ActiveRecord::Base.establish_connection(
  482. :adapter => config[enviroment]['adapter'],
  483. :url => config[enviroment]['url'],
  484. :database => config[enviroment]['database'],
  485. :username => config[enviroment]['username'],
  486. :password => config[enviroment]['password']
  487. )
  488. sentencia_sql = "sp_CONFaltasEvaluacion #{id_inscripcion}"
  489.  
  490. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  491. end
  492.  
  493. def self.datos_horario_alumno_tutorias (id_inscripcion, id_ciclo_escolar)
  494. #sp_movcInscripcionesAnexo6 8,[IdInscripcion], 0, 0, 0, 0, 0, 0, 0, 0,[IdCicloEscolar], '', '', '', 0, 0, 0, '', '', '', '', '', '', 0, '', 0, '', 0, '', 0, 0
  495. config = Rails.configuration.database_configuration
  496. enviroment = 'sega_' + Rails.env
  497. @connection = ActiveRecord::Base.establish_connection(
  498. :adapter => config[enviroment]['adapter'],
  499. :url => config[enviroment]['url'],
  500. :database => config[enviroment]['database'],
  501. :username => config[enviroment]['username'],
  502. :password => config[enviroment]['password']
  503. )
  504. sentencia_sql = "sp_movcInscripcionesAnexo6 8,#{id_inscripcion}, 0, 0, 0, 0, 0, 0, 0, 0,#{id_ciclo_escolar}, '', '', '', 0, 0, 0, '', '', '', '', '', '', 0, '', 0, '', 0, '', 0, 0"
  505.  
  506. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  507. end
  508.  
  509. def self.datos_horario_examenes_tutorias(id_inscripcion)
  510. config = Rails.configuration.database_configuration
  511. enviroment = 'sega_' + Rails.env
  512. @connection = ActiveRecord::Base.establish_connection(
  513. :adapter => config[enviroment]['adapter'],
  514. :url => config[enviroment]['url'],
  515. :database => config[enviroment]['database'],
  516. :username => config[enviroment]['username'],
  517. :password => config[enviroment]['password']
  518. )
  519. sentencia_sql = "sp_CONHorarioEvaluacionesAlumno #{id_inscripcion}"
  520.  
  521. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  522. end
  523.  
  524. def self.datos_carnet_salud_tutorias (matricula, id_facultad, id_programa_edicativo)
  525. #sp_catcCarnetAlumnos 6, 0,[Matricula],'[Facultad]','[IdProgramaEducativo]','','',0,'','','','',''
  526. config = Rails.configuration.database_configuration
  527. enviroment = 'sega_' + Rails.env
  528. @connection = ActiveRecord::Base.establish_connection(
  529. :adapter => config[enviroment]['adapter'],
  530. :url => config[enviroment]['url'],
  531. :database => config[enviroment]['database'],
  532. :username => config[enviroment]['username'],
  533. :password => config[enviroment]['password']
  534. )
  535. sentencia_sql = "sp_catcCarnetAlumnos 6, 0, #{matricula}, '#{id_facultad}', #{id_programa_edicativo}','','',0,'','','','',''"
  536.  
  537. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  538. end
  539.  
  540. def self.datos_kardex_tutorias (id_inscripcion)
  541. #sp_movdKardex 9, 0,[IdInscripcion], 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', '', '', '', '', 0, 0, 0, 0, '', 0
  542. config = Rails.configuration.database_configuration
  543. enviroment = 'sega_' + Rails.env
  544. @connection = ActiveRecord::Base.establish_connection(
  545. :adapter => config[enviroment]['adapter'],
  546. :url => config[enviroment]['url'],
  547. :database => config[enviroment]['database'],
  548. :username => config[enviroment]['username'],
  549. :password => config[enviroment]['password']
  550. )
  551. sentencia_sql = "sp_movdKardex 9, 0,#{id_inscripcion}, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', 0, 0, '', '', '', '', '', 0, 0, 0, 0, '', 0"
  552.  
  553. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  554. end
  555.  
  556. def self.datos_ceneval_globales_tutorias (matricula, id_facultad)
  557. #sp_TutoriasConsultaDatosEscolares 15,'[Facultad]','',[Matricula], 0,'','',0
  558.  
  559. config = Rails.configuration.database_configuration
  560. enviroment = 'sega_' + Rails.env
  561. @connection = ActiveRecord::Base.establish_connection(
  562. :adapter => config[enviroment]['adapter'],
  563. :url => config[enviroment]['url'],
  564. :database => config[enviroment]['database'],
  565. :username => config[enviroment]['username'],
  566. :password => config[enviroment]['password']
  567. )
  568. sentencia_sql = "sp_TutoriasConsultaDatosEscolares 15,'#{id_facultad}','',#{matricula}, 0,'','',0"
  569.  
  570. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  571. end
  572.  
  573. def self.datos_ceneval_modulos_tutorias (matricula, id_facultad)
  574. #sp_TutoriasConsultaDatosEscolares 15,'[Facultad]','',[Matricula], 0,'','',0
  575.  
  576. config = Rails.configuration.database_configuration
  577. enviroment = 'sega_' + Rails.env
  578. @connection = ActiveRecord::Base.establish_connection(
  579. :adapter => config[enviroment]['adapter'],
  580. :url => config[enviroment]['url'],
  581. :database => config[enviroment]['database'],
  582. :username => config[enviroment]['username'],
  583. :password => config[enviroment]['password']
  584. )
  585. sentencia_sql = "sp_TutoriasConsultaDatosEscolares 16,'#{id_facultad}','',#{matricula}, 0,'','',0"
  586.  
  587. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  588. end
  589.  
  590.  
  591. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  592. def self.informacion_gral_alumno_codafyr(matricula)
  593. config = Rails.configuration.database_configuration
  594. enviroment = 'sega_' + Rails.env
  595. @connection = ActiveRecord::Base.establish_connection(
  596. :adapter => config[enviroment]['adapter'],
  597. :url => config[enviroment]['url'],
  598. :database => config[enviroment]['database'],
  599. :username => config[enviroment]['username'],
  600. :password => config[enviroment]['password']
  601. )
  602. sentencia_sql =
  603. "
  604. Select c.PrimerApellido,c.SegundoApellido,c.Nombre,c.Genero,c.FechaNacimiento,c.Curp,c.RFC,c.Calle +' '+ c.NumeroExterior+' Col. '+ c.Colonia As Direccion,c.CodigoPostal,c.Telefono,
  605. c.Celular,d.descripcion As Nacionalidad,g.descripcion as Estado, f.descripcion as Municipio,
  606. a.promedio,b.UnidadAcademica,b.DescProgramaEducativo,b.DescNivelAcademico,b.DescModalidad,b.Campus
  607. From movcInscripciones a
  608. Inner Join catdDetalleCampus b
  609. On a.IddCampus = b.IddCampus
  610. Inner Join catcPersonas c
  611. On a.IdPersona = c.IdPersona
  612. Inner Join catcNacionalidades d
  613. On c.IdNacionalidad = d.IdNacionalidad
  614. Inner Join catcLocalidades e
  615. On c.IdLocalidad = e.IdLocalidad
  616. Inner Join catcMunicipios f
  617. On e.IdMunicipio = f.IdMunicipio
  618. Inner Join catcEstados g
  619. On f.IdEstado = g.IdEstado
  620. Where a.Matricula = #{matricula.strip}
  621. "
  622.  
  623.  
  624.  
  625. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  626. end
  627.  
  628.  
  629. #Método que nos sirve para conocer el estatus de la titulación de los alumnos por idInscripcion
  630. def self.faltas_alumno_codafyr(idInscripcion)
  631. config = Rails.configuration.database_configuration
  632. enviroment = 'sega_codafyr_' + Rails.env
  633. @connection = ActiveRecord::Base.establish_connection(
  634. :adapter => config[enviroment]['adapter'],
  635. :url => config[enviroment]['url'],
  636. :database => config[enviroment]['database'],
  637. :username => config[enviroment]['username'],
  638. :password => config[enviroment]['password']
  639. )
  640. sentencia_sql = " sp_CONFaltasMes #{idInscripcion}"
  641.  
  642. p sentencia_sql.inspect
  643.  
  644. @resultado = @connection.connection.exec_query(sentencia_sql, :skip_logging)
  645. end
  646.  
  647.  
  648.  
  649.  
  650.  
  651. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement