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/SpotRegController.py

from flask import request, Blueprint, jsonify, redirect, url_for,flash, render_template,session,json
from core.model.SpotRegModel import SpotRegModel
from core.model.UserModel import UserModel
from core.model.BOModel import BOModel
from .. import Cryptography
from .. import Helper
from core.library.email import EMAIL
# from flask import session, app
from random import randint
import datetime
from .. import Cryptography,Auth,RouteGroup,Helper,Custom
from datetime import timedelta,date,datetime,time

from werkzeug.utils import secure_filename

from os.path import join, dirname, realpath
import os
import flask
import string
 
from flask import Flask
import boto3, botocore
from botocore.exceptions import ClientError
import requests

from collections import defaultdict
import math
from core import app

app = Blueprint('spot_reg', __name__)



@app.route('/<int:conf_id>/<conf_key>/check', methods = ["GET", "POST"])
@RouteGroup.conf_required
def Check(conf_id,conf_key):
	email = "ashwint03@yahoo.co.in"
	data  = SpotRegModel().check_email(email,conf_id)
	return json(data)


@app.route('/<int:conf_id>/<conf_key>/post_data', methods = ["POST"])
@RouteGroup.conf_required
def postData(conf_id,conf_key):
	# email = "ashwint03@yahoo.co.in"
	data  = SpotRegModel().check_email(email,conf_id)
	is_interest   =	request.form['is_interest'] or None
	arrival_date  =	request.form['arrival_date'] or None
	arrival_time  =	request.form['arrival_time'] or None
	depature_date =	request.form['depature_date'] or None 
	depature_time =	request.form['depature_time'] or None
	reason        =	request.form['reason'] or None

	data = {
				'is_interest'   : is_interest,
				'arrival_date'  : arrival_date,
				'arrival_time'  : arrival_time,
				'depature_date' : depature_date,
				'depature_time' : depature_time,
				'reason'        : reason
	}
	update =  SpotRegModel().update_email(email,conf_id,is_interest,arrival_date,arrival_time,depature_date,depature_time,reason)
	
	return json(update)



@app.route('/<int:conf_id>/<conf_key>/self_spot_reg', methods = ["GET", "POST"])
@RouteGroup.conf_required
def ViewSpotReg(conf_id,conf_key):
	now              = datetime.now()
	curr_dt          = now.strftime("%Y-%m-%d %H:%M:%S")
	conf             = BOModel().get_conf(conf_id,conf_key)
	society_id       = conf['society_id']
	now              = datetime.now()
	delegate_id      = 0
	is_custom_addons = 1
	state_id         = UserModel().get_states()  
	country_id       = UserModel().get_country()
	user_type_data   = SpotRegModel().get_user_type(conf_id)
	reg_types        = BOModel().get_addon_reg_type(conf_id)
	addons           = UserModel().get_addons(delegate_id,curr_dt,conf_id,None,is_custom_addons)
	badge_role       = BOModel().get_badge_model(conf_id)
	return render_template('spot_registration/spot_reg_form.html',states=state_id,countries=country_id,user_type_data=user_type_data,reg_types=reg_types,addons=addons,str=str,type=type,conf=conf,badge_role=badge_role)



@app.route('/<int:conf_id>/<conf_key>/post_spot_reg', methods = ["POST"])
@RouteGroup.conf_required
def PostSpotReg(conf_id,conf_key):
	now             = datetime.now()
	dt_string       = now.strftime("%Y-%m-%d %H:%M:%S")
	conf            = BOModel().get_conf(conf_id,conf_key)
	
	conf_id         = request.form['conf_id']
	conf_key        = request.form['conf_key']
	society_id      = conf['society_id']
	delegate_id     = 0
	
	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.values.get('gender',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
	utr_number      = request.values.get('utr_no') or None
	reg_type        = request.values.get('reg_type') or None
	payment_method  = request.values.get('payment_method') or "UPI"
	
	if membership_no:
		member_type_id = 1
	else:
		member_type_id = 2  
			
	conference_id   = conf_id
	total_amount    = 0
	
	del_data = {
					'prefix'        : prefix,
					'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,
					'utr_number'    : utr_number,
					'payment_method': payment_method,
					'reg_type'      : reg_type
				}
				
		
	spot_reg_data   = SpotRegModel().insert_spotregdata_getdata(del_data)
	register_id     = spot_reg_data["register_id"]

	status = 1
	msg    = "Your <b> Form Code </b> is " +   str(register_id)+ ". Please share this form code to the offline registration team."
	data = { 
			'msg'				   : msg,
			'status'			   : status
			}

	file  = request.files.get('files',None)
	if file :
		acl            ="public-read"
		s3             = boto3.client("s3",aws_access_key_id='AKIAILLDAQ7NFUMVOYLQ',aws_secret_access_key='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')
		filename       = secure_filename(file.filename)
		file_extension = os.path.splitext(filename)[1]
		file_str       = "payment_proof"+file_extension
		if " " in file_str :
			file_str   = file_str.replace(" ","")
		else :
			pass

		try:
			bucket     = "delegateapp"
			
			foldername = "spot_attachement"
			file_path  = "https://"+bucket+".s3-ap-southeast-1.amazonaws.com/"+foldername+"/"+str(conf_key)+"/"+str(register_id)
			# data_1     = {'bucketname' : societyData['aws_bucket'],'foldername':foldername,'file_name':file_str+"?"+str(Helper.getcurrenttimestamp()),'msg':'Image successfully uploded','file_extension':file_extension,'status':1} 
# 			file_path  = "https://delegateapp.s3-ap-southeast-1.amazonaws.com/"+foldername+"/"+str(register_id)
			data_1     = {
						'attach_path'      : file_path,
						'attach_file_name' : file_str,
						'updated_at'       : now
						 }
			update_data = SpotRegModel().update_payment_proof_attachemant(register_id,data_1)
			response   = s3.upload_fileobj(file, bucket,foldername+'/'+str(conf_key)+'/'+str(register_id)+'/'+ file_str, ExtraArgs={"ACL": acl,"ContentType": file.content_type})				 
		except ClientError as e:
			logging.error(e)
			data = {
					'msg': 'Please try again... ',
					'status': 0

			}	
	else:
		pass
	
	return jsonify(data)
	return redirect (url_for('spot_reg.ViewSpotReg'))


@app.route('/<int:conf_id>/<conf_key>/bo_spot_registration', methods = ["GET", "POST"])
@RouteGroup.conf_required
@RouteGroup.bologin_required
def BoSpotRegistration(conf_id,conf_key):
	now              = datetime.now()
	curr_dt           = now.strftime("%Y-%m-%d %H:%M:%S")
	first_row_data  = None
	second_row_data = None
	count_per_row   = 5
	i               = 0 
	conf             = UserModel().get_confUserModel(conf_id,conf_key)
	society_id       = conf['society_id']
	user_id          = Auth.user(society_id)['user_id']
	delegate         = None
	badge_role       = BOModel().get_badge_model(conf_id)

	society_id       = conf['society_id']
	parent_user_id   = Auth.user(society_id)['user_id']
	delegate_id      = 0
	is_custom_addons = 1
	payment_types    = BOModel().get_payment_types(conf_id)
	reg_types        = BOModel().get_addon_reg_type(conf_id)
	addons           = BOModel().get_addonsBOModel(delegate_id,curr_dt,conf_id,None,is_custom_addons)
	state_id         = UserModel().get_states()  
	country_id       = UserModel().get_country()
	get_spot_data 	 = SpotRegModel().get_spot_code(conf_id)
	
	if get_spot_data :
		s = get_spot_data
		a = [s[count_per_row*i:count_per_row*i+count_per_row] for i in range(0,math.ceil(len(s)/count_per_row))]
		if len(a) > 0 :
			first_row_data = a[0]
		if len(a) > 5 :
			second_row_data = a[1]	
	else :
		pass


	get_remark_data  = BOModel().get_remark_value(conf_id,user_id)
	return render_template('spot_registration/bo_common_spot_registration.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,get_remark_data=get_remark_data,first_row_data=first_row_data, second_row_data=second_row_data,get_spot_data=get_spot_data) 
		
'''------------------------------     SPOT REGISTRATION      ----------------------------------------'''
@app.route('/<int:conf_id>/<conf_key>/bo_common_spot_post_add_register', methods = ["POST","GET" ])
@RouteGroup.conf_required
def BoSpotCommonPostAddRegister(conf_id,conf_key):
	conf              = Auth.getConf(conf_id,conf_key)
	society_id        = conf['society_id']
	msg               = ""
	status            = 1
	data              = ""
	delegate_id       = 0  
	parent_user_id    = Auth.user(society_id)['user_id']
	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

	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         = BOModel().get_addon_reg_type(conf_id)
	addons            = BOModel().get_addonsBOModel(delegate_id,curr_dt,conf_id)

	reg_addons        = {} 
	insert_del_addons = []
	delete_del_addons = [] 

	created_at   = now
	user_type_id = None
	

	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"           : 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      
					}
					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;
			
	if register_id:
		user       = SpotRegModel().get_search_spot_user(register_id,conf_id)
		if user:
			if user['delegate_no'] is not None:
				status = 2
				delegate_no = None
				user_details     = BOModel().get_delegate_details_from_delegate_no(user['delegate_no'],conf_id)
				if user_details:
					confimation_mail_link = "/bo_view_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>'
				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. <span style = "color:blue;" >'+str(delegate_no) if delegate_no else str(user['delegate_no'])+'</span>',
						'user'	 : user,
						'payment_screenshot': payment_screenshot
				}
				msg = 'Already registered. Delegate no. '+str(delegate_no) if delegate_no else str(user['delegate_no'])
				data = { 'msg':msg,'data':data,'status':2,'reg_validation' :  reg_Validation}
				return jsonify(data)		

	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,
				'reg_type_id'   : user_type_id
			}
		
	if status == 1:
		delegate_ids     = BOModel().insert_delegate(del_data)
		BOModel().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          = Auth.user(society_id)['user_id']
		full_name        = Auth.user(society_id)['full_name']
		email            = Auth.user(society_id)['email']
		mobile           = Auth.user(society_id)['mobile']
		if delegate_ids:
			delegate_id = delegate_ids
			delegate =  UserModel().get_delegate(delegate_id)
			name         = delegate['full_name']
			prefix       = delegate['prefix']
			full_name    = prefix + " " + name if prefix else name
			# full_name    = delegate['full_name']
			email        = delegate['email']
			mobile       = delegate['mobile']

		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
		delegate_ids    = delegate_id
		app_type        = Helper.AppType
		is_generate     = 1

		update_payment_proof = {
								'attach_path'     : attach_path,
								'attach_file_name': attach_file_name,
								'unique_id'       : unique_id,
								'created_at'      : now,
								'attach_type'     : 'payment_proof',
								'delegate_id'     : delegate_id, 
								'conf_id'         : conf_id,
								'user_id'         : user_id
		}
		
		if attach_path and attach_file_name:
			update_data = SpotRegModel().insert_payment_screenshot(update_payment_proof)

		if payment_method == "Free": # return "free" 
			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)
		else: # return "cash"
			generate_payement = BOModel().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('back_office.BoSpotCommonPaymentServerResponse',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>/bo_spot_search_register', methods = ["GET", "POST"])
@RouteGroup.conf_required
def BospotSearchRegister(conf_id,conf_key):
	conf            = Auth.getConf(conf_id,conf_key)
	society_id      = conf['society_id']
	if request.method == 'POST':
		search     = request.values.get('register_no')
		user       = SpotRegModel().get_search_spot_user(search,conf_id)
		if user:
			attach_path      = user['attach_path'] or None
			attach_file_name = user['attach_file_name'] or None
			if user and user['delegate_no'] :
				user_details     = BOModel().get_delegate_details_from_delegate_no(user['delegate_no'],conf_id)
				if user_details:
					confimation_mail_link = "/bo_view_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>'
					if attach_path and attach_file_name:
						payment_screenshot = attach_path+"/"+attach_file_name
					else:
						payment_screenshot = None
					status = 2
					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
					}
		
			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(user['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:
			status = 0
			data = {
				'status':status,
				'msg'   : 'No Record Found...'
			}
			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>/bo_spot_search_register', methods = ["GET", "POST"])
# @RouteGroup.conf_required
# def BospotSearchRegister(conf_id,conf_key):
# 	conf            = Auth.getConf(conf_id,conf_key)
# 	society_id      = conf['society_id']
# 	if request.method == 'POST':
# 		search     = request.values.get('register_no')
# 		user       = SpotRegModel().get_search_spot_user(search,conf_id)
# 		if user and user['delegate_no'] :
# 			user_details     = BOModel().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 = "/bo_view_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>/bo/bo_search_alerady_registered_delegate_details', methods = ["POST"])
@RouteGroup.conf_required
def BoSearchAlreadyRegisteredDelegateDetails(conf_id,conf_key):
	if request.method == 'POST':
		conf        = Auth.getConf(conf_id,conf_key)
		search_data 			 = request.values.get("search_data")
		user      		 = BOModel().bo_search_alerady_registered_delegate_details(search_data,conf_id)
		if user == None:
			html = None
		else:   
			html = render_template('backoffice_user/bo_search_alerady_registered_delegate_details.html' , user_data= user,conf_id=conf_id,conf_key=conf_key,conf=conf)
		return json.dumps(html ,default=str)


@app.route('/<int:conf_id>/<conf_key>/bo_common_spot_remark',methods = ["POST","GET" ])
@RouteGroup.conf_required
def BoCommonSpotRemark(conf_id,conf_key):
	
	now = datetime.now()
	current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
	conf        = Auth.getConf(conf_id,conf_key)
	society_id  = conf['society_id']
	user_id          = Auth.user(society_id)['user_id']
	full_name        = Auth.user(society_id)['full_name']
	email            = Auth.user(society_id)['email']
	mobile           = Auth.user(society_id)['mobile']
	remarks          = request.values.get('remark_new')
	is_default       = 1
	data  = {
			  'is_default'	 : is_default,
			  'conf_id'		 : conf_id,
			  'user_id'		 : user_id,
			  'full_name'	 : full_name,
			  'email'		 : email,
			  'mobile'		 : mobile,
			  'remarks'		 : remarks,
			  'created_at'	 : current_dt,
			  

	}
	check_is_default = BOModel().Check_is_defualt(conf_id,user_id)
	
	data1  = {
			  'is_default'	 : is_default,
			  'conf_id'		 : conf_id,
			  'user_id'		 : user_id,
			  'full_name'	 : full_name,
			  'email'		 : email,
			  'mobile'		 : mobile,
			  'remarks'		 : remarks,
			  'updated_at'	 : current_dt
	}
	if(check_is_default == "success"):
		update = BOModel().update_remark(conf_id,user_id,data1)
		
	else:
		new_remark_id = BOModel().insert_remark(data)
	get_remark_data = BOModel().get_spot_remark(conf_id,user_id)
	remark_data     = get_remark_data["remarks"] or None
	remark_view     = { 'remark_data' : remark_data,'status':1}
	return json.dumps(remark_view,default=str)



@app.route('/<int:conf_id>/<conf_key>/bo_common_remove_default',methods = ["POST","GET" ])
@RouteGroup.conf_required
def BoCommonRemoveRemark(conf_id,conf_key):
	now = datetime.now()
	current_dt = now.strftime("%Y-%m-%d %H:%M:%S")
	conf        = Auth.getConf(conf_id,conf_key)
	society_id  = conf['society_id']
	user_id          = Auth.user(society_id)['user_id']
	remarks          =  request.values.get('remark_new')

	is_default       = 0
	data2  = {
			  'is_default'	 : is_default,
			  'conf_id'		 : conf_id,
			  'user_id'		 : user_id,
			  'remarks'		 : remarks or None,
			  'remove_at'	 : current_dt		

	}
	
	check_remark = BOModel().get_remark(conf_id,user_id)

	if(check_remark == "success"):
		update = BOModel().update_remark(conf_id,user_id,data2)
		get_remark_data = BOModel().get_remark_data(conf_id,user_id)

		remark_data     = get_remark_data["remarks"] or ' '
		remark_view     = { 'remark_data' : remark_data,'status':1}
		return json.dumps(remark_view,default=str)


# new spot registration form start here

@app.route('/<int:conf_id>/<conf_key>/spot_registration', methods = ["GET", "POST"])
@RouteGroup.conf_required
@RouteGroup.bologin_required
def SpotRegistration(conf_id,conf_key):
	now              = datetime.now()
	curr_dt          = now.strftime("%Y-%m-%d %H:%M:%S")
	conf             = UserModel().get_confUserModel(conf_id,conf_key)
	society_id       = conf['society_id']
	user_id          = Auth.user(society_id)['user_id']
	delegate         = None
	badge_role       = BOModel().get_badge_model(conf_id)
	society_id       = conf['society_id']
	parent_user_id   = Auth.user(society_id)['user_id']
	delegate_id      = 0
	is_custom_addons = 1
	payment_types    = BOModel().get_payment_types(conf_id)
	reg_types        = BOModel().get_addon_reg_type(conf_id)
	addons           = BOModel().get_addonsBOModel(delegate_id,curr_dt,conf_id,None,is_custom_addons)
	state_id         = UserModel().get_states()  
	country_id       = UserModel().get_country()
	get_spot_data 	 = SpotRegModel().get_spot_code(conf_id)
	get_remark_data  = BOModel().get_remark_value(conf_id,user_id)
	return render_template('spot_registration/bo_new_common_spot_registration.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,get_remark_data=get_remark_data,get_spot_data=get_spot_data) 



@app.route('/<int:conf_id>/<conf_key>/spot_reg_form/<int:register_no>', methods = ["GET", "POST"])
@RouteGroup.conf_required
@RouteGroup.bologin_required
def BospotSearchRegisterForForm(conf_id,conf_key,register_no):
	conf             = Auth.getConf(conf_id,conf_key)
	society_id       = conf['society_id']
	now              = datetime.now()
	curr_dt          = now.strftime("%Y-%m-%d %H:%M:%S")
	user_id          = Auth.user(society_id)['user_id']
	delegate         = None
	badge_role       = BOModel().get_badge_model(conf_id)
	parent_user_id   = Auth.user(society_id)['user_id']
	delegate_id      = 0
	is_custom_addons = 1
	payment_types    = BOModel().get_payment_types(conf_id)
	reg_types        = BOModel().get_addon_reg_type(conf_id)
	addons           = BOModel().get_addonsBOModel(delegate_id,curr_dt,conf_id,None,is_custom_addons)
	state_id         = UserModel().get_states()  
	country_id       = UserModel().get_country()
	get_spot_data 	 = SpotRegModel().get_spot_code(conf_id)
	get_remark_data  = BOModel().get_remark_value(conf_id,user_id)
	search     		 = register_no
	user       		 = SpotRegModel().get_search_spot_user(search,conf_id)
	if user:
		attach_path      = user['attach_path'] or None
		attach_file_name = user['attach_file_name'] or None
		if user and user['delegate_no'] :
			user_details     = BOModel().get_delegate_details_from_delegate_no(user['delegate_no'],conf_id)
			if user_details:
				confimation_mail_link = "/bo_view_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>'
				if attach_path and attach_file_name:
					payment_screenshot = attach_path+"/"+attach_file_name
				else:
					payment_screenshot = None
				status = 2
				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
				}
	
		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(user['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 render_template('spot_registration/bo_new_common_spot_registration_form.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,get_remark_data=get_remark_data,get_spot_data=get_spot_data,register_no=register_no,data=data)
	else:
		status = 0
		data = {
			'status':status,
			'msg'   : 'No Record Found...'
		}
		return render_template('spot_registration/bo_new_common_spot_registration_form.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,get_remark_data=get_remark_data,get_spot_data=get_spot_data,data=data)


# new spot registration form end here

# DELEGATE NUMBER TO FIND CURRENT YEAR DETAILS TO NEXT YEAR SPOT REG

@app.route('/<int:conf_id>/<conf_key>/bo_spot_search_del_register', methods = ["GET", "POST"])
@RouteGroup.conf_required
def BospotSearchDelRegister(conf_id,conf_key):
	conf            = Auth.getConf(conf_id,conf_key)
	society_id      = conf['society_id']
	if request.method == 'POST':
		search     = request.values.get('del_no')
		if search :
			if conf_id == 39:
				current_year_conf_id = 17
			elif conf_id == 10:
				current_year_conf_id = 2
			elif conf_id == 48:
				current_year_conf_id = 10	
			else:
				current_year_conf_id = 0
			user_details     = BOModel().get_delegate_details_from_delegate_no(search,current_year_conf_id)
			if user_details:
				payment_screenshot = None
				status = 2
				data = {
					'status' : status,
					'user'	 : user_details,
					'payment_screenshot': payment_screenshot
				}
	
				return json.dumps(data ,default=str)			

		else:
			status = 0
			data = {
				'status':status,
				'msg'   : 'No Record Found...'
			}
			return json.dumps(data ,default=str)

	else:
		return redirect(url_for('back_office.BoRegister',conf_id=conf_id,conf_key=conf_key))

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