예제 #1
0
파일: profile.py 프로젝트: skhendake/phr
def add_profile_to_db(data,profile_id):
	res = json.loads(data)
	actdata = res['actualdata']		
	dt = json.loads(actdata)
	sub = dt['person_firstname']+" "+dt['person_lastname']+" "+"delinked Successfully"
	make_log(profile_id,"profile","delink",sub)
	args = {'person_firstname':dt['person_firstname'],'person_middlename':dt['person_middlename'],'person_lastname':dt['person_lastname'],'email':dt['email'],'mobile':dt['mobile'],'received_from':'Desktop','provider':'false'}
	
	cie = frappe.db.get_value("LinkedPHR Images",{"profile_id":res['entityid']}, ["barcode", "profile_image"], as_dict=1)

	path = ""
	if cie.get('barcode'):
		path = cie.get('barcode')
	else:
		path = ""

	if cie.get('profile_image'):
		args['user_image'] = cie.get('profile_image')
	else:
		args['user_image']= ""

	ret_res = create_profile_in_db(res['entityid'],args,res,path)
	user = frappe.get_doc("User",frappe.session.user)
	send_phrs_mail(user.email,"PHR:Linked PHR Account Delinked","templates/emails/delink_phr.html",{"name":args['person_firstname']})
	msg = get_sms_template("delink",{"phr_name":args['person_firstname']})
	if user.contact:
		rec_list = []
		rec_list.append(user.contact)
		send_sms(rec_list,msg=msg)
	sub = dt['person_firstname']+" "+dt['person_lastname']+" "+"Profile Created Successfully"
	make_log(profile_id,"profile","create",sub)
	return ret_res
예제 #2
0
def notify_about_linked_phrs(profile_id,
                             email_msg=None,
                             text_msg=None,
                             entity=None,
                             user_name=None):
    linked_phr = frappe.db.sql("""select profile_id from 
		`tabNotification Configuration` 
		where linked_phr=1 and profile_id='%s'""" % (profile_id))
    if linked_phr:
        user = frappe.get_doc(
            'User',
            frappe.db.get_value("User", {"profile_id": profile_id}, "name"))
        if user:
            send_phrs_mail(user.name,
                           "HealthSnapp Updates:" + entity + " Updated",
                           "templates/emails/linked_phrs_updates.html", {
                               "user_name": user_name,
                               "entity": entity
                           })
            if frappe.db.get_value("Mobile Verification", {
                    "mobile_no": user.contact,
                    "mflag": 1
            }, "name"):
                rec_list = []
                rec_list.append(user.contact)
                send_sms(rec_list, msg=text_msg)
        else:
            from phr.templates.pages.dashboard import search_profile_data_from_solr
            search_profile_data_from_solr(profile_id)
예제 #3
0
파일: profile.py 프로젝트: skhendake/phr
def notify_about_linked_phrs(profile_id,email_msg=None,text_msg=None,entity=None,user_name=None):
	linked_phr = frappe.db.sql("""select profile_id from 
		`tabNotification Configuration` 
		where linked_phr=1 and profile_id='%s'"""%(profile_id))
	if linked_phr:
		user = frappe.get_doc('User',frappe.db.get_value("User",{"profile_id":profile_id},"name"))
		if user:
			send_phrs_mail(user.name,"HealthSnapp Updates:"+entity+" Updated","templates/emails/linked_phrs_updates.html",{"user_name":user_name,"entity":entity})
			if frappe.db.get_value("Mobile Verification",{"mobile_no":user.contact,"mflag":1},"name"):
				rec_list = []
				rec_list.append(user.contact)
				send_sms(rec_list,msg=text_msg)
		else:
			from phr.templates.pages.dashboard import search_profile_data_from_solr
			search_profile_data_from_solr(profile_id)
예제 #4
0
def add_profile_to_db(data, profile_id):
    res = json.loads(data)
    actdata = res['actualdata']
    dt = json.loads(actdata)
    sub = dt['person_firstname'] + " " + dt[
        'person_lastname'] + " " + "delinked Successfully"
    make_log(profile_id, "profile", "delink", sub)
    args = {
        'person_firstname': dt['person_firstname'],
        'person_middlename': dt['person_middlename'],
        'person_lastname': dt['person_lastname'],
        'email': dt['email'],
        'mobile': dt['mobile'],
        'received_from': 'Desktop',
        'provider': 'false'
    }

    cie = frappe.db.get_value("LinkedPHR Images",
                              {"profile_id": res['entityid']},
                              ["barcode", "profile_image"],
                              as_dict=1)

    path = ""
    if cie.get('barcode'):
        path = cie.get('barcode')
    else:
        path = ""

    if cie.get('profile_image'):
        args['user_image'] = cie.get('profile_image')
    else:
        args['user_image'] = ""

    ret_res = create_profile_in_db(res['entityid'], args, res, path)
    user = frappe.get_doc("User", frappe.session.user)
    send_phrs_mail(user.email, "PHR:Linked PHR Account Delinked",
                   "templates/emails/delink_phr.html",
                   {"name": args['person_firstname']})
    msg = get_sms_template("delink", {"phr_name": args['person_firstname']})
    if user.contact:
        rec_list = []
        rec_list.append(user.contact)
        send_sms(rec_list, msg=msg)
    sub = dt['person_firstname'] + " " + dt[
        'person_lastname'] + " " + "Profile Created Successfully"
    make_log(profile_id, "profile", "create", sub)
    return ret_res
예제 #5
0
파일: todo.py 프로젝트: skhendake/phr
def notify_to_do():
	profile_ids = get_profile_ids()
	print "########## TODO #############"
	print profile_ids
	if profile_ids:
		msg={}
		email_msg={}
		for profile in profile_ids:
			user = frappe.db.get_value("User",{"profile_id":profile['profile_id']},"name")
			todoobj = frappe.get_doc('ToDo',profile['name'])
			msgg = get_sms_template("todo",{"to_do":todoobj.description})
			if user:
				pobj = frappe.get_doc('User',user)
				send_phr_sms(pobj.contact,msg=msgg)
				send_phrs_mail(pobj.name,"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":pobj.first_name})
			else:
				data = search_profile_data_from_solr(profile['profile_id'])
				
				if data:
					child = data['childProfile']
					
					if child['mobile'] and frappe.db.get_value("Mobile Verification",{"mobile_no":child['mobile'],"mflag":1},"name"):
						send_phr_sms(child['mobile'],msg=msgg)
					else:
						parent = data['parentProfile']
						send_phr_sms(parent['mobile'],msg=msgg)
					
					if child['email']:
						send_phrs_mail(child['email'],"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":data["person_firstname"]})
					else:
						send_phrs_mail(parent['email'],"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":data["person_firstname"]})	
예제 #6
0
파일: todo.py 프로젝트: skhendake/phr
def notify_to_do():
    profile_ids = get_profile_ids()
    print "########## TODO #############"
    print profile_ids
    if profile_ids:
        msg = {}
        email_msg = {}
        for profile in profile_ids:
            user = frappe.db.get_value("User",
                                       {"profile_id": profile['profile_id']},
                                       "name")
            todoobj = frappe.get_doc('ToDo', profile['name'])
            msgg = get_sms_template("todo", {"to_do": todoobj.description})
            if user:
                pobj = frappe.get_doc('User', user)
                send_phr_sms(pobj.contact, msg=msgg)
                send_phrs_mail(pobj.name, "PHR:To Do Alert",
                               "templates/emails/todo.html", {
                                   "todo": todoobj.description,
                                   "name": pobj.first_name
                               })
            else:
                data = search_profile_data_from_solr(profile['profile_id'])

                if data:
                    child = data['childProfile']

                    if child['mobile'] and frappe.db.get_value(
                            "Mobile Verification", {
                                "mobile_no": child['mobile'],
                                "mflag": 1
                            }, "name"):
                        send_phr_sms(child['mobile'], msg=msgg)
                    else:
                        parent = data['parentProfile']
                        send_phr_sms(parent['mobile'], msg=msgg)

                    if child['email']:
                        send_phrs_mail(
                            child['email'], "PHR:To Do Alert",
                            "templates/emails/todo.html", {
                                "todo": todoobj.description,
                                "name": data["person_firstname"]
                            })
                    else:
                        send_phrs_mail(
                            parent['email'], "PHR:To Do Alert",
                            "templates/emails/todo.html", {
                                "todo": todoobj.description,
                                "name": data["person_firstname"]
                            })
예제 #7
0
def send_adv_email(adv):
	send_phrs_mail(adv.get("notify_to"), adv.get("title"), "templates/emails/adv_notify.html", adv)