{% extends "base.html" %} {% block title %}{{ company.name }} - Panel Admin{% endblock %} {% block extra_css %} {% endblock %} {% block content %}

{{ company.name }} {{ company.status or 'pending' }}

{{ completeness.score }}%
Kompletność
{{ users|length }}
Użytkownicy
{{ company.created_at|local_time('%d.%m.%Y') if company.created_at else '---' }}
Utworzono

Dane firmy

{% if enrichment.logo.path %} Logo {{ company.name }} {% else %} {% endif %}

{{ company.name }}

{% if company.legal_name and company.legal_name != company.name %}
{{ company.legal_name }}
{% endif %}
NIP
{% if company.nip %}{{ company.nip }}{% else %}{% endif %}
KRS
{% if company.krs %}{{ company.krs }}{% else %}{% endif %}
REGON
{% if company.regon %}{{ company.regon }}{% else %}{% endif %}
Forma prawna
{{ company.legal_form or '' }}{%- if not company.legal_form %}{% endif %}
PKD
{% if company.pkd_code %}{{ company.pkd_code }}{% if company.pkd_description %} — {{ company.pkd_description }}{% endif %}{% else %}{% endif %}
Właściciel
{% if company.owner_first_name or company.owner_last_name %}{{ company.owner_first_name or '' }} {{ company.owner_last_name or '' }}{% else %}{% endif %}
Adres
{% if company.address_street or company.address_city %} {{ company.address_street or '' }}{% if company.address_street and company.address_city %}, {% endif %} {{ company.address_postal or '' }} {{ company.address_city or '' }} {% else %} {% endif %}
Email
{% if company.email %}{{ company.email }}{% else %}{% endif %}
Telefon
{{ company.phone or '' }}{%- if not company.phone %}{% endif %}
Strona WWW
{% if company.website %}{{ company.website }}{% else %}{% endif %}
Kategoria
{{ company.category.name if company.category else '' }}{%- if not company.category %}{% endif %}
Opis
{% if company.description_short %}{{ company.description_short[:200] }}{% if company.description_short|length > 200 %}...{% endif %}{% else %}{% endif %}
{% if company.admin_notes %}
Notatki administracyjne
{{ company.admin_notes }}
{% endif %}

Workflow uzbrajania firmy

1

Dane urzędowe

{% if enrichment.registry.done %} Wykonano{% if enrichment.registry.date %} {{ enrichment.registry.date|local_time('%d.%m.%Y') }}{% endif %} {% else %} Nie wykonano {% endif %}
{% if enrichment.registry.stale %}
Dane z rejestru pobrane ponad 6 mcy temu — odśwież
{% endif %} {% if enrichment.registry.source %}
Źródło: {{ enrichment.registry.source }}
{% endif %}
2

Audyt SEO

{% if enrichment.seo.done %} Wykonano{% if enrichment.seo.date %} {{ enrichment.seo.date|local_time('%d.%m.%Y') }}{% endif %} {% else %} Nie wykonano {% endif %}
{% if enrichment.seo.score is not none and enrichment.seo.score is defined %}
Wynik: {{ enrichment.seo.score }}/100
{% endif %}
3

Audyt Social Media

{% if enrichment.social.done %} Wykonano ({{ enrichment.social.count }} profili) {% else %} Nie wykonano {% endif %}
4

Audyt GBP

{% if enrichment.gbp.done %} Wykonano{% if enrichment.gbp.date %} {{ enrichment.gbp.date|local_time('%d.%m.%Y') }}{% endif %} {% else %} Nie wykonano {% endif %}
{% if enrichment.gbp.score is not none and enrichment.gbp.score is defined %}
Wynik: {{ enrichment.gbp.score }}/100
{% endif %}
5

Logo firmy

{% if enrichment.logo.done %} Pobrano {% else %} Nie pobrano {% endif %}

Podgląd profilu użytkownika

{# Social Media #}

Social Media

{% if social_accounts and social_accounts|length > 0 %}
{% for sm in social_accounts %} {% set colors = {'facebook': '#1877F2', 'instagram': '#E4405F', 'linkedin': '#0A66C2', 'youtube': '#FF0000', 'twitter': '#000000', 'tiktok': '#000000'} %} {% set color = colors.get(sm.platform, '#6b7280') %}
{% if sm.platform == 'facebook' %} {% elif sm.platform == 'instagram' %} {% elif sm.platform == 'linkedin' %} {% elif sm.platform == 'youtube' %} {% elif sm.platform == 'tiktok' %} {% else %} {% endif %}
{{ sm.platform }}
{% if sm.followers_count %}
{{ sm.followers_count }} obserwujących
{% elif sm.page_name %}
{{ sm.page_name|truncate(25) }}
{% endif %} {% if sm.check_status == 'needs_verification' %} Do weryfikacji {% elif sm.is_valid %} Zweryfikowany {% endif %} {% if sm.url %} Zobacz profil {% endif %}
{% endfor %}
{% else %}
Brak profili social media. Uruchom audyt powyżej.
{% endif %}
{# SEO PageSpeed #}

SEO — PageSpeed

{% if seo_analysis and seo_analysis.seo_audited_at %}
{% set scores = [ ('SEO', seo_analysis.pagespeed_seo_score), ('Wydajność', seo_analysis.pagespeed_performance_score), ('Dostępność', seo_analysis.pagespeed_accessibility_score), ('Best Practices', seo_analysis.pagespeed_best_practices_score) ] %} {% for label, score in scores %}
{% if score is not none %} {% if score >= 90 %} {% set sc = '#166534' %}{% set bg = '#dcfce7' %}{% set bc = '#86efac' %} {% elif score >= 50 %} {% set sc = '#92400e' %}{% set bg = '#fef3c7' %}{% set bc = '#fcd34d' %} {% else %} {% set sc = '#991b1b' %}{% set bg = '#fee2e2' %}{% set bc = '#fca5a5' %} {% endif %}
{{ score }}
{% else %}
{% endif %}
{{ label }}
{% endfor %}
{% else %}
Brak audytu SEO. Uruchom audyt powyżej.
{% endif %}
{# GBP #}

Google Business Profile

{% if gbp_audit and gbp_audit.completeness_score is not none %}
{# Reviews #}
{{ gbp_audit.review_count or 0 }}
Opinii
{# Rating #}
{% set rating = gbp_audit.average_rating or 0 %} {% if rating >= 4.5 %}{% set rc = '#166534' %} {% elif rating >= 3.5 %}{% set rc = '#d97706' %} {% else %}{% set rc = '#991b1b' %}{% endif %}
{{ '%.1f'|format(rating) }}
Średnia ocen
{# Photos #}
{{ gbp_audit.photo_count or 0 }}
Zdjęć
{# Completeness #}
{% set cs = gbp_audit.completeness_score %} {% if cs >= 90 %}{% set cc = '#166534' %} {% elif cs >= 50 %}{% set cc = '#d97706' %} {% else %}{% set cc = '#991b1b' %}{% endif %}
{{ cs }}%
Kompletność
{% else %}
Brak audytu GBP. Uruchom audyt powyżej.
{% endif %}

Lista kompletności ({{ completeness.filled }}/{{ completeness.total }})

{% for field_name, is_filled in completeness.fields.items() %}
{% if is_filled %} {{ field_name }} {% else %} {{ field_name }} {% if hints and hints.get(field_name) %}
{{ hints[field_name].source }}{% if hints[field_name].value %}: {{ hints[field_name].value[:40] }}{% endif %} {% if hints[field_name].get('google_name') %} (profil: {{ hints[field_name].google_name[:30] }}) {% endif %} {% if hints[field_name].action == 'apply' and hints[field_name].value %} {% elif hints[field_name].action == 'fetch_registry' %} {% endif %}
{% endif %} {% endif %}
{% endfor %}
{% endblock %} {% block extra_js %} var csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); // Preview section toggle function togglePreview() { var body = document.getElementById('previewBody'); var toggle = document.querySelector('.preview-toggle'); body.classList.toggle('collapsed'); toggle.classList.toggle('collapsed'); } function showToast(message, type) { var container = document.getElementById('toastContainer'); var toast = document.createElement('div'); toast.className = 'toast ' + (type || 'success'); toast.innerHTML = '' + message + '' + ''; container.appendChild(toast); setTimeout(function() { toast.style.animation = 'slideOut 0.3s ease forwards'; setTimeout(function() { toast.remove(); }, 300); }, 5000); } function applyHint(companyId, fieldName, value) { if (!confirm('Uzupełnić pole "' + fieldName + '" wartością: ' + value + '?')) return; fetch('/api/company/' + companyId + '/apply-hint', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrfToken }, body: JSON.stringify({field: fieldName, value: value}) }) .then(function(r) { return r.json(); }) .then(function(data) { if (data.success) { showToast('Pole "' + fieldName + '" uzupełnione', 'success'); setTimeout(function() { location.reload(); }, 1000); } else { showToast('Błąd: ' + data.error, 'error'); } }) .catch(function(err) { showToast('Błąd: ' + err.message, 'error'); }); } var _skipReload = false; function runEnrichAction(btn, url, body) { var original = btn.innerHTML; btn.disabled = true; btn.innerHTML = ' Pobieram...'; return fetch(url, { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify(body || {}) }) .then(function(resp) { return resp.json(); }) .then(function(data) { if (data.success) { showToast(data.message || 'Gotowe!', 'success'); btn.innerHTML = ' Gotowe'; if (!_skipReload) { setTimeout(function() { location.reload(); }, 1500); } return true; } else { showToast(data.error || 'Wystąpił błąd', 'error'); btn.innerHTML = original; btn.disabled = false; return false; } }) .catch(function() { showToast('Błąd połączenia z serwerem', 'error'); btn.innerHTML = original; btn.disabled = false; return false; }); } function fetchRegistry() { var btn = document.getElementById('btn-registry'); return runEnrichAction(btn, '/api/company/{{ company.id }}/enrich-registry', {}); } function fetchLogo() { var btn = document.getElementById('btn-logo'); var original = btn.innerHTML; btn.disabled = true; btn.innerHTML = ' Szukam...'; return fetch('/api/company/{{ company.id }}/fetch-logo', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify({action: 'fetch'}) }) .then(function(r) { return r.json(); }) .then(function(data) { btn.innerHTML = original; btn.disabled = false; if (!data.success || !data.candidates || data.candidates.length === 0) { showToast(data.message || 'Nie znaleziono logo', 'error'); return false; } var container = document.getElementById('logo-candidates'); var html = '
Wybierz logo (' + data.candidates.length + ' kandydatów):
'; html += '
'; data.candidates.forEach(function(c) { var imgUrl = '/static/img/companies/' + c.filename + '?t=' + Date.now(); var rec = (c.index === data.recommended_index) ? ' recommended' : ''; html += '
'; html += '
'; if (c.index === data.recommended_index) { html += 'OK'; } html += 'Kandydat ' + (c.index + 1) + ''; html += '
'; html += '
' + c.label + '
'; html += '
'; }); html += '
'; html += ''; container.innerHTML = html; container.style.display = 'block'; showToast('Znaleziono ' + data.candidates.length + ' kandydatów — wybierz logo', 'success'); return true; }) .catch(function() { showToast('Błąd połączenia z serwerem', 'error'); btn.innerHTML = original; btn.disabled = false; return false; }); } function confirmLogo(index) { var container = document.getElementById('logo-candidates'); container.innerHTML = ' Zapisuję...'; fetch('/api/company/{{ company.id }}/fetch-logo', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify({action: 'confirm', index: index}) }) .then(function(r) { return r.json(); }) .then(function(data) { if (data.success) { showToast('Logo zapisane!', 'success'); setTimeout(function() { location.reload(); }, 1000); } else { showToast(data.message || 'Błąd zapisu', 'error'); container.style.display = 'none'; } }) .catch(function() { showToast('Błąd połączenia', 'error'); container.style.display = 'none'; }); } function cancelLogo() { fetch('/api/company/{{ company.id }}/fetch-logo', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify({action: 'cancel'}) }); document.getElementById('logo-candidates').style.display = 'none'; showToast('Anulowano', 'info'); } function runSeoAudit() { var btn = document.getElementById('btn-seo'); return runEnrichAction(btn, '/api/seo/audit', {company_id: {{ company.id }}}); } function runSocialAudit() { var btn = document.getElementById('btn-social'); return runEnrichAction(btn, '/api/social/audit', {company_id: {{ company.id }}}); } function runGbpAudit() { var btn = document.getElementById('btn-gbp'); return runEnrichAction(btn, '/api/gbp/audit', {company_id: {{ company.id }}, fetch_google: true}); } function fetchLogoAuto() { /* Wersja logo dla trybu automatycznego — wybiera rekomendowanego kandydata */ var btn = document.getElementById('btn-logo'); var original = btn.innerHTML; btn.disabled = true; btn.innerHTML = ' Szukam logo...'; return fetch('/api/company/{{ company.id }}/fetch-logo', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify({action: 'fetch'}) }) .then(function(r) { return r.json(); }) .then(function(data) { if (!data.success || !data.candidates || data.candidates.length === 0) { btn.innerHTML = original; btn.disabled = false; showToast('Logo: brak kandydatów', 'warning'); return false; } var pick = (data.recommended_index !== null && data.recommended_index !== undefined) ? data.recommended_index : 0; btn.innerHTML = ' Zapisuję logo...'; return fetch('/api/company/{{ company.id }}/fetch-logo', { method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken}, body: JSON.stringify({action: 'confirm', index: pick}) }) .then(function(r) { return r.json(); }) .then(function(res) { btn.innerHTML = original; btn.disabled = false; if (res.success) { showToast('Logo zapisane automatycznie (kandydat #' + (pick + 1) + ')', 'success'); } return res.success; }); }) .catch(function() { btn.innerHTML = original; btn.disabled = false; return false; }); } function armCompany(forceAll) { _skipReload = true; var isRefresh = !!forceAll; var masterBtn = document.getElementById(isRefresh ? 'btn-refresh' : 'btn-arm'); var otherBtn = document.getElementById(isRefresh ? 'btn-arm' : 'btn-refresh'); masterBtn.disabled = true; otherBtn.disabled = true; masterBtn.innerHTML = ' ' + (isRefresh ? 'Aktualizuję...' : 'Uzbrajam firmę...'); var steps = [ {id: 'btn-registry', fn: fetchRegistry, skip: forceAll ? false : {{ 'true' if enrichment.registry.done else 'false' }}, requires: {{ 'true' if company.nip else 'false' }} }, {id: 'btn-seo', fn: runSeoAudit, skip: forceAll ? false : {{ 'true' if enrichment.seo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} }, {id: 'btn-social', fn: runSocialAudit, skip: forceAll ? false : {{ 'true' if enrichment.social.done else 'false' }}, requires: true }, {id: 'btn-gbp', fn: runGbpAudit, skip: forceAll ? false : {{ 'true' if enrichment.gbp.done else 'false' }}, requires: true }, {id: 'btn-logo', fn: fetchLogoAuto, skip: forceAll ? false : {{ 'true' if enrichment.logo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} } ]; var pending = steps.filter(function(s) { return !s.skip && s.requires; }); if (pending.length === 0) { showToast('Wszystkie kroki zostały już wykonane!', 'success'); masterBtn.disabled = false; otherBtn.disabled = false; masterBtn.innerHTML = isRefresh ? ' Zaktualizuj dane' : ' Uzbrój firmę'; _skipReload = false; return; } var idx = 0; var label = isRefresh ? 'Aktualizuję' : 'Uzbrajam'; function runNext() { if (idx >= pending.length) { showToast(label + ' zakończone! Odświeżam stronę...', 'success'); setTimeout(function() { location.reload(); }, 2000); return; } var step = pending[idx]; idx++; masterBtn.innerHTML = ' Krok ' + idx + '/' + pending.length + '...'; step.fn().then(function() { runNext(); }); } runNext(); } {% endblock %}