{{ _('MyHoreca OLAP-to-GoogleSheets') }}

{% if current_user.is_authenticated %}
{{ _('Logged in as:') }} {{ current_user.username }} | {{ _('Logout') }} 🇷🇺 / 🇬🇧
{% else %}
{{ _('Login') }} | {{ _('Register') }}
{% endif %} {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %}
{{ message }}
{% endfor %} {% endif %} {% endwith %} {% if current_user.is_authenticated %}

{{ _('RMS Server Configuration') }}

{% trans %}Enter the details for your RMS server API. This information is used to connect, authenticate, and retrieve the list of available OLAP report presets.{% endtrans %}




{% if rms_config.password_is_set %} {{ _('Password is saved. Enter a new one only if you need to change it.') }}
{% else %} {{ _('Enter the API password for your RMS server.') }}
{% endif %}
{% if presets %}

{{ _('Status:') }} {% trans num=presets|length %}Successfully connected to RMS. Found %(num)s OLAP presets.{% endtrans %}

{% elif rms_config.get('host') %}

{{ _('Status:') }} {{ _('RMS configuration saved. Presets not yet loaded or connection failed.') }}

{% endif %}

{{ _('Google Sheets Configuration') }}

{% trans %}To allow the application to write to your Google Sheet, you need to provide credentials for a Google Service Account. This account will act on behalf of the application.{% endtrans %}

{{ _('How to get credentials:') }}
1. {{ _('Go to Google Cloud Console.') }}
2. {{ _('Create a new project or select an existing one.') }}
3. {{ _('Enable the "Google Sheets API" and "Google Drive API" for the project.') }}
4. {{ _('Go to "Credentials", click "Create Credentials", choose "Service Account".') }}
5. {{ _('Give it a name and grant it the "Editor" role.') }}
6. {{ _('Create a JSON key for the service account and download the file.') }}
7. {% trans %}Share your target Google Sheet with the service account's email address (found in the downloaded JSON file, key `client_email`).{% endtrans %}


{% if client_email %}

{{ _('Current Service Account Email:') }} {{ client_email }}

{{ _('Upload a new file only if you need to change credentials.') }}
{% else %} {{ _('Upload the JSON file downloaded from Google Cloud Console.') }}
{% endif %}

{% trans %}Enter the URL of the Google Sheet you want to use. The service account email (shown above after uploading credentials) must have edit access to this sheet.{% endtrans %}

{% if sheets %}

{{ _('Status:') }} {% trans num=sheets|length %}Successfully connected to Google Sheet. Found %(num)s worksheets.{% endtrans %}

{% elif google_config.get('sheet_url') %}

{{ _('Status:') }} {{ _('Google Sheet URL saved. Worksheets not yet loaded or connection failed.') }}

{% endif %}

{{ _('Map Worksheets to OLAP Reports') }}

{% trans %}Select which OLAP report from RMS should be rendered into each specific worksheet (tab) in your Google Sheet.{% endtrans %}

{% if sheets and presets %}
{% for sheet in sheets %} {% endfor %}
{{ _('Worksheet (Google Sheets)') }} {{ _('OLAP-report (RMS)') }}
{{ sheet.title }}
{% elif not sheets and not presets %}

{{ _('Worksheets and OLAP presets are not loaded. Please configure RMS and Google Sheets first.') }}

{% elif not sheets %}

{{ _('Worksheets are not loaded. Check Google Sheets configuration.') }}

{% elif not presets %}

{{ _('OLAP presets are not loaded. Check RMS configuration.') }}

{% endif %}

{{ _('Render Reports') }}

{% trans %}Select the date range and click "Render to sheet" for each mapping you wish to execute. The application will retrieve the OLAP data from RMS for the selected report and period, clear the corresponding worksheet in Google Sheets, and write the new data.{% endtrans %}

{% if mappings and mappings|length > 0 %}


{% for sheet in sheets %} {% set mappings = mappings.get(sheet.title) %} {% if mapping_info and mapping_info.get('report_id') %} {% set report_id = mapping_info.get('report_id') %} {% set matching_presets = presets | selectattr('id', 'equalto', report_id) | list %} {% set preset_name = _('ID: ') + report_id %} {% if matching_presets %} {% set preset = matching_presets[0] %} {% set preset_name = preset.get('name', _('Unnamed Preset')) %} {% endif %} {% endif %} {% endfor %}
{{ _('Worksheet') }} {{ _('Mapped OLAP Report') }} {{ _('Action') }}
{{ sheet.title }} {{ preset_name }}
{% else %}

{{ _('No mappings configured yet.') }}

{{ _('Please go to the "Mapping Sheets to OLAP Reports" section (Step 3) to set up mappings.') }}

{% endif %}

{{ _('Schedule Settings') }}

{% trans %}Here you can set up a CRON schedule for automatic report generation. The report will be generated for the specified period relative to the execution time.{% endtrans %}

{{ _('Cron Schedule Builder') }}

{% trans %}Use this tool to build a cron string, then copy it to the desired field below.{% endtrans %}


{% for sheet_title, params in mappings.items() %} {% endfor %}
{{ _('Worksheet') }} {{ _('Schedule (Cron)') }} {{ _('Report Period') }}
{{ sheet_title }} {% set current_period = params.get('schedule_period', '') %}
{% else %}

{{ _('Please,') }} {{ _('login') }} {{ _('or') }} {{ _('register') }}

{% endif %}