HRM-10/HRM.UI/ClientApp/src/app/ess/component-uploader/component-uploader.component.html

341 lines
16 KiB
HTML
Raw Normal View History

<app-loading-panel></app-loading-panel>
2026-11-29 13:53:28 +06:00
<div class="cu-page" [ngClass]="{'customGrid': apiService.isSelService === true}">
<!-- ══════════ TOP: form card + sidebar ══════════ -->
<div class="cu-top">
<!-- ── Main card ── -->
<div class="cu-card cu-main-card">
<!-- Header -->
<div class="cu-card-header">
<div class="cu-title-group">
<div class="cu-icon-wrap">
<svg width="22" height="22" viewBox="0 0 22 22" fill="none">
<path d="M11 14V8M11 8L8.5 10.5M11 8l2.5 2.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M7 18a5 5 0 01-1.031-9.875A7.5 7.5 0 1119 14h-1.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div>
<h2 class="cu-title">Component Uploader</h2>
<p class="cu-subtitle">Upload your assigned salary components for the current month</p>
</div>
</div>
<button class="cu-btn-ghost" (click)="downloadSample()">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<path d="M7 2v7M7 9L4.5 6.5M7 9l2.5-2.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2 12h10" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
</svg>
Download Sample
</button>
</div>
<!-- Validity warning — only when the upload window is closed -->
@if (!deadlinePassed && !windowValid && windowMessage) {
<div class="cu-banner cu-banner-closed">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path d="M8 2l6.5 11.5H1.5L8 2z" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/>
<path d="M8 6.5v3.5M8 12h.01" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
<span>{{ windowMessage }}</span>
</div>
}
<!-- Step 1 — component -->
<div class="cu-step">
<div class="cu-step-hdr">
<span class="cu-step-num">1</span>
<span class="cu-step-title">Select Component</span>
</div>
<div class="cu-step-body">
<div class="cu-dd-wrap">
<kendo-dropdownlist
[data]="components"
[value]="selectedComponent"
[defaultItem]="defaultComponent"
[textField]="'description'"
[valueField]="'itemID'"
[disabled]="components.length === 0"
(valueChange)="onComponentChange($event)"
style="width:100%">
</kendo-dropdownlist>
@if (components.length === 0) {
<p class="cu-empty-hint">
No components are assigned to you. Please contact your Payroll team.
</p>
}
</div>
</div>
</div>
<!-- Step 2 — file (always visible; disabled until a component is selected) -->
<div class="cu-step cu-step-file" [class.cu-step-disabled]="!canUpload">
<div class="cu-step-hdr">
<span class="cu-step-num">2</span>
<span class="cu-step-title">Upload Excel File</span>
</div>
<div class="cu-step-body">
<div class="cu-dropzone" [class.cu-dropzone-over]="dragOver && canUpload"
[class.cu-dropzone-disabled]="!canUpload"
(dragover)="onDragOver($event)" (dragleave)="onDragLeave($event)" (drop)="onDrop($event)">
<div class="cu-dz-icon">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M12 15V7M12 7L9.5 9.5M12 7l2.5 2.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8 20a5.5 5.5 0 01-1.138-10.863A8.5 8.5 0 1121.5 16H20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<p class="cu-dz-text">Drag &amp; drop your file here</p>
<span class="cu-dz-or">or</span>
<label class="cu-btn-choose">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none">
<path d="M6.5 9V3M6.5 3L4 5.5M6.5 3L9 5.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2 11h9" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
</svg>
Choose File
<input type="file" hidden [disabled]="!canUpload" (change)="onFileSelect($event)" accept=".xls,.xlsx">
</label>
<p class="cu-dz-hint">{{ uploadHint }}</p>
</div>
</div>
</div>
<!-- Already-uploaded status -->
@if (selectedComponent && alreadyUploaded) {
<div class="cu-step">
<div class="cu-status"
[class.cu-status-approved]="approved" [class.cu-status-pending]="!approved">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.4"/>
<path d="M8 4.5v4M8 11h.01" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
<span>{{ statusMessage }}</span>
</div>
</div>
}
<!-- Actions -->
<div class="cu-actions">
@if (selectedFile) {
<div class="cu-file-chip">
<svg width="14" height="16" viewBox="0 0 14 16" fill="none">
<path d="M2 2h7l4 4v9a1 1 0 01-1 1H2a1 1 0 01-1-1V3a1 1 0 011-1z" fill="#DCFCE7" stroke="#16A34A" stroke-width="1.2"/>
<path d="M9 2v4h4" stroke="#16A34A" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="cu-file-name">{{ selectedFile.name }}</span>
<span class="cu-file-remove" (click)="removeFile()">×</span>
</div>
}
@if (alreadyUploaded) {
<button class="cu-btn-outline" (click)="viewUploaded()">
<svg width="15" height="15" viewBox="0 0 15 15" fill="none">
<path d="M1.5 7.5s2.3-4.5 6-4.5 6 4.5 6 4.5-2.3 4.5-6 4.5-6-4.5-6-4.5z" stroke="currentColor" stroke-width="1.2"/>
<circle cx="7.5" cy="7.5" r="1.8" stroke="currentColor" stroke-width="1.2"/>
</svg>
View Uploaded
</button>
}
@if (alreadyUploaded && !approved) {
<button class="cu-btn-danger" (click)="deleteUploaded()">
<svg width="15" height="15" viewBox="0 0 15 15" fill="none">
<path d="M2.5 4h10M6 2.5h3M3.5 4l.6 8a1 1 0 001 1h3.8a1 1 0 001-1l.6-8" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Delete Upload
</button>
}
2026-11-29 13:53:28 +06:00
<!-- Approval date for this salary month has passed — on the far right of this row, next to Upload -->
<div class="cu-actions-right">
@if (deadlinePassed) {
<div class="cu-banner cu-banner-locked cu-banner-inline">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<rect x="3" y="7" width="10" height="7" rx="1.5" stroke="currentColor" stroke-width="1.4"/>
<path d="M5.5 7V5a2.5 2.5 0 015 0v2" stroke="currentColor" stroke-width="1.4"/>
</svg>
<span>The approval date{{ uploadDeadline ? (' (' + (uploadDeadline | date:'dd MMM yyyy') + ')') : '' }} for {{ salaryMonth ? (salaryMonth | date:'MMMM yyyy') : 'this' }} salary month has passed. Component upload is closed.</span>
</div>
}
<button class="cu-btn-primary" [disabled]="!canUpload || !selectedFile" (click)="upload()">
<svg width="17" height="17" viewBox="0 0 17 17" fill="none">
<path d="M8.5 12V4M8.5 4L5 7.5M8.5 4L12 7.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 13.5h11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
Upload
</button>
2026-11-29 13:53:28 +06:00
</div>
</div>
</div><!-- /main card -->
<!-- ── Sidebar ── -->
<div class="cu-sidebar">
<div class="cu-sidebar-card">
<p class="cu-sc-label">Upload Window</p>
<div class="cu-window-box">
<div class="cu-window-row">
<span class="cu-window-key">Salary Month</span>
<span class="cu-window-val">{{ salaryMonth ? (salaryMonth | date:'MMMM yyyy') : '—' }}</span>
</div>
<div class="cu-window-row">
<span class="cu-window-key">Upload By</span>
<span class="cu-window-val">{{ uploadDeadline ? (uploadDeadline | date:'dd MMM yyyy') : '—' }}</span>
</div>
</div>
<span class="cu-pill"
[class.cu-pill-open]="windowValid && !deadlinePassed"
[class.cu-pill-closed]="!windowValid || deadlinePassed">
{{ deadlinePassed ? 'Deadline passed' : (windowValid ? 'Open now' : 'Closed') }}
</span>
</div>
<div class="cu-sidebar-card">
<div class="cu-sc-title-row">
<div class="cu-sc-icon">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
<path d="M9 1.5L2.5 4.5V9c0 4 2.8 7.5 6.5 8.5C12.7 16.5 15.5 13 15.5 9V4.5L9 1.5z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M6 9l2 2 4-4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<span class="cu-sc-title">Guidelines</span>
</div>
<ul class="cu-guidelines">
@for (g of ['Only Excel files (.xls, .xlsx) are accepted',
'Download the sample file for the exact column format',
'One upload per component — delete the old one to replace it',
'Approved uploads cannot be edited or deleted',
'Uploads are only accepted inside the monthly window']; track g) {
<li>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" style="flex-shrink:0;margin-top:1px">
<circle cx="7.5" cy="7.5" r="7.5" fill="#22C55E"/>
<path d="M4.5 7.5l2 2 4-4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
{{ g }}
</li>
}
</ul>
</div>
</div><!-- /sidebar -->
</div><!-- /top -->
<!-- ══════════ Upload result ══════════ -->
@if (results && results.length) {
<div class="cu-card cu-results-card">
<div class="cu-results-hdr">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
<path d="M9 2l6.5 11.5H2.5L9 2z" stroke="#DC2626" stroke-width="1.4" stroke-linejoin="round"/>
<path d="M9 6.5v3.5M9 12h.01" stroke="#DC2626" stroke-width="1.5" stroke-linecap="round"/>
</svg>
<span class="cu-results-title">{{ results.length }} row(s) need attention</span>
</div>
2026-11-29 13:53:28 +06:00
<kendo-grid [kendoGridBinding]="results" [pageable]="false" [sortable]="true" [resizable]="true">
<kendo-grid-column field="rowNo" title="Excel Row" [width]="120"></kendo-grid-column>
<kendo-grid-column field="employeeNo" title="Employee ID" [width]="160"></kendo-grid-column>
<kendo-grid-column field="message" title="Message"></kendo-grid-column>
</kendo-grid>
</div>
}
<!-- ══════════ Uploaded Components ══════════ -->
<div class="cu-card cu-results-card">
<div class="cu-list-hdr">
<div class="cu-list-title-grp">
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
<path d="M4 2h8l4 4v10a1 1 0 01-1 1H4a1 1 0 01-1-1V3a1 1 0 011-1z" fill="#EEF4FF" stroke="currentColor" stroke-width="1.3"/>
<path d="M12 2v4h4" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M6 10h6M6 13h4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
</svg>
<span class="cu-list-title">Uploaded Components</span>
<span class="cu-count-pill">{{ uploadedList.length }}</span>
</div>
<div class="cu-search-wrap cu-list-search">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<circle cx="6" cy="6" r="4.5" stroke="#9CA3AF" stroke-width="1.3"/>
<path d="M9.5 9.5L12.5 12.5" stroke="#9CA3AF" stroke-width="1.3" stroke-linecap="round"/>
</svg>
<input class="cu-search" placeholder="Search…"
[(ngModel)]="uploadedListSearch" (ngModelChange)="filterUploadedList($event)">
</div>
</div>
2026-11-29 13:53:28 +06:00
<kendo-grid [kendoGridBinding]="uploadedList" [pageable]="true" [pageSize]="10" [sortable]="true" [resizable]="true">
<kendo-grid-column field="description" title="Component Name">
<ng-template kendoGridCellTemplate let-row>
{{ row.description }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column field="uploadedDate" title="Upload Date" [width]="190">
<ng-template kendoGridCellTemplate let-row>
{{ row.uploadedDate ? (row.uploadedDate | date:'dd MMM yyyy, hh:mm a') : '—' }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column field="salaryMonth" title="Salary Month" [width]="140">
<ng-template kendoGridCellTemplate let-row>
{{ row.salaryMonth ? (row.salaryMonth | date:'MMM yyyy') : '—' }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column field="approver" title="Approver"></kendo-grid-column>
<kendo-grid-column field="status" title="Status" [width]="130"></kendo-grid-column>
<kendo-grid-column title="Action" [width]="170" [sortable]="false">
<ng-template kendoGridCellTemplate let-row>
<div class="cu-row-actions">
<button class="cu-tbl-btn cu-tbl-btn-view" (click)="viewById(row.uploadedComponentID)">View</button>
@if (row.status !== 'Approved') {
<button class="cu-tbl-btn cu-tbl-btn-delete"
(click)="deleteById(row.uploadedComponentID)">Delete</button>
}
</div>
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>
<span class="cu-empty-row">You haven't uploaded any component yet.</span>
</ng-template>
</kendo-grid>
</div>
</div>
<!-- ══════════ View uploaded — overlay ══════════ -->
@if (showViewPanel) {
<div class="cu-overlay" (click)="closeViewPanel()">
<div class="cu-modal" (click)="$event.stopPropagation()">
<div class="cu-modal-hdr">
<span class="cu-modal-title">
Uploaded Rows
<span class="cu-count-pill">{{ viewRows.length }}</span>
</span>
<span class="cu-modal-close" (click)="closeViewPanel()">×</span>
</div>
<div class="cu-modal-toolbar">
<div class="cu-search-wrap">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<circle cx="6" cy="6" r="4.5" stroke="#9CA3AF" stroke-width="1.3"/>
<path d="M9.5 9.5L12.5 12.5" stroke="#9CA3AF" stroke-width="1.3" stroke-linecap="round"/>
</svg>
<input class="cu-search" placeholder="Search employee, amount…"
[(ngModel)]="viewSearch" (ngModelChange)="filterViewRows($event)">
</div>
</div>
2026-11-29 13:53:28 +06:00
<div class="cu-modal-table">
<kendo-grid [kendoGridBinding]="viewRows" [pageable]="true" [pageSize]="20" [sortable]="true" [resizable]="true">
<kendo-grid-column field="employeeNo" title="Employee No" [width]="140"></kendo-grid-column>
<kendo-grid-column field="name" title="Employee Name"></kendo-grid-column>
<kendo-grid-column field="amount" title="Amount" [width]="140"
[headerStyle]="{'text-align': 'right'}" [style]="{'text-align': 'right'}">
<ng-template kendoGridCellTemplate let-row>
{{ row.amount != null ? (row.amount | number:'1.0-2') : '—' }}
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>
<span class="cu-empty-row">No rows to show.</span>
</ng-template>
</kendo-grid>
</div>
</div>
</div>
}