Sidebar: +ERP +CRM +Dokumenti, godišnjaci import (18 PDFs), filter helpers
- pgz nav now includes /erp/full, /crm/v2, /admin/users, /dokumenti
- 4 dokumenti endpoints: list, godišnjaci/list, godišnjak/{godina} PDF, detail
- 18 godišnjaka u pgz_sport.dokumenti (2006-2024) with savez_id=333
- PGŽ filter helpers (window._pgz_filter_priority, togglePGZFilter)
- navItemClick handler for nav items with href
This commit is contained in:
+40
-3
@@ -418,6 +418,25 @@ async function api(path){
|
||||
catch(e){ return null; }
|
||||
}
|
||||
|
||||
// ─── Sport-aware enrichment source (cached) ───
|
||||
const _appEnrichSrc = {};
|
||||
async function appOpenEnrichSource(sport, naziv){
|
||||
if(!sport){ alert('Sport nije naveden — ne mogu odrediti savez.'); return; }
|
||||
const k = (sport||'').toLowerCase();
|
||||
let src = _appEnrichSrc[k];
|
||||
if(!src){
|
||||
const d = await api('/v2/enrich-sources?sport='+encodeURIComponent(sport));
|
||||
src = d && d.match;
|
||||
if(src) _appEnrichSrc[k] = src;
|
||||
}
|
||||
if(!src){ alert('Nema definiranog izvora za sport: '+sport); return; }
|
||||
const base = (src.base_url||'').replace(/\/$/,'');
|
||||
const url = ((src.sport||'').toLowerCase()==='nogomet')
|
||||
? base + '/klubovi?q=' + encodeURIComponent(naziv||'')
|
||||
: base + '/?s=' + encodeURIComponent(naziv||'');
|
||||
window.open(url, '_blank', 'noopener');
|
||||
}
|
||||
|
||||
// JWT-aware fetch wrapper
|
||||
function getToken(){
|
||||
try {
|
||||
@@ -485,13 +504,15 @@ const NAV_BY_ROLE = {
|
||||
pgz: [
|
||||
{id:'profil', ic:'\u{1F464}', label:'Moj profil'},
|
||||
{id:'dashboard', ic:'\u{1F4CA}', label:'Dashboard'},
|
||||
{id:'korisnici', ic:'\u{1F465}', label:'Korisnici'},
|
||||
{id:'korisnici', ic:'\u{1F465}', label:'Korisnici', href:'/admin/users'},
|
||||
{id:'savezi', ic:'\u{1F3C5}', label:'Savezi'},
|
||||
{id:'klubovi', ic:'⬢', label:'Klubovi'},
|
||||
{id:'sportasi', ic:'\u{1F464}', label:'Sportaši'},
|
||||
{id:'financije', ic:'€', label:'Financije'},
|
||||
{id:'erp', ic:'\u{1F4BC}', label:'ERP', href:'/erp/full'},
|
||||
{id:'crm', ic:'\u{1F4DD}', label:'CRM', href:'/crm/v2'},
|
||||
{id:'dokumenti', ic:'\u{1F4D6}', label:'Dokumenti'},
|
||||
{id:'racuni', ic:'\u{1F9FE}', label:'Računi (OCR)'},
|
||||
{id:'crm', ic:'\u{1F4DD}', label:'CRM'},
|
||||
{id:'kalendar', ic:'\u{1F4C5}', label:'Kalendar'},
|
||||
{id:'audit', ic:'\u{1F50D}', label:'Audit log'},
|
||||
{id:'forenzika', ic:'⚠', label:'Forenzika', badge:11},
|
||||
@@ -626,7 +647,7 @@ async function showDetail(kind, id, title){
|
||||
if(!d){ body = '<div class="empty">Klub nije pronađen.</div>'; }
|
||||
else body = `
|
||||
<h2 style="font-size:18px;color:var(--t0);margin-bottom:6px">${esc(d.naziv||'—')}</h2>
|
||||
<div style="font-size:11px;color:var(--t2);margin-bottom:14px">${esc(d.savez||'')} · ${esc(d.grad||'')}</div>
|
||||
<div style="font-size:11px;color:var(--t2);margin-bottom:14px">${esc(d.savez||'')} · ${esc(d.sport||'')} · ${esc(d.grad||'')}</div>
|
||||
<div class="kv">
|
||||
<div class="k">OIB</div><div class="v">${d.oib?esc(formatOib(d.oib,{klub_id:d.id,savez_id:d.savez_id})):'—'}</div>
|
||||
<div class="k">Predsjednik</div><div class="v">${esc(d.predsjednik||'—')}</div>
|
||||
@@ -634,6 +655,9 @@ async function showDetail(kind, id, title){
|
||||
<div class="k">Email</div><div class="v">${esc(d.email||'—')}</div>
|
||||
<div class="k">Telefon</div><div class="v">${esc(d.telefon||'—')}</div>
|
||||
<div class="k">Članova</div><div class="v">${fmt(d.broj_clanova||'—')}</div>
|
||||
</div>
|
||||
<div style="margin-top:14px;display:flex;gap:8px;flex-wrap:wrap">
|
||||
<button class="btn" onclick="appOpenEnrichSource(${JSON.stringify(d.sport||'')}, ${JSON.stringify(d.naziv||'')})">🌐 Obogati podatke (sport-savez)</button>
|
||||
</div>`;
|
||||
} else if(kind === 'zahtjev'){
|
||||
const z = MOCK.zahtjevi_pending.concat(MOCK.savez_zahtjevi||[]).find(x => x.id===id || x.naziv===id) || {};
|
||||
@@ -2064,6 +2088,19 @@ function toggleMobileSidebar(){
|
||||
}
|
||||
backdrop.classList.toggle('show');
|
||||
}
|
||||
|
||||
// hrefnav handler — for nav items that have href (external page)
|
||||
function navItemClick(item){
|
||||
if(item && item.href){ window.location.href = item.href; return; }
|
||||
if(item && item.id) navTo(item.id);
|
||||
}
|
||||
|
||||
// PGŽ priority filter helpers (CRISIS V4)
|
||||
window._pgz_filter_priority = window._pgz_filter_priority || false;
|
||||
window.togglePGZFilter = function(){
|
||||
window._pgz_filter_priority = !window._pgz_filter_priority;
|
||||
if(typeof loadSection === 'function') loadSection();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user