{% extends "layout.html" %} {% macro chartScript(divId, data, unit)%} {% set hash = divId | md5 %} data_{{ hash }} = [{% for stop in data %}{ "date": "{{stop.date}}", "value": {{stop.value}} }{% if not loop.last %},{%endif%} {% endfor%} ] var chart_{{ hash }} = createChart('{{divId}}', data_{{ hash }}, '{{unit}}'); function zoom_chart_{{ hash }}() { chart_{{ hash }}.zoomToIndexes( chart_{{ hash }}.dataProvider.length - 40, chart_{{ hash }}.dataProvider.length - 1 ); } chart_{{ hash }}.addListener("rendered", zoom_chart_{{ hash }}); zoom_chart_{{ hash }}() {% endmacro %} {% macro nav_tab(id, text, active) %} {# Create a UI element to select the shown pane of a tabbed view id: id of the pane to select text: the text in the UI element active: boolean stating if the tab is active or not #}
  • {{ text }}
  • {% endmacro %} {% macro tab_pane(id, content, active) %}
    {{ content }}
    {% endmacro %} {% macro chart(data, baseId, unit, link) %} {% if data|length > 0 %} {% set chartID = 'chart_' + baseId %}
    {% else %} {% endif %} {% endmacro %} {% macro print_consumable_table(consumable) %}
    Average Distance: {{ consumable.average_distance | round(2) }} km
    Amount fuelled: {{ consumable.overall_amount | round(2) }} {{ consumable.unit }}
    Average Amount fuelled: {{ consumable.average_amount_fuelled | round(2) }} {{ consumable.unit }}
    Average Amount used: {{ consumable.average_amount_used | round(2) }} {{ consumable.unit }}/100km
    {% endmacro %} {% macro print_vehicle_table(vehicle) %}

    {{vehicle.name}}

    {% if vehicle.costs_per_distance != 'N/A' %} {% else %} {% endif %}
    Logged Distance: {{ vehicle.overall_distance | round(2) }} km
    Logged Costs: {{ vehicle.overall_costs | round(2) }} €
    Logged Costs per km:{{ vehicle.costs_per_distance | round(2) }} €/100km{{ vehicle.costs_per_distance }}
    {% endmacro %} {% macro tab_script(id) %} {% endmacro %} {% block body %}
    {% for vehicle in data %}
    {{ print_vehicle_table(vehicle) }}
    {{ tab_pane( vehicle.id|string + '_odometer', chart( vehicle.odometers, 'ref_' + vehicle.id|string + '_odometer', 'km', url_for('select_consumable_for_new_pitstop', vid=vehicle.id) ), true ) }} {{ tab_pane( vehicle.id|string + '_costs', chart( vehicle.costs, 'ref_' + vehicle.id|string + '_costs', '€', url_for('select_consumable_for_new_pitstop', vid=vehicle.id) ), false ) }} {% for consumable in vehicle.consumables %}
    {{ print_consumable_table(consumable) }}
    {{ tab_pane( vehicle.id|string + '_' + consumable.id|string + '_consumption', chart( consumable.average_amount, 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_consumption', consumable.unit + '/100km', url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) ), true ) }} {{ tab_pane( vehicle.id|string + '_' + consumable.id|string + '_amount', chart( consumable.amounts, 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_amount', consumable.unit, url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) ), false ) }} {{ tab_pane( vehicle.id|string + '_' + consumable.id|string + '_price', chart( consumable.price, 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_price', '€ / '+consumable.unit, url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) ), false ) }}
    {{ tab_script('vehicle_' + vehicle.id|string + '_' + consumable.id|string + '_tabs') }}
    {% endfor %}
    {{ tab_script('vehicle_' + vehicle.id|string + '_tabs') }}
    {% endfor %}
    {{ tab_script('vehicle_tabs') }}
    {% endblock %}