Exemple #1
0
def edit_package(pkg):
    pks, itms = EnterpriseAPI.FetchPackage(pkg)
    pkk = EnterpriseAPI.GetPackages()
    itt = EnterpriseAPI.ItemPicker()
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                EnterpriseAPI.UpdatePackage(session['username'],
                                            session['password'], pkg,
                                            request.form['packagename'],
                                            request.form.getlist('code'),
                                            request.form.getlist('Name'),
                                            request.form.getlist('unit'),
                                            request.form.getlist('unitprice'),
                                            request.form.getlist('unitcost'),
                                            request.form.getlist('quantity'),
                                            request.form['description'])
                flash('Package Updated Successfully', category='success')
                return redirect(url_for('invoices.packages'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.packages'))
    return render_template('invoices/edit_package.html',
                           username=session['username'],
                           role=session['role'],
                           pks=pks,
                           itms=itms,
                           pkk=pkk,
                           itt=itt)
Exemple #2
0
def packages():
    itms = EnterpriseAPI.ItemPicker()
    pkg = EnterpriseAPI.GetPackages()
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                EnterpriseAPI.CreatePackage(session['username'],
                                            session['password'],
                                            request.form['packagename'],
                                            request.form.getlist('code'),
                                            request.form.getlist('Name'),
                                            request.form.getlist('unit'),
                                            request.form.getlist('unitprice'),
                                            request.form.getlist('unitcost'),
                                            request.form.getlist('quantity'),
                                            request.form['description'])
                flash('Package Created Successcully', category='success')
                return redirect(url_for('invoices.packages'))
            except Exception as e:
                i = str(request.form.getlist('unit'))
                flash(str(e), category='fail')
                return redirect(url_for('invoices.packages'))

    return render_template('invoices/packages.html',
                           username=session['username'],
                           role=session['role'],
                           itms=itms,
                           pkg=pkg)