Sindbad~EG File Manager

Current Path : /home/numerotech/workshops.numerotech.com/common_workshop_reg/core/controller/
Upload File :
Current File : //home/numerotech/workshops.numerotech.com/common_workshop_reg/core/controller/FreeRegController.py

from flask import Flask, request, Blueprint, jsonify, redirect, url_for,flash, render_template,session,Response,jsonify,json
from core.model.UserModel import UserModel
from core.model.BOModel import BOModel
from core.library.email import EMAIL
from .. import Cryptography,Auth,RouteGroup,Helper,Custom
from flask import session, app
from werkzeug.utils import secure_filename
import ast
from mandrill import Mandrill
from os.path import join, dirname,isfile, realpath
from datetime import datetime, timedelta
import os
import requests,mandrill,json,math
import base64
import flask

app = Blueprint('free_reg', __name__)




@app.route('/<int:conf_id>/<conf_key>/check_dob', methods = [ "GET","POST"])
def CheckDOB(conf_id,conf_key):
	conf            = Auth.getConf(conf_id,conf_key)
	date_of_birth   = request.values.get('dob',0)
	member_type_id  = request.values.get('member_type_id',0)
	conf_id         = request.values.get('conf_id',0)
	conf_key        = request.values.get('conf_key',0)
	society_id      = conf['society_id']
	delegate_id     = None
	
	if date_of_birth:
		try:
			dob     = datetime.strptime(date_of_birth, '%d-%m-%Y')
		except Exception as e:
			dob     = None
	else:
		dob         = None
	today           = datetime.now()
	if dob:
		age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day))
	else:
		age = 0

	# No Status id
	addons     = UserModel().get_addons(delegate_id,today,conf_id)
	reg_types  = UserModel().get_addon_reg_typeUserModel(conf_id)
	user_type  = UserModel().get_reg_type()
	if member_type_id == 1:
		user_type_id = "13" # KOS Member
	else:
		user_type_id = 14 # KOS Non-Member

	if age > 75 :
		status = 2 # if status id =2 , free reg above 75 age
		html   = render_template('users/reg_addons.html',member_type_id=member_type_id,addons=addons,reg_types=reg_types,conf=conf,user_type_id=user_type_id,str=str)
	else:
		status = 0
		html   = None
	
	data = {'status':status,'html':html,'age':age}
	return json.dumps(data ,default=str)




@app.route('/<int:conf_id>/<conf_key>/kos_mem_check_dob', methods = [ "GET","POST"])
def KOSMemCheckDOB(conf_id,conf_key):
	conf            = Auth.getConf(conf_id,conf_key)
	status          = 0
	html            = ""
	age             = 0 
	if conf_id in [4]:
		user_id         = request.values.get('user_id',0)
		member_type_id  = request.values.get('member_type_id',0)
		date_of_birth   = request.values.get('dob',0)
		conf_id         = request.values.get('conf_id',0)
		conf_key        = request.values.get('conf_key',0)
		society_id      = conf['society_id']
		delegate_id     = None

		if date_of_birth:
			try:
				dob     = datetime.strptime(date_of_birth, '%d-%m-%Y')
			except Exception as e:
				dob     = None
		else:
			dob         = None
		today           = datetime.now()
		if dob:
			age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day))
		else:
			age = 0
   
		if int(member_type_id) == 1 and age >= 70 and age <= 75:
			status          = 1
			is_custom_addon = 1 
			user_type_id    = "17"

		elif age > 75 :
			status          = 1
			is_custom_addon = 1
			user_type_id    = "32"
		else:
			status = 1
			is_custom_addon = None
			user_type_id = None
		
		# user       = UserModel().get_user(user_id,society_id)

		# No Status id
		addons     = UserModel().get_addons(delegate_id,today,conf_id,user_type_id,is_custom_addon)
		reg_types  = UserModel().get_addon_reg_typeUserModel(conf_id)
		
		html   = render_template('users/reg_addons.html',member_type_id=member_type_id,addons=addons,reg_types=reg_types,conf=conf,str=str,user_type_id=user_type_id)    
	data = {'status':status,'html':html,'age':age}
	return json.dumps(data ,default=str)



@app.route('/<int:conf_id>/<conf_key>/post_free_add_register', methods = ["POST"])
@RouteGroup.conf_required
def PostFreeAddRegister(conf_id,conf_key):
	conf        = Auth.getConf(conf_id,conf_key)
	msg             = ""
	status          = 1
	data            = ""
	delegate_id     = request.form['delegate_id']  
	parent_user_id  = request.form['parent_user_id'] 
	user_id         = request.form['user_id']

	now             = datetime.now()
	conf_id         = request.form['conf_id']
	conf_key        = request.form['conf_key']
	# conf            = UserModel().get_conf(conf_id,conf_key)
	society_id      = conf['society_id']
	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'] 
	mobile          = request.form['mobile']
	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
	gender          = request.form['gender'] or None
	address1        = request.form['address1'] or None
	address2        = request.form['address2'] or None
	address3        = request.form['address3'] or None
	city            = request.form['city'] or None
	pincode         = request.form['pincode'] or None
	state_id        = request.form['state_id'] or None
	country_id      = request.form['country_id'] or None
	mc_number       = request.form['mc_number'] or None
	mc_state_id     = request.form['mc_state_id'] or None
	membership_no   = request.form['membership_no'] or None
	if int(user_id) > 0:
		member_type_id = request.form['member_type_id'] or None
	else:
		member_type_id = 2      
			
	conference_id   = conf_id
	time_set        = request.form['time_set'] or None
	user_type_id    = None
	
	reg_types         = UserModel().get_addon_reg_typeUserModel(conf_id)
	addons            = UserModel().get_addons(delegate_id,now,conf_id)
	reg_addons        = {} 
	insert_del_addons = []
	delete_del_addons = [] 

	created_at_date   = {'created_at': dt_string}
	updated_at_date   = {'updated_at': dt_string} 

	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)]
				user_type_id = addon.get("user_type_id")
				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"           : addon.get("amount",0),
								 "original_amount"  : addon.get("amount",0),
								 "reg_status"       : 0       
					}
					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 field is mandatory."})  
			status = 0;
			msg="Please choose the delegate type"
			data = { 
				'msg':msg,
				'status':status,
				 'reg_validation' :  reg_Validation
			}
			return jsonify(data)
	if int(user_id) > 0 and int(user_id) != int(parent_user_id):
		user = UserModel().get_user(user_id,society_id,conf_id)
		del_data = {
				'parent_user_id': parent_user_id,
				'prefix'        : user["prefix"],
				'user_id'       : user["user_id"] if int(user["user_id"]) > 0 else None ,
				'full_name'     : user["full_name"],  
				'email'         : user["email"],
				'mobile'        : user["mobile"],
				'dob'           : user["dob"],
				'gender'        : user["gender"],
				'address1'      : user["address1"],
				'address2'      : user["address2"],
				'address3'      : user["address3"],
				'city'          : user["city"],
				'pincode'       : user["pincode"],
				'state_id'      : user["state_id"],
				'country_id'    : user["country_id"],
				'mc_number'     : user["mc_number"],
				'mc_state_id'   : user["mc_state_id"],
				'conference_id' : conference_id,
				'membership_no' : user["membership_no"] or None,
				'member_type_id': user["member_type_id"],
				'society_id'    : user['society_id'],
				'reg_type_id'   : user_type_id,
				'del_status_id' : 0
			}   
	else:
		del_data = {
					'parent_user_id': parent_user_id,
					'prefix'        : prefix,
					'user_id'       : user_id if int(user_id) >0 else None,
					'full_name'     : full_name,
					'email'         : email,
					'mobile'        : mobile,
					'dob'           : dob,
					'gender'        : gender,
					'address1'      : address1,
					'address2'      : address2,
					'address3'      : address3,
					'city'          : city,
					'pincode'       : pincode,
					'state_id'      : state_id,
					'country_id'    : country_id,
					'mc_number'     : mc_number,
					'mc_state_id'   : mc_state_id,
					'conference_id' : conference_id,
					'membership_no' : membership_no,
					'member_type_id': member_type_id,
					'society_id'    : society_id,
					'reg_type_id'   : user_type_id,
					'del_status_id' : 0
				}

	if int(time_set) == 0:
		del_data.update(created_at_date)
	else:
		del_data.update(updated_at_date)                


	if int(delegate_id) > 0:
		delegate     = UserModel().get_delegate(delegate_id)
		if delegate:
			if delegate['delegate_no'] and delegate['delegate_no'] >0:
				status = 0
				msg    = "Registration Already Completed."
		else:
			status = 0
			msg    = "your request cannot be processed. click here to try after some time"

		if status == 1:
			update        = UserModel().update_delegateUserModel(delegate_id,del_data)
			UserModel().save_delegates_addons(delegate_id,insert_del_addons,delete_del_addons,now)
			incompleted_template = get_parent_incompleted_delegates(parent_user_id,conf_id,conf_key)
		data = { 
				'msg':'Update completed ...',
				'status':status,
				'incompleted_template' : incompleted_template,
				 'reg_validation' :  reg_Validation
			}
		return jsonify(data)    
	else:
		existing_data = None
		if int(user_id) > 0 :
			existing_data       = UserModel().get_check_exsits_delegate(user_id,parent_user_id,conf_id)
			
		if existing_data:
			delegate_no  = existing_data["delegate_no"]

			if delegate_no and delegate_no > 0 :
				data={ 'msg':'Registration Already Completed.','status' : 0,'data' : ''}
					
				return jsonify(data)
			else:
				delegate_id     = UserModel().insert_delegate(del_data)
				UserModel().save_delegates_addons(delegate_id,insert_del_addons,delete_del_addons,now)

				incompleted_template = get_parent_incompleted_delegates(parent_user_id,conf_id,conf_key)
				data={ 'msg':'Add Successfully','status': 1,'incompleted_template':incompleted_template}
				return jsonify(data)    

		else:   
			if status == 1:
				delegate_id     = UserModel().insert_delegate(del_data)
				UserModel().save_delegates_addons(delegate_id,insert_del_addons,delete_del_addons,now)

				incompleted_template = get_parent_incompleted_delegates(parent_user_id,conf_id,conf_key)
				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
				user_id         = Auth.user()['user_id']
				payment_for     = app_name
				payment_method  = "free"
				if int(conf_id) == 37:
					remarks = "Free Registration For Faculty"
				else:
					remarks = "Free Registration For 75 years Above"
				txn_id          = None
				unique_id       = app_key+"_"+unique_id
				prefix          = Auth.user(society_id)['prefix'] or None
				name            = Auth.user(society_id)['full_name'] or None
				if prefix :
					name_1 = prefix + " " + name
				else :
					name_1 = name

				full_name        = name_1
				email            = Auth.user(society_id)['email']
				mobile           = Auth.user(society_id)['mobile']
				user_id          = Auth.user(society_id)['user_id']
				delegate_ids     = delegate_id
				is_generate      = None
				app_type         = Helper.AppType
				receipt_mail     = "receipt_mail"
				confimation_mail = "confimation_mail"
				generate_payement = BOModel().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)
				return redirect(url_for('free_reg.FreeRegUpdates',user_id=user_id,unique_id=unique_id,payment_method=payment_method,email=email,receipt_mail=receipt_mail,confimation_mail=confimation_mail,conf_id=conf_id,conf_key=conf_key))
			else:
				data= { 'msg':'','status' : 0,'data':'','reg_validation':reg_Validation}
				return jsonify(data)


@app.route('/free_reg_updates/<int:conf_id>/<conf_key>', methods = ["GET", "POST"])
@RouteGroup.conf_required
def FreeRegUpdates(conf_id,conf_key):
	conf                = Auth.getConf(conf_id,conf_key)
	society_id          = conf['society_id']
	status              = "success"
	user_id             = request.values.get('user_id')
	email               = request.values.get('email')
	mobile              = request.values.get('mobile')
	unique_id           = request.values.get('unique_id')
	amount              = request.values.get('amount')
	payment_method      = request.values.get('method')
	now                 = datetime.now()
	dt_string           = now.strftime('%Y-%m-%d %H:%M:%S')
	data                = {'status' : status,'updated_at' :dt_string,'paid_at' :dt_string}
	update_and_get_data = UserModel().UserupdatePayment(unique_id,data,dt_string) # update payment status in your table
	is_generate_link_payment = 0
	if update_and_get_data == "updated" and status =="success":
		u = UserModel()
		generatedDelegates = u.Userdelegate_no_generate(unique_id,conf_id)
		if generatedDelegates:
			for delegate in generatedDelegates:
				delegate_id  = delegate['delegate_id']
				is_generate_link_payment  = delegate['is_generate_link_payment']
				# ConfirmationDelegateMail(conf_id,conf_key,delegate_id,delegate,1)
				if conf_id not in [50,49,51]:
					ConfirmationDelegateMail(conf_id,conf_key,delegate_id,None,1)
			# generatedDelegates[0].parent_user_id  

		# Added Status
		if payment_method and payment_method.lower() != "free":
			receipt_datas = u.receipt_no_generate_and_get(unique_id,conf_id);
		else:
			pass
		# Added Status



# 		if receipt_datas:
# # 			ReceiptDelegagteMail(conf_id,conf_key,unique_id,receipt_datas[0],1)
# 			pass
	else:   
		flash("An attempt to make the payment has failed. Please try again to make the payment.  For any assistance, please click here to send an email to support","errorMsg")    
	
	
	incompleted_template    = get_parent_incompleted_delegates(user_id,conf_id,conf_key)
	completed_template  = get_parent_completed_delegates(user_id,conf_id,conf_key)
	delegate_dashboard_html =  RegisterDashboard(conf_id,conf_key)
	check_user_del          = UserModel().check_user_delegateUserModel(user_id,society_id,conf_id)
	status = 3
	if conf_id in [50,49,51]:
		msg = "Profile Update Completed."
	else:
		msg = "Registered Completed <br> <br> The confirmation mail has been sent to your registered mail-id  {}.".format(email)
	data={
			'status':status,
			'msg':msg,
			'incompleted_template':incompleted_template,
			'completed_template':completed_template,
			'delegate_dashboard_html':delegate_dashboard_html,
			'check_user_del':check_user_del
	}
	return jsonify(data)


@app.route('/<int:conf_id>/<conf_key>/<parent_user_id>/get_parent_incompleted_delegates', methods = ["GET", "POST"])
def get_parent_incompleted_delegates(parent_user_id,conf_id,conf_key):
	conf        = Auth.getConf(conf_id,conf_key)
	unique_id = None
	delegateData    = UserModel().get_incompleted_delegates_by_parent_user_idUserModel(parent_user_id,unique_id,conf_id,reg_mode=0)

	if delegateData:
		total_amount = 0
		for index , value in enumerate(delegateData):
			total_amount = total_amount + (value['total_amt'] if value['total_amt'] is not None else 0)
		del_html_data = render_template('users/incompleted_information.html' ,user_data = delegateData,user_id = parent_user_id,conf_id =conf_id,conf_key=conf_key,total_amount=total_amount,conf=conf)
	else:
		del_html_data = ""
	return del_html_data


@app.route('/<int:conf_id>/<conf_key>/<parent_user_id>/get_parent_completed_delegates', methods = ["GET", "POST"])
def get_parent_completed_delegates(parent_user_id,conf_id,conf_key):
	conf           = Auth.getConf(conf_id,conf_key)
	delegateData   = UserModel().get_completed_delegates_by_parent_user_id_UserModel(parent_user_id,conf_id)
	addons         = UserModel().get_addon_reg_typeUserModel(conf_id)
	addon_type_ids = UserModel().get_addon_types(conf_id)
	show_conf_ids  = addon_type_ids['show_conf_ids']
	if delegateData:
		del_html_data =   render_template('users/completed_information.html' ,user_data = delegateData,conf_id =conf_id,conf_key=conf_key,conf=conf,addons=addons,addon_type_ids=addon_type_ids,str=str,show_conf_ids=show_conf_ids)
	else:
		del_html_data = ""
	return del_html_data
	

@app.route('/receipt_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def ReceiptDelegagteMail(conf_id,conf_key,unique_id,receipt_data,is_send):
	conf            = Auth.getConf(conf_id,conf_key)
	template_name   = "receipt_mail"
	mailData        = UserModel().get_mail_template(template_name,conf_id)
	if receipt_data is None :
		receipt_datas   = UserModel().receipt_no_generate_and_get(unique_id,conf_id)
		if receipt_datas:
			receipt_data = receipt_datas[0]
	if receipt_data:
		email                 = receipt_data['email']
		# email                   = 'karthiashokan23@gmail.com' 
		receipt_no            = receipt_data['receipt_no']
		delegate_nos          = receipt_data['delegate_nos']
		amount                = receipt_data['amount']
		amount                = int(amount)
		amount                = f"{amount:,}"
	   
		if amount == "Free" :
			amount = "Free"
		elif float(amount) == 0 :
			amount = "Free"
		else:
			amount = "Rs."+amount+"/-"

		amount_with_commas    = amount
		


		if amount == "Free" : 
			amount_in_words = "Free"
		else :
			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+"/-"


		# 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']
		
		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)
		
		
# 		subject    = "Receipt #{} for delegate registration ({})".format(receipt_no,amount)
		# flash("An amount of Rs.{} 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(amount,conf_name,email,receipt_no,delegate_nos),"successMsg")
# 		html       = render_template('email/receipt_email.html',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)
		html      = render_template('email/receipt_email_v1.html',mail_content=mail_content,conf=conf)
		if is_send == 1:
			if conf['is_email_enable'] == 1:
				EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf) # if we want send receipt mail for free reg uncommand this 
				if conf['backup_email_2']:
					EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf) # if we want send receipt mail for free reg uncommand this
		else:   
			return html     
	else :
		return None

@app.route('/confirmation_delegate_mail/<int:conf_id>/<conf_key>/<delegate_id>', methods = ["GET", "POST"])
def ConfirmationDelegateMail(conf_id,conf_key,delegate_id,delegate,is_send):
	conf            = Auth.getConf(conf_id,conf_key)
	template_name   = "confirmation_mail"
	mailData        = UserModel().get_mail_template(template_name,conf_id)
	if delegate is None:
		delegates   = BOModel().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']
		ref_no       = delegate['ref_no']
		if prefix:
			name = delegate["prefix"] +" "+ delegate["full_name"]
		else:
			name = delegate["full_name"]
		amount   = "Rs."+str(amount) 
		
		is_gen_number = conf['is_gen_number']


		# Reference number added here
		if is_gen_number == 'ref_number':
			subject = "Confirmation of registration - "+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('email/confirmation_mail_v1.html',mail_content=mail_content,conf=conf)
		
# 		subject  = "Confirmation of registration - {}".format(delegate_no)
		# subject  = "VRSI 2022. Delegate No {} .Amount Rs.{}".format(delegate_no,amount)
# 		html     = render_template('email/confirmation_mail.html',delegate=delegate,conf_id=conf_id,conf_key=conf_key,delegate_id=delegate_id,conf=conf)
		if is_send == 1:
			if email :
				if conf['is_email_enable'] == 1:
					EMAIL.MailTemplateSendMail(subject,html,email,mailData,conf)
					if conf['backup_email_2']:
						EMAIL.MailTemplateSendMail(subject,html,conf['backup_email_2'],mailData,conf)
			elif not email :
				if conf['is_email_enable'] == 1:
					EMAIL.MailTemplateSendMail(subject,html,parent_email,mailData,conf)
			if email != parent_email :
				if conf['is_email_enable'] == 1:
					EMAIL.MailTemplateSendMail(subject,html,parent_email,mailData,conf)    
		else:   
			return html     
	else :
		return None
		
		
@app.route('/<int:conf_id>/<conf_key>/register_dash', methods = ["GET", "POST"])
def RegisterDashboard(conf_id,conf_key):
	conf_data     = UserModel().get_conference(conf_id,conf_key)
	now           = datetime.now()
	curr_dt       = now.strftime("%Y-%m-%d %H:%M:%S")
	conf          = Auth.getConf(conf_id,conf_key)
	dict_1        = {}
	society_id    = conf['society_id']
	users         = Auth.user(society_id)
	user_id       = users["user_id"]
	membership_no = users["membership_no"]
	prefix        = users["prefix"]
	full_name     = users["full_name"] or ' '

	e_support_email = conf['e_support_email']
	addons_member_list = conf_data['addons_member_list']
	if addons_member_list:
		parent_user_id_count = UserModel().get_parent_user_id_count(conf_id,user_id)
		if parent_user_id_count['parent_user_id'] >= addons_member_list:
			is_show_member_div = 1
		else:
			is_show_member_div = 0	
	else:
		is_show_member_div = 0

	check_addon   = UserModel().get_check_addons_UserModel(user_id,conf_id)
	data          = UserModel().get_state_country_users_type(user_id,society_id,None,conf_id,None,None)
	code          = UserModel().check_appliction_to_close_or_openUserModel(conf_id,curr_dt)
	user_reg_content = UserModel().get_user_register_content(conf_id)
	# membership_no = Auth.user(society_id).get('membership_no')
	full_name =   "Dr. " + full_name if not prefix else prefix + " "  + full_name  
	# prefix        = 'Dr. ' if not Auth.user(society_id).get('prefix') else Auth.user(society_id).get('prefix')
	if conf_id in [18,5,26,49,58] : # BOA 2023
		show_content = "Welcome <b> " + full_name +"<hr/>"
	
	else:
		if membership_no:
			# show_content = "Welcome  <b> "+prefix+" {}.</b> <br/> You are logged in as a member.".format(Auth.user(society_id).get('full_name'))
			show_content = "Welcome  <b> "+full_name+" </b> <hr/> You are logged in as a member."
		else:
			if conf_id in [19,54]:
				# show_content ="Welcome <b> "+prefix+" {}.</b> <br/> You are logged in as a non-member since the email id you have used to login is not associated with any membership record.<br/>Visit <a href='https://asiindia.org/member-application/' target='_blank'>https://asiindia.org/member-application/</a> to apply for ASI membership.<br/><br/>If you are a member, please login with the email id associated with your membership record.<br/><br/> For any assistance, please wrote to <b>{}</b> and get a response in one working day.".format(Auth.user(society_id).get('full_name'),conf['e_support_email'])
				show_content ="Welcome <b> "+full_name+" </b> <hr/> You are logged in as a non-member since the email id you have used to login is not associated with any membership record.<br/>Visit <a href='https://asiindia.org/member-application/' target='_blank'>https://asiindia.org/member-application/</a> to apply for ASI membership.<br/><br/>If you are a member, please login with the email id associated with your membership record.<br/><br/> For any assistance, please wrote to <b> "+e_support_email+" </b> and get a response in one working day."
			else:
				show_content ="Welcome <b> "+full_name+"</b> <hr/> You are logged in as a non-member since the email id you have used to login is not associated with any membership record.<br/>If you are a member, please login with the email id associated with your membership record.<br/><br/> For any assistance, please wrote to <b> "+e_support_email+" </b> and get a response in one working day."
	
	for index,value in enumerate(data):
		if index == 0:
			state_id = value[0]
		if index == 1:
			country_id = value[0]
		if index == 2:
			user = value[0]
			user_data = user
		if index == 3:
			reg_type = value[0]
		if index == 7:
			delegate = value
			if delegate:
				delegate = delegate[0]
			else:
				delegate = None 	


	for value in check_addon:
		status      = value['status']
		msg         = value['msg']
		count       = value['count']

	if count > 0:
		if status == 1:
			flash(msg,"successMsg")
			
	if conf_id == 17:
		display_addons = UserModel().get_wetdrylab_open_close(conf_id)
		display_addon = display_addons.get('display_addon')
	else:
		display_addon = 0		
	
	delegateData            = UserModel().get_completed_delegates_by_parent_user_id_UserModel(user_id,conf_id)
	
	html_data = render_template('users/delegate_dashboard_page.html',states=state_id,countries=country_id,user=user,user_data=user_data,reg_type=reg_type,str=str,type=type,conf=conf,code=code,delegateData=delegateData,show_content=show_content,int=int,display_addon=display_addon,user_reg_content=user_reg_content,is_show_member_div=is_show_member_div)
	return html_data		

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists