Example #1
0
def GrabService(code):
    s = InvoicesAPI.GetService(code)
    return jsonify(serviceid=s[0],
                   servicename=s[1],
                   servicetype=s[2],
                   servicecost=s[3],
                   serviceprice=s[4])
Example #2
0
def EditService(code):
    AllServices = InvoicesAPI.GetAllServices()
    Service = InvoicesAPI.GetService(code)
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                InvoicesAPI.UpdateService(
                    session['username'], session['password'], code,
                    request.form['servicename'], request.form['servicetype'],
                    request.form['servicecost'], request.form['serviceprice'],
                    request.form['description'])
                flash('Service updated successfully...', category='success')
                return redirect(url_for('invoices.Services'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.EditService', code=code))
    return render_template('invoices/edit_service.html',
                           username=session['username'],
                           role=session['role'],
                           AllServices=AllServices,
                           Service=Service)