/* tkpurchase-partner-history.js - Partner work history */ let historyPage = 1; const historyLimit = 20; function initPartnerHistory() { if (!initAuth()) return; const token = getToken(); const decoded = decodeToken(token); if (!decoded || !decoded.partner_company_id) { location.href = '/'; return; } // 기본 날짜: 최근 30일 const today = new Date(); const thirtyDaysAgo = new Date(today); thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); document.getElementById('filterDateTo').value = today.toISOString().substring(0, 10); document.getElementById('filterDateFrom').value = thirtyDaysAgo.toISOString().substring(0, 10); loadHistory(); } async function loadHistory(page) { historyPage = page || 1; const dateFrom = document.getElementById('filterDateFrom').value; const dateTo = document.getElementById('filterDateTo').value; const params = new URLSearchParams(); if (dateFrom) params.set('date_from', dateFrom); if (dateTo) params.set('date_to', dateTo); params.set('page', historyPage); params.set('limit', historyLimit); const container = document.getElementById('historyList'); container.innerHTML = '
로딩 중...
'; try { const r = await api('/checkins/my-history?' + params.toString()); const checkins = r.data || []; const total = r.total || 0; renderHistoryList(checkins); renderPagination(total); } catch(e) { container.innerHTML = '데이터를 불러올 수 없습니다.
'; } } function renderHistoryList(checkins) { const container = document.getElementById('historyList'); if (!checkins.length) { container.innerHTML = `조회 기간에 작업 이력이 없습니다.
${escapeHtml(c.work_description)}
` : ''}