Sindbad~EG File Manager
from flask import Flask, request, Blueprint, jsonify, redirect, url_for,flash, render_template,session,Response,jsonify,json,render_template_string
from random import randint
from .. import Cryptography,RouteGroup,Helper,Custom
from core.model.OfflineRegistrationModel import OfflineRegistrationModel
from core.model.ConfAppModel import ConfAppModel
import datetime
from core.library.email import EMAIL
import math
from datetime import timedelta,date,datetime
from flask import session, app
from os import listdir
import io
import csv
import ast
import requests,mandrill,json,math
import base64
import flask
from num2words import num2words
import webbrowser
import os #use for new instance of chrome
import urllib.parse
from ast import literal_eval
app = Blueprint('offline_reg', __name__)
@app.route('/free_reg', methods = ["GET","POST"])
def FreeReg():
conf_id = request.values.get('conf_id'or None )
conf_key = request.values.get('conf_key'or None )
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
if conf:
badge_role = OfflineRegistrationModel().OR_get_badge_model(conf_id)
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
delegate = None
badge_role = OfflineRegistrationModel().OR_get_badge_model(conf_id)
delegate_id = 0
is_custom_addons = 1
payment_types = OfflineRegistrationModel().OR_get_payment_types(conf_id)
reg_types = OfflineRegistrationModel().OR_get_addon_reg_type(conf_id)
generate_by_data = OfflineRegistrationModel().OR_get_is_admin(conf_id)
addons = OfflineRegistrationModel().OR_get_addonsBOModel(delegate_id,curr_dt,conf_id,None,is_custom_addons)
state_id = OfflineRegistrationModel().OR_get_states()
country_id = OfflineRegistrationModel().OR_get_country()
return render_template('conferenceapp/free_reg_page.html',conf=conf,badge_role=badge_role,reg_types=reg_types,addons=addons,str=str,type=type,payment_types=payment_types,states=state_id,countries=country_id,generate_by_data=generate_by_data)
else:
return "<h1>Invalid URL </h1>"
@app.route('/<int:conf_id>/<conf_key>/post_free_reg', methods = ["POST","GET" ])
def PostFreeReg(conf_id,conf_key):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
society_id = conf['society_id']
msg = ""
status = 1
data = ""
delegate_id = 0
parent_user_id = None
now = datetime.now()
curr_dt = now.strftime("%Y-%m-%d %H:%M:%S")
# conf_id = request.form['conf_id'] # Comment by Ganesan J
# conf_key = request.form['conf_key']
# conf = BOModel().get_conf(conf_id,conf_key)
dt_string = now.strftime("%Y-%m-%d %H:%M:%S")
prefix = request.form['prefix'] or None
full_name = request.form['full_name'] or None
email = request.form['email'] or None
mobile = request.form['mobile'] or None
d_is_kit = request.values.get('d_is_kit',0)
membership_no = request.form['membership_no'] or None
city = request.form['city'] or None
gender = request.form['gender'] or None
state_id = request.form['state_id'] or None
mc_number = request.form['mc_number'] or None
mc_state_id = request.form['mc_state_id'] or None
country_id = request.form['country_id'] or None
register_id = request.form['register_id'] or None
txn_id = request.form['utr_number'] or None
generate_by = request.form['generate_by'] or None
date_of_birth = request.form['dob'] or None
if date_of_birth:
try:
dob = datetime.strptime(date_of_birth, '%d-%m-%Y')
except Exception as e:
dob = None
else:
dob = None
# attach_path = request.form['attach_path'] or None
# attach_file_name = request.form['attach_file_name'] or None
conf_id = conf_id
confirmation_mail = request.values.get('confirmation_mail' or None ) or None # added confirmation_mail
receipt_mail = request.values.get('receipt_mail'or None ) or None # added receipt_mail
role = request.form['role'] or 'DELEGATE_1'
if role :
if "_" in role :
role_1 = role.split("_")
role = role_1[0]
range_1 = role_1[1]
else :
role = "DELEGATE"
range_1 = 1
reg_types = OfflineRegistrationModel().OR_get_addon_reg_type(conf_id)
addons = OfflineRegistrationModel().OR_get_addonsBOModel(delegate_id,curr_dt,conf_id)
reg_addons = {}
insert_del_addons = []
delete_del_addons = []
created_at = now
for addon in addons:
reg_addons[addon["addon_id"]] = addon
#collect all delegate_addon_id for delegate
if addon["delegate_addon_id"] and addon["delegate_addon_id"] > 0:
delete_del_addons.append(addon["delegate_addon_id"])
is_mandatory = {}
for rt in reg_types:
is_mandatory[rt['addon_type_id']] = rt['is_mandatory']
values = request.values.getlist(rt.get('input_name'))
if values:
is_mandatory[rt['addon_type_id']] = 0
for val in values:
addon = reg_addons[int(val)]
if addon.get("delegate_addon_id") and addon.get("delegate_addon_id") > 0:
#if already have addon and deleate not change the addon then we removed delegate_addon_id in delete_addons variable
delete_del_addons.remove(addon.get("delegate_addon_id"))
else:
add_data = {
"addon_id" : val,
"amount" : request.form['addon_amount_'+val] or addon.get("amount",0),
"original_amount" : request.form['addon_amount_'+val] or addon.get("amount",0),
"reg_status" : 0,
"conference_id" : conf_id
}
insert_del_addons.append(add_data)
reg_Validation = []
for key in is_mandatory:
if is_mandatory[key] == 1:
reg_Validation.append({'key': key ,'msg': "following list is mandatory."})
status = 0;
del_data = {
'parent_user_id': parent_user_id,
'prefix' : prefix,
'full_name' : full_name,
'email' : email,
'mobile' : mobile,
'city' : city,
'conference_id' : conf_id,
'admin_user_id' : parent_user_id,
'society_id' : society_id,
'is_offline' : 1,
'role' : role,
'd_is_kit' : d_is_kit,
'membership_no' : membership_no,
'country_id' : country_id,
'mc_state_id' : mc_state_id,
'mc_number' : mc_number,
'state_id' : state_id,
'gender' : gender,
'created_at' : created_at,
'is_present' : 1,
'generate_by' : generate_by,
'dob' : dob
}
if status == 1:
delegate_ids = OfflineRegistrationModel().OR_insert_delegate(del_data)
OfflineRegistrationModel().OR_save_delegates_addons(delegate_ids,insert_del_addons,delete_del_addons,now)
payment_method = request.values.get('method')
remarks = request.values.get('remarks')
now = datetime.now()
dt_string = now.strftime("%Y-%m-%d %H:%M:%S")
society_id = conf['society_id']
user_id = None
name = full_name
full_name = prefix + " " + name if prefix else name
unique_id = now.strftime('%Y%m%d%H%M%S')
created_at = now
url = conf['paymentgateway_api_url']
r = requests.get(url)
apikey = json.loads(r.content.decode())
am_id = conf['paymentgateway_appmaster_id']
is_test = conf['paymentgateway_is_test']
for index,value in enumerate(apikey) :
api_am_id = value['am_id']
if api_am_id == am_id:
app_key = value['app_key']
app_name = value['app_name']
break
else:
pass
payment_for = app_name
unique_id = app_key+"_"+unique_id
app_type = Helper.AppType
is_generate = 1
if payment_method == "Free": # return "free"
generate_payement = OfflineRegistrationModel().OR_usp_del_generate_free_payement(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)
else: # return "cash"
generate_payement = OfflineRegistrationModel().OR_usp_del_generate_cash_payement(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 generate_payement : # added confirmation and receipt_mail
return redirect(url_for('offline_reg.FreeCommonPaymentServerResponse',user_id=user_id,unique_id=unique_id,payment_method=payment_method,conf_id=conf_id,conf_key=conf_key,role=role,register_id=register_id,receipt_mail=receipt_mail,confirmation_mail=confirmation_mail))
else :
flash("Please select atleast one delegate","Payerror")
return redirect(url_for('spot_reg.BoRegister',conf_id=conf_id,conf_key=conf_key))
else:
data = { 'msg':'','status':0,'data':'','reg_validation' : reg_Validation}
return jsonify(data)
@app.route('/<int:conf_id>/<conf_key>/free_search_register', methods = ["GET", "POST"])
def FreeSearchRegister(conf_id,conf_key):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
society_id = conf['society_id']
if request.method == 'POST':
search = request.values.get('register_no')
user = OfflineRegistrationModel().OR_get_search_spot_user(search,conf_id)
print("................................",user)
if user:
user_details = OfflineRegistrationModel().get_delegate_details_from_delegate_no(user['delegate_no'],conf_id)
attach_path = user['attach_path'] or None
attach_file_name = user['attach_file_name'] or None
if user_details:
confimation_mail_link = "/free_confirmation_delegate_mail/"+str(conf_id)+"/"+str(conf_key)+"/"+str(user_details['delegate_id'])
delegate_no = '<a href="'+confimation_mail_link+'" target="_blank" >'+str(user_details['delegate_no'])+'</a>'
else:
attach_path = None
attach_file_name = None
if user == None:
status = 0
data = {
'status':status,
'msg' : 'No Record Found...'
}
elif user['delegate_no'] is not None:
status = 2
if attach_path and attach_file_name:
payment_screenshot = attach_path+"/"+attach_file_name
else:
payment_screenshot = None
data = {
'status' : status,
# 'msg' : "Already registered. Delegate no. " + str(user['delegate_no']),
'msg' : "Already registered. Delegate no. " + str(delegate_no),
'user' : user,
'payment_screenshot': payment_screenshot
}
else:
status = 1
if attach_path and attach_file_name:
payment_screenshot = attach_path+"/"+attach_file_name
else:
payment_screenshot = None
data = {
'status' : status,
'user' : user,
'payment_screenshot': payment_screenshot
}
return json.dumps(data ,default=str)
else:
return redirect(url_for('back_office.BoRegister',conf_id=conf_id,conf_key=conf_key))
@app.route('/<int:conf_id>/<conf_key>/state', methods = ["GET","POST"])
def State(conf_id,conf_key):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
country_id = request.values['country_id'] or 101
data = OfflineRegistrationModel().OR_get_states_of_india(country_id)
return json.dumps(data)
@app.route('/<int:conf_id>/<conf_key>/spot_common_payment_server_response', methods = ["GET", "POST"])
def FreeCommonPaymentServerResponse(conf_id,conf_key):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
status = "success"
user_id = request.values.get('user_id')
unique_id = request.values.get('unique_id')
payment_method = request.values.get('payment_method')
role = request.values.get('role')
register_id = request.values.get('register_id')
# return "success"
confirmation_mail = request.values.get('confirmation_mail') # added confirmation_mail
receipt_mail = request.values.get('receipt_mail') # added receipt_mail
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
getData = OfflineRegistrationModel().OR_freegetDataforPayments(unique_id,conf_id)
# return "get data in call payment route"
if getData :
getData_1 = getData[0]
email = getData_1['email']
mobile = getData_1['mobile']
delegate_ids = getData_1['delegate_ids']
# role = getData_1['role'] or None
range_1 = getData_1['range_1'] or 1
data = {'status' : status,'updated_at' :dt_string,'paid_at' :dt_string,'payment_method':payment_method}
update_and_get_data = OfflineRegistrationModel().OR_updatePayment(unique_id,data,dt_string) # update payment status in your table
if update_and_get_data == "updated" and status =="success":
roles = []
for index,value in enumerate(getData) :
range_1 = value["range_1"]
role = value["role"]
roles.append(role)
roles = list(dict.fromkeys(roles))
i = 0
for role in roles:
generatedDelegates = OfflineRegistrationModel().OR_BOdelegate_no_generate(unique_id,conf_id,role)
i = i+ 1
delegate_id = delegate_ids
badge_table = conf['del_table_name']
# if badge_table:
# update_badge_data = OfflineRegistrationModel().OR_update_delegates_in_dele_badge(delegate_no,conf_id,badge_table)
status = 1
if confirmation_mail == "confirmation_mail" and receipt_mail == "receipt_mail":
success_msg = FreeConfirmationAndReceiptDelegagteMail(conf_id,conf_key,delegate_id,unique_id,None,1,email)
elif confirmation_mail == "confirmation_mail" :
FreeConfirmationDelegateMail(conf_id,conf_key,delegate_id,None,1,None)
success_msg = FreeConfirmationAndReceiptDelegagteMail(conf_id,conf_key,delegate_id,unique_id,None,0,email)
elif receipt_mail == "receipt_mail":
FreeReceiptDelegagteMail(conf_id,conf_key,unique_id,None,1,None)
success_msg = FreeConfirmationAndReceiptDelegagteMail(conf_id,conf_key,delegate_id,unique_id,None,0,email)
else:
FreeReceiptDelegagteMail(conf_id,conf_key,unique_id,None,0,None)
success_msg = FreeConfirmationAndReceiptDelegagteMail(conf_id,conf_key,delegate_id,unique_id,None,0,email)
else:
status = 0
success_msg = "Failed"
data={
'status' : status,
'success_msg' : success_msg,
'msg' :'Registered Completed'
}
return jsonify(data)
@app.route('/free_confirmation_and_receipt_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>/<unique_id>', methods = ["GET", "POST"])
def FreeConfirmationAndReceiptDelegagteMail(conf_id,conf_key,delegate_id,unique_id,receipt_data,is_send,email=None):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
del_table_name = None
otp_1 = None
if conf :
del_table_name = conf["del_table_name"]
if receipt_data is None :
receipt_datas = OfflineRegistrationModel().OR_BOreceipt_no_generate_and_get(unique_id,conf_id)
if receipt_datas:
receipt_data = receipt_datas[0]
if receipt_data:
# email = 'sai@numerotec.com'
receipt_no = receipt_data['receipt_no']
r_amount = receipt_data['amount']
conf_name = receipt_data['conf_name']
delegate_nos = receipt_data['delegate_nos']
is_kit = receipt_data['d_is_kit']
company_name = receipt_data['d_company_name']
if str(r_amount) == "0.00":
r_amount = "Free"
else:
r_amount = int(r_amount)
r_amount = f"{r_amount:,}"
amount_with_commas = r_amount
amount_fOR_convertion = int(receipt_data['amount'])
amount_in_words = Helper.amountTowords(amount_fOR_convertion)
amount_in_words = amount_in_words.title()
if r_amount == "Free" :
r_amount = r_amount
else:
r_amount = "Rs."+r_amount+"/-"
delegate = None
if delegate is None:
delegates = OfflineRegistrationModel().OR_usp_del_get_delegates_by_delegate_id(delegate_id)
if delegates:
delegate = delegates[0]
if delegate:
if email:
email = email
else:
email = delegate['email']
# email = delegate['email']
# parent_email = delegate['parent_email']
delegate_no = delegate['delegate_no']
c_amount = delegate['total_amount']
prefix = delegate["prefix"]
conf_name = delegate['conf_name']
if prefix:
name = delegate["prefix"] +" "+ delegate["full_name"]
else:
name = delegate["full_name"]
########### Ganesan Nov 25 ,2022
# add kit counter for session map
# del_table_name = conf["del_table_name"]
# if del_table_name :
# kc_del_sess_tab = conf["kc_del_session_table_name"]
# fc_del_sess_tab = conf["fc_del_session_table_name"]
# if is_kit and int(is_kit) > 0 :
# session_table = "kc_sessions"
# del_ses_table = kc_del_sess_tab
# else :
# session_table = "fc_sessions"
# del_ses_table = fc_del_sess_tab
# del_id_int = int(delegate_no)
# insert_session = OfflineRegistrationModel().OR_sessionMapSpotReg(conf_id,del_id_int,session_table,del_ses_table,fc_del_sess_tab)
badge_print_url = "https://conference.numerotech.com/"+str(conf_id)+"/"+str(conf_key)+"/delegate_batch_print_from_reg?del_nos="+str(delegate_nos)+"&is_kit="+str(is_kit)
btn_link = '<a href="'+badge_print_url+'" target="_blank" > <i class ="fa fa-print fa-1x"></i> <span aria-hidden="true" title="Print Badge">Print Badge</span></a>'
if conf_id in [8,18,22]:
btn_link = btn_link
else:
btn_link = ""
if del_table_name and conf_id == 12 :
otp_1 = OfflineRegistrationModel().OR_getOTPforConfirmationMail(delegate_no,conf_id,del_table_name)
else :
pass
if otp_1 :
otp = otp_1["otp"]
else:
otp = None
confimation_mail_link = "/free_confirmation_delegate_mail/"+str(conf_id)+"/"+str(conf_key)+"/"+str(delegate_id)
delegate_no = '<a href="'+confimation_mail_link+'" target="_blank" >'+delegate_nos+'</a>'
success_msg = "An amount of {} has been made towards {} registration. The receipt has been email to {}.\nA delegate registration confirmation email has been sent to the email id of the delegate(s). Receipt no. {} .Delegate no(s). {} <br/> {}".format(r_amount,conf_name,email,receipt_no,delegate_no,btn_link)
subject = "Confirmation and Receipt Mail for Delegate Registration."
html = render_template('conferenceapp/email/confirmation_and_receipt_mail.html',delegate=delegate,delegate_id=delegate_id,receipt_data=receipt_data,conf_id=conf_id,conf_key=conf_key ,amount_in_words=amount_in_words,amount_with_commas=amount_with_commas,conf=conf,otp=otp)
if is_send == 1:
if conf['is_email_enable'] == 1:
EMAIL.sendMail(subject,html,email,conf)
return success_msg
else:
return success_msg
else:
return success_msg
return html
@app.route('/free_confirmation_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def FreeConfirmationDelegateMail(conf_id,conf_key,delegate_id,delegate=None,is_send=None,email=None):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
template_name = "confirmation_mail"
mailData = ConfAppModel().get_mail_template(template_name,conf_id)
if delegate is None:
delegates = OfflineRegistrationModel().OR_usp_del_get_delegates_by_delegate_id(delegate_id)
if delegates:
delegate = delegates[0]
if delegate:
if email:
email = email
else:
email = delegate['email']
parent_email = delegate['parent_email']
# parent_email = 'karthiashokan23@gmail.com'
delegate_no = delegate['delegate_no']
amount = delegate['total_amount']
prefix = delegate["prefix"]
conf_name = delegate['conf_name']
if prefix:
name = delegate["prefix"] +" "+ delegate["full_name"]
else:
name = delegate["full_name"]
if str(amount) == "0.00":
amount = "Free"
else:
amount = "Rs."+str(amount)
sub_data = {
'delegate_no':str(delegate_no)
}
subject = Helper.merge_tags(mailData['subject'],sub_data)
m_data = {
'mail_content' : mailData['mail_content'],
'delegate' : delegate,
'conf' : conf
}
mail_content = Helper.convert_html_for_mail_screen(m_data)
html = render_template('conferenceapp/email/confirmation_mail_v1.html',mail_content=mail_content,conf=conf)
tricon_subject = "Book your Accommodation for TRICON now!"
tricon_tnoa_23_html = render_template('conferenceapp/email/tricon_tnoa_23_accommodation_mail.html',conf=conf)
if is_send == 1:
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if conf['backup_email_2']:
EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf)
if email != parent_email:
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,parent_email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if conf_id == 17:
EMAIL.sendMail(tricon_subject,tricon_tnoa_23_html,email,conf)
else:
return html
else :
return None
@app.route('/bo_receipt_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def FreeReceiptDelegagteMail(conf_id,conf_key,unique_id,receipt_data,is_send,email):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
template_name = "receipt_mail"
mailData = ConfAppModel().get_mail_template(template_name,conf_id)
if receipt_data is None :
receipt_datas = OfflineRegistrationModel().OR_BOreceipt_no_generate_and_get(unique_id,conf_id)
if receipt_datas:
receipt_data = receipt_datas[0]
if receipt_data:
if email:
email = email
else:
email = receipt_data['email']
receipt_no = receipt_data['receipt_no']
amount = receipt_data['amount']
conf_name = receipt_data['conf_name']
delegate_nos = receipt_data['delegate_nos']
delegate_id = receipt_data['delegate_ids']
if str(amount) == "0.00":
amount = "Free"
else:
amount = int(amount)
amount = f"{amount:,}"
amount_with_commas = amount
amount_fOR_convertion = int(receipt_data['amount'])
amount_in_words = Helper.amountTowords(amount_fOR_convertion)
amount_in_words = amount_in_words.title()
if amount == "Free" :
amount = amount
else:
amount = "Rs."+amount+"/-"
update_data = {
'amount_with_commas':amount_with_commas,
'amount_in_words':amount_in_words
}
receipt_data.update(update_data)
sub_data = {
'receipt_no':str(receipt_no),'amount':str(amount)
}
subject = Helper.merge_tags(mailData['subject'],sub_data)
m_data = {
'mail_content': mailData['mail_content'],'receipt_data': receipt_data,'conf': conf
}
mail_content = Helper.convert_html_for_mail_screen(m_data)
badge_print_url = "https://conference.numerotech.com/"+str(conf_id)+"/"+conf_key+"/delegate_batch_print_from_reg?del_nos="+delegate_nos
btn_link = '<a href="'+badge_print_url+'" target="_blank" ><i class ="fa fa-print fa-1x"></i> <span aria-hidden="true" title="Print Badge">Print Badge</span></a>'
if conf_id in [8]:
btn_link = btn_link
else:
btn_link = ""
if int(session.get('showSuccessMsg',0)) == 0:
session["showSuccessMsg"] = 1
if conf_id == 17 and amount_fOR_convertion in [500,1000,1500,2000]:
flash("An amount of {} inclusive of GST has been made towards WET & DRY lab registration.<br/>The receipt has been emailed to {}.<br/><br/> Receipt no. {}".format(amount,email,receipt_no),"successMsg")
else:
flash("An amount of {} has been made towards {} registration. The receipt has been email to {}.\nA delegate registration confirmation email has been sent to the email id of the delegate(s). Receipt no. {} .Delegate no(s). {} <br/> {}".format(amount,conf_name,email,receipt_no,delegate_nos,btn_link),"successMsg")
html = render_template('conferenceapp/email/receipt_email_v1.html',mail_content=mail_content,conf=conf)
if is_send == 1:
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if conf['backup_email_2']:
EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf)
return html
@app.route('/<int:conf_id>/<conf_key>/free_search_alerady_registered_delegate_details', methods = ["POST"])
def FreeSearchAlreadyRegisteredDelegateDetails(conf_id,conf_key):
if request.method == 'POST':
search_data = request.values.get("search_data")
user = OfflineRegistrationModel().OR_free_search_alerady_registered_delegate_details(search_data,conf_id)
if user == None:
html = None
else:
html = render_template('conferenceapp/free_search_alerady_registered_delegate_details.html' , user_data= user,conf_id=conf_id,conf_key=conf_key)
return json.dumps(html ,default=str)
@app.route('/bo_view_confirmation_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def FreeViewConfirmationDelegateMail(conf_id,conf_key,delegate_id):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
template_name = "confirmation_mail"
mailData = ConfAppModel().get_mail_template(template_name,conf_id)
delegates = OfflineRegistrationModel().OR_usp_del_get_delegates_by_delegate_id(delegate_id)
if delegates:
delegate = delegates[0]
if delegate:
email = delegate['email']
# email = 'karthiashokan23@gmail.com'
parent_email = delegate['parent_email']
# parent_email = 'karthiashokan23@gmail.com'
delegate_no = delegate['delegate_no']
amount = delegate['total_amount']
prefix = delegate["prefix"]
conf_name = delegate['conf_name']
title = "View Confimation Mail"
if prefix:
name = delegate["prefix"] +" "+ delegate["full_name"]
else:
name = delegate["full_name"]
if str(amount) == "0.00":
amount = "Free"
else:
amount = "Rs."+str(amount)
sub_data = {
'delegate_no':str(delegate_no)
}
subject = Helper.merge_tags(mailData['subject'],sub_data)
m_data = {
'mail_content' : mailData['mail_content'],
'delegate' : delegate,
'conf' : conf
}
mail_content = Helper.convert_html_for_mail_screen(m_data)
html_data = render_template('conferenceapp/email/confirmation_mail_v1.html',mail_content=mail_content,conf=conf)
html = render_template('conferenceapp/email/view_confirmation_email.html',delegate=delegate,conf_id=conf_id,conf_key=conf_key,delegate_id=delegate_id,conf=conf,subject=subject,html_data=html_data,title=title)
return html
else :
return None
# View Mail functions ---------------------------------------------------------------------------------
@app.route('/view_confirmation_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def ViewConfirmationMail(conf_id,conf_key,delegate_id):
return SendConfirmationDelegateMail(conf_id,conf_key,delegate_id,None,0,None)
@app.route('/view_receipt_mail/<int:conf_id>/<conf_key>/<unique_id>', methods = ["GET", "POST"])
def ViewReceiptMail(conf_id,conf_key,unique_id):
return SendReceiptDelegateMail(conf_id,conf_key,unique_id,None,0,None)
# Send Sample Mail functions --------------------------------------------------------------------------------
@app.route('/send_confirmation_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def SendConfirmationMail(conf_id,conf_key,delegate_id):
email = request.values.get('sample_email',None)
SendConfirmationDelegateMail(conf_id,conf_key,delegate_id,None,1,email)
return "Confirmation mail sent Successful"
@app.route('/send_receipt_mail/<int:conf_id>/<conf_key>/<unique_id>', methods = ["GET", "POST"])
def SendReceiptMail(conf_id,conf_key,unique_id):
email = request.values.get('sample_email',None)
SendReceiptDelegateMail(conf_id,conf_key,unique_id,None,1,email)
return "Receipt mail sent Successful"
@app.route('/send_confirmation_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def SendConfirmationDelegateMail(conf_id,conf_key,delegate_id,delegate,is_send,email=None):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
template_name = "confirmation_mail"
mailData = ConfAppModel().get_mail_template(template_name,conf_id)
if delegate is None:
delegates = OfflineRegistrationModel().OR_usp_del_get_delegates_by_delegate_id(delegate_id)
if delegates:
delegate = delegates[0]
if delegate:
if email:
email = email
else:
email = delegate['email']
parent_email = delegate['parent_email']
delegate_no = delegate['delegate_no']
amount = delegate['total_amount']
prefix = delegate["prefix"]
conf_name = delegate['conf_name']
if prefix:
name = delegate["prefix"] +" "+ delegate["full_name"]
else:
name = delegate["full_name"]
amount = "Rs."+str(amount)
if conf['is_gen_number'] :
sub_data = {
'delegate_no':str(ref_no)
}
else :
sub_data = {
'delegate_no':str(delegate_no)
}
subject = Helper.merge_tags(mailData['subject'],sub_data)
m_data = {
'mail_content' : mailData['mail_content'],
'delegate' : delegate,
'conf' : conf
}
mail_content = Helper.convert_html_for_mail_screen(m_data)
html = render_template('conferenceapp/email/confirmation_mail_v1.html',mail_content=mail_content,conf=conf)
if is_send == 1:
if email :
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if conf['backup_email_2']:
EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf)
# EMAIL.sendMail(subject,html,conf['backup_email_2'],conf)
elif not email :
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,parent_email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if email != parent_email :
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,parent_email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
else:
return html
else :
return None
@app.route('/send_receipt_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def SendReceiptDelegateMail(conf_id,conf_key,unique_id,receipt_data,is_send,email=None):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
template_name = "receipt_mail"
mailData = ConfAppModel().get_mail_template(template_name,conf_id)
if receipt_data is None :
receipt_datas = OfflineRegistrationModel().OR_BOreceipt_no_generate_and_get(unique_id,conf_id)
if receipt_datas:
receipt_data = receipt_datas[0]
if receipt_data:
if email:
email = email
else:
email = receipt_data['email']
receipt_no = receipt_data['receipt_no']
delegate_nos = receipt_data['delegate_nos']
delegate_id = receipt_data['delegate_ids']
amount = receipt_data['amount']
amount = int(amount)
amount = f"{amount:,}"
amount_with_commas = amount
amount_for_convertion = int(receipt_data['amount'])
amount_in_words = Helper.amountTowords(amount_for_convertion)
amount_in_words = amount_in_words.title()
conf_name = receipt_data['conf_name']
if amount == "Free" :
amount = "Free"
else:
amount = "Rs."+amount+"/-"
update_data = {
'amount_with_commas':amount_with_commas,
'amount_in_words':amount_in_words
}
receipt_data.update(update_data)
sub_data = {
'receipt_no':str(receipt_no),'amount':str(amount)
}
subject = Helper.merge_tags(mailData['subject'],sub_data)
m_data = {
'mail_content': mailData['mail_content'],'receipt_data': receipt_data,'conf': conf
}
mail_content = Helper.convert_html_for_mail_screen(m_data)
html = render_template('conferenceapp/email/receipt_email_v1.html',mail_content=mail_content,conf=conf)
if is_send == 1:
if conf['is_email_enable'] == 1:
data_1 = EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
if conf['backup_email_2']:
EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf)
else:
return html
else :
return None
@app.route('/view_confirmation_receipt_mail/<int:conf_id>/<conf_key>/<int:delegate_id>/<unique_id>', methods = ["GET", "POST"])
def ViewConfirmationReceiptMail(conf_id,conf_key,delegate_id,unique_id):
return SendConfirmationReceiptDelegateMail(conf_id,conf_key,delegate_id,unique_id,None,0,None)
@app.route('/send_confirmation_receipt_mail/<int:conf_id>/<conf_key>/<int:delegate_id>/<unique_id>', methods = ["GET", "POST"])
def SendConfirmationReceiptMail(conf_id,conf_key,delegate_id,unique_id):
email = request.values.get('sample_email',None)
SendConfirmationReceiptDelegateMail(conf_id,conf_key,delegate_id,unique_id,None,1,email)
return "Confirmation and Receipt mail sent Successful"
@app.route('/send_confirmation_receipt_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>/<unique_id>', methods = ["GET", "POST"])
def SendConfirmationReceiptDelegateMail(conf_id,conf_key,delegate_id,unique_id,receipt_data,is_send,email=None):
conf = OfflineRegistrationModel().OR_get_confUserModel(conf_id,conf_key)
now = datetime.now()
dt_string = now.strftime('%Y-%m-%d %H:%M:%S')
del_table_name = None
otp_1 = None
if conf :
del_table_name = conf["del_table_name"]
if receipt_data is None :
receipt_datas = OfflineRegistrationModel().OR_BOreceipt_no_generate_and_get(unique_id,conf_id)
if receipt_datas:
receipt_data = receipt_datas[0]
if receipt_data:
receipt_no = receipt_data['receipt_no']
r_amount = receipt_data['amount']
conf_name = receipt_data['conf_name']
delegate_nos = receipt_data['delegate_nos']
is_kit = receipt_data['d_is_kit']
company_name = receipt_data['d_company_name']
if str(r_amount) == "0.00":
r_amount = "Free"
else:
r_amount = int(r_amount)
r_amount = f"{r_amount:,}"
amount_with_commas = r_amount
amount_fOR_convertion = int(receipt_data['amount'])
amount_in_words = Helper.amountTowords(amount_fOR_convertion)
amount_in_words = amount_in_words.title()
if r_amount == "Free" :
r_amount = r_amount
else:
r_amount = "Rs."+r_amount+"/-"
delegate = None
if delegate is None:
delegates = OfflineRegistrationModel().OR_usp_del_get_delegates_by_delegate_id(delegate_id)
if delegates:
delegate = delegates[0]
if delegate:
if email:
email = email
else:
email = delegate['email']
# email = delegate['email']
# parent_email = delegate['parent_email']
delegate_no = delegate['delegate_no']
c_amount = delegate['total_amount']
prefix = delegate["prefix"]
conf_name = delegate['conf_name']
if prefix:
name = delegate["prefix"] +" "+ delegate["full_name"]
else:
name = delegate["full_name"]
########### Ganesan Nov 25 ,2022
# add kit counter for session map
# del_table_name = conf["del_table_name"]
# if del_table_name :
# kc_del_sess_tab = conf["kc_del_session_table_name"]
# fc_del_sess_tab = conf["fc_del_session_table_name"]
# if is_kit and int(is_kit) > 0 :
# session_table = "kc_sessions"
# del_ses_table = kc_del_sess_tab
# else :
# session_table = "fc_sessions"
# del_ses_table = fc_del_sess_tab
# del_id_int = int(delegate_no)
# insert_session = OfflineRegistrationModel().OR_sessionMapSpotReg(conf_id,del_id_int,session_table,del_ses_table,fc_del_sess_tab)
badge_print_url = "https://conference.numerotech.com/"+str(conf_id)+"/"+str(conf_key)+"/delegate_batch_print_from_reg?del_nos="+str(delegate_nos)+"&is_kit="+str(is_kit)
btn_link = '<a href="'+badge_print_url+'" target="_blank" > <i class ="fa fa-print fa-1x"></i> <span aria-hidden="true" title="Print Badge">Print Badge</span></a>'
if conf_id in [8,18,22]:
btn_link = btn_link
else:
btn_link = ""
if del_table_name and conf_id == 12 :
otp_1 = OfflineRegistrationModel().OR_getOTPforConfirmationMail(delegate_no,conf_id,del_table_name)
else :
pass
if otp_1 :
otp = otp_1["otp"]
else:
otp = None
confimation_mail_link = "/free_confirmation_delegate_mail/"+str(conf_id)+"/"+str(conf_key)+"/"+str(delegate_id)
delegate_no = '<a href="'+confimation_mail_link+'" target="_blank" >'+str(delegate_no)+'</a>'
success_msg = "An amount of {} has been made towards {} registration. The receipt has been email to {}.\nA delegate registration confirmation email has been sent to the email id of the delegate(s). Receipt no. {} .Delegate no(s). {} ".format(r_amount,conf_name,email,receipt_no,delegate_no)
subject = "Confirmation and Receipt Mail for Delegate Registration."
html = render_template('conferenceapp/email/confirmation_and_receipt_mail.html',delegate=delegate,delegate_id=delegate_id,receipt_data=receipt_data,conf_id=conf_id,conf_key=conf_key ,amount_in_words=amount_in_words,amount_with_commas=amount_with_commas,conf=conf,otp=otp)
if is_send == 1:
if conf['is_email_enable'] == 1:
data_1 = EMAIL.SendMailDuplicate(subject,html,email,conf)
if data_1:
data_1 = json.loads(data_1)
update_data = {
'delegate_id' : str(delegate_id),
'conf_id' : str(conf_id),
'created_at' : str(dt_string)
}
data_1.update(update_data)
OfflineRegistrationModel().insert_mandrill_logs(data_1)
else:
return html
else :
return None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists