Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from sqlalchemy import text
from core import app
import json
from .. import engine,engine_conf_db,engine_fk_db
import sqlite3
import pandas as pd
# engine = create_engine(app.config['DATABASE_URI'])
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class BOModel():
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.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)
self.mail_logs = Table("mail_logs", self.meta, autoload_with=engine)
except Exception as e:
print("table not found",e)
def get_bo_users_uuid(self,user_uuid,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 inner join m_member_type m on m.member_type_id = u.member_type_id where u.user_uuid = '"+user_uuid+"' and c.society_id = "+str(society_id)+" and c.conf_id = "+str(conf_id)+" limit 1;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def save_delegate_report_sendmail(self,stmt_1):
with engine.connect() as conn:
result = conn.execute(text(stmt_1))
conn.commit()
return result
def insert_back_offie_login_logs(self,data):
with engine.connect() as conn:
result = conn.execute(self.admin_logs.insert(), data)
conn.commit()
return result.lastrowid
# def get_payment_types(self,conf_id):
# with engine.connect() as conn:
# stmt = text ("select * from m_payment_type where is_delegate = 1 and conf_id= "+str(conf_id)+" and is_bo_visible = 1 and is_visible =1;");
# result = conn.execute(stmt).all()
# return [dict(r._mapping) for r in result] if result else None
def get_payment_types(self,conf_id):
with engine.connect() as conn:
stmt = text ("select distinct payment_type,order_by from ("
+" select distinct payment_type,order_by from m_payment_type where conf_id = "+str(conf_id)+" and is_delegate = 1 and is_bo_visible = 1 and is_visible =1"
+" union all"
+" select distinct payment_method as payment_type,NULL as order_by from user_payment where conf_id = "+str(conf_id)+" and app_type = 'DELEGATE' and payment_method is not null group by payment_method"
+" ) as t order by isnull(order_by),order_by;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_daily_count_send_mail(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text ("select r.report_id,r.conf_id,r.full_name,r.email,r.mobile,c.conf_name,c.e_support_email,c.reg_start_on,c.reg_end_on from trigger_daily_reports_mails r left join conference c on c.conf_id = r.conf_id inner join society_applications sa on c.conf_id = sa.conf_id where c.conf_id ="+str(conf_id)+" and c.conf_key='"+str(conf_key)+"' and r.is_active > 0 and r.email is not null and r.is_del = 1 and sa.app_type_id = 2 and is_separate_mail = 1 order by report_id asc ;");
result = conn.execute(stmt)
return [dict(r._mapping) for r in result] if result else None
def GetRegDataForMail(self,previous_date,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_reg_report_v1",[previous_date,conf_id])
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 update_refund_data(self,unique_id,refund_date,refund_amount,refund_txn_id,payment_id,remarks,addon_ids,delegate_id,current_date):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_update_refund_amount",[unique_id or None,refund_date or None,refund_amount or None,refund_txn_id or None,payment_id or None,remarks or None,addon_ids or None,delegate_id or None,current_date])
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 edit_remarks(self,payment_id,remarks):
with engine.connect() as conn:
stmt = text("Update user_payment set remarks = '"+remarks+"' where payment_id = "+str(payment_id)+" ;")
result = conn.execute(stmt)
conn.commit()
return "updated"
def delegate_no_generate(self,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_completed_payment_res_and_gen_del_no_v2",[unique_id,conf_id])
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:
return None
def BOdelegate_no_generate(self,unique_id,conf_id,role): # Ganesan anna code
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_completed_payment_res_and_gen_del_no_v4",[unique_id,conf_id,role])
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 BOreceipt_no_generate_and_get(self,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_receipt_no_generate_and_get_payment_details_v2",[unique_id,conf_id])
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_conf(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select c.*,sa.* from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id where c.conf_id ="+str(conf_id)+" and c.conf_key='"+conf_key+"' and sa.app_type_id = 2 ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
# Added Status id
def update_delegate(self,delegate_id,data,delegate_no,conf_id):
with engine.connect() as conn:
stmt = self.delegates.update().where(self.delegates.c.delegate_id.in_([delegate_id])).values(data)
result = conn.execute(stmt)
conn.commit()
if delegate_no:
stmt1 = text("select d.user_id,d.conference_id,d.delegate_no,d.role,d.prefix,d.full_name,d.email,d.mobile,d.city,s.state_name,d.membership_no from delegates d left join states s on s.state_id = d.state_id where d.delegate_no ="+delegate_no+" and d.del_status_id = 2 and d.conference_id = "+conf_id+" ;")
else:
stmt1 = text("select d.user_id,d.conference_id,d.delegate_no,d.role,d.prefix,d.full_name,d.email,d.mobile,d.city,s.state_name,d.membership_no from delegates d left join states s on s.state_id = d.state_id where d.conference_id = "+conf_id+";")
res = conn.execute(stmt1).all()
return [dict(r._mapping) for r in res] if res else None
def BOgetDataforPayments(self,unique_id,conf_id): # Function name modified by Ganesan on Dec 12,2022
# print("BOgetDataforPayments")
with engine.connect() as conn:
stmt = text("select up.full_name ,up.email,up.mobile,up.amount,up.am_id,up.is_test,up.payment_for,up.unique_id,up.delegate_ids,d.role,b.range_1 from user_payment up "
+" inner join delegates_addons da on da.unique_id = up.unique_id "
+ " inner join delegates d on d.delegate_id = da.delegate_id "
+ " left join badge_role b on b.b_role = d.role and b.conf_id = "+str(conf_id)+" "
+ " where up.unique_id = '"+unique_id+"' ;")
# print(stmt)
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# Added Status id
def updatePayment(self,unique_id,data,dt_string):
with engine.connect() as conn:
conn = engine.connect()
if unique_id and "null" not in unique_id :
stmt = self.user_payment.update().where(self.user_payment.c.unique_id.in_([unique_id])).values(data)
result = conn.execute(stmt)
conn.commit()
stmt2 = text("update delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id inner join user_payment up on up.unique_id COLLATE utf8mb4_general_ci = da.unique_id set d.del_status_id =2 ,d.registered_on ='"+str(dt_string)+"' where da.unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt2)
conn.commit()
return "updated"
else :
return "Unique id missing"
def get_addon_reg_type(self,conf_id):
with engine.connect() as conn:
stmt = text("SELECT * FROM addon_types where is_visible =1 and find_in_set("+str(conf_id)+",show_conf_ids);")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_addonsBOModel(self,delegate_id,curr_dt,conf_id,user_type_ids = None,is_custom_addons = None):
with engine.connect() as conn:
user_type_where_con = "";
if user_type_ids:
user_type_where_con += " and (a.user_type_id in ("+user_type_ids+") or a.user_type_id is null )"
if is_custom_addons is None:
user_type_where_con += " and (a.is_custom_addon is null or a.is_custom_addon = 0 ) "
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+ str(delegate_id)+" "
+" left join addon_types ats on ats.addon_type_id = a.addon_type_id "
+" where ats.is_visible=1 AND '"+curr_dt+"' between a.start_by and a.end_by "
+" and a.conference_id ="+str(conf_id)+" "
+ user_type_where_con
+" order by a.order_by;")
conn = engine.connect()
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# Added Status id
def check_delegate_addons(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt = text("select d.*,group_concat(ats.addon_type_id)as addon_type_ids,group_concat(a.addon_id)as addon_ids from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_id inner join addons a on a.addon_id = da.addon_id inner join addon_types ats on ats.addon_type_id = a.addon_type_id where d.conference_id = "+str(conf_id)+" and d.delegate_id = "+str(delegate_id)+" and da.reg_status in (2,3) and d.del_status_id in (2);")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def get_addon_reg_type_for_modal(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt = text("select ats.*,addons_count,addon_ids from addon_types ats left join (select a.addon_type_id,count(da.addon_id) as addons_count,group_concat(a.addon_id) as addon_ids from delegates_addons da left join addons a on a.addon_id = da.addon_id where a.conference_id = "+str(conf_id)+" and da.delegate_id = "+str(delegate_id)+" and da.reg_status = 2 group by a.addon_type_id) as t on t.addon_type_id = ats.addon_type_id where ats.is_visible=1 and FIND_IN_SET("+str(conf_id)+",ats.show_conf_ids);")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# Doubt
def get_addons_pendings(self,delegate_id,curr_dt,conf_id,addon_ids):
with engine.connect() as conn:
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+str(delegate_id)+" "
+" where a.is_visible=1 AND '"+str(curr_dt)+"' between a.start_by and a.end_by"
+" and a.conference_id ="+str(conf_id)+" and a.addon_id not in( "+str(addon_ids)+" )and a.addon_type_id not in(1)"
+" order by a.addon_id;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_users_value(self,user_id):
with engine.connect() as conn:
stmt = text("select * FROM users where user_id = '"+user_id+"' ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else 0
def usp_del_get_delegates_by_delegate_id(self,delegate_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_delegates_by_delegate_id",[delegate_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
def insert_delegate(self,data):
with engine.connect() as conn:
result = conn.execute(self.delegates.insert(), data)
conn.commit()
return result.lastrowid
def get_selected_users(self,search_input):
with engine.connect() as conn:
stmt1 = text("SELECT * FROM users where user_id = "+"'"+search_input+"'"+" ;")
result = conn.execute(stmt1).all()
return [dict(r._mapping) for r in result] if result else None
def delete_delegate(self,delegate_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_delete_delegates",[delegate_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
return None
# left join addons a on a.addon_id = da.addon_id
""" insert or delete delegates_addons """
def save_delegates_addons(self,delegate_id,inser_dal_addon,delete_del_addon,now):
sql_insert = ""
sql_delete = ""
with engine.connect() as conn:
for d in inser_dal_addon:
sql_insert = " insert into delegates_addons (delegate_id,addon_id,amount,original_amount,reg_status,created_at) values ({},{},{},{},{},'{}');".format(delegate_id,d['addon_id'],d['amount'],d['original_amount'],d['reg_status'],now)
if sql_insert:
insert_stmt = text(sql_insert)
result = conn.execute(insert_stmt)
conn.commit()
for da_id in delete_del_addon:
sql_delete = " delete from delegates_addons where delegate_addon_id = {};".format(da_id)
if sql_delete:
delete_stmt = text(sql_delete)
result = conn.execute(delete_stmt)
conn.commit()
return True
""" Sridhar on 204/Mar 2022 """
def check_user_delegate(self,user_id,society_id):
with engine.connect() as conn:
stmt = text("select count(*) as count from delegates where user_id="+str(user_id)+" and society_id="+str(society_id)+" ;")
result = conn.execute(stmt).one_or_none()
result = dict(result._mapping)
if result:
return result["count"]
else:
return 0
def check_duplicate_delegate(self,delegate_ids,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_registration_cart_validation",[delegate_ids,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
def get_incompleted_delegates_by_parent_user_id(self,parent_user_id,unique_id,conf_id,reg_mode):
print("usp_del_get_incompleted_delegates_by_parent_user_id")
print(parent_user_id,unique_id,conf_id,reg_mode)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_incompleted_delegates_by_parent_user_id",[parent_user_id,unique_id,conf_id,reg_mode])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
def get_course_incompleted_delegates_by_parent_user_id(self,parent_user_id,unique_id,conf_id,reg_mode):
print(parent_user_id,unique_id,conf_id,reg_mode)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_course_incompleted_delegates_by_parent_user_id",[parent_user_id,unique_id,conf_id,reg_mode])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
def usp_del_generate_payment_link_details(self,unique_id,payment_ids,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_generate_payment_link_details",[unique_id,payment_ids,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
def get_completed_delegates_by_parent_user_id(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_completed_delegates_by_parent_user_id_v2",[parent_user_id,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
return None
# Below code for payment data update -- by ganesan
def usp_del_generate_free_payement(self,unique_id,delegate_ids,user_id,payment_for,payment_method,remarks,full_name,email,mobile,is_generate,created_at,txn_id,society_id,app_type,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_generate_free_payement_v4",[unique_id,delegate_ids,user_id,payment_for,payment_method,remarks,full_name,email,mobile,is_generate,created_at,txn_id,society_id,app_type,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
def usp_del_generate_cash_payement(self,unique_id,delegate_ids,user_id,payment_for,payment_method,remarks,full_name,email,mobile,is_generate,created_at,txn_id,society_id,app_type,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_generate_cash_payement_v4",[unique_id,delegate_ids,user_id,payment_for,payment_method,remarks,full_name,email,mobile,is_generate,created_at,txn_id,society_id,app_type,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
def usp_del_generate_payement(self,unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type,conf_id):
# print(unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_generate_payement_v4",[unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
def get_bo_users_email(self,email,society_id,conf_id):
with engine.connect() as conn:
stmt = text("select * from users u inner join conference c on u.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 inner join m_member_type m on m.member_type_id = u.member_type_id where u.email = '"+email+"' and c.society_id = "+str(society_id)+" and c.conf_id = "+str(conf_id)+" limit 1;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def getdata(self,delegate_nos,from_del_no,to_del_no,receipt_nos,from_receipt_no,to_receipt_no,search,user_type,del_status_id,From,to,orderby,order_type,reg_mode,pay_mode,amount_from,amount_to,limit,offset,conf_id,society_id,role):
# print(delegate_nos,from_del_no,to_del_no,receipt_nos,from_receipt_no,to_receipt_no,search,user_type,status,From,to,orderby,order_type,limit,offset,reg_mode,conf_id,society_id)
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_course_user_report",[(delegate_nos or None),(from_del_no or None),(to_del_no or None),(receipt_nos or None),(from_receipt_no or None),(to_receipt_no or None),(search or None),(user_type or None),(del_status_id or None),(From or None),(to or None),(orderby or None),(order_type or None),(reg_mode or None),(pay_mode or None),(amount_from or None),(amount_to or None),(limit or None),(offset or None),conf_id,society_id,(role or None)])
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_countBOModel(self,conf_id):
with engine.connect() as conn:
stmt=text("SELECT count( delegate_id ) as total from delegates where conference_id = "+str(conf_id)+" ;")
result = conn.execute(stmt)
result = result.fetchone()
return result.total if result else 0
def get_dele(self,delegate_ids):
with engine.connect() as conn:
stmt = text("select sum(da.amount) as total from delegates d left join delegates_addons da on da.delegate_id =d.delegate_id left join user_payment up on up.unique_id = da.unique_id where d.delegate_id in ("+delegate_ids+");")
result = conn.execute(stmt).fetchone()
return result.total if result else 0
def get_addons_total_amount(self,addon_ids,delegate_id):
with engine.connect() as conn:
stmt = text("select sum(amount) as total from delegates_addons where addon_id in ("+str(addon_ids)+") and delegate_id = "+str(delegate_id)+" ;")
conn = engine.connect()
result = conn.execute(stmt).fetchone()
return result.total if result else 0
#-------------------- bo_users code ends here ------------------------------------------
def get_badge_model(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from badge_role where conf_id = "+str(conf_id)+" and is_visible > 0 ;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def bo_generate_delegate_no_and_receipt_no(self,unique_id,conf_id,role):
connection = engine.raw_connection()
cursor = connection.cursor()
# cursor.callproc("usp_del_bo_generate_delegate_no_and_receipt_no_v2",[unique_id,conf_id,role])
cursor.callproc("usp_del_bo_generate_delegate_no_and_receipt_no_v4",[unique_id,conf_id,role])
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:
return None
def bo_get_completed_waiting_delegates_by_parent_user_id(self,parent_user_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_waiting_gen_delegate_no_v1",[parent_user_id,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
return None
def usp_del_bo_view_waiting_gen_del_no_and_receipt_no(self,unique_id,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_view_waiting_gen_del_no_and_receipt_no_v2",[unique_id,conf_id])
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:
return None
def usp_del_bo_view_waiting_gen_del_no_and_receipt_no_only_pg(self,unique_id,conf_id,delegate_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_view_waiting_gen_del_no_and_receipt_no_only_pg",[unique_id,conf_id,delegate_id])
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:
return None
def spot_delegate_no_generate(self,unique_id,conf_id,role):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_spot_completed_payment_res_and_gen_del_no_v2",[unique_id,conf_id,role])
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:
return None
def bo_update_reject_payment(self,data):
with engine.connect() as conn:
result = conn.execute(self.delegate_user_logs.insert(), data)
conn.commit()
return result.lastrowid
# Added Status id
def bo_update_reg_status_delegates_addons(self,unique_id,delegate_id,updated_at,del_status_id = None):
with engine.connect() as conn:
if del_status_id == 7 :
stmt = text("Update delegates_addons set reg_status = 7,updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+") and unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt)
conn.commit()
stmt = text("Update delegates set del_status_id = 7,updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+") and delegate_no is null;")
result = conn.execute(stmt)
conn.commit()
else :
stmt = text("Update delegates_addons set reg_status = 4,updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+") and unique_id = '"+unique_id+"' ;")
result = conn.execute(stmt)
conn.commit()
stmt = text("Update delegates set del_status_id = 4,updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+") and delegate_no is null;")
result = conn.execute(stmt)
conn.commit()
return "updated"
#-------------------- 2022-11-25 ------------------------------------------
def sessionMapSpotReg(self,conf_id,del_id_int,del_table_name,kc_del_sess_table,fc_del_sess_table) :
connection = engine_fk_db.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_delegate_session_map",[conf_id,del_id_int,del_table_name,kc_del_sess_table,fc_del_sess_table])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
else :
cursor.close()
connection.commit()
return None
def update_delegates_in_dele_badge(self,delegate_no,conf_id,dele_badge_table,is_update):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_update_badge_from_delegates_table",[delegate_no,conf_id,dele_badge_table,is_update])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
else :
cursor.close()
connection.commit()
return None
def get_reg_addon_date(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" inner join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+str(delegate_id)+" "
+" where "
+" a.conference_id ="+str(conf_id)+""
+" order by a.addon_type_id,a.addon_id limit 1;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
# Added Status id
def get_delegate_payment_details(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt = text("select up.* from delegates d inner join delegates_addons da on da.delegate_id = d.delegate_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 inner join user_payment up on up.unique_id COLLATE utf8mb4_general_ci = da.unique_id where d.delegate_id = "+str(delegate_id)+" and d.conference_id = "+str(conf_id)+" and d.del_status_id = 2 limit 1;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def update_payment_detail(self,unique_id,conf_id,app_type,payment_details_add):
with engine.connect() as conn:
conn = engine.connect()
stmt = self.user_payment.update().where(self.user_payment.c.unique_id.in_([unique_id]),self.user_payment.c.conf_id.in_([conf_id]),self.user_payment.c.app_type.in_([app_type])).values(payment_details_add)
result = conn.execute(stmt)
conn.commit()
return 'success' if result else 'fail'
def Update_delegates_addons(self,delegate_id,unique_id,addon_id,original_amount,amount,now):
with engine.connect() as conn:
stmt =text("UPDATE delegates_addons SET original_amount ={},amount ={},updated_at = '{}', addon_id ={} WHERE delegate_id = {} and unique_id = '{}' ;".format(original_amount,amount,now,addon_id,delegate_id,unique_id))
conn = engine.connect()
result = conn.execute(stmt)
conn.commit()
return 'success' if result else 'fail'
def get_edit_all_addons(self,delegate_id,now,conf_id,user_type_ids = None,is_custom_addons = None):
with engine.connect() as conn:
user_type_where_con = "";
if user_type_ids:
user_type_where_con += " and (a.user_type_id in ("+user_type_ids+") or a.user_type_id is null )"
if is_custom_addons is None:
user_type_where_con += " and (a.is_custom_addon is null or a.is_custom_addon = 0 ) "
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id "
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+str(delegate_id)+" and da.reg_status = 2 "
+" where '"+str(now)+"' between a.start_by and a.end_by "
+ user_type_where_con
+" and a.conference_id = "+str(conf_id)+" "
+" order by a.addon_type_id,a.addon_id;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def getOTPforConfirmationMail(self,delegate_no,conf_id,del_table_name):
with engine.connect() as conn:
stmt = text("select otp from "+del_table_name+" where delegate_no = "+str(delegate_no)+" and conf_id = "+str(conf_id)+";")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
# Purpose : Searching Email,Mobile,Transaction Id already registered or not
def bo_search_alerady_registered_delegate_details(self,search_data,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_search_alerady_registered_delegate_details",[search_data,conf_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
# Added Status id
def get_delegate_for_edit(self,delegate_id):
with engine.connect() as conn:
stmt = text("select * FROM delegates d inner join delegates_addons da on d.delegate_id = da.delegate_id inner join user_types ut on ut.user_type_id = d.reg_type_id where d.delegate_id = "+str(delegate_id)+" and (d.delegate_no >0 or d.ref_no_only >0) and da.reg_status = 2 and d.del_status_id = 2 limit 1; ")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else 0
def get_delegate_details_from_delegate_no(self,delegate_no,conf_id):
with engine.connect() as conn:
stmt = text("select * FROM delegates where delegate_no = "+str(delegate_no)+" and delegate_no >0 and conference_id ="+str(conf_id)+"; ")
conn = engine.connect()
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else 0
def get_all_conference_daily_count_send_mail(self):
with engine.connect() as conn:
stmt = text ("select group_concat(t.conf_id order by c.conf_key asc)as conf_id ,group_concat(c.conf_key order by c.conf_key asc) as conf_key,t.full_name,t.email,t.mobile from trigger_daily_reports_mails t inner join conference c on find_in_set(c.conf_id,t.conf_id) where t.is_del =1 and t.is_active =1 and email like '%@numerotec.com%' and is_consolidate_mail = 1 group by t.email order by c.conf_id asc;");
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_conference(self):
with engine.connect() as conn:
stmt = text ("select c.conf_id,c.conf_key,c.conf_title,c.conf_name,c.mail_header_logo,sa.app_url from conference c inner join society_applications sa on sa.conf_id = c.conf_id where c.reg_end_on >= (select convert_tz(utc_timestamp() ,'+00:00','+05:30')) and sa.app_type_id = 2 order by c.conf_key asc;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def get_conference_details(self,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_backoffice_fc_kc_get_details",[conf_id])
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 insert_remark(self,data):
with engine.connect() as conn:
result = conn.execute(self.reg_remark.insert(), data)
conn.commit()
return result.lastrowid
def get_spot_remark(self,conf_id,user_id):
with engine.connect() as conn:
stmt=text("SELECT * FROM reg_remark where conf_id = "+str(conf_id)+" and user_id = "+str(user_id)+" and is_default = 1 ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def Check_is_defualt(self,conf_id,user_id):
with engine.connect() as conn:
stmt = text("select * from reg_remark where conf_id ='"+str(conf_id)+"' and user_id = "+str(user_id)+" ;")
result = conn.execute(stmt).one_or_none()
return "success" if result else "fail"
def update_remark(self,conf_id,user_id,data):
with engine.connect() as conn:
stmt = self.reg_remark.update().where(self.reg_remark.c.conf_id.in_([conf_id])).where(self.reg_remark.c.user_id.in_([user_id])).values(data)
result = conn.execute(stmt)
conn.commit()
return 'success' if result else 'fail'
def get_remark(self,conf_id,user_id):
with engine.connect() as conn:
stmt = text("select * from reg_remark where conf_id ="+str(conf_id)+" and user_id = "+str(user_id)+" ;")
result = conn.execute(stmt).one_or_none()
return "success" if result else "fail"
def get_remark_value(self,conf_id,user_id):
with engine.connect() as conn:
stmt=text("SELECT * FROM reg_remark where conf_id = "+str(conf_id)+" and user_id = "+str(user_id)+";")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def get_remark_data(self,conf_id,user_id):
with engine.connect() as conn:
stmt=text("SELECT * FROM reg_remark where conf_id = "+str(conf_id)+" and user_id = "+str(user_id)+" ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def usp_del_get_delegates_by_delegate_no(self,delegate_no,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_delegates_by_delegate_no",[delegate_no,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
return None
# def get_walkathon_data(self,conf_id):
# 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 ;")
# conn = engine.connect()
# result = conn.execute(stmt)
# results = [dict(r) for r in result] if result else None
# conn.close()
# if results :
# return results
# else:
# return None
# Date : 14-03-2023 (ramya)
# Purpose : Addons Closing Alert mail before one day
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 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
# end here
# Ganesan
def GetWetDryReportForMail(self,date_1,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_reg_report_wetDryLab_v1",[date_1,conf_id])
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
# start bulk mail
def receipt_no_generate_and_get_delegate_no_bulk(self,delegate_nos,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_delegates_by_delegate_nos",[delegate_nos,conf_id])
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
# end bulk mail
def get_addons_senior_BOModel(self,delegate_id,curr_dt,conf_id,user_type_ids = None,is_custom_addons = None):
with engine.connect() as conn:
user_type_where_con = "";
if user_type_ids:
user_type_where_con += " and (a.user_type_id in ("+user_type_ids+") or a.user_type_id is null )"
if is_custom_addons is None:
user_type_where_con += " and (a.is_custom_addon is null or a.is_custom_addon = 0 ) "
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+ str(delegate_id)+" "
+" left join addon_types ats on ats.addon_type_id = a.addon_type_id "
+" where ats.is_visible=1 AND '"+curr_dt+"' between a.start_by and a.end_by "
+" and a.conference_id ="+str(conf_id)+" "
+ user_type_where_con
+" order by a.order_by;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def save_delegates_addonsBOModel(self,delegate_id,inser_dal_addon,delete_del_addon,now):
sql_insert = ""
sql_delete = ""
with engine.connect() as conn:
for d in inser_dal_addon:
sql_insert = " insert into delegates_addons (delegate_id,addon_id,amount,original_amount,reg_status,unique_id,created_at,updated_at,is_bo_update) values ({},{},{},{},{},'{}','{}','{}',{});".format(delegate_id,d['addon_id'],d['amount'],d['original_amount'],d['reg_status'],d['unique_id'],now,now,d['is_bo_update'])
if sql_insert:
insert_stmt = text(sql_insert)
result = conn.execute(insert_stmt)
conn.commit()
for da_id in delete_del_addon:
sql_delete = " delete from delegates_addons where delegate_addon_id = {};".format(da_id)
if sql_delete:
delete_stmt = text(sql_delete)
result = conn.execute(delete_stmt)
conn.commit()
return True
def get_edit_all_addons_for_post(self,delegate_id,now,conf_id,user_type_ids = None,is_custom_addons = None):
with engine.connect() as conn:
user_type_where_con = "";
if user_type_ids:
user_type_where_con += " and (a.user_type_id in ("+user_type_ids+") or a.user_type_id is null ) "
if is_custom_addons is None:
user_type_where_con += " and (a.is_custom_addon is null or a.is_custom_addon = 0) "
stmt = text("select a.*,ut.*,da.delegate_id,da.amount as del_amount,da.delegate_addon_id,da.reg_status,da.unique_id from addons a "
+" left join user_types ut on ut.user_type_id = a.user_type_id"
+" left join delegates_addons da on da.addon_id = a.addon_id and da.delegate_id = "+str(delegate_id)+" and da.reg_status = 2 "
+" where a.conference_id = "+str(conf_id)+" "
+ user_type_where_con
+" order by a.addon_id;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def usp_del_choose_payment_generate_payement(self,unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type,conf_id):
# print(unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type)
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_choose_payment_generate_payement",[unique_id,delegate_ids,user_id,am_id,is_test,payment_for,is_generate,full_name,email,mobile,is_generate_link_payment,created_at,society_id,app_type,conf_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
# Added Status id
def get_surgical_delegates_details(self,conf_id):
with engine.connect() as conn:
stmt =text("select d.*,s.state_name,mc.state_name as mc_state_name,(case when d.prefix is null then d.full_name else concat(d.prefix, '' , d.full_name) end) as name,date_format(d.registered_on, '%d-%m-%Y %H:%i:%s') as registered_date from delegates d left join states s on s.state_id = d.state_id left join states mc on mc.state_id = d.mc_state_id where d.conference_id = "+str(conf_id)+ " and d.delegate_no is not null and d.del_status_id = 2;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# Purpose : To View Acknowledge Mail
# Created on 2023-11-02 10:12 by Ramya
def get_view_user_payment_data(self,conf_id,delegate_id,unique_id):
with engine.connect() as conn:
stmt =text("select (case when d.prefix is null then d.full_name else concat(d.prefix,'', d.full_name) end) as full_name,up.utr_number 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 up.conf_id = "+str(conf_id)+" and up.delegate_ids in ("+str(delegate_id)+") and up.unique_id = '"+unique_id+"'")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
# Purpose : To check In Progress data registered or not
# Created on 2023-12-12 14:57:00 by ramya
def bo_check_registered_or_not_data(self,conf_id,email,mobile):
with engine.connect() as conn:
stmt = text(" select d.delegate_id,d.delegate_no,d.prefix,d.full_name,d.email,d.mobile,"
+ " group_concat(a.display_name,': Rs.' , da.amount) as reg_for,da.amount as total_amount,p.status,p.receipt_no,"
+ " a.display_name as reg_for_without_amount"
+ " 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 user_payment p on p.unique_id = da.unique_id"
+ " left 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 "
+ " where d.conference_id = "+str(conf_id)+" "
+ " and d.delegate_no is not null and da.reg_status =2 "
+ " and ( d.email like '%"+email+"%' or d.mobile like '%"+mobile+"%') "
+ " group by d.delegate_id")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
# Purpose : To Delete In Progress data by delegate_id
# Created on 2023-12-13 10:44:00 by ramya
def bo_delete_inprogress_data(self,conf_id,delegate_id):
with engine.connect() as conn:
try:
da_stmt = text("delete FROM delegates_addons WHERE delegate_id = "+str(delegate_id)+" and reg_status = 0;")
result = conn.execute(da_stmt)
conn.commit()
stmt = text("delete FROM delegates WHERE delegate_id = "+str(delegate_id)+" and conference_id = "+str(conf_id)+" and delegate_no is null;")
result = conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
conn.close()
return str(e)
# PG Added
def BoGetDataCompletedDelegatesSubmittedProofVerify(self,conf_id):
with engine.connect() as conn:
stmt = text("select *,concat(pg_cert_path,'',pg_cert_name) as proof_screen_shot from delegates inner join user_types ut on ut.user_type_id = reg_type_id where conference_id = "+str(conf_id)+" and delegate_no is not null and del_status_id = 2 and pg_cert_name is not null and pg_cert_path is not null;")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def bo_update_reg_status_delegates_addons_for_pg_proof_reject(self,unique_id,delegate_id,updated_at,del_status_id):
with engine.connect() as conn:
# stmt = text("Update delegates_addons set reg_status = "+str(del_status_id)+",updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+") and unique_id = '"+unique_id+"' ;")
# result = conn.execute(stmt)
# conn.commit()
stmt = text("Update delegates set del_status_id = "+str(del_status_id)+",updated_at = '"+str(updated_at)+"' where delegate_id in ("+str(delegate_id)+");")
result = conn.execute(stmt)
conn.commit()
return "updated"
# PG Added
def bo_generate_delegate_no_and_receipt_no_only_pg(self,unique_id,conf_id,role,delegate_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_bo_generate_delegate_no_and_receipt_no_only_pg",[unique_id,conf_id,role,delegate_id])
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:
return None
def get_auto_login_url_by_delegate_id(self,delegate_id,conf_id):
with engine.connect() as conn:
stmt = text("select concat(sa.app_url,'/auto_login/',u.user_uuid) as auto_login_url from delegates d"
+ " inner join users u on u.user_id = d.parent_user_id"
+ " inner join society_applications sa on sa.conf_id = d.conference_id and sa.app_type_id = 2 "
+ " where d.conference_id = "+str(conf_id)+" and d.delegate_id = "+delegate_id+";")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
# Purpose : Separate conference mail version 2 start
# Created on 2024-04-13 12:00
def GetRegDataForMail_v2(self,previous_date,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_reg_report_v4",[previous_date,conf_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
# Purpose : Searching Email,Mobile,Transaction Id already registered or not
def bo_search_utr_details(self,parent_user_id,conf_id,search_data,del_status_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_waiting_gen_delegate_no_search_utr_v1",[parent_user_id,conf_id,search_data,del_status_id])
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
if results :
return results
else :
return None
def get_trade_reg_deashboard(self,parent_user_id,conf_id,society_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_check_trade_list",[parent_user_id,conf_id,society_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def session_data_InsertToSqlite(self):
try:
sqlite_conn = sqlite3.connect('primary_db_del.db')
tables = ['societies', 'conference', 'society_applications', 'mail_setting', 'daily_digest_mail_color_template']
for table in tables:
mysql_query = f"SELECT * FROM {table}"
df = pd.read_sql(mysql_query, engine)
df.to_sql(table, sqlite_conn, if_exists='replace', index=False)
sqlite_conn.commit()
engine.dispose()
sqlite_conn.close()
return "success"
except Exception as e:
# Handle exceptions
print(f"Error: {e}")
return "failure"
def get_delegate_count(self, conf_id,dt_string,from_photo_upload_dt,is_gen_number):
with engine.connect() as conn:
if is_gen_number == 'ref_number':
stmt = text("select count(*) as total_count,SUM(CASE WHEN del_img_path IS NOT NULL AND del_img_filename IS NOT NULL THEN 1 ELSE 0 END) AS upload_count,SUM(CASE WHEN del_img_path IS NOT NULL AND Date(is_photo_upload_at) >= '"+from_photo_upload_dt[conf_id]+"' THEN 1 ELSE 0 END) AS from_photo_count,SUM(CASE WHEN del_img_path IS NULL AND del_img_filename IS NULL THEN 1 ELSE 0 END) AS not_upload_count FROM delegates WHERE conference_id = "+str(conf_id)+" AND del_status_id = 2 AND ref_no is not null ;")
else:
stmt = text("select count(*) as total_count,SUM(CASE WHEN del_img_path IS NOT NULL AND del_img_filename IS NOT NULL THEN 1 ELSE 0 END) AS upload_count,SUM(CASE WHEN del_img_path IS NOT NULL AND Date(is_photo_upload_at) >= '"+from_photo_upload_dt[conf_id]+"' THEN 1 ELSE 0 END) AS from_photo_count,SUM(CASE WHEN del_img_path IS NULL AND del_img_filename IS NULL THEN 1 ELSE 0 END) AS not_upload_count FROM delegates WHERE conference_id = "+str(conf_id)+" AND del_status_id = 2 AND delegate_no > 0 AND delegate_no IS NOT NULL;")
print("------------delegate_count_model",stmt)
result = conn.execute(stmt).first()
return dict(result._mapping) if result else None
def bo_photo_report_details(self, conf_id, report_type, is_gen_number, dt_string,from_photo_upload_dt):
with engine.connect() as conn:
column_name = "ref_no" if is_gen_number == 'ref_number' else "delegate_no"
base_query = f"select * from delegates d where conference_id = {conf_id} and del_status_id = 2 and {column_name} is not null "
if int(report_type) == 1:
query = f"{base_query} and del_img_path is not null and del_img_filename is not null"
elif int(report_type) == 2:
query = f"{base_query} and del_img_path is null and del_img_filename is null order by is_photo_upload_at desc"
elif int(report_type) == 4:
query = f"{base_query} and Date(is_photo_upload_at) >= '"+from_photo_upload_dt[conf_id]+"' and del_img_path is not null and del_img_filename is not null order by is_photo_upload_at desc"
else:
query = base_query
stmt = text(query + ";")
print(stmt)
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
def update_del_pg_uproval_at(self, conf_id,delegate_id,created_at):
try:
with engine.connect() as conn:
# stmt = text("update delegates set del_status_id = 8 where conference_id = "+str(conf_id)+" and delegate_id = '"+delegate_id+"' ;")
stmt = text("update delegates set is_pg_verify_at = '"+created_at+"' where conference_id = "+str(conf_id)+" and delegate_id in("+delegate_id+") ;")
result = conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
return str(e)
def update_delegate_data_bonafide(self, conf_id,delegate_id,created_at):
try:
with engine.connect() as conn:
# stmt = text("update delegates set del_status_id = 8 where conference_id = "+str(conf_id)+" and delegate_id = '"+delegate_id+"' ;")
stmt = text("update delegates d inner join delegates_addons da on d.delegate_id = da.delegate_id set d.del_status_id = 2,is_pg_verify_at = '"+created_at+"' where d.conference_id = "+str(conf_id)+" and d.delegate_id = '"+delegate_id+"' ;")
result = conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
return str(e)
# Purpose : To view all receipt
# Created by Ramya . S
def all_receipt_no_generate_and_get(self,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_all_receipt_payment_details",[conf_id])
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 all_usp_del_get_delegates(self,conf_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_all_delegates",[conf_id])
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 bo_photo_delete(self,conf_id,del_ids,is_gen_number,report_type,from_photo_upload_dt):
with engine.connect() as conn:
try:
da_stmt = text("update delegates set del_img_path = null ,del_img_filename = null WHERE conference_id = "+str(conf_id)+" and delegate_id in ("+del_ids+");")
result_1 = conn.execute(da_stmt)
conn.commit()
# return "success"
column_name = "ref_no" if is_gen_number == 'ref_number' else "delegate_no"
base_query = f"select * from delegates d where conference_id = {conf_id} and del_status_id = 2 and {column_name} is not null "
if int(report_type) == 1:
query = f"{base_query} and del_img_path is not null and del_img_filename is not null"
elif int(report_type) == 2:
query = f"{base_query} and del_img_path is null and del_img_filename is null order by is_photo_upload_at desc"
elif int(report_type) == 4:
query = f"{base_query} and Date(is_photo_upload_at) >= '"+from_photo_upload_dt[conf_id]+"' and del_img_path is not null and del_img_filename is not null order by is_photo_upload_at desc"
else:
query = base_query
stmt = text(query + ";")
result = conn.execute(stmt).all()
return [dict(r._mapping) for r in result] if result else None
except Exception as e:
conn.close()
return str(e)
def get_user_payment_data(self,conf_id,unique_id):
with engine.connect() as conn:
stmt = text("select * from user_payment "
+ " where conf_id = "+str(conf_id)+" and unique_id = '"+str(unique_id)+"';")
result = conn.execute(stmt).fetchone()
return dict(result._mapping) if result else None
def GetRegDataForMail_v3(self,previous_date,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_conf_del_reg_report",[previous_date,conf_id])
while 1:
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
if cursor.description is None:
break
finally:
connection.close()
return sets
def usp_del_get_delegates_by_delegate_id_and_unique_id(self,delegate_id,unique_id):
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_del_get_delegates_by_delegate_id_and_unique_id",[delegate_id,unique_id])
if cursor.description :
columns = [column[0] for column in cursor.description]
results = []
for row in cursor.fetchall():
results.append(dict(zip(columns, row)))
cursor.close()
connection.commit()
return results
else :
cursor.close()
connection.commit()
return None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists