def items(): form = EnterForms.ItemsForm(request.form) data = EnterpriseAPI.GetItems() form.Group.choices = EnterpriseAPI.Groups() form.SecondaryUnit.choices = EnterpriseAPI.SecondaryUnits() form.Provider.choices = EnterpriseAPI.ProvidersList() if request.method == 'POST': if request.form['submit'] == 'Submit' and form.validate(): try: EnterpriseAPI.CreateItem( session['username'], session['password'], request.form['ItemName'], request.form['Brand'], request.form['Provider'], request.form['Unit'], request.form['UnitPrice'], request.form['UnitCost'], request.form['Description'], request.form['Size'], request.form['Color'], request.form['SKU'], request.form['PartNumber'], request.form['IEME'], request.form['Length'], request.form['Width'], request.form['Height'], request.form['Diameter'], request.form['LengthUnit'], request.form['WidthUnit'], request.form['HeightUnit'], request.form['DiamaterUnit'], request.form['Group'], request.form['Category'], request.form['SecondaryUnit']) flash('Item added successfully', category='success') return redirect(url_for('invoices.items')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('invoices.items')) return render_template('invoices/items.html', username=session['username'], role=session['role'], form=form, data=data)
def edit_item(itm): data = EnterpriseAPI.GetItems() data1 = EnterpriseAPI.FetchItem(itm) provs = EnterpriseAPI.ProvidersList() grp = EnterpriseAPI.Groups() secunit = EnterpriseAPI.SecondaryUnits() wh = EnterpriseAPI.GetWareHouses() if request.method == 'POST': if request.form['submit'] == 'Submit': #try: EnterpriseAPI.UpdateItem( session['username'], session['password'], itm, request.form['ItemName'], request.form['Brand'], request.form['Provider'], request.form['Unit'], request.form['UnitPrice'], request.form['UnitCost'], request.form['Description'], request.form['Size'], request.form['Color'], request.form['SKU'], request.form['PartNumber'], request.form['IEME'], request.form['Length'], request.form['Width'], request.form['Height'], request.form['Diameter'], request.form['LengthUnit'], request.form['WidthUnit'], request.form['HeightUnit'], request.form['DiamaterUnit'], request.form['Group'], request.form['Category'], request.form['SecondaryUnit']) flash('Item updated successfully', category='success') return redirect(url_for('logistics.items')) #except Exception as e: # flash(str(e), category = 'fail') # return redirect(url_for('logistics.items')) return render_template('logistics/edit_item.html', username=session['username'], role=session['role'], data=data, data1=data1, provs=provs, grp=grp, wh=wh, secunit=secunit)