12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- from connect import connection
- import sqlalchemy as db
-
- def visitas():
- query ='SELECT t1.id, t2.nombres e_nombre, t2.apellidos e_apellido,\
- t1.nombres p_nombre, t1.apellidos p_apellido, t1.razon, t1.acciones, t1.fecha\
- FROM (SELECT v.id, u.nombres, u.apellidos,v.razon, v.acciones, v.fecha\
- FROM visitas_enfermeria v, usuarios u\
- WHERE v.estudiante_id = u.id) t1,\
- (SELECT v.id, u.nombres, u.apellidos\
- FROM visitas_enfermeria v, usuarios u\
- WHERE v.enfermera_id = u.id) t2\
- WHERE t1.id=t2.id'
- result_db = connection.execute(query).fetchall()
-
- ###### headers
-
- headers = '['
- headers += '{"nombre":"Dia y hora"}'
- headers += ','
- headers += '{"nombre":"Nombre Estudiante"}'
- headers += ','
- headers += '{"nombre":"Razon"}'
- headers += ','
- headers += '{"nombre":"Informacion"}'
- headers += ','
- headers += '{"nombre":"Editar"}'
- headers += ']'
-
- ###### tabla
-
- modal_content = '['
- tabla = '['
- i = 0
- len_result = len(result_db)
- for q in result_db:
- i = i+1
- tabla += '{'
- modal_content += '{'
- tabla += '"Dia y hora":"'+str(q[7])+'"'
- modal_content += '"Nombre Enfermera":"'+(q[1])+' '+(q[2])+'"'
- tabla += ','
- modal_content += ','
- tabla += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
- modal_content += '"Nombre Estudiante":"'+(q[3])+' '+(q[4])+'"'
- tabla += ','
- modal_content += ','
-
- tabla += '"Razon":"'+(q[5])+'"'
- modal_content += '"Razon":"'+(q[5])+'"'
- modal_content += ','
- modal_content += '"Explicación":"'+(q[6])+'"'
- modal_content += ','
- modal_content += '"Dia y hora":"'+str(q[7])+'"'
-
-
- tabla += ','
- modal_content += ','
- tabla += '"user_id":"'+str(q[0])+'"'
- modal_content += '"user_id":"'+str(q[0])+'"'
- tabla += '}'
- modal_content += '}'
- if i < len_result:
- tabla += ','
- modal_content+= ','
- tabla += ']'
- modal_content += ']'
-
- ###### info
-
- info = '{'
- info += '"dash_name":"Enfermeria- Manejar Visitas"'
- info += ','
- info += '"dash_link":"/enfermeria/ver/"'
- info += ','
- info += '"dash_sub_name":"Visitas hechas"'
- info += ','
- info += '"add":"Anadir Visita"'
- info += ','
- info += '"add_link":"/enfermeria/forma/add/visitas_enfermeria/"'
- info += ','
- info += '"dir1":"#"'
- info += ','
- info += '"dir2":"/enfermeria/forma/edit/visitas_enfermeria/"'
- info += '}'
-
- ###### modal
- modal = '{'
- modal += '"infoName":"Ver informacion"'
- modal += ','
- modal += '"editName":"#"'
- modal += '}'
-
- result = '{"headers":'+headers+',"tabla":'+tabla+',"modal_content":'+modal_content+',"info":'+info+',"modal":'+modal+'}'
-
- # print(result)
- return(result)
|