Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from flask import Flask,flash
from core import app
from sqlalchemy.sql import and_, or_
from sqlalchemy import asc, desc
engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
engine_conf = create_engine(app.config['DATABASE_URI_CONF'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class BOReportModel():
def __init__(self):
try:
self.meta = MetaData()
self.users = Table("users", self.meta, autoload_with=engine)
except Exception as e:
print("table not found",e)
# ramya wet lab and dey lab report updated on 2023-07-06 10:22:00
def get_addons_course(self,conf_id):
with engine.connect() as conn:
if conf_id == 28 :
where_con = " group by a.display_name order by a.display_name asc"
elif conf_id == 17 :
where_con = " "
else :
where_con = " "
stmt = text ("select ut.user_type,a.*,ats.addon_type from addons a "
+" left join addon_types ats on FIND_IN_SET("+ str(conf_id)+",ats.show_conf_ids) and ats.addon_type_id = a.addon_type_id "
+" left join numerotech_primary_db.user_types ut on ut.user_type_id = a.user_type_id "
+" where a.is_visible = 1 and a.conference_id = "+ str(conf_id)+" and a.addon_type_id not in (1) "+str(where_con)+"; ");
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
if results :
return results
else:
return None
def get_addontype_for_course(self,conf_id):
with engine.connect() as conn:
stmt = text("select group_concat(addon_type_id) as addon_type_ids from addon_types where FIND_IN_SET("+str(conf_id)+",show_conf_ids) and addon_type_id not in (1);")
results = conn.execute(stmt).one_or_none()
if results :
return dict(results._mapping)
else:
return None
def get_datas_by_addon_ids(self,addon_ids,addon_type_id,conf_id):
with engine.connect() as conn:
if addon_ids :
if conf_id == 17 :
where_con = " and a.addon_id in ("+addon_ids+") group by a.addon_id order by a.addon_id asc ;"
elif conf_id == 28 :
where_con = " and a.display_name in ('"+addon_ids+"') group by a.display_name order by a.display_name asc ;"
else :
where_con = " "
else :
if conf_id == 17 :
where_con = " group by a.addon_id order by a.addon_id asc ;"
elif conf_id == 28 :
where_con = " group by a.display_name order by a.display_name asc ;"
else :
where_con = " "
stmt = text("select a.addon_id,a.display_name,a.head_count,count(d.delegate_id)as delegate_count,ats.addon_type "
+" from numerotech_primary_db.delegates d"
+" inner join numerotech_primary_db.delegates_addons da on da.delegate_id = d.delegate_id"
+" inner join numerotech_primary_db.addons a on a.addon_id = da.addon_id"
+" inner join numerotech_primary_db.addon_types ats on ats.addon_type_id = a.addon_type_id"
+" where d.conference_id ="+str(conf_id)+" and da.reg_status in (2,3) and delegate_no is not null"
+" and a.addon_type_id in("+addon_type_id+") "+str(where_con)+" ")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
if results :
return results
else:
return None
def boreport_get_registered_delegate_data(self,conf_id,addon_type_id,addon_id,is_export_selected_course):
with engine.connect() as conn:
if addon_id :
if is_export_selected_course == 1 :
add_col = " ,group_concat(a.display_name separator ' , ' ) as addon_names"
if conf_id == 17:
where_con = " and a.addon_id in ( "+addon_id+" ) group by d.delegate_no"
elif conf_id == 28 :
where_con = " and a.display_name in ('"+addon_id+"') group by d.delegate_no"
else :
where_con = " "
else:
add_col = " ,a.display_name as addon_names"
if conf_id == 28:
where_con = " and a.display_name in ('"+addon_id+"') "
elif conf_id == 17:
where_con = " and a.addon_id in ( "+addon_id+" ) "
else :
where_con = " "
else :
add_col = " ,group_concat(a.display_name separator ' , ' ) as addon_names"
where_con = " group by d.delegate_no"
stmt = text("select d.conference_id,d.delegate_id,d.delegate_no,concat(ifnull(concat(d.prefix,' '),''),d.full_name) as full_name,d.email,"
+" d.mobile,da.amount,date_format(up.paid_at, '%d-%m-%Y %H:%i:%s') as paid_at,up.api_payment_id,"
+" concat(ifnull(up.payment_method_from_gateway,''),case when up.payment_method_from_gateway is null then up.payment_method else concat(' - ',up.payment_method) end) as payment_method,"
+" ats.addon_type,da.reg_status,a.day,ut.user_type ,up.utr_number "+str(add_col)+" "
+" from numerotech_primary_db.delegates d inner join numerotech_primary_db.delegates_addons da on da.delegate_id = d.delegate_id"
+" inner join numerotech_primary_db.addons a on a.addon_id = da.addon_id"
+" inner join numerotech_primary_db.addon_types ats on ats.addon_type_id = a.addon_type_id"
+" inner join numerotech_primary_db.user_payment up on up.unique_id = da.unique_id"
+" inner join numerotech_primary_db.user_types ut on ut.user_type_id= a.user_type_id"
+" where a.conference_id = "+str(conf_id)+" and a.addon_type_id in ("+addon_type_id+") and da.reg_status in (2,3) "+str(where_con)+" ;")
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
if results :
return results
else:
return None
def get_course_detail(self,conf_id,addon_id):
with engine.connect() as conn:
if conf_id == 17 :
where_con = " and a.addon_id = "+str(addon_id)+" "
elif conf_id == 28 :
where_con = " and a.display_name in ('"+addon_id+"') "
else :
where_con = " "
stmt = text("select a.*,ats.addon_type from addons a inner join addon_types ats on ats.addon_type_id = a.addon_type_id "
+" where a.conference_id = "+str(conf_id)+" "+ str(where_con)+" ; ")
results = conn.execute(stmt).one_or_none()
if results :
return dict(results._mapping)
else:
return None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists