def sendSuccessfulTransferEmail(eventUid, venueUid, orders, OTDB):
    

    recipientList = OTDB.getOrderTransferEmailRecipientList(venueUid) 
    print str(recipientList)


    eventName, eventDateUTC, levyEventId, localTimeZone, venueName, employeeFirstName, employeeLastName, total = OTDB.getTransferedOrderData(eventUid)

    localEventDate = convertUTCToLocalTime(eventDateUTC, localTimeZone)
    subject = "Event: " + eventName + " successfully transfered"

    currentTimeUTC = datetime.datetime.now()
    currentTime = convertUTCToLocalTime(currentTimeUTC, localTimeZone)

    failedOrders = OTDB.getFailedTransferOrders(eventUid)

 

    emailBody = "<p>Event: " + eventName + " - " + localEventDate.strftime("%b %-d, %Y %-I:%M %p") + " </p><p>Venue: " + venueName + "</p><p>Successfully Transferred " + str(len(orders)-len(failedOrders)) + " orders at " + currentTime.strftime("%-I:%M %p") + " on " + currentTime.strftime("%b %-d, %Y") + " for a total of $" + "{0:.2f}".format(total) + ".</p>" + "<p>Event was closed by " + employeeFirstName + " " + employeeLastName + ".</p>"

    if len(failedOrders) > 0:
        subject = "Event: " + eventName + " transfered with errors"
        emailBody += "<p>The following orders experienced errors while transfering, please investigate and close on a terminal</p><ul>"
        for failedOrder in failedOrders:
            emailBody += "<li>" + str(failedOrder[0]) + "</li>"

        emailBody += "</ul>"

    for to in recipientList:
        print "Sending Transfer Email to " + str(to[0])
        gmail.sendGmail("*****@*****.**", "fkTUfbmv2YVy", "*****@*****.**", str(to[0]), subject, emailBody, "You need to enable HTML to view this message")
def sendSuccessfulTransferEmail(eventUid, venueUid, OTDB):

    recipientList = OTDB.getOrderTransferEmailRecipientList(venueUid)

    eventName, eventDateUTC, levyEventId, localTimeZone, venueName, employeeFirstName, employeeLastName, total, orderCount = OTDB.getTransferedOrderData(
        eventUid)

    localEventDate = convertUTCToLocalTime(eventDateUTC, localTimeZone)
    subject = "Event: " + eventName + " successfully transferred"

    currentTimeUTC = datetime.datetime.now()
    currentTime = convertUTCToLocalTime(currentTimeUTC, localTimeZone)

    failedOrders = OTDB.getFailedTransferOrders(eventUid)

    locale.setlocale(locale.LC_ALL, '')

    emailBody = ""

    openOrders = OTDB.getOpenOrders(eventUid)
    if len(openOrders) > 0:
        emailBody += "<h3> There were " + str(
            len(openOrders)) + " open orders when the event was locked.</h3>"


#    print "TOTAL: " +  str(total)

    if total is None:
        total = 0

    emailBody += "<p>Event: " + eventName + " - " + localEventDate.strftime(
        "%b %-d, %Y @ %-I:%M %p"
    ) + " </p><p>Venue: " + venueName + "</p><p>Closed By: " + employeeFirstName + " " + employeeLastName + "</p><p>Transfer Time: " + currentTime.strftime(
        "%b %-d, %Y @ %-I:%M %p") + " </p><p>Orders: " + str(
            orderCount) + "</p><p>Sales: " + locale.currency(
                total, grouping=True) + " </p>"

    if len(failedOrders) > 0:
        subject = "Event: " + eventName + " transferred with errors"
        emailBody += "<p>The following orders experienced errors while transfering, please investigate and close on a terminal</p><ul>"
        for failedOrder in failedOrders:
            emailBody += "<li>" + str(failedOrder[0]) + "</li>"

        emailBody += "</ul>"

    for to in recipientList:
        print "Sending Transfer Email to " + str(to[0])
        gmail.sendGmail("*****@*****.**",
                        "fkTUfbmv2YVy", "*****@*****.**",
                        str(to[0]), subject, emailBody,
                        "You need to enable HTML to view this message")
def sendRequiredActionSummary(venueUid, requiredActions):

    body = "<h3> Aramark Integration Complete: Manual Alignment Required <h3>"
    body += '<table border = "1">'
    for action in requiredActions:
        body += action.getHTMLFormattedRow()

    body += "</table>"

    toEmails = dbCore.getErrorEmailRecipients(venueUid)
    for toEmail in toEmails:
        toEmail = toEmail[0]
        gmail.sendGmail("*****@*****.**", "fkTUfbmv2YVy",
                        "*****@*****.**", toEmail,
                        "ACTION REQUIRED: Aramark Integration", body,
                        "enable html")
def sendStatusEmail(venueUid, eventUid, manual=False):
    """
        Sends an email for the given event to everyone on the email list of the given
        venue.
            1. Builds the email html body
            2. gathers the email addresses
            3. sends emails

        Parameters
        __________
        venueUid : int the venue_uid to send status emails for
        evenutUid : int the event_uid to send status emails for

        Reutrns
        _______
        out : boolean True if successful
    """

    from db_connection import DbConnection
    conn = DbConnection().connection

    statusRows = getStatusRows(conn, venueUid)

    body = '<font face="verdana">'

    table = getTable(statusRows)

    body += getIntro(conn, venueUid, eventUid)

    summary, totalTablets, badTablets = getSummary(statusRows)
    body += summary

    body += table

    if (manual):
        body += "<h1><b>*</b></h1>"

    subject = getSubject(totalTablets, badTablets)

    emailList = getEmailList(conn, venueUid)

    for email in emailList:
        gmail.sendGmail("*****@*****.**", "fkTUfbmv2YVy",
                        "*****@*****.**", email[0], subject,
                        body, 'Please, enable html to view this report')

    return True
def sendIntegrationErrorSummary(venueUid, errors):

    body = "<h3> Aramark Integration Encountered " + str(
        len(errors)) + " Errors</h3>"
    body += '<table border="1">'
    body += '<tr><th>Integration Field</th><th>Integration Data</th><th>Error Stack Trace</th></tr>'
    for error in errors:
        body += error.getHTMLFormattedRow()

    body += "</table>"

    toEmails = dbCore.getErrorEmailRecipients(venueUid)
    print "Error Emails: " + str(toEmails)
    for toEmail in toEmails:
        toEmail = toEmail[0]
        print "Script crashed, sending an email to " + toEmail
        gmail.sendGmail("*****@*****.**", "fkTUfbmv2YVy",
                        "*****@*****.**", toEmail,
                        "ERRORS: Aramark Integration", body, "enable html")
 def sendMail(self):
     global MailList
     rv = self.mailEntry.get()
     gmail.sendGmail(rv, MailList)
def sendAppliedIntegrationSummary(venueUid, appliedIntegrations):

    emailBody = "Aramark Integration has completed, the following changes have been applied"
    sendIntegrationEmail = False

    appliedIntegrations = getAppliedIntegrationsByVenue(
        venueUid, appliedIntegrations)

    if len(appliedIntegrations) > 0:
        sendIntegrationEmail = True

    appliedInserts = getAppliedInserts(appliedIntegrations)
    appliedUpdates = getAppliedUpdates(appliedIntegrations)

    #units
    insertedUnits = getAppliedIntegrationsByTable('setup', 'units',
                                                  appliedInserts)
    updatedUnits = getAppliedIntegrationsByTable('setup', 'units',
                                                 appliedUpdates)

    if len(insertedUnits) + len(updatedUnits) != 0:
        emailBody += "<h3>UNITS:</h3>"
        if len(insertedUnits) != 0:
            emailBody += "New Units:<ul>"
            for insertedUnit in insertedUnits:
                emailBody += insertedUnit.formatEmailRow()
            emailBody += "</ul>"
        if len(updatedUnits) != 0:
            emailBody = "Updated Units:<ul>"
            for updatedUnit in updatedUnits:
                emailBody += updatedUnit.formatEmailRow()
            emailBody += "</ul>"

    #events
    insertedEvents = getAppliedIntegrationsByTable('setup', 'events',
                                                   appliedInserts)
    updatedEvents = getAppliedIntegrationsByTable('setup', 'events',
                                                  appliedUpdates)

    if len(insertedEvents) + len(updatedEvents) != 0:
        emailBody += "<h3>EVENTS:</h3>"
        if len(insertedEvents) != 0:
            emailBody += "New Events:<ul>"
            for insertedEvent in insertedEvents:
                emailBody += insertedEvent.formatEmailRow()
            emailBody += "</ul>"
        if len(updatedEvents) != 0:
            emailBody += "Updated Events:<ul>"
            for updatedEvent in updatedEvents:
                emailBody += updatdEvent.formatEmailRow()
            emailBody += "</ul>"

    #menu_categories

    #menus

    #menu_items
    insertedMenuItems = getAppliedIntegrationsByTable('menus', 'menu_items',
                                                      appliedInserts)
    updatedMenuItems = getAppliedIntegrationsByTable('menus', 'menu_items',
                                                     appliedUpdates)

    if len(insertedMenuItems) + len(updatedMenuItems) != 0:
        emailBody += "<h3> MENU ITEMS:</h3>"
        if len(insertedMenuItems) != 0:
            emailBody += "New Menu Items:<ul>"
            for insertedMenuItem in insertedMenuItems:
                emailBody += insertedMenuItem.formatEmailRow()
            emailBody += "</ul>"
        if len(updatedMenuItems) != 0:
            emailBody += "Updated Menu Items:<ul>"
            for updatedMenuItem in updatedMenuItems:
                emailBody += updatedMenuItem.formatEmailRow()
            emailBody += "</ul>"

    #customers
    insertedPatrons = getAppliedIntegrationsByTable('patrons', 'patrons',
                                                    appliedInserts)
    updatedPatrons = getAppliedIntegrationsByTable('patrons', 'patrons',
                                                   appliedUpdates)

    if len(insertedPatrons) + len(updatedPatrons) > 0:
        emailBody += "<h3>PATRONS: </h3>"
        if len(insertedPatrons) > 0:
            emailBody += "New Patrons:<ul>"
            for insertedPatron in insertedPatrons:
                emailBody += insertedPatron.formatEmailRow()
            emailBody += '</ul>'

        if len(updatedPatrons) > 0:
            emailBody += "Updated Patrons: <ul>"
            for updatedPatron in updatedPatrons:
                emailBody += updatedPatron.formatEmailRow()
            emailBody += '</ul>'

    if sendIntegrationEmail:
        recipients = dbCore.getAramarkEmailRecipients(venueUid)
        for recipient in recipients:
            email = recipient[0]
            gmail.sendGmail(
                "*****@*****.**", "fkTUfbmv2YVy",
                "*****@*****.**", email,
                "Aramark Integration Summary", emailBody,
                "Please view this email in an html compatable email client")
Exemplo n.º 8
0
    if success:
        conn.commit()

        emailBody = "Food and Beverage ordering for the following  event has been opened: \n\n"

        emailBody = emailBody + eventName + '\n'

        cursor.execute('SELECT local_timezone_long \
                        FROM setup.venues \
                        WHERE id = 422')
        localTimeZone = cursor.fetchone()[0]

        localDateTime = eventDate.replace(tzinfo=pytz.utc).astimezone(timezone(localTimeZone)) 

        emailBody = emailBody + localDateTime.strftime('%B  %-d, %Y %-I:%M %p')

     

        for email in notify:
            gmail.sendGmail('*****@*****.**', 'fkTUfbmv2YVy', '*****@*****.**', email, 'Event Opened', emailBody, emailBody)


        print HipChat.sendMessage("Food and Beverage ordering open for event " + str(eventUid), "FandBCron", 447878, 'purple')

    else:
        print "Everything failed"

else:
    print "Nothing to do"
Exemplo n.º 9
0
 def Frame3_SendMail(self):
     gmail.sendGmail(list(self.BookMark.values()))