سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 17:00 UTC
Update title and version information in index.html
davoodmehraban89 committed
Sep 16, 2026 at 15:44 UTC
2a5ccf4c2df7f2d57135ed46bea03f9de38b62ab
1 file changed
+242
-38
index.html
+242
-38
@@ -3,7 +3,7 @@
3
<head>
4
<meta charset="UTF-8" />
5
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
6
- <title>ایزی فاکتور | سامانه صدور فاکتور و مدیریت مالی</title>
6
+ <title>ایزی فاکتور | نسخه تجاری ۱.۰</title>
7
8
<link rel="manifest" href="manifest.json" />
9
<meta name="apple-mobile-web-app-capable" content="yes" />
@@ -28,25 +28,23 @@
28
--success: #059669;
29
--warning: #d97706;
30
--sidebar-w: 240px;
31
- --nav-h: 70px;
31
+ --nav-h: 74px;
32
}
33
34
- html, body {
35
- width: 100%;
36
- max-width: 100%;
37
- overflow-x: hidden !important;
38
- position: relative;
39
- }
34
+ html, body { width: 100%; max-width: 100%; overflow-x: hidden !important; position: relative; }
35
+ * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Vazirmatn FD', -apple-system, BlinkMacSystemFont, Tahoma, sans-serif; -webkit-tap-highlight-color: transparent; }
36
+ body { background-color: var(--bg); color: var(--text); font-size: 14px; }
37
41
- * {
42
- box-sizing: border-box;
43
- margin: 0;
44
- padding: 0;
45
- font-family: 'Vazirmatn FD', -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
46
- -webkit-tap-highlight-color: transparent;
38
+ /* صفحه احراز هویت (ورود / ثبتنام) */
39
+ #auth-screen {
40
+ position: fixed; top: 0; left: 0; right: 0; bottom: 0;
41
+ background: linear-gradient(135deg, #1e3a8a, #2563eb);
42
+ z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px;
43
+ }
44
+ .auth-card {
45
+ background: #fff; border-radius: 16px; max-width: 420px; width: 100%; padding: 30px;
46
+ box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); text-align: right;
47
}
48
-
49
- body { background-color: var(--bg); color: var(--text); font-size: 14px; }
48
49
.app-root { display: flex; min-height: 100vh; width: 100%; max-width: 100%; overflow-x: hidden; }
50
.sidebar { width: var(--sidebar-w); background: var(--card-bg); border-left: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; right: 0; z-index: 100; }
@@ -60,7 +58,6 @@
58
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); text-align: center; }
59
.main-surface { flex: 1; margin-right: var(--sidebar-w); padding: 20px; padding-bottom: 100px; max-width: calc(100% - var(--sidebar-w)); overflow-x: hidden; }
60
63
- /* ناو بار موبایل ۶ تبهسازی شده جهت دسترسی به تنظیمات در آیفون */
61
.mobile-dock { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); background: rgba(255,255,255,0.98); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid #cbd5e1; z-index: 200; justify-content: space-around; align-items: center; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 12px rgba(0,0,0,0.06); }
62
.dock-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #475569; text-decoration: none; font-size: 10.5px; font-weight: 600; flex: 1; height: 100%; cursor: pointer; }
63
.dock-tab.active { color: var(--primary); font-weight: 800; }
@@ -130,6 +127,32 @@
127
</head>
128
<body>
129
130
+ <!-- صفحه ورود و ثبتنام تجاری نسخه ۱.۰ -->
131
+ <div id="auth-screen">
132
+ <div class="auth-card">
133
+ <div style="text-align:center; margin-bottom:20px;">
134
+ <div style="width:50px; height:50px; background:var(--primary); color:#fff; font-weight:bold; font-size:24px; border-radius:12px; display:inline-flex; align-items:center; justify-content:center; margin-bottom:10px;">ایزی</div>
135
+ <h2 style="font-size:20px; font-weight:bold; color:var(--text);">سامانه ایزی فاکتور</h2>
136
+ <p style="font-size:12px; color:var(--text-muted); margin-top:4px;">ورود به حساب کاربری یا ثبتنام (نسخه تجاری)</p>
137
+ </div>
138
+
139
+ <div id="auth-form-container">
140
+ <div class="form-group">
141
+ <label>نام کاربری یا شماره همراه</label>
142
+ <input type="text" id="auth-username" class="form-control" placeholder="admin یا شماره همراه" />
143
+ </div>
144
+ <div class="form-group">
145
+ <label>رمز عبور</label>
146
+ <input type="password" id="auth-password" class="form-control" placeholder="رمز عبور" />
147
+ </div>
148
+ <div style="display:flex; gap:10px; margin-top:16px;">
149
+ <button class="btn btn-primary" style="flex:1;" onclick="handleLogin()">ورود به سامانه</button>
150
+ <button class="btn btn-secondary" style="flex:1;" onclick="switchToRegister()">ثبتنام جدید</button>
151
+ </div>
152
+ </div>
153
+ </div>
154
+ </div>
155
+
156
<div class="app-root">
157
<!-- منوی کناری دسکتاپ -->
158
<aside class="sidebar">
@@ -137,7 +160,7 @@
160
<div class="brand-icon">ایزی</div>
161
<div>
162
<h2 style="font-size: 15px; font-weight: bold;">ایزی فاکتور</h2>
140
- <small style="color: var(--text-muted); font-size: 11px;">نگارش ۴.۱ (موبایل و دسکتاپ)</small>
163
+ <small style="color: var(--text-muted); font-size: 11px;">نگارش تجاری ۱.۰</small>
164
</div>
165
</div>
166
<ul class="sidebar-menu">
@@ -148,9 +171,11 @@
171
<li><a href="#" class="nav-link" data-view="view-cheques">💳 چکها و صیاد</a></li>
172
<li><a href="#" class="nav-link" data-view="view-expenses">💰 هزینهها و درآمد</a></li>
173
<li><a href="#" class="nav-link" data-view="view-settings">⚙️ تنظیمات و شرکتها</a></li>
174
+ <!-- منوی اختصاصی ادمین کل -->
175
+ <li id="menu-admin-panel" style="display:none;"><a href="#" class="nav-link" data-view="view-admin" style="background:#fef2f2; color:#dc2626; font-weight:bold;">👑 مدیریت لایسنس کاربران</a></li>
176
</ul>
177
<div class="sidebar-footer">
153
- نگارش ۴.۱ | <span id="lbl-build-date">۱۴۰۵/۰۶/۲۶</span>
178
+ <span id="logged-user-label">کاربر</span> | <a href="#" onclick="handleLogout()" style="color:var(--danger); text-decoration:none;">خروج</a>
179
</div>
180
</aside>
181
@@ -161,10 +186,13 @@
186
<section id="view-dashboard" class="view-pane active">
187
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px;">
188
<div>
164
- <h1 style="font-size: 20px; font-weight: bold;">سامانه ایزی فاکتور</h1>
189
+ <h1 style="font-size: 20px; font-weight: bold;">سامانه ایزی فاکتور (نسخه تجاری ۱.۰)</h1>
190
<p style="color: var(--text-muted); font-size: 13px;" id="dashboard-date-display"></p>
191
</div>
167
- <button class="btn btn-inline no-print" onclick="startNewInvoice()">➕ صدور فاکتور جدید</button>
192
+ <div style="display:flex; align-items:center; gap:10px;">
193
+ <span id="user-license-status-badge" class="badge badge-warning">آزمایشی (Trial)</span>
194
+ <button class="btn btn-inline no-print" onclick="startNewInvoice()">➕ صدور فاکتور جدید</button>
195
+ </div>
196
</div>
197
198
<div class="grid-kpi">
@@ -267,7 +295,6 @@
295
</div>
296
</div>
297
270
- <!-- جدول اقلام فاکتور -->
298
<div style="margin: 16px 0;">
299
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:8px;">
300
<h4 style="font-size: 14px;">اقلام کالا یا خدمات</h4>
@@ -532,7 +559,7 @@
559
</div>
560
</section>
561
535
- <!-- ۷. تنظیمات و شرکتها (با دسترسی کامل در موبایل و دسکتاپ) -->
562
+ <!-- ۷. تنظیمات و شرکتها -->
563
<section id="view-settings" class="view-pane">
564
565
<div class="accordion-item open">
@@ -622,7 +649,7 @@
649
<div class="accordion-body">
650
<h3 style="font-size:16px; font-weight:bold;">ایزی فاکتور - EasyFactor</h3>
651
<p style="color:var(--text-muted); font-size:13px; margin:6px 0 12px 0;">سیستم هوشمند صدور فاکتور رسمی و غیررسمی (ریال)</p>
625
- <p style="font-size:13px; margin-bottom:14px;">نگارش فعال: <strong>نسخه ۴.۱ (موبایل بهینهشده)</strong></p>
652
+ <p style="font-size:13px; margin-bottom:14px;">نگارش فعال: <strong>نسخه ۱.۰ (تجاری - لایسنسدار)</strong></p>
653
<div style="display:flex; gap:10px;">
654
<button class="btn btn-primary" onclick="alert('آخرین نگارش نصب است.')">بررسی آپدیت</button>
655
<button class="btn btn-secondary" onclick="alert('پشتیبانی فعال است.')">گزارش باگ</button>
@@ -632,6 +659,29 @@
659
660
</section>
661
662
+ <!-- بخش ادمین کل (مختص شما) -->
663
+ <section id="view-admin" class="view-pane">
664
+ <div class="card">
665
+ <h2 style="font-size: 18px; margin-bottom: 12px; color:var(--danger);">👑 پنل مدیریت مرکزی لایسنس کاربران</h2>
666
+ <p style="color:var(--text-muted); font-size:13px; margin-bottom:16px;">
667
+ مدیریت دسترسی کاربران، تمدید حسابهای آزمایشی (Trial) و ارتقای حسابها به نسخه تجاری نامحدود.
668
+ </p>
669
+ <div class="table-responsive">
670
+ <table>
671
+ <thead>
672
+ <tr>
673
+ <th>نام کاربری</th>
674
+ <th>وضعیت اشتراک</th>
675
+ <th>تاریخ انقضا / اعتبار</th>
676
+ <th>عملیات ادمین (ارتقای لایسنس)</th>
677
+ </tr>
678
+ </thead>
679
+ <tbody id="admin-users-table-body"></tbody>
680
+ </table>
681
+ </div>
682
+ </div>
683
+ </section>
684
+
685
<!-- قالب پرینت چندصفحهای استاندارد -->
686
<div id="printable-invoice" style="display:none;"></div>
687
@@ -643,8 +693,8 @@
693
<div class="modal-card">
694
<h3 style="font-size:16px; margin-bottom:12px;">➕ تعریف سریع خریدار</h3>
695
<div class="form-row">
646
- <div class="form-group"><label>نوع</label><select id="quick-c-entity" class="form-control" onchange="handleQuickCEntityChange()"><option value="natural">حقیقی</option><option value="legal">حقوقی</option></select></div>
647
- <div class="form-group" id="box-quick-c-prefix"><label>پیشوند</label><select id="quick-c-prefix" class="form-control"><option value="آقا/خانم">آقا/خانم</option><option value="فروشگاه">فروشگاه</option></select></div>
696
+ <div class="form-group"><label>نوع</label><select id="quick-c-entity" class="form-control" onchange="handleQuickCEntityChange()"><option value="natural">شخص حقیقی</option><option value="legal">شخص حقوقی</option></select></div>
697
+ <div class="form-group" id="box-quick-c-prefix"><label>پیشوند</label><select id="quick-c-prefix" class="form-control"><option value="آقا/خانم">آقا / خانم</option><option value="فروشگاه">فروشگاه</option></select></div>
698
<div class="form-group"><label>نام</label><input type="text" id="quick-c-name" class="form-control" /></div>
699
</div>
700
<div class="form-row">
@@ -713,8 +763,13 @@
763
</nav>
764
765
<script>
716
- const STORAGE_KEY = 'easy_factor_datastore_v4_1';
717
- const APP_BUILD_TIMESTAMP = '۱۴۰۵/۰۶/۲۶ - ۱۵:۱۰';
766
+ const STORAGE_KEY = 'easy_factor_commercial_v1_0';
767
+ const AUTH_KEY = 'easy_factor_auth_users_v1_0';
768
+
769
+ let currentUser = null;
770
+ let usersDb = [
771
+ { username: 'admin', pass: 'admin123', role: 'admin', license_type: 'lifetime', expire_date: '2099-01-01' }
772
+ ];
773
774
let datastore = {
775
default_settings: { invoice_kind: 'non_formal', vat_mode: 'none', vat_rate: 10, default_company_id: 'COMP-1' },
@@ -756,8 +811,165 @@
811
expenses: []
812
};
813
814
+ function initAuthSystem() {
815
+ const savedUsers = localStorage.getItem(AUTH_KEY);
816
+ if (savedUsers) {
817
+ try { usersDb = JSON.parse(savedUsers); } catch(e) {}
818
+ } else {
819
+ localStorage.setItem(AUTH_KEY, JSON.stringify(usersDb));
820
+ }
821
+
822
+ const activeSession = sessionStorage.getItem('easy_factor_session');
823
+ if (activeSession) {
824
+ const u = usersDb.find(x => x.username === activeSession);
825
+ if (u) {
826
+ loginSuccess(u);
827
+ return;
828
+ }
829
+ }
830
+ document.getElementById('auth-screen').style.display = 'flex';
831
+ }
832
+
833
+ function handleLogin() {
834
+ const user = document.getElementById('auth-username').value.trim();
835
+ const pass = document.getElementById('auth-password').value.trim();
836
+ const found = usersDb.find(x => x.username === user && x.pass === pass);
837
+
838
+ if (!found) {
839
+ alert('نام کاربری یا رمز عبور اشتباه است.');
840
+ return;
841
+ }
842
+
843
+ sessionStorage.setItem('easy_factor_session', found.username);
844
+ loginSuccess(found);
845
+ }
846
+
847
+ function switchToRegister() {
848
+ const user = document.getElementById('auth-username').value.trim();
849
+ const pass = document.getElementById('auth-password').value.trim();
850
+
851
+ if (!user || !pass) {
852
+ alert('لطفاً نام کاربری و رمز عبور را وارد کنید.');
853
+ return;
854
+ }
855
+
856
+ if (usersDb.some(x => x.username === user)) {
857
+ alert('این نام کاربری قبلاً ثبتنام کرده است.');
858
+ return;
859
+ }
860
+
861
+ // محاسبه ۱۵ روز آزمایشی (Trial)
862
+ const now = new Date();
863
+ now.setDate(now.getDate() + 15);
864
+ const expireStr = now.toISOString().split('T')[0];
865
+
866
+ const newUser = {
867
+ username: user,
868
+ pass: pass,
869
+ role: 'user',
870
+ license_type: 'trial',
871
+ expire_date: expireStr
872
+ };
873
+
874
+ usersDb.push(newUser);
875
+ localStorage.setItem(AUTH_KEY, JSON.stringify(usersDb));
876
+ sessionStorage.setItem('easy_factor_session', newUser.username);
877
+ alert('ثبتنام با موفقیت انجام شد. حساب شما به مدت ۱۵ روز به صورت آزمایشی فعال شد.');
878
+ loginSuccess(newUser);
879
+ }
880
+
881
+ function loginSuccess(userObj) {
882
+ currentUser = userObj;
883
+ document.getElementById('auth-screen').style.display = 'none';
884
+ document.getElementById('logged-user-label').innerText = userObj.username + (userObj.role === 'admin' ? ' (مدیر کل)' : '');
885
+
886
+ const adminMenu = document.getElementById('menu-admin-panel');
887
+ if (userObj.role === 'admin') {
888
+ adminMenu.style.display = 'block';
889
+ } else {
890
+ adminMenu.style.display = 'none';
891
+ }
892
+
893
+ // بررسی انقضای لایسنس
894
+ checkLicenseValidity(userObj);
895
+ initDatastore();
896
+ }
897
+
898
+ function checkLicenseValidity(user) {
899
+ const badge = document.getElementById('user-license-status-badge');
900
+ if (user.role === 'admin') {
901
+ badge.innerText = 'نسخه دائمی (Lifetime)';
902
+ badge.className = 'badge badge-success';
903
+ return;
904
+ }
905
+
906
+ const today = new Date().toISOString().split('T')[0];
907
+ if (user.expire_date && user.expire_date < today) {
908
+ badge.innerText = 'منقضی شده';
909
+ badge.className = 'badge badge-danger';
910
+ alert('مهلت استفاده آزمایشی ۱۵ روزه شما به پایان رسیده است. لطفاً جهت ارتقا با مدیریت تماس بگیرید.');
911
+ } else {
912
+ badge.innerText = `آزمایشی (تا ${user.expire_date})`;
913
+ badge.className = 'badge badge-warning';
914
+ }
915
+ }
916
+
917
+ function handleLogout() {
918
+ sessionStorage.removeItem('easy_factor_session');
919
+ window.location.reload();
920
+ }
921
+
922
+ // پنل ادمین کل
923
+ function renderAdminPanel() {
924
+ const tbody = document.getElementById('admin-users-table-body');
925
+ tbody.innerHTML = usersDb.map(u => `
926
+ <tr>
927
+ <td><strong>${u.username}</strong> ${u.role === 'admin' ? '👑' : ''}</td>
928
+ <td><span class="badge ${u.license_type === 'trial' ? 'badge-warning' : 'badge-success'}">${u.license_type}</span></td>
929
+ <td>${u.expire_date || 'نامحدود'}</td>
930
+ <td>
931
+ <button class="btn btn-secondary btn-inline" style="padding:2px 8px; font-size:11px;" onclick="upgradeUserLicense('${u.username}', 30)">+ ۱ ماه</button>
932
+ <button class="btn btn-secondary btn-inline" style="padding:2px 8px; font-size:11px;" onclick="upgradeUserLicense('${u.username}', 90)">+ ۳ ماه</button>
933
+ <button class="btn btn-secondary btn-inline" style="padding:2px 8px; font-size:11px;" onclick="upgradeUserLicense('${u.username}', 365)">+ ۱ سال</button>
934
+ <button class="btn btn-success btn-inline" style="padding:2px 8px; font-size:11px;" onclick="upgradeUserLicense('${u.username}', 'lifetime')">دائمی (Lifetime)</button>
935
+ </td>
936
+ </tr>
937
+ `).join('');
938
+ }
939
+
940
+ function upgradeUserLicense(username, durationDays) {
941
+ const u = usersDb.find(x => x.username === username);
942
+ if (!u) return;
943
+
944
+ if (durationDays === 'lifetime') {
945
+ u.license_type = 'lifetime';
946
+ u.expire_date = '2099-01-01';
947
+ } else {
948
+ u.license_type = 'pro';
949
+ const d = new Date();
950
+ d.setDate(d.getDate() + durationDays);
951
+ u.expire_date = d.toISOString().split('T')[0];
952
+ }
953
+
954
+ localStorage.setItem(AUTH_KEY, JSON.stringify(usersDb));
955
+ alert(`لایسنس کاربر ${username} با موفقیت ارتقا یافت.`);
956
+ renderAdminPanel();
957
+ }
958
+
959
+ // ثبتنام در منوهای داشبورد
960
+ document.querySelectorAll('.nav-link').forEach(btn => {
961
+ btn.addEventListener('click', (e) => {
962
+ e.preventDefault();
963
+ const targetView = btn.getAttribute('data-view');
964
+ if (targetView === 'view-admin') {
965
+ renderAdminPanel();
966
+ }
967
+ switchView(targetView);
968
+ });
969
+ });
970
+
971
function initDatastore() {
760
- const persisted = localStorage.getItem(STORAGE_KEY) || localStorage.getItem('easy_factor_datastore_v4_0');
972
+ const persisted = localStorage.getItem(STORAGE_KEY);
973
if (persisted) {
974
try { datastore = JSON.parse(persisted); } catch(e) {}
975
}
@@ -794,13 +1006,6 @@
1006
window.scrollTo({ top: 0, behavior: 'smooth' });
1007
}
1008
797
- document.querySelectorAll('.nav-link').forEach(btn => {
798
- btn.addEventListener('click', (e) => {
799
- e.preventDefault();
800
- switchView(btn.getAttribute('data-view'));
801
- });
802
- });
803
-
1009
function toggleAccordion(headerEl) {
1010
const item = headerEl.parentElement;
1011
item.classList.toggle('open');
@@ -1673,8 +1878,7 @@
1878
}
1879
1880
window.addEventListener('DOMContentLoaded', () => {
1676
- initDatastore();
1677
- addInvoiceItemRow();
1881
+ initAuthSystem();
1882
});
1883
</script>
1884
</body>