コード例 #1
0
def notifyOnDate(dateType, ESC=0):
    level1 = dict()  # Collect lists for summary e-mail
    today = dt.date.today()
    if (dateType == 'BDAY'):
        body = bdayBody
        subject = bdaySubject
        mBody = bdayManagerBody
        mSubject = bdayManagerSubject

    if (dateType == 'ANIV'):
        body = aniversaryBody
        subject = aniversarySubject
        mBody = aniverasaryManagerBody
        mSubject = aniverasaryManagerSubject

    #get all emps
    elist = getAllEmployees()
    #for each emp
    for e in elist:
        #check if today's date matches birthdate
        if not matchDate(e, dateType, today):
            continue
        #send email to employee
        sendNotificationOnDate(e, body, subject, ESC)
        addToDict(level1, e, getReportingManagerEmpNum(e.EMPLOYEE_ID))
        addToDict(level1, e, getDcLeadEmpNum(e.EMPLOYEE_ID))
    #send summary e-mail to 1st and 2nd level managers
    sendSummaryToManagers(mBody, mSubject, level1)
    db.session.close()
    return "Notifications Sent"
コード例 #2
0
def getAllEmpCell():
    emps = hrmsdomain.getAllEmployees()
    messageList = []
    numList = []
    tcount = 0
    count = 0
    for e in emps:
        tcount += 1
        #        if not (e.EMPLOYEE_ID == '63' or e.EMPLOYEE_ID == '274'): continue
        if e.MOBILE_NO:
            (isValid, isIndian,
             national_number) = isValidIndianPhoneNumber(e.MOBILE_NO)
            if isValid and isIndian:
                numList += [
                    "91" + str(national_number)
                ]  # Store the number in international format without a +
                count += 1
            else:
                messageList += [
                    e.OFFICE_EMAIL_ID +
                    ":Invalid Mobile Number or not Indian Number"
                ]
        else:
            messageList += [e.OFFICE_EMAIL_ID + ":Mobile Number unavailable"]
    print("Total=%d, Clean=%d" % (tcount, count))
    return (numList, messageList)
コード例 #3
0
def checkBCSEmailsWithHRMS(nameHash):
    retStr = ""
    emps = getAllEmployees()
    empDict = {e.OFFICE_EMAIL_ID.lower(): e.OFFICE_EMAIL_ID for e in emps}
    for n in nameHash.values():
        if n.lower() not in empDict.keys():
            retStr += ":" + n
    if retStr:
        return ("Following BCS-Emails not in HRMS:" + retStr)
    return ("")
コード例 #4
0
def sendDataMissingMsgToAll(sendEmailToEmp=True) :
    empList = hrmsdomain.getAllEmployees() 
#    empList = ['*****@*****.**']
    count = 0
    respStr = ""
    empCount = 0
    for emp in empList : #For each employee
        (resp,retval) = dataMissingMsg(empObj = emp, email="", sendEmailToEmp=sendEmailToEmp)
        respStr += "<p>" + resp + "</p>"
        if retval : count += 1
        empCount += 1

    #Send a summary to myself- to be moved to config file
    retStr = "<p>Total %d employees (out of %d) notified.</p>" % (count, empCount) + respStr
    notify("*****@*****.**", "HRMS: Data Update Status", retStr ,  templateId="-1")
    return (htmlhead + retStr + respStr + htmlfooter)
コード例 #5
0
def fixDCs():

    return (
        "Remove ME TO UPDATE ONLY DC-DATA. USE fixManagers Instead..it fixes both "
    )

    #Create a Manager Hash by email ID!!! No emp. number?
    #Get Manager -> email -> Object -> emp-number -> ManagerInfo-table->Select the 1st one -> get ID
    mgrList = ManagerInfo.query.all()

    #Create a Department HASH - by name
    dcList = Departmant.query.all()
    dcHash = dict()
    for d in dcList:
        dcHash[d.DEPARTMENT_NAME] = d.ID

    #Create an emp_hash with Key as the email ID in all lower-case
    empHash = dict()
    emps = hrmsdomain.getAllEmployees()
    for e in emps:
        empHash[e.OFFICE_EMAIL_ID.lower()] = e  # Store the object

    #Read exl-file and create a hash of employee-EMAILs, Depart and Manager
    df = pd.read_excel(
        "Employee Email  Organisational_Structure_2018-04-04.xlsx"
    )  # Skip the first 4 lines, start from the 5th, ZERO indexed
    #Name	Email	Responsibilities	DC Team	DC Manager	DC_Num
    found = 0
    notfound = 0
    for e in df.Email:
        e = e.lower()
        if e in empHash.keys():
            found += 1
            empObj = empHash[e]
            newDept = df[df.Email == e].DC_Num.data[0]
            #            print("NewDept:" + str(newDept) )
            oldDept = empObj.DEPARTMENT_ID
            #empObj.DEPARTMENT_ID = newDept
            print("Employee %s:Old/New Dept:%s:%s" %
                  (e, str(oldDept), newDept))
        else:
            notfound += 1
#            print("Email:%s not found" % (e))
#db.session.commit()
    return "See Console %d:%d" % (found, notfound)
コード例 #6
0
def notifyAllEmps(sendEmail=0) :
    #return getEmpDictbyEmail("*****@*****.**")
    empList = hrmsdomain.getAllEmployees()
    allinfo = ""
    errCount = 0 # Check the count
    totalCount = len(empList)
    errEmailList = []
    for emp in empList : #For each employee
        #Run each check and add to msgStr
        msgDict =  getEmpDictbyObj(emp)
        num = 0 # No of items per line
        errNum = 0
        errStr = "" # Put errors separately, att to the top
        msgStr = ""
        for k in msgDict.keys() :
            if msgDict[k] == "Not Available" :
                errStr += "%s:%s" %(k,"Not Available" )
                errNum += 1
                if not errNum % 4 :
                    errStr += "\n"
                else :
                    errStr += "\t"
            else :
                msgStr +=  "%s:%s" %(k,msgDict[k] )
                num += 1
                if not num % 4 :
                    msgStr += "\n"
                else :
                    msgStr += "\t"
        if errStr :
            name = "Hi " + emp.FIRST_NAME + " " + emp.LAST_NAME + "\nPlease Update the Following:\n"
            emailMsg = name +  errStr
        if msgStr :
            emailMsg +=  "\n\nPlease verify and correct(if required) the following:\n" + msgStr
        print ('notify(%s, "Action Required:Correct HRMS Data", %s)' % (emp.OFFICE_EMAIL_ID, emailMsg) )
#        print(emaiMsg +"\n")
        allinfo += emailMsg +'<p>'
        #Notify employee
    return allinfo
コード例 #7
0
def getAllEmpsWOManager():
    #mgrList = ManagerInfo.query.all() # All Managers
    #dcList = Departmant.query.all() # All DCs
    empList = hrmsdomain.getAllEmployees()  # All employees

    for emp in empList:
        dept = emp.departmant
        dc_emp = ""
        dcLead = ""
        mgrName = ""
        mgrEmail = ""
        if dept:
            dcName = emp.departmant.DEPARTMENT_NAME
            if emp.departmant.DC_LEAD:
                dc_emp = Employee.query.filter_by(
                    EMPLOYEE_ID=emp.departmant.DC_LEAD).first()
                if dc_emp:
                    dcLead = dc_emp.OFFICE_EMAIL_ID

        mgr_dept = emp.Manager_ID
        if mgr_dept:  # If this present, better check
            (mgr, dept) = mgr_dept.split(
                '-'
            )  # Need to see what this is, has two numbers with a hyphen in between, looks for manager_info table
            mgrInfoObj = ManagerInfo.query.filter_by(
                ID=mgr).first()  # Get manger Object
            if mgrInfoObj:
                mgrName = mgrInfoObj.name
                manager_emp = Employee.query.filter_by(
                    EMPLOYEE_ID=mgrInfoObj.emp_id).first()
                if manager_emp:
                    mgrEmail = manager_emp.OFFICE_EMAIL_ID
        if not dc_emp or not dcLead or not mgrName or not mgrEmail:
            print("Emp:%s, %s,%s,%s,%s" %
                  (emp.OFFICE_EMAIL_ID, str(dc_emp), str(dcLead), str(mgrName),
                   str(mgrEmail)))
    return "Completed"
コード例 #8
0
def getAllEmpEmails():
    empList = hrmsdomain.getAllEmployees()
    emailList = [e.OFFICE_EMAIL_ID.lower() for e in empList]
    return emailList