Exemple #1
0
 def dist(self):
     db = DB()
     if (request.method == "GET"):
         hostSite = db.getHostSiteByName(request.params['hostSiteName'])
         orderList = db.getAllOrdersByHostSite(hostSite.get('id'),
                                               request.params['sortid'])
         return Sale.toDistList(orderList, request.params['hostSiteName'])
Exemple #2
0
    def toCashSaleList(orders, hostSiteName):
        tableStr = "<table class=\"table\" id=\"usersTable\" style=\"background-color:white;cursor: pointer; cursor: hand; \"><thread><tr id=\"info\"><th>Pickup Site</th><th>Pickup Date</th><th>Customer</th><th>Phone</th><th>Email</th><th>No. Small</th><th>No. Large</th><th>Paid</th><th>Donation</th><th>Ordered On</th></tr></thread><tbody>"

        #calls to database is made to get the name of the hostsite

        db = DB()
        hostSite = db.getHostSiteByName(hostSiteName)

        #This for loop loops through the list of dictionaries and selects certain values to add to the table

        for order in orders:
            if str(order.get('hostsitecreated_idFK', '')) != str(
                    hostSite.get('id')):
                continue

            tableStr += "<tr id=\"" + str(order.get('id')) + "\">"
            tableStr += "<td>" + hostSiteName + "</td>"

            tableStr += "<td>" + str(order.get('distribution_date')) + "</td>"
            tableStr += "<td>" + str(
                order.get('customer_first_name')) + " " + str(
                    order.get('customer_last_name')) + "</td>"
            tableStr += "<td>" + str(order.get('customer_phone')) + "</td>"
            tableStr += "<td>" + str(order.get('customer_email'))
            if str(order.get('email_notifications')) == "1":
                tableStr += " (Notifications)</td>"
            else:
                tableStr += "</td>"

            tableStr += "<td>" + str(order.get('small_quantity')) + "</td>"
            tableStr += "<td>" + str(order.get('large_quantity')) + "</td>"
            tableStr += "<td>" + str(order.get('total_paid')) + "</td>"

            cost = 20.0 * float(order.get('large_quantity', 0)) + 15.0 * float(
                order.get('small_quantity', 0))
            owe = cost - float(order.get('total_paid', 0.00))

            tableStr += "<td>" + str(order.get('donation'))
            if str(order.get('donation_receipt')) == "1":
                tableStr += " (Reciept)</td>"
            else:
                tableStr += "</td>"

            tableStr += "<td>" + str(order.get('creation_date')) + "</td>"
            tableStr += "</td></tr>"

        tableStr += "</tbody></table>"
        return tableStr
Exemple #3
0
	def toCashSaleList(orders, hostSiteName):
		tableStr = "<table class=\"table\" id=\"usersTable\" style=\"background-color:white;cursor: pointer; cursor: hand; \"><thread><tr id=\"info\"><th>Pickup Site</th><th>Pickup Date</th><th>Customer</th><th>Phone</th><th>Email</th><th>No. Small</th><th>No. Large</th><th>Paid</th><th>Donation</th><th>Ordered On</th></tr></thread><tbody>"
		
		#calls to database is made to get the name of the hostsite
		
		db = DB()
		hostSite = db.getHostSiteByName(hostSiteName)

		#This for loop loops through the list of dictionaries and selects certain values to add to the table

		for order in orders:
			if str(order.get('hostsitecreated_idFK','')) != str(hostSite.get('id')):
				continue;

			tableStr += "<tr id=\"" + str(order.get('id')) + "\">"
			tableStr += "<td>" + hostSiteName +"</td>"
			
			tableStr += "<td>" + str(order.get('distribution_date')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_first_name')) + " " + str(order.get('customer_last_name')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_phone')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_email'))
			if str(order.get('email_notifications')) == "1":
				tableStr += " (Notifications)</td>"
			else:
				tableStr += "</td>"
			
			tableStr += "<td>" + str(order.get('small_quantity')) +"</td>"
			tableStr += "<td>" + str(order.get('large_quantity')) +"</td>"
			tableStr += "<td>" + str(order.get('total_paid')) +"</td>"
			
			cost = 20.0 * float(order.get('large_quantity', 0)) + 15.0 * float(order.get('small_quantity', 0))
			owe = cost - float(order.get('total_paid', 0.00))
			
			tableStr += "<td>" + str(order.get('donation'))
			if str(order.get('donation_receipt')) == "1":
				tableStr += " (Reciept)</td>"
			else:
				tableStr += "</td>"

			tableStr += "<td>" + str(order.get('creation_date')) +"</td>"
			tableStr += "</td></tr>"

		tableStr += "</tbody></table>"
		return tableStr
 def dist(self):
     db = DB()
     if request.method == "GET":
         hostSite = db.getHostSiteByName(request.params["hostSiteName"])
         orderList = db.getAllOrdersByHostSite(hostSite.get("id"), request.params["sortid"])
         return Sale.toDistList(orderList, request.params["hostSiteName"])
Exemple #5
0
	def toDistList(orders, hostSiteName):
		tableStr = "<div class=\"input-group\" style=\"padding-top: 0;margin-bottom: 5px; margin-top: 0; padding-left: 0\"><span class=\"input-group-addon\">Filter</span><input id=\"filterbox\" type=\"text\" class=\"form-control\" placeholder=\"Type here to filter the table (by sites, dates, names, etc.)\"></div>"
		tableStr += "<table class=\"table\" id=\"usersTable\" style=\"background-color:white;cursor: pointer; cursor: hand; \"><thread><tr id=\"info\"><th>Pickup Site</th><th>Pickup Date</th><th>Customer</th><th>Phone</th><th>Email</th><th>No. Small</th><th>No. Large</th><th>Paid</th><th>Ordered On</th><th></th></tr></thread><tbody class=\"searchable\">"
		
		#calls to database is made to get the name of the hostsite
		db = DB()
		hostSite = db.getHostSiteByName(hostSiteName)

		#This for loop loops through the list of dictionaries and selects certain values to add to the table

		for order in orders:
			is_not_overdue = False
			d_date = datetime.datetime.strptime(order.get('distribution_date'), '%Y-%m-%d') - datetime.timedelta(days=12)
			current_date = datetime.datetime.today()
			
			
			if (current_date < d_date):
				is_not_overdue = True
				
# 			if str(order.get('hostsitepickup_idFK','')) != str(hostSite.get('id')):
# 				continue;

			tableStr += "<tr id=\"" + str(order.get('id')) + "\">"
			tableStr += "<td>" + hostSiteName +"</td>"
			
			tableStr += "<td>" + str(order.get('distribution_date')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_first_name')) + " " + str(order.get('customer_last_name')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_phone')) +"</td>"
			tableStr += "<td>" + str(order.get('customer_email'))
			if str(order.get('email_notifications')) == "1":
				tableStr += " (Notifications)</td>"
			else:
				tableStr += "</td>"
			
			tableStr += "<td>" + str(order.get('small_quantity')) +"</td>"
			tableStr += "<td>" + str(order.get('large_quantity')) +"</td>"
			if float(order.get('total_paid')) > 0.0:
				isPaid = "Paid"
				buttonType = "success"
			else:
				isPaid = "Unpaid"
				if (is_not_overdue):
					buttonType = "primary"
				else:
					buttonType = "warning"
			tableStr += "<td><button id=\"paid_" + str(order.get('id')) + "\" type=\"button\" class=\"label label-"+ buttonType + "\">" + isPaid +"</td>"
			
			cost = 20.0 * float(order.get('large_quantity', 0)) + 15.0 * float(order.get('small_quantity', 0))
			owe = cost - float(order.get('total_paid', 0.00))
# 			tableStr += "<td>" + str(owe) +"</td>"
# 			
# 			tableStr += "<td>" + str(order.get('donation'))
			if str(order.get('donation_receipt')) == "1":
				tableStr += " (Reciept)</td>"
			else:
				tableStr += "</td>"

			tableStr += "<td>" + str(order.get('creation_date')) +"</td>"
			tableStr += "</td>"
			
			tableStr += "<td><button id=\"delete_" + str(order.get('id')) + "\" type=\"button\" class=\"btn btn-danger\" onclick=\"deleteClicked(event);\">Delete</button></td>"
		
			tableStr += "</tr>"

		tableStr += "</tbody></table>"
		return tableStr
Exemple #6
0
	def __init__(self, orderId, creationDate, distributionDate, customerFirstName, customerLastName, customerEmail, customerPhone, emailNotifications, smallQuantity, largeQuantity, donation, donationReceipt, totalPaid, hostsitepickupIdFK, hostsitecreatedIdFK, customerID):
		
		values = [None,'']

		#basic error checking is done. If a parameter is an empty string or None it is set to a default vaule

		if orderId in values:
			self.orderId = None
		else:
			self.orderId = orderId

		if distributionDate in values:
			self.distributionDate = None
		else:
			# mm/dd/yyyy
			parts = distributionDate.split('-')
			d = datetime.date(int(parts[0]),int(parts[1]),int(parts[2]))
			self.distributionDate = d

		if creationDate in values:
			self.creationDate = None
		else:
			# mm/dd/yyyy
			parts = creationDate.split('-')
			d = datetime.date(int(parts[0]),int(parts[1]),int(parts[2]))
			self.creationDate = d

		if customerFirstName in values:
			self.customerFirstName = None
		else:
			self.customerFirstName = customerFirstName

		if customerLastName in values:
			self.customerLastName = None
		else:
			self.customerLastName = customerLastName

		if customerEmail in values:
			self.customerEmail = ''
		else:
			self.customerEmail = customerEmail

		if customerPhone in values:
			self.customerPhone = ''
		else:
			self.customerPhone = customerPhone

		if emailNotifications in values:
			self.emailNotifications = 0
		else:
			self.emailNotifications = emailNotifications

		if smallQuantity in values:
			self.smallQuantity = 0
		else:
			self.smallQuantity = smallQuantity

		if largeQuantity in values:
			self.largeQuantity = 0
		else:
			self.largeQuantity = largeQuantity

		if donation in values:
			self.donation = 0
		else:
			self.donation = donation

		if donationReceipt in values:
			self.donationReceipt = 0
		else:
			self.donationReceipt = donationReceipt

		if totalPaid in values:
			self.totalPaid = 0
		else:
			self.totalPaid = totalPaid
		
		if customerID in values:
			self.customerID = None
		else:
			self.customerID = customerID
			
		if hostsitepickupIdFK in values:
			self.hostsitepickupIdFK = None
		else:
			self.hostsitepickupIdFK = hostsitepickupIdFK

		if hostsitecreatedIdFK in values:
			self.hostsitecreatedIdFK = None
		elif hostsitecreatedIdFK == "-99":
			# this order was placed online
			db = DB()
			hostSite = db.getHostSiteByName("Online")
			self.hostsitecreatedIdFK = hostSite.get('id')
		else:
			self.hostsitecreatedIdFK = hostsitecreatedIdFK
		
		self.dict = {}
Exemple #7
0
    def toDistList(orders, hostSiteName):
        tableStr = "<div class=\"input-group\" style=\"padding-top: 0;margin-bottom: 5px; margin-top: 0; padding-left: 0\"><span class=\"input-group-addon\">Filter</span><input id=\"filterbox\" type=\"text\" class=\"form-control\" placeholder=\"Type here to filter the table (by sites, dates, names, etc.)\"></div>"
        tableStr += "<table class=\"table\" id=\"usersTable\" style=\"background-color:white;cursor: pointer; cursor: hand; \"><thread><tr id=\"info\"><th>Pickup Site</th><th>Pickup Date</th><th>Customer</th><th>Phone</th><th>Email</th><th>No. Small</th><th>No. Large</th><th>Paid</th><th>Ordered On</th><th></th></tr></thread><tbody class=\"searchable\">"

        #calls to database is made to get the name of the hostsite
        db = DB()
        hostSite = db.getHostSiteByName(hostSiteName)

        #This for loop loops through the list of dictionaries and selects certain values to add to the table

        for order in orders:
            is_not_overdue = False
            d_date = datetime.datetime.strptime(
                order.get('distribution_date'),
                '%Y-%m-%d') - datetime.timedelta(days=12)
            current_date = datetime.datetime.today()

            if (current_date < d_date):
                is_not_overdue = True

# 			if str(order.get('hostsitepickup_idFK','')) != str(hostSite.get('id')):
# 				continue;

            tableStr += "<tr id=\"" + str(order.get('id')) + "\">"
            tableStr += "<td>" + hostSiteName + "</td>"

            tableStr += "<td>" + str(order.get('distribution_date')) + "</td>"
            tableStr += "<td>" + str(
                order.get('customer_first_name')) + " " + str(
                    order.get('customer_last_name')) + "</td>"
            tableStr += "<td>" + str(order.get('customer_phone')) + "</td>"
            tableStr += "<td>" + str(order.get('customer_email'))
            if str(order.get('email_notifications')) == "1":
                tableStr += " (Notifications)</td>"
            else:
                tableStr += "</td>"

            tableStr += "<td>" + str(order.get('small_quantity')) + "</td>"
            tableStr += "<td>" + str(order.get('large_quantity')) + "</td>"
            if float(order.get('total_paid')) > 0.0:
                isPaid = "Paid"
                buttonType = "success"
            else:
                isPaid = "Unpaid"
                if (is_not_overdue):
                    buttonType = "primary"
                else:
                    buttonType = "warning"
            tableStr += "<td><button id=\"paid_" + str(
                order.get('id')
            ) + "\" type=\"button\" class=\"label label-" + buttonType + "\">" + isPaid + "</td>"

            cost = 20.0 * float(order.get('large_quantity', 0)) + 15.0 * float(
                order.get('small_quantity', 0))
            owe = cost - float(order.get('total_paid', 0.00))
            # 			tableStr += "<td>" + str(owe) +"</td>"
            #
            # 			tableStr += "<td>" + str(order.get('donation'))
            if str(order.get('donation_receipt')) == "1":
                tableStr += " (Reciept)</td>"
            else:
                tableStr += "</td>"

            tableStr += "<td>" + str(order.get('creation_date')) + "</td>"
            tableStr += "</td>"

            tableStr += "<td><button id=\"delete_" + str(
                order.get('id')
            ) + "\" type=\"button\" class=\"btn btn-danger\" onclick=\"deleteClicked(event);\">Delete</button></td>"

            tableStr += "</tr>"

        tableStr += "</tbody></table>"
        return tableStr
Exemple #8
0
    def __init__(self, orderId, creationDate, distributionDate,
                 customerFirstName, customerLastName, customerEmail,
                 customerPhone, emailNotifications, smallQuantity,
                 largeQuantity, donation, donationReceipt, totalPaid,
                 hostsitepickupIdFK, hostsitecreatedIdFK, customerID):

        values = [None, '']

        #basic error checking is done. If a parameter is an empty string or None it is set to a default vaule

        if orderId in values:
            self.orderId = None
        else:
            self.orderId = orderId

        if distributionDate in values:
            self.distributionDate = None
        else:
            # mm/dd/yyyy
            parts = distributionDate.split('-')
            d = datetime.date(int(parts[0]), int(parts[1]), int(parts[2]))
            self.distributionDate = d

        if creationDate in values:
            self.creationDate = None
        else:
            # mm/dd/yyyy
            parts = creationDate.split('-')
            d = datetime.date(int(parts[0]), int(parts[1]), int(parts[2]))
            self.creationDate = d

        if customerFirstName in values:
            self.customerFirstName = None
        else:
            self.customerFirstName = customerFirstName

        if customerLastName in values:
            self.customerLastName = None
        else:
            self.customerLastName = customerLastName

        if customerEmail in values:
            self.customerEmail = ''
        else:
            self.customerEmail = customerEmail

        if customerPhone in values:
            self.customerPhone = ''
        else:
            self.customerPhone = customerPhone

        if emailNotifications in values:
            self.emailNotifications = 0
        else:
            self.emailNotifications = emailNotifications

        if smallQuantity in values:
            self.smallQuantity = 0
        else:
            self.smallQuantity = smallQuantity

        if largeQuantity in values:
            self.largeQuantity = 0
        else:
            self.largeQuantity = largeQuantity

        if donation in values:
            self.donation = 0
        else:
            self.donation = donation

        if donationReceipt in values:
            self.donationReceipt = 0
        else:
            self.donationReceipt = donationReceipt

        if totalPaid in values:
            self.totalPaid = 0
        else:
            self.totalPaid = totalPaid

        if customerID in values:
            self.customerID = None
        else:
            self.customerID = customerID

        if hostsitepickupIdFK in values:
            self.hostsitepickupIdFK = None
        else:
            self.hostsitepickupIdFK = hostsitepickupIdFK

        if hostsitecreatedIdFK in values:
            self.hostsitecreatedIdFK = None
        elif hostsitecreatedIdFK == "-99":
            # this order was placed online
            db = DB()
            hostSite = db.getHostSiteByName("Online")
            self.hostsitecreatedIdFK = hostSite.get('id')
        else:
            self.hostsitecreatedIdFK = hostsitecreatedIdFK

        self.dict = {}