Example #1
0
def index():
    menu = "societe"
    submenu = "entreprise"
    context = "charge"
    title_page = "Parametre - Charges/Impots"

    search = False
    q = request.args.get("q")
    if q:
        search = True
    try:
        page = int(request.args.get("page", 1))
    except ValueError:
        page = 1

    datas = Charge.query()

    pagination = Pagination(
        css_framework="bootstrap3", page=page, total=datas.count(), search=search, record_name="Charges"
    )

    if datas.count() > 10:
        if page == 1:
            offset = 0
        else:
            page -= 1
            offset = page * 10

        datas = Charge.query().fetch(limit=10, offset=offset)

    return render_template("charge/index.html", **locals())
Example #2
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'charge'
    title_page = 'Parametre - Charges/Impots'

    search = False
    q = request.args.get('q')
    if q:
        search = True
    try:
        page = int(request.args.get('page', 1))
    except ValueError:
        page = 1

    offset = 0
    limit = 25
    if page > 1:
        offset = ((page - 1) * 25)

    datas = Charge.objects().skip(offset).limit(limit)
    count = Charge.objects().count()

    pagination = Pagination(css_framework='bootstrap3', page=page, total=count, search=search, record_name='Charges')

    return render_template('charge/index.html', **locals())
Example #3
0
def delete(charge_id):
    charges = Charge.get_by_id(charge_id)

    from ..budget.models_budget import ChargeBudget

    bugdet = ChargeBudget.query(ChargeBudget.charge_id == charges.key).count()

    if bugdet:
        flash("Impossible de supprimer cet element", "warning")
    else:
        charges.key.delete()
        flash("Suppression reussie", "success")
    return redirect(url_for("charge.index"))
Example #4
0
def edit(charge_id=None):

    if charge_id:
        charges = Charge.get_by_id(charge_id)
        form = FormCharge(obj=charges)
    else:
        charges = Charge()
        form = FormCharge()

    success = False
    if form.validate_on_submit():
        entreprise = Societe.query().get()

        charges.libelle = form.libelle.data
        charges.societe = entreprise.key
        charges.put()

        flash("Enregistement effectue avec succes", "success")
        success = True

    return render_template("charge/edit.html", **locals())
Example #5
0
def edit(charge_id=None):

    if charge_id:
        charges = Charge.objects.get(id=charge_id)
        form = FormCharge(obj=charges)
    else:
        charges = Charge()
        form = FormCharge()

    success = False
    if form.validate_on_submit():
        entreprise = Societe.objects.first()

        charges.libelle = form.libelle.data
        charges.societe = entreprise
        charges.save()

        flash('Enregistement effectue avec succes', 'success')
        success = True

    return render_template('charge/edit.html', **locals())