Example #1
0
def delete(client_id):
    from ..budget.models_budget import ClientBudget
    from ..projet.models_projet import Projet

    prospect = request.args.get('prospect')

    client = Client.get_by_id(client_id)

    projet_client = Projet.query(
        Projet.client_id == client.key
    ).count()

    if projet_client:
        flash('Impossible de supprimer cette element', 'danger')
    else:
        contact_client = Contact.query(
            Contact.client_id == client.key
        )

        budget_client = ClientBudget.query(
            ClientBudget.client_id == client.key
        )

        for contact in contact_client:
            contact.key.delete()

        for client in budget_client:
            client.key.delete()

        client.key.delete()
        flash('Suppression reussie', 'success')

    return redirect(url_for('client.index', prospect=prospect))
Example #2
0
def index():
    menu = 'client'
    submenu = 'contact'
    context = 'charge'
    title_page = 'Client - Contact'

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

    datas = Contact.query()
    pagination = Pagination(css_framework='bootstrap3', page=page, total=datas.count(), search=search, record_name='Contacts')
    if datas.count() > 10:
        if page == 1:
            offset = 0
        else:
            page -= 1
            offset = page * 10
        datas = datas.fetch(limit=10, offset=offset)

    return render_template('client/contacts.html', **locals())
Example #3
0
def contact(client_id, prospect=None):
    menu = 'client'
    if prospect:
        submenu = 'prospect'
        title_page = 'Prospect'
    else:
        submenu = 'client'
        title_page = 'Client'
    context = 'contact'

    client = Client.get_by_id(client_id)

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

    datas = Contact.query(
        Contact.client_id == client.key
    )
    pagination = Pagination(css_framework='bootstrap3', page=page, total=datas.count(), search=search, record_name='Contact')

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

    return render_template('client/contact.html', **locals())