سامانه صدور فاکتور و حسابداری
Refactor subscription status handling in index.html
Updated user subscription status display logic and removed unused plan labels.
davoodmehraban89 committed
Sep 17, 2026 at 13:23 UTC
2b1022131ffa1185235e7b76138a11057a884b0f
1 file changed
+21
-62
index.html
+21
-62
@@ -610,7 +610,12 @@
610
611
<!-- ۷. تنظیمات و شرکتها -->
612
<section id="view-settings" class="view-pane">
613
-
613
+
614
+ <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:14px;">
615
+ <h2 style="font-size:17px;">⚙️ تنظیمات و شرکتها</h2>
616
+ <button class="btn btn-danger btn-inline no-print" style="padding:6px 12px; font-size:12px; min-height:32px;" onclick="handleLogout()">🚪 خروج از حساب کاربری</button>
617
+ </div>
618
+
619
<div class="accordion-item open">
620
<div class="accordion-header" onclick="toggleAccordion(this)">
621
<span>🏢 اطلاعات فروشگاه و چاپ (مدیریت شرکتها)</span>
@@ -1106,6 +1111,9 @@
1111
const badge = document.getElementById('user-license-status-badge');
1112
const detailsBox = document.getElementById('dashboard-license-details');
1113
1114
+ // دیگر بنر توضیحی جدا نمایش داده نمیشود؛ همهچیز در همین یک برچسب کوچک بالا-سمتچپ خلاصه میشود.
1115
+ if (detailsBox) { detailsBox.style.display = 'none'; detailsBox.innerHTML = ''; }
1116
+
1117
const sub = user.subscription || {
1118
type: user.subscriptionType || 'trial',
1119
startDate: user.subscriptionStart || user.createdAt,
@@ -1113,75 +1121,26 @@
1121
status: user.licenseStatus || 'trial'
1122
};
1123
1116
- const planLabels = {
1117
- monthly: 'طرح ۱ ماهه',
1118
- three_months: 'طرح ۳ ماهه',
1119
- annual: 'طرح ۱ ساله',
1120
- lifetime: 'دائمی (Lifetime)',
1121
- trial: 'آزمایشی (Trial)'
1122
- };
1123
-
1124
const remDays = getRemainingDays(sub.endDate);
1125
const isExpired = remDays <= 0 && sub.type !== 'lifetime';
1126
-
1126
const hasActiveLicense = (sub.status === 'active') && (sub.type === 'lifetime' || !isExpired) && (sub.type !== 'trial');
1127
1129
- if (hasActiveLicense) {
1130
- const planName = planLabels[sub.type] || sub.type;
1131
- const startJalali = formatToJalali(sub.startDate);
1132
- const endJalali = sub.type === 'lifetime' ? 'نامحدود' : formatToJalali(sub.endDate);
1133
- const remText = sub.type === 'lifetime' ? 'نامحدود' : toPersianDigits(remDays) + ' روز';
1128
+ if (!badge) return;
1129
1135
- if (badge) {
1130
+ if (hasActiveLicense) {
1131
+ if (sub.type === 'lifetime') {
1132
badge.className = 'badge badge-success';
1137
- badge.innerText = `اشتراک فعال (${planName})`;
1138
- }
1139
- if (detailsBox) {
1140
- detailsBox.style.display = 'block';
1141
- detailsBox.innerHTML = `
1142
- <div style="font-size:12px; display:flex; flex-wrap:wrap; gap:16px; align-items:center; background:#ecfdf5; border:1px solid #6ee7b7; color:#065f46; padding:8px 14px; border-radius:8px; margin-bottom:14px;">
1143
- <div><strong>وضعیت:</strong> اشتراک فعال</div>
1144
- <div><strong>نوع طرح:</strong> ${planName}</div>
1145
- <div><strong>تاریخ شروع:</strong> ${startJalali}</div>
1146
- <div><strong>تاریخ پایان:</strong> ${endJalali}</div>
1147
- <div><strong>روزهای باقیمانده:</strong> ${remText}</div>
1148
- </div>
1149
- `;
1150
- }
1151
- } else {
1152
- if (isExpired || sub.status === 'cancelled') {
1153
- if (badge) {
1154
- badge.className = 'badge badge-danger';
1155
- badge.innerText = 'منقضی شده / لغو شده';
1156
- }
1157
- if (detailsBox) {
1158
- detailsBox.style.display = 'block';
1159
- detailsBox.innerHTML = `
1160
- <div style="font-size:12px; display:flex; flex-wrap:wrap; gap:16px; align-items:center; background:#fef2f2; border:1px solid #fca5a5; color:#991b1b; padding:8px 14px; border-radius:8px; margin-bottom:14px;">
1161
- <div><strong>وضعیت:</strong> اشتراک غیرفعال / منقضی شده</div>
1162
- <div><strong>تاریخ انقضا:</strong> ${formatToJalali(sub.endDate)}</div>
1163
- <div>لطفاً با مدیر سامانه جهت تمدید یا فعالسازی لایسنس تماس بگیرید.</div>
1164
- </div>
1165
- `;
1166
- }
1133
+ badge.innerText = 'وضعیت اشتراک : نامحدود';
1134
} else {
1168
- const endJalali = formatToJalali(sub.endDate);
1169
- const remText = toPersianDigits(Math.max(0, remDays)) + ' روز';
1170
- if (badge) {
1171
- badge.className = 'badge badge-warning';
1172
- badge.innerText = `نسخه آزمایشی (${remText} باقیمانده)`;
1173
- }
1174
- if (detailsBox) {
1175
- detailsBox.style.display = 'block';
1176
- detailsBox.innerHTML = `
1177
- <div style="font-size:12px; display:flex; flex-wrap:wrap; gap:16px; align-items:center; background:#fffbeb; border:1px solid #fcd34d; color:#92400e; padding:8px 14px; border-radius:8px; margin-bottom:14px;">
1178
- <div><strong>وضعیت:</strong> نسخه آزمایشی (Trial)</div>
1179
- <div><strong>تاریخ پایان مهلت آزمایشی:</strong> ${endJalali}</div>
1180
- <div><strong>روزهای باقیمانده:</strong> ${remText}</div>
1181
- </div>
1182
- `;
1183
- }
1135
+ badge.className = 'badge badge-success';
1136
+ badge.innerText = `وضعیت اشتراک : تا تاریخ ${formatToJalali(sub.endDate)}`;
1137
}
1138
+ } else if (isExpired || sub.status === 'cancelled') {
1139
+ badge.className = 'badge badge-danger';
1140
+ badge.innerText = 'وضعیت اشتراک : منقضی شده';
1141
+ } else {
1142
+ badge.className = 'badge badge-warning';
1143
+ badge.innerText = `وضعیت اشتراک : آزمایشی تا تاریخ ${formatToJalali(sub.endDate)}`;
1144
}
1145
}
1146