def edit_provider(prv): form = EnterForms.ProvidersForm(request.form) data = EnterpriseAPI.GetProviders() data1 = EnterpriseAPI.FetchProvider(session['username'], session['password'], prv) if request.method == 'POST': if request.form['submit'] == 'Submit' and form.validate(): try: EnterpriseAPI.UpdateProvider( session['username'], session['password'], prv, request.form['name'], request.form['address'], request.form['phone1'], request.form['phone2'], request.form['email'], request.form['pobox'], request.form['description']) flash('Provider updated successfully', category='success') return redirect(url_for('invoices.Providers')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('invoices.Providers')) return render_template('invoices/edit_provider.html', username=session['username'], role=session['role'], form=form, data=data, data1=data1)
def Providers(): form = EnterForms.ProvidersForm(request.form) data = EnterpriseAPI.GetProviders() wh = EnterpriseAPI.GetWareHouses() if request.method == 'POST': if request.form['submit'] == 'Submit' and form.validate(): try: EnterpriseAPI.CreateProvider( session['username'], session['password'], request.form['name'], request.form['address'], request.form['phone1'], request.form['phone2'], request.form['email'], request.form['pobox'], request.form['description']) flash('Provider added Successfully', category='success') return redirect(url_for('logistics.Providers')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('logistics.Providers')) return render_template('logistics/providers.html', username=session['username'], role=session['role'], form=form, data=data, wh=wh)