Exemple #1
0
def temp():
	print((request.form.getlist('productName')))
	incompleteVal ='False'
	multi =False
	if len(request.form.getlist('productName'))>2:

		productName =request.form.get('productName','')
		if productName == "":
			incompleteVal = 'True'
		products =request.form.getlist('productName')
		chineseName = request.form.get('chinese_name','')
		chinese = request.form.getlist('chinese_name')
		if chineseName == "":
			incompleteVal = 'True'
		SKU =request.form.get('SKU','')
		SKUS =request.form.getlist('SKU')
		if SKU == "":
			incompleteVal = 'True'

		multi ='True'
	else:
		productName =request.form.get('productName')
		if productName == "":
			incompleteVal = 'True'
		chineseName = request.form.get('chinese_name')
		if chineseName == "":
			incompleteVal = 'True'
		SKU =request.form.get('SKU')
		if SKU == "":
			incompleteVal = 'True'
		multi = 'False'

	colour =request.form.get('Colour','')
	if colour == "":
			incompleteVal = 'True'
	weight =request.form.get('weight','')
	if weight == "":
			incompleteVal = 'True'
	height =request.form.get('Height','')
	if height == "":
			incompleteVal = 'True'
	width =request.form.get('Width','')
	if width == "":
			incompleteVal = 'True'
	lenght =request.form.get('Lenght','')
	if lenght == "":
			incompleteVal = 'True'
	description =request.form.get('item_description','')
	if description == "":
			incompleteVal = 'True'
	material =request.form.get('item_materials','')
	if material == "":
			incompleteVal = 'True'
	quantity_inStock =request.form.get('stock','')
	
	if quantity_inStock == '':
			quantity_inStock = 0
			incompleteVal = 'True'
	currency =request.form.get('currencyType')
	if currency == "":
			incompleteVal = 'True'
	cost_price =request.form.get('cost_price',0.00)
	if cost_price == 0.00:
			incompleteVal = 'True'
	category = request.form.get('category')
	print(category)
	if category == "none":
		print('cat true')
		incompleteVal = 'True'
	elif category == 'OtherCat':
		print('other cat')
		category = request.form['otherCat']
		if categories.objects(category=(request.form['otherCat']).capitalize()).count()>0:
			pass
		else:
			catagoryCreate((request.form['otherCat']).capitalize())
	envelope = request.form.get('envelope','none')  
	if envelope == "none":
		incompleteVal = 'True'
	elif envelope == "Other":
		envelope = request.form['envName']
		enveCreate(envelope)
	if 1==1:
		if productInfo.objects(productName=productName).count()>1:
			print('asdfasdfsdf')
			return(redirect(url_for('products')))
	
		else:
			if productInfo.objects(SKU=SKU) == True:
					pass
			else:
				if currency == 'AUD':
					AUD = float(cost_price)
					USD = AUD/1.4
					RMB = AUD* 4.77
				elif currency == 'USD':
					AUD = 1.4 * float(cost_price)
					USD = float(cost_price)
					RMB = 6.68 * float(cost_price)
				elif currency == 'RMB':
					RMB = float(cost_price)
					USD = RMB/6.68
					AUD = .21 * RMB 
				else:
					AUD = 0.00
					USD = 0.00
					RMB = 0.00

				
				fileExists = tHistory.find({ "Item Title": productName})
				if fileExists.count() >0:
					stockOut = 0
					for i in range(fileExists.count()):
						stockOut += int(fileExists[i]['Quantity'])

					if int(quantity_inStock) - int(stockOut)<1:
						itemStockUpdate2(SKU,productName)
						incompleteVal = 'True'
					if multi =='True':
						itemInsert5(productName,chineseName,SKU,products,chinese,SKUS,colour,weight,height,width,lenght,description,material,int(quantity_inStock),int(AUD),int(RMB),int(USD),category,incompleteVal,stockOut)
					else:
						itemInsert2(productName,chineseName,SKU,colour,weight,height,width,lenght,description,material,int(quantity_inStock),int(AUD),int(RMB),int(USD),category,incompleteVal,stockOut)
					
					noteExists = notificationUnautItem.objects(itemName=productName).delete()
					
				else:
					#if len(productName)>1:
					if multi =='True':
						itemInsert5(productName,chineseName,SKU,products,chinese,SKUS,colour,weight,height,width,lenght,description,material,int(quantity_inStock),int(AUD),int(RMB),int(USD),category,incompleteVal)
					else:	
						itemInsert(productName,chineseName,SKU,colour,weight,height,width,lenght,description,material,int(quantity_inStock),int(AUD),int(RMB),int(USD),category,incompleteVal)
		
		if notificationUnautItem.objects(SKU = request.form.get('SKU','')).count()>0:
			notificationUnautItem.objects(SKU = request.form.get('SKU','')).delete()		
			x = tHistory.find({'Custom Label': request.form.get('SKU','')})
			for i in x:
				if i['Status'] == 'Incomplete_SKU':
					i['Status'] = 'None'		
	return(redirect(url_for('products')))
Exemple #2
0
def addProduct():
		if 'username' in session:
			temp=categories.objects() 
			
			return render_template('add-product.html',categories =categories.objects(),envelope = envelope.objects() )
		return render_template('login.html')
Exemple #3
0
def editProduct(ItemName):
	if 'username' in session:
		for product in productInfo.objects( productName= ItemName):
			aud = product.cost_AUD
			usd =product.cost_USD
			rmb = product.cost_RMB
			cat = product.category

			if (aud != 0):
				currencyType = 'AUD'
				cost = product.cost_AUD
			elif (usd != 0):
				currencyType = 'USD'
				cost = product.cost_USD
			elif rmb != 0:
				currencyType = 'RMB'
				cost = product.cost_RMB 
			else:
				currencyType ='Select Currency'
				cost = 0.00
			
			item = productInfo.objects( productName= ItemName).first()
			envelopeItem = item.envelope
			


			return render_template('edit-product.html',product = product, currencyType = currencyType, cost = cost, envelope= envelopeItem,selectCat =cat,categories =categories.objects(),envelopes = envelope.objects() )
	return render_template('login.html')
Exemple #4
0
def editTemp(ItemName):

	if not 'username' in session:
		return redirect(url_for('index'))

	
	incompleteVal = 'False'
	productName =request.form.get('productName','')
	if productName == "":
		incompleteVal = 'True'
	chineseName = request.form.get('chinese_name', '')
	if chineseName == "":
		incompleteVal = 'True'
	SKU =request.form.get('SKU','')
	if SKU == "":
		incompleteVal = 'True'
	colour =request.form.get('Colour','')
	if colour == "":
		incompleteVal = 'True'
	weight =request.form.get('weight','')
	if weight == "":
		incompleteVal = 'True'
	height =request.form.get('Height','')
	if height == "":
		incompleteVal = 'True'
	width =request.form.get('Width','')
	if width == "":
		incompleteVal = 'True'
	lenght =request.form.get('Lenght','')
	if lenght == "":
		incompleteVal = 'True'
	description =request.form.get('item_description','')
	if description == "":
		incompleteVal = 'True'
	material =request.form.get('item_materials','')
	if material == "":
		incompleteVal = 'True'
	quantity_inStock =request.form.get('stock','')
	if quantity_inStock == '':
		quantity_inStock = 0
		incompleteVal = 'True'
	currency =request.form.get('currencyType','none')
	if currency == "none":
		incompleteVal = 'True'
	cost_price =request.form.get('cost_price',0.00)
	if cost_price == 0.00:
		cost_price = 0.00
		incompleteVal = 'True'
	category = request.form.get('category','none')
	if category == "none":
		incompleteVal = 'True'
	elif category == 'OtherCat':
		category = request.form.get('otherCat')
		if categories.objects(category=(request.form['otherCat']).capitalize()).count()>0:
			pass
		else:
			catagoryCreate((request.form['otherCat']).capitalize())
	envelope = request.form.get('envelope','none')  
	if envelope == "none":
		incompleteVal = 'True'
	elif envelope == "Other":
		envelope = request.form['OtherEnvelope']
	temp = productInfo.objects(productName = ItemName).delete()
	if currency == 'AUD':
		AUD = int(cost_price)
		USD = AUD/1.4
		RMB = AUD* 4.77
	elif currency == 'USD':
		AUD = 1.4 * int(cost_price)
		USD = int(cost_price)
		RMB = 6.68 * int(cost_price)
	elif currency == 'RMB':
		RMB = int(cost_price)
		USD = RMB/6.68
		AUD = .21 * RMB
	else:
		RMB = 0.00
		USD = 0.00
		AUD =0.00
		currencyType = 'none'
	if productInfo.objects(productName=ItemName) == True:
		return(redirect(url_for('products')))
	else:
		try:
			skucheck = productInfo.objects(SKU = SKU).get()
			for i in skucheck:
				skucheck = i.sku
		except:
			skucheck = 'notExitst'
		if (skucheck)=="notExitst":
					
			itemInsert(productName,chineseName,SKU,colour,weight,height,width,lenght,description,material,int(quantity_inStock),float(AUD),float(RMB),float(USD),category,incompleteVal)
			
				
					
			return redirect(url_for('products'))
		elif skucheck!="notExitst":
			if skucheck !="":
				return render_template('edit-product.html', product = temp,currencyType= currencyType, cost = cost_price,envelope = envelope, hiddenText = 'This SKU is already in use. Please change it')
			else:
							
				itemInsert(productName,chineseName,SKU,colour,weight,height,width,lenght,description,material,int(quantity_inStock),float(AUD),float(RMB),float(USD),category,incompleteVal)
				
					
				return redirect(url_for('products'))
		return redirect(url_for('products'))
Exemple #5
0
def categoryDelete(category):
		categories.objects(category=category).delete()
		return redirect(url_for('products'))