Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from core import app
import json
from .. import engine
# engine = create_engine(app.config['DATABASE_URI'])
# engine = create_engine(app.config['DATABASE_URI'],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)
self.states = Table("states", self.meta, autoload_with=engine)
self.conference = Table("conference", self.meta, autoload_with=engine)
self.del_user_logs = Table("del_user_logs", self.meta, autoload_with=engine)
self.user_payment = Table("user_payment", self.meta, autoload_with=engine)
self.user_types = Table("user_types", self.meta, autoload_with=engine)
self.m_payment_type = Table("m_payment_type", self.meta, autoload_with=engine)
self.logs = Table("logs", self.meta, autoload_with=engine)
self.delegates = Table("delegates", self.meta, autoload_with=engine)
self.delegates_addons = Table("delegates_addons", self.meta, autoload_with=engine)
self.admin_logs = Table("admin_logs", self.meta, autoload_with=engine)
self.trigger_daily_reports_mails = Table("trigger_daily_reports_mails", self.meta, autoload_with=engine)
self.export_filter_cols = Table("export_filter_cols", self.meta, autoload_with=engine)
self.badge_role = Table("badge_role", self.meta, autoload_with=engine)
self.society_applications = Table("society_applications", self.meta, autoload_with=engine)
self.delegate_user_logs = Table("delegate_user_logs", self.meta, autoload_with=engine)
self.delegate_attachments = Table("delegate_attachments", self.meta, autoload_with=engine)
self.reg_remark = Table("reg_remark", self.meta, autoload_with=engine)
except Exception as e:
print("table not found",e)
def get_export_columns(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from export_filter_cols where FIND_IN_SET ("+str(conf_id)+",conf_ids) and is_visible =1 and is_del =1 and orderby is not null order by orderby asc;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_select_columns(self,export_columns,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select * from export_filter_cols where FIND_IN_SET ("+str(conf_id)+",conf_ids) and is_visible =1 and is_del =1 and cols_value_name in ("+str(export_columns)+") and orderby is not null order by FIELD(cols_value_name,"+str(export_columns)+");")
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_walkathon_data(self,conf_id):
with engine.connect() as conn:
stmt=text("select d.delegate_no,concat(d.prefix ,' ' ,d.full_name) as full_name,d.email,d.mobile,d.gender,d.membership_no,ut.user_type,d.mc_number, d.city,s.state_name,d.mc_number ,d.delegate_remarks,up.api_payment_id,up.payment_id,up.payment_method as pay_method,up.payment_for,up.amount,up.status,up.paid_at,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 from delegates d left join delegates_addons da on da.delegate_id = d.delegate_id left join addons a on a.addon_id = da.addon_id left join addon_types atype on atype.addon_type_id = a.addon_type_id left join users u on u.user_id = d.parent_user_id left join states s on s.state_id = d.state_id left join states mc on mc.state_id = d.mc_state_id left join user_types ut on ut.user_type_id = a.user_type_id inner join conference c on c.conf_id = d.conference_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 left join user_payment up on up.unique_id = da.unique_id where d.is_take_part_bpw = 1 and d.delegate_no is not null and d.conference_id = "+str(conf_id)+" and a.addon_type_id = 1 order by d.delegate_no asc ;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def bo_get_numerotec_team_members(self):
with engine.connect() as conn:
stmt =text("select * from numerotec_team_members where is_delegate = 1;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_conference_is_active(self):
with engine.connect() as conn:
stmt = text ("select conf_id,conf_key,conf_title,conf_name,mail_header_logo from conference where reg_end_on >= (select convert_tz(utc_timestamp() ,'+00:00','+05:30')) and is_active order by conf_key asc;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_addons_by_enddate(self,next_day,conf_id):
with engine.connect() as conn:
stmt = text("select * from addons where '"+ next_day+ "' between start_by and end_by and conference_id = "+str(conf_id)+" ;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_conference_by_enddate(self,next_day,conf_id):
with engine.connect() as conn:
stmt = text("select * from conference where '"+ next_day+ "' between reg_start_on and reg_end_on and conf_id = "+str(conf_id)+";")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def usp_webdry_lab_report(self,conf_id,wet_reg_type,dry_reg_type):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_webdry_lab_report",[conf_id,wet_reg_type,dry_reg_type])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
def get_wetdry_data(self,conf_id):
with engine.connect() as conn:
stmt = text ("select * from addons where is_visible = 1 and conference_id = "+str(conf_id)+" and addon_type_id in (2,5) group by reg_type;");
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# June
def uspWaitingPaymentProofApproval(self,conf_id,payment_type):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_waiting_for_pg_proof_approval",[conf_id,payment_type])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
# ramya wet lab and dey lab report updated on 2023-07-06 10:22:00
def get_addons_wetdrylab(self,conf_id):
with engine.connect() as conn:
stmt = text ("select a.*,ats.addon_type,concat(ifnull(display_name,'') ,' - ', ifnull(day,'') ,' ( ', ifnull(start_time,'') ,' - ', ifnull(end_time,'') ,' )' ) as addon_display_name from addons a inner join addon_types ats on ats.addon_type_id = a.addon_type_id where a.is_visible = 1 and a.conference_id = "+str(conf_id)+" and a.addon_type_id in (2,5,24,3);");
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_datas_by_addon_ids(self,addon_ids,conf_id):
with engine.connect() as conn:
if addon_ids :
where_con = " and a.addon_id in ("+addon_ids+") group by a.addon_id order by ats.addon_type DESC,a.addon_name ,a.day,a.addon_id ;"
else :
where_con = " group by a.addon_id order by ats.addon_type DESC,a.addon_name ,a.day,a.addon_id ;"
stmt = text("select a.addon_id,a.display_name,a.head_count,count(da.delegate_id)as delegate_count,ats.addon_type,a.day,a.start_time,a.end_time "
+" from numerotech_primary_db.addons a"
+" left join numerotech_primary_db.delegates_addons da on a.addon_id = da.addon_id and da.reg_status in (2,3)"
+" left join numerotech_primary_db.addon_types ats on ats.addon_type_id = a.addon_type_id"
# +" where a.is_visible = 1 and a.conference_id ="+str(conf_id)+" and a.addon_type_id in(2,5) "+str(where_con)+" "
+" where a.is_visible = 1 and a.conference_id ="+str(conf_id)+" and ats.addon_type_id not in (1) and ats.show_conf_ids like '%"+str(conf_id)+"%'" +str(where_con)+" "
+" ")
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def boreport_get_registered_delegate_data(self,conf_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 ,' - ', a.day,' - (',a.start_time,' - ' ,a.end_time,')' separator ' , ' ) as addon_names"
where_con = " and a.addon_id in ( "+addon_id+" ) group by d.delegate_no"
else:
add_col = " ,group_concat(a.display_name ,' - ', a.day,' - (',a.start_time,' - ' ,a.end_time,')' separator ' , ' ) as addon_names"
where_con = " and a.addon_id in ( "+addon_id+" ) "
else :
add_col = " ,group_concat(a.display_name ,' - ', a.day,' - (',a.start_time,' - ' ,a.end_time,')' separator ' , ' ) as addon_names"
where_con = " group by d.delegate_no"
stmt = text("select 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 (2,5) and da.reg_status in (2,3) "+str(where_con)+" ;")
+" where a.conference_id = "+str(conf_id)+" and ats.addon_type_id not in (1) and ats.show_conf_ids like '%"+str(conf_id)+"%' and da.reg_status in (2,3) "+str(where_con)+" ;")
result = conn.execute(stmt).all()
print(stmt)
return [dict(r._mapping) for r in result] if result else None
def get_course_detail(self,conf_id,addon_id):
with engine.connect() as conn:
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)+" and a.addon_id = "+str(addon_id)+" ; ")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def get_datas_by_labs_addon_ids(self,delegate_nos,to,from_date,search,addon_ids):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_moscon23_labs_reports",[(delegate_nos or None),(to or None),(from_date or None),(search or None),(addon_ids or None)])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
# common workshop details get
def get_labs_details(self,conf_id):
with engine.connect() as conn:
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.is_visible = 1 and a.conference_id = "+str(conf_id)+" and a.addon_type_id not in (1);");
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_labs_count_details(self):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_moscon23_labs_count_reports")
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.close()
return sets
def get_payment_report_data(self,conf_id):
with engine.connect() as conn:
stmt = text ("select up.payment_method,count(*) as reg_count,sum(da.amount) as total_amount from delegates d "
+"inner join delegates_addons da on da.delegate_id = d.delegate_id "
+"inner join user_payment up on up.unique_id = da.unique_id "
+"where d.conference_id = "+str(conf_id)+" and (d.delegate_no is not null or d.ref_no is not null) and up.status = 'success' and da.reg_status = 2 "
+"group by up.payment_method ;");
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def Complete_pg_bonafide_deteils(self,conf_id,payment_type):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_waiting_for_pg_proof_approval_complete",[conf_id,payment_type])
if cursor.description :
columns = [column[0] for column in cursor.description]
results_1 = []
for row in cursor.fetchall():
results_1.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results_1
else:
cursor.close()
connection.commit()
return None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists