سامانه صدور فاکتور و حسابداری
Change greeting from 'Hello' to 'Goodbye'
davoodmehraban89 committed
Sep 16, 2026 at 12:32 UTC
3e1a7f0bad8c34485c25e47749f5dab617e9cb84
1 file changed
+267
-247
index.html
+267
-247
@@ -5,14 +5,12 @@
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>
7
8
- <!-- تنظیمات PWA و آیفون -->
8
<link rel="manifest" href="manifest.json" />
9
<meta name="apple-mobile-web-app-capable" content="yes" />
10
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
11
<meta name="apple-mobile-web-app-title" content="فاکتورا" />
12
<meta name="theme-color" content="#1e3a8a" />
13
15
- <!-- فونت وزیرمتن با اعداد فارسی -->
14
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/misc/Farsi-Digits/Vazirmatn-FD-font-face.css" />
15
16
<style>
@@ -24,59 +22,61 @@
22
--card-bg: #ffffff;
23
--text: #0f172a;
24
--text-muted: #64748b;
27
- --border: #e2e8f0;
25
+ --border: #cbd5e1;
26
--danger: #dc2626;
27
--success: #059669;
28
--warning: #d97706;
29
--sidebar-w: 240px;
32
- --nav-h: 68px;
30
+ --nav-h: 74px;
31
}
32
33
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Vazirmatn FD', Tahoma, sans-serif; -webkit-tap-highlight-color: transparent; }
36
- body { background-color: var(--bg); color: var(--text); overflow-x: hidden; }
34
+ body { background-color: var(--bg); color: var(--text); overflow-x: hidden; font-size: 15px; }
35
36
.app-root { display: flex; min-height: 100vh; }
37
.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; }
38
.brand-box { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
41
- .brand-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 20px; }
39
+ .brand-icon { width: 44px; height: 44px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 22px; }
40
41
.sidebar-menu { list-style: none; padding: 16px 8px; flex: 1; overflow-y: auto; }
44
- .sidebar-menu li a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; border-radius: 8px; margin-bottom: 4px; font-size: 14px; transition: all 0.2s; }
42
+ .sidebar-menu li a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; border-radius: 10px; margin-bottom: 6px; font-size: 15px; font-weight: 500; transition: all 0.2s; }
43
.sidebar-menu li a:hover, .sidebar-menu li a.active { background: #eff6ff; color: var(--accent); font-weight: bold; }
44
47
- .main-surface { flex: 1; margin-right: var(--sidebar-w); padding: 24px; padding-bottom: 90px; }
45
+ .main-surface { flex: 1; margin-right: var(--sidebar-w); padding: 24px; padding-bottom: 100px; }
46
49
- .mobile-dock { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); background: rgba(255,255,255,0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); z-index: 200; justify-content: space-around; align-items: center; padding-bottom: env(safe-area-inset-bottom); }
50
- .dock-tab { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-muted); text-decoration: none; font-size: 11px; flex: 1; cursor: pointer; }
51
- .dock-tab.active { color: var(--accent); font-weight: bold; }
52
- .dock-tab svg { width: 22px; height: 22px; }
47
+ /* داک پایین گوشی با کلیدهای بزرگتر و درشت */
48
+ .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); }
49
+ .dock-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #475569; text-decoration: none; font-size: 13px; font-weight: 600; flex: 1; height: 100%; cursor: pointer; }
50
+ .dock-tab.active { color: var(--accent); font-weight: 800; }
51
+ .dock-tab svg { width: 26px; height: 26px; stroke-width: 2.2; }
52
54
- .card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
53
+ .card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.03); }
54
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
55
.kpi-unit { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; align-items: center; gap: 14px; }
57
- .kpi-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
58
- .kpi-val { font-size: 17px; font-weight: bold; margin-top: 4px; }
59
- .kpi-lbl { color: var(--text-muted); font-size: 12px; }
56
+ .kpi-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
57
+ .kpi-val { font-size: 19px; font-weight: bold; margin-top: 4px; }
58
+ .kpi-lbl { color: var(--text-muted); font-size: 13px; font-weight: 500; }
59
61
- .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; background: var(--primary); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.2s; }
60
+ /* دکمههای بزرگ با فاصله لمسی مناسب */
61
+ .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; background: var(--primary); color: #fff; border: none; border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 600; transition: background 0.2s; }
62
.btn:hover { background: var(--primary-hover); }
63
.btn-secondary { background: #e2e8f0; color: var(--text); }
64
.btn-secondary:hover { background: #cbd5e1; }
65
.btn-success { background: var(--success); }
66
.btn-danger { background: var(--danger); }
67
68
- .form-group { margin-bottom: 14px; }
69
- .form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
70
- .form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.2s; }
71
- .form-control:focus { border-color: var(--accent); }
72
- .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
68
+ .form-group { margin-bottom: 16px; }
69
+ .form-group label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: #334155; }
70
+ .form-control { width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 15px; outline: none; background: #fff; transition: border-color 0.2s; }
71
+ .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
72
+ .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
73
74
.table-responsive { overflow-x: auto; }
75
- table { width: 100%; border-collapse: collapse; text-align: right; font-size: 13px; }
76
- th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
77
- th { background: #f1f5f9; color: var(--text-muted); font-weight: 600; }
75
+ table { width: 100%; border-collapse: collapse; text-align: right; font-size: 14px; }
76
+ th, td { padding: 14px 12px; border-bottom: 1px solid var(--border); }
77
+ th { background: #f1f5f9; color: #334155; font-weight: 700; font-size: 14px; }
78
79
- .badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
79
+ .badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
80
.badge-success { background: #d1fae5; color: #065f46; }
81
.badge-warning { background: #fef3c7; color: #92400e; }
82
.badge-danger { background: #fee2e2; color: #991b1b; }
@@ -94,45 +94,47 @@
94
95
@media (max-width: 768px) {
96
.sidebar { display: none; }
97
- .main-surface { margin-right: 0; padding: 16px; padding-bottom: calc(var(--nav-h) + 24px); }
97
+ .main-surface { margin-right: 0; padding: 16px; padding-bottom: calc(var(--nav-h) + 26px); }
98
.mobile-dock { display: flex; }
99
+ .btn { width: 100%; }
100
+ .btn-inline { width: auto; }
101
}
102
</style>
103
</head>
104
<body>
105
106
<div class="app-root">
105
- <!-- منوی کناری مخصوص دسکتاپ -->
107
+ <!-- منوی کناری دسکتاپ -->
108
<aside class="sidebar">
109
<div class="brand-box">
110
<div class="brand-icon">فـ</div>
111
<div>
110
- <h2 style="font-size: 15px; font-weight: bold;">فاکتورا وب</h2>
111
- <small style="color: var(--text-muted); font-size: 11px;">سیستم جامع مالی و صدور فاکتور</small>
112
+ <h2 style="font-size: 16px; font-weight: bold;">فاکتورا</h2>
113
+ <small style="color: var(--text-muted); font-size: 12px;">صدور سریع انواع فاکتور</small>
114
</div>
115
</div>
116
<ul class="sidebar-menu">
117
<li><a href="#" class="nav-link active" data-view="view-dashboard">📊 داشبورد تحلیلی</a></li>
118
<li><a href="#" class="nav-link" data-view="view-invoices">🧾 فاکتورها و اسناد</a></li>
117
- <li><a href="#" class="nav-link" data-view="view-products">📦 کالاها و انبار</a></li>
119
+ <li><a href="#" class="nav-link" data-view="view-products">📦 تعریف کالاها و خدمات</a></li>
120
<li><a href="#" class="nav-link" data-view="view-contacts">👥 طرفحسابها و معین</a></li>
121
<li><a href="#" class="nav-link" data-view="view-cheques">💳 چکها و صیاد</a></li>
122
<li><a href="#" class="nav-link" data-view="view-expenses">💰 هزینهها و درآمد</a></li>
121
- <li><a href="#" class="nav-link" data-view="view-settings">⚙️ پشتیبانگیری و تنظیمات</a></li>
123
+ <li><a href="#" class="nav-link" data-view="view-settings">⚙️ تنظیمات و پشتیبان</a></li>
124
</ul>
125
</aside>
126
125
- <!-- بدنه اصلی برنامه -->
127
+ <!-- محتوای اصلی صفحات -->
128
<main class="main-surface">
129
130
<!-- ۱. داشبورد -->
131
<section id="view-dashboard" class="view-pane active">
130
- <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
132
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px;">
133
<div>
132
- <h1 style="font-size: 20px; font-weight: bold;">مرکز مدیریت و وضعیت فروشگاه</h1>
133
- <p style="color: var(--text-muted); font-size: 13px;" id="dashboard-date-display"></p>
134
+ <h1 style="font-size: 22px; font-weight: bold;">مرکز مدیریت فروشگاه</h1>
135
+ <p style="color: var(--text-muted); font-size: 14px;" id="dashboard-date-display"></p>
136
</div>
135
- <button class="btn no-print" onclick="switchView('view-invoices')">➕ صدور فاکتور جدید</button>
137
+ <button class="btn btn-inline no-print" onclick="switchView('view-invoices')">➕ صدور فاکتور جدید</button>
138
</div>
139
140
<div class="grid-kpi">
@@ -167,38 +169,39 @@
169
</div>
170
171
<div class="card">
170
- <h3 style="font-size: 15px; margin-bottom: 14px;">آخرین اسناد فاکتور صادره</h3>
172
+ <h3 style="font-size: 16px; margin-bottom: 14px;">آخرین فاکتورهای صادر شده</h3>
173
<div class="table-responsive">
174
<table>
175
<thead>
176
<tr>
177
<th>شماره</th>
178
<th>طرف حساب</th>
177
- <th>تاریخ</th>
179
+ <th>نوع سند</th>
180
<th>مبلغ نهایی (تومان)</th>
179
- <th>روش پرداخت</th>
180
- <th>وضعیت</th>
181
+ <th>روش تسویه</th>
182
+ <th>عملیات</th>
183
</tr>
184
</thead>
185
<tbody id="dashboard-recent-table">
184
- <tr><td colspan="6" style="text-align:center; color:var(--text-muted);">سندی ثبت نشده است.</td></tr>
186
+ <tr><td colspan="6" style="text-align:center; color:var(--text-muted); padding:20px;">هنوز فاکتوری ثبت نشده است.</td></tr>
187
</tbody>
188
</table>
189
</div>
190
</div>
191
</section>
192
191
- <!-- ۲. صدور و بایگانی فاکتور -->
193
+ <!-- ۲. صدور فاکتور -->
194
<section id="view-invoices" class="view-pane">
195
<div class="card no-print">
194
- <h2 style="font-size: 17px; margin-bottom: 16px;">صدور سند فاکتور فروش / پیشفاکتور</h2>
196
+ <h2 style="font-size: 18px; margin-bottom: 16px;">صدور فاکتور فروش</h2>
197
<div class="form-row">
198
<div class="form-group">
197
- <label>نوع سند</label>
198
- <select id="invoice-kind" class="form-control">
199
- <option value="sale">فاکتور فروش قطعی</option>
200
- <option value="pre_invoice">پیشفاکتور رسمی</option>
201
- <option value="return">برگشت از فروش</option>
199
+ <label>قالب و نوع سند</label>
200
+ <select id="invoice-kind" class="form-control" onchange="onInvoiceKindChange()">
201
+ <option value="non_formal">فاکتور معمولی / آزاد (غیررسمی)</option>
202
+ <option value="formal">فاکتور رسمی (با ارزش افزوده)</option>
203
+ <option value="pre_invoice">پیشفاکتور استعلام قیمت</option>
204
+ <option value="receipt">رسید دریافت کالا / حواله</option>
205
</select>
206
</div>
207
<div class="form-group">
@@ -210,36 +213,36 @@
213
<select id="invoice-contact-id" class="form-control"></select>
214
</div>
215
<div class="form-group">
213
- <label>تاریخ سند (شمسی)</label>
216
+ <label>تاریخ فاکتور (شمسی)</label>
217
<input type="text" id="invoice-date-input" class="form-control" />
218
</div>
219
</div>
220
218
- <div style="margin: 16px 0;">
219
- <h4 style="font-size: 14px; margin-bottom: 10px;">جدول اقلام کالا و خدمات</h4>
221
+ <div style="margin: 20px 0;">
222
+ <h4 style="font-size: 15px; margin-bottom: 10px;">اقلام فاکتور</h4>
223
<div class="table-responsive">
224
<table>
225
<thead>
226
<tr>
224
- <th>شرح کالا یا خدمت</th>
225
- <th style="width:120px;">تعداد / مقدار</th>
226
- <th style="width:160px;">فی واحد (تومان)</th>
227
- <th style="width:160px;">جمع کل سطر</th>
227
+ <th>انتخاب کالا / خدمت</th>
228
+ <th style="width:110px;">تعداد</th>
229
+ <th style="width:170px;">قیمت واحد (تومان)</th>
230
+ <th style="width:170px;">جمع سطر</th>
231
<th style="width:50px;">حذف</th>
232
</tr>
233
</thead>
234
<tbody id="invoice-items-table-body"></tbody>
235
</table>
236
</div>
234
- <button class="btn btn-secondary" style="margin-top: 10px;" onclick="addInvoiceItemRow()">➕ افزودن ردیف کالا</button>
237
+ <button class="btn btn-secondary btn-inline" style="margin-top: 12px;" onclick="addInvoiceItemRow()">➕ افزودن ردیف کالا</button>
238
</div>
239
237
- <div class="form-row" style="background:#f8fafc; padding:14px; border-radius:8px; margin-top:12px;">
240
+ <div class="form-row" style="background:#f1f5f9; padding:16px; border-radius:12px; margin-top:14px;">
241
<div class="form-group">
239
- <label>نحوه تسویه</label>
242
+ <label>نحوه تسویه حساب</label>
243
<select id="invoice-payment-method" class="form-control">
241
- <option value="cash">نقدی / کارتخوان</option>
242
- <option value="credit">نسیه (بدهکار در معین)</option>
244
+ <option value="cash">نقدی / کارتخوان (تسویه کامل)</option>
245
+ <option value="credit">نسیه (مانده در حساب خریدار)</option>
246
<option value="cheque">چک صیادی</option>
247
<option value="installment">فروش اقساطی</option>
248
</select>
@@ -249,34 +252,34 @@
252
<input type="number" id="invoice-discount-fixed" class="form-control" value="0" oninput="recomputeTotals()" />
253
</div>
254
<div class="form-group">
252
- <label>مالیات ارزش افزوده (۱۰٪)</label>
255
+ <label>مالیات بر ارزش افزوده (۱۰٪)</label>
256
<select id="invoice-vat-toggle" class="form-control" onchange="recomputeTotals()">
254
- <option value="1">اعمال مالیات ۱۰٪</option>
255
- <option value="0">معاف از مالیات</option>
257
+ <option value="0">بدون ارزش افزوده (معاف / آزاد)</option>
258
+ <option value="1">محاسبه ۱۰٪ مالیات ارزش افزوده</option>
259
</select>
260
</div>
261
<div class="form-group">
262
<label>مبلغ نهایی قابل پرداخت</label>
260
- <input type="text" id="invoice-grand-total-display" class="form-control" readonly style="font-weight:bold; background:#e2e8f0;" />
263
+ <input type="text" id="invoice-grand-total-display" class="form-control" readonly style="font-weight:bold; font-size:16px; background:#e2e8f0;" />
264
</div>
265
</div>
266
264
- <div style="display:flex; gap:10px; margin-top: 16px;">
265
- <button class="btn btn-success" onclick="commitSaveInvoice()">💾 ثبت نهایی سند</button>
266
- <button class="btn btn-secondary" onclick="printActiveInvoice()">🖨️ چاپ مستقیم / PDF</button>
267
+ <div style="display:flex; gap:12px; margin-top: 20px; flex-wrap:wrap;">
268
+ <button class="btn btn-success" onclick="commitSaveInvoice()">💾 ثبت و صدور فاکتور</button>
269
</div>
270
</div>
271
272
<div class="card no-print">
271
- <h3 style="font-size: 15px; margin-bottom: 12px;">دفتر بایگانی فاکتورها</h3>
273
+ <h3 style="font-size: 16px; margin-bottom: 14px;">سوابق و بایگانی فاکتورها</h3>
274
<div class="table-responsive">
275
<table>
276
<thead>
277
<tr>
278
<th>شماره</th>
279
<th>خریدار</th>
280
+ <th>نوع</th>
281
<th>تاریخ</th>
279
- <th>مبلغ نهایی (تومان)</th>
282
+ <th>مبلغ کل (تومان)</th>
283
<th>تسویه</th>
284
<th>عملیات</th>
285
</tr>
@@ -287,10 +290,10 @@
290
</div>
291
</section>
292
290
- <!-- ۳. کالاها و موجودی انبار -->
293
+ <!-- ۳. کالاها و خدمات -->
294
<section id="view-products" class="view-pane">
295
<div class="card no-print">
293
- <h2 style="font-size: 17px; margin-bottom: 16px;">ثبت کالا یا خدمت جدید</h2>
296
+ <h2 style="font-size: 18px; margin-bottom: 16px;">تعریف کالا / خدمات جدید</h2>
297
<div class="form-row">
298
<div class="form-group">
299
<label>کد کالا</label>
@@ -298,54 +301,54 @@
301
</div>
302
<div class="form-group">
303
<label>عنوان کالا یا خدمت</label>
301
- <input type="text" id="prod-name-input" class="form-control" />
304
+ <input type="text" id="prod-name-input" class="form-control" placeholder="مثلاً: بلوک سیمانی ۱۰" />
305
+ </div>
306
+ <div class="form-group">
307
+ <label>مشخصه / مدل / نوع</label>
308
+ <input type="text" id="prod-spec-input" class="form-control" placeholder="مثلاً: سبک، سنگین، ته پر، سایز و..." />
309
</div>
310
<div class="form-group">
311
<label>نوع ردیف</label>
312
<select id="prod-type-input" class="form-control">
306
- <option value="good">کالای فیزیکی (کنترل انبار)</option>
307
- <option value="service">خدمات (نامحدود)</option>
313
+ <option value="good">کالای فیزیکی (انبارداری)</option>
314
+ <option value="service">خدمات و اجرا (نامحدود)</option>
315
</select>
316
</div>
317
+ </div>
318
+ <div class="form-row">
319
<div class="form-group">
320
<label>واحد اندازهگیری</label>
312
- <input type="text" id="prod-unit-input" class="form-control" value="عدد" />
321
+ <input type="text" id="prod-unit-input" class="form-control" value="عدد" placeholder="عدد، متر، قالب، تن..." />
322
</div>
314
- </div>
315
- <div class="form-row">
323
<div class="form-group">
317
- <label>قیمت خرید انبار (تومان)</label>
324
+ <label>قیمت خرید (تومان)</label>
325
<input type="number" id="prod-buy-input" class="form-control" value="0" />
326
</div>
327
<div class="form-group">
321
- <label>قیمت فروش مصوب (تومان)</label>
328
+ <label>قیمت فروش (تومان)</label>
329
<input type="number" id="prod-sale-input" class="form-control" value="0" />
330
</div>
331
<div class="form-group">
325
- <label>موجودی فیزیکی اولیه</label>
332
+ <label>موجودی فیزیکی اولیه (اختیاری)</label>
333
<input type="number" id="prod-stock-input" class="form-control" value="0" />
334
</div>
328
- <div class="form-group">
329
- <label>حد هشدار سفارش (حداقل)</label>
330
- <input type="number" id="prod-reorder-input" class="form-control" value="5" />
331
- </div>
335
</div>
333
- <button class="btn btn-success" onclick="commitSaveProduct()">➕ افزودن به انبار</button>
336
+ <button class="btn btn-success" onclick="commitSaveProduct()">➕ افزودن به لیست کالاها</button>
337
</div>
338
339
<div class="card">
337
- <h3 style="font-size: 15px; margin-bottom: 12px;">کاردکس و موجودی فعلی انبار</h3>
340
+ <h3 style="font-size: 16px; margin-bottom: 14px;">لیست کالاها و مشخصات</h3>
341
<div class="table-responsive">
342
<table>
343
<thead>
344
<tr>
345
<th>کد</th>
346
<th>عنوان کالا</th>
347
+ <th>مشخصه / نوع</th>
348
<th>واحد</th>
345
- <th>قیمت خرید</th>
346
- <th>قیمت فروش</th>
349
+ <th>قیمت فروش (تومان)</th>
350
<th>موجودی</th>
348
- <th>وضعیت انبار</th>
351
+ <th>عملیات</th>
352
</tr>
353
</thead>
354
<tbody id="products-catalog-table-body"></tbody>
@@ -357,14 +360,14 @@
360
<!-- ۴. اشخاص و طرفحسابها -->
361
<section id="view-contacts" class="view-pane">
362
<div class="card no-print">
360
- <h2 style="font-size: 17px; margin-bottom: 16px;">ثبت طرف حساب تجاری جدید</h2>
363
+ <h2 style="font-size: 18px; margin-bottom: 16px;">ثبت طرف حساب جدید</h2>
364
<div class="form-row">
365
<div class="form-group">
363
- <label>نام و نام خانوادگی / نام شرکت</label>
364
- <input type="text" id="contact-name-input" class="form-control" />
366
+ <label>نام و نام خانوادگی / شرکت</label>
367
+ <input type="text" id="contact-name-input" class="form-control" placeholder="مثلاً: شرکت آرا بتن / آقای احمدی" />
368
</div>
369
<div class="form-group">
367
- <label>نقش تجاری</label>
370
+ <label>نقش</label>
371
<select id="contact-role-input" class="form-control">
372
<option value="customer">مشتری (خریدار)</option>
373
<option value="supplier">تامینکننده (فروشنده)</option>
@@ -380,24 +383,31 @@
383
<input type="text" id="contact-national-input" class="form-control" />
384
</div>
385
</div>
383
- <div class="form-group">
384
- <label>نشانی کامل و کد پستی</label>
385
- <input type="text" id="contact-address-input" class="form-control" />
386
+ <div class="form-row">
387
+ <div class="form-group">
388
+ <label>کد پستی (۱۰ رقمی)</label>
389
+ <input type="text" id="contact-postal-input" class="form-control" placeholder="کد پستی مجزا" />
390
+ </div>
391
+ <div class="form-group" style="grid-column: span 2;">
392
+ <label>نشانی کامل</label>
393
+ <input type="text" id="contact-address-input" class="form-control" placeholder="استان، شهر، آدرس دقیق..." />
394
+ </div>
395
</div>
387
- <button class="btn btn-success" onclick="commitSaveContact()">➕ ثبت طرف حساب</button>
396
+ <button class="btn btn-success" onclick="commitSaveContact()">➕ ثبت اطلاعات طرف حساب</button>
397
</div>
398
399
<div class="card">
391
- <h3 style="font-size: 15px; margin-bottom: 12px;">دفتر اشخاص و وضعیت معین مانده</h3>
400
+ <h3 style="font-size: 16px; margin-bottom: 14px;">دفتر طرفحسابها و معین مانده حساب</h3>
401
<div class="table-responsive">
402
<table>
403
<thead>
404
<tr>
405
<th>نام شخص / شرکت</th>
406
<th>نقش</th>
398
- <th>شماره همراه</th>
399
- <th>مانده حساب معین (تومان)</th>
400
- <th>وضعیت حساب</th>
407
+ <th>همراه</th>
408
+ <th>کد پستی</th>
409
+ <th>مانده حساب (تومان)</th>
410
+ <th>وضعیت</th>
411
</tr>
412
</thead>
413
<tbody id="contacts-ledger-table-body"></tbody>
@@ -406,16 +416,16 @@
416
</div>
417
</section>
418
409
- <!-- ۵. چکهای صیادی -->
419
+ <!-- ۵. چکهای صیاد -->
420
<section id="view-cheques" class="view-pane">
421
<div class="card no-print">
412
- <h2 style="font-size: 17px; margin-bottom: 16px;">ثبت برگ چک صیادی (دریافتی / پرداختی)</h2>
422
+ <h2 style="font-size: 18px; margin-bottom: 16px;">ثبت چک صیادی</h2>
423
<div class="form-row">
424
<div class="form-group">
415
- <label>گردش چک</label>
425
+ <label>نوع چک</label>
426
<select id="chq-direction-input" class="form-control">
427
<option value="inbound">چک دریافتی از مشتری</option>
418
- <option value="outbound">چک صادره پرداختی به تامینکننده</option>
428
+ <option value="outbound">چک صادره پرداختی</option>
429
</select>
430
</div>
431
<div class="form-group">
@@ -424,11 +434,11 @@
434
</div>
435
<div class="form-group">
436
<label>شناسه ۱۶ رقمی صیاد</label>
427
- <input type="text" id="chq-sayad-input" class="form-control" placeholder="0812345678901235" />
437
+ <input type="text" id="chq-sayad-input" class="form-control" placeholder="شماره صیاد" />
438
</div>
439
<div class="form-group">
430
- <label>بانک و شعبه</label>
431
- <input type="text" id="chq-bank-input" class="form-control" placeholder="ملت - مرکزی" />
440
+ <label>نام بانک و شعبه</label>
441
+ <input type="text" id="chq-bank-input" class="form-control" placeholder="ملت، ملی، صادرات..." />
442
</div>
443
</div>
444
<div class="form-row">
@@ -441,9 +451,9 @@
451
<input type="text" id="chq-due-input" class="form-control" placeholder="1405/04/15" />
452
</div>
453
<div class="form-group">
444
- <label>وضعیت صیادی</label>
454
+ <label>وضعیت وصول</label>
455
<select id="chq-status-input" class="form-control">
446
- <option value="registered">ثبت شده در جریان وصول</option>
456
+ <option value="registered">در جریان وصول</option>
457
<option value="cleared">وصول شده</option>
458
<option value="returned">برگشت خورده</option>
459
</select>
@@ -453,14 +463,14 @@
463
</div>
464
465
<div class="card">
456
- <h3 style="font-size: 15px; margin-bottom: 12px;">کارتابل سررسید چکهای صیاد</h3>
466
+ <h3 style="font-size: 16px; margin-bottom: 14px;">دفتر چکهای ثبتشده</h3>
467
<div class="table-responsive">
468
<table>
469
<thead>
470
<tr>
461
- <th>جهت</th>
471
+ <th>نوع</th>
472
<th>طرف حساب</th>
463
- <th>شناسه صیاد و بانک</th>
473
+ <th>بانک / صیاد</th>
474
<th>مبلغ (تومان)</th>
475
<th>سررسید</th>
476
<th>وضعیت</th>
@@ -475,39 +485,39 @@
485
<!-- ۶. هزینهها و درآمدها -->
486
<section id="view-expenses" class="view-pane">
487
<div class="card no-print">
478
- <h2 style="font-size: 17px; margin-bottom: 16px;">ثبت سند هزینه یا درآمد</h2>
488
+ <h2 style="font-size: 18px; margin-bottom: 16px;">ثبت هزینه / درآمد متفرقه</h2>
489
<div class="form-row">
490
<div class="form-group">
491
<label>نوع تراکنش</label>
492
<select id="trx-kind-input" class="form-control">
483
- <option value="expense">هزینه (پرداخت نقدی/بانکی)</option>
493
+ <option value="expense">هزینه (پرداخت)</option>
494
<option value="income">درآمد متفرقه (دریافت)</option>
495
</select>
496
</div>
497
<div class="form-group">
498
<label>سرفصل</label>
499
<select id="trx-category-input" class="form-control">
490
- <option value="قبوض">قبوض آب، برق، گاز و ارتباطات</option>
491
- <option value="اجاره">اجاره دفتر / فروشگاه</option>
492
- <option value="حقوق">حقوق و دستمزد</option>
493
- <option value="حمل و نقل">حمل و نقل و پیک</option>
500
+ <option value="کرایه و حمل">کرایه، باربری و تخلیه</option>
501
+ <option value="حقوق">حقوق و دستمزد کارگران</option>
502
+ <option value="قبوض">قبوض آب، برق، گاز و تلفن</option>
503
+ <option value="تعمیرات">تعمیرات و نگهداری دستگاهها</option>
504
<option value="سایر">سایر موارد</option>
505
</select>
506
</div>
507
<div class="form-group">
498
- <label>مبلغ تراکنش (تومان)</label>
508
+ <label>مبلغ (تومان)</label>
509
<input type="number" id="trx-amount-input" class="form-control" />
510
</div>
511
<div class="form-group">
512
<label>شرح سند</label>
503
- <input type="text" id="trx-desc-input" class="form-control" placeholder="توضیحات تکمیلی" />
513
+ <input type="text" id="trx-desc-input" class="form-control" placeholder="توضیح کوتاه..." />
514
</div>
515
</div>
516
<button class="btn btn-success" onclick="commitSaveExpense()">➕ ثبت در دفاتر</button>
517
</div>
518
519
<div class="card">
510
- <h3 style="font-size: 15px; margin-bottom: 12px;">دفتر روزنامه هزینهها و درآمدها</h3>
520
+ <h3 style="font-size: 16px; margin-bottom: 14px;">گردش هزینهها و درآمدها</h3>
521
<div class="table-responsive">
522
<table>
523
<thead>
@@ -524,10 +534,10 @@
534
</div>
535
</section>
536
527
- <!-- ۷. تنظیمات و پشتیبانگیری -->
537
+ <!-- ۷. تنظیمات و بکاپ -->
538
<section id="view-settings" class="view-pane">
539
<div class="card">
530
- <h2 style="font-size: 17px; margin-bottom: 16px;">مشخصات فروشگاه (جهت درج در سربرگ فاکتور)</h2>
540
+ <h2 style="font-size: 18px; margin-bottom: 16px;">مشخصات فروشگاه (سربرگ فاکتور)</h2>
541
<div class="form-row">
542
<div class="form-group">
543
<label>نام فروشگاه / شرکت</label>
@@ -543,24 +553,24 @@
553
</div>
554
</div>
555
<div class="form-group">
546
- <label>نشانی فروشگاه</label>
556
+ <label>نشانی کامل</label>
557
<input type="text" id="set-address-input" class="form-control" />
558
</div>
559
<div class="form-group">
550
- <label>متن پاورقی فاکتور</label>
560
+ <label>پاورقی فاکتور</label>
561
<textarea id="set-footer-text" class="form-control" rows="2"></textarea>
562
</div>
553
- <button class="btn btn-primary" onclick="commitSaveSettings()">ذخیره تنظیمات</button>
563
+ <button class="btn btn-primary" onclick="commitSaveSettings()">ذخیره مشخصات</button>
564
</div>
565
566
<div class="card">
557
- <h3 style="font-size: 15px; margin-bottom: 14px;">پشتیبانگیری و انتقال اطلاعات</h3>
558
- <p style="color:var(--text-muted); font-size:13px; margin-bottom:12px;">
559
- جهت جابهجایی اطلاعات بین گوشی آیفون، اندروید و کامپیوتر میتوانید فایل بکاپ JSON را دانلود و در دستگاه دیگر بازگردانی نمایید.
567
+ <h3 style="font-size: 16px; margin-bottom: 14px;">پشتیبانگیری از اطلاعات</h3>
568
+ <p style="color:var(--text-muted); font-size:14px; margin-bottom:14px;">
569
+ جهت جابهجایی اطلاعات بین گوشی آیفون، اندروید و کامپیوتر میتوانید فایل بکاپ را دانلود کنید.
570
</p>
561
- <div style="display:flex; gap:10px;">
562
- <button class="btn btn-secondary" onclick="exportDataBlob()">📥 دانلود پشتیبان (JSON)</button>
563
- <label class="btn btn-secondary" style="margin-bottom:0;">
571
+ <div style="display:flex; gap:12px; flex-wrap:wrap;">
572
+ <button class="btn btn-secondary btn-inline" onclick="exportDataBlob()">📥 دانلود فایل پشتیبان (JSON)</button>
573
+ <label class="btn btn-secondary btn-inline" style="margin-bottom:0;">
574
📤 بازگردانی فایل پشتیبان
575
<input type="file" id="import-json-file" style="display:none;" onchange="importDataBlob(event)" accept=".json" />
576
</label>
@@ -568,50 +578,50 @@
578
</div>
579
</section>
580
571
- <!-- قالب چاپ فاکتور A4 -->
572
- <div id="printable-invoice" style="display:none; background:#fff; padding:24px; border:1px solid #111; margin-top:20px; border-radius:4px;">
573
- <div style="display:flex; justify-content:space-between; align-items:center; border-bottom:2px solid #111; padding-bottom:12px;">
581
+ <!-- قالب پرینت فاکتور A4 (سازگار با رسمی و غیررسمی) -->
582
+ <div id="printable-invoice" style="display:none; background:#fff; padding:24px; border:1px solid #222; margin-top:20px; border-radius:4px;">
583
+ <div style="display:flex; justify-content:space-between; align-items:center; border-bottom:2px solid #222; padding-bottom:12px;">
584
<div>
575
- <h1 id="p-org-name" style="font-size:18px; margin:0;">فاکتورا</h1>
576
- <p id="p-org-details" style="font-size:11px; color:#444; margin-top:4px;"></p>
585
+ <h1 id="p-org-name" style="font-size:19px; margin:0;">فاکتورا</h1>
586
+ <p id="p-org-details" style="font-size:12px; color:#444; margin-top:4px;"></p>
587
</div>
588
<div style="text-align:left;">
579
- <h2 id="p-doc-kind" style="font-size:16px; margin:0;">صورتحساب فروش</h2>
580
- <p style="font-size:11px; margin-top:4px;">شماره: <span id="p-doc-number"></span></p>
581
- <p style="font-size:11px;">تاریخ: <span id="p-doc-date"></span></p>
589
+ <h2 id="p-doc-kind" style="font-size:17px; margin:0;">صورتحساب فروش کالا و خدمات</h2>
590
+ <p style="font-size:12px; margin-top:4px;">شماره: <span id="p-doc-number"></span></p>
591
+ <p style="font-size:12px;">تاریخ: <span id="p-doc-date"></span></p>
592
</div>
593
</div>
594
585
- <div style="margin:12px 0; font-size:12px; background:#f8fafc; padding:8px; border-radius:4px; border:1px solid #e2e8f0;">
586
- خریدار: <strong id="p-target-name"></strong> | تلفن: <span id="p-target-phone"></span>
595
+ <div style="margin:12px 0; font-size:13px; background:#f8fafc; padding:10px; border-radius:4px; border:1px solid #cbd5e1;">
596
+ خریدار: <strong id="p-target-name"></strong> | همراه: <span id="p-target-phone"></span> | کد پستی: <span id="p-target-postal"></span><br />
597
+ نشانی: <span id="p-target-address"></span>
598
</div>
599
600
<table style="width:100%; border-collapse:collapse; margin:14px 0;">
601
<thead>
602
<tr style="background:#f1f5f9;">
592
- <th style="border:1px solid #ccc; padding:6px; width:40px; text-align:center;">ردیف</th>
593
- <th style="border:1px solid #ccc; padding:6px; text-align:right;">شرح کالا یا خدمت</th>
594
- <th style="border:1px solid #ccc; padding:6px; width:60px; text-align:center;">تعداد</th>
595
- <th style="border:1px solid #ccc; padding:6px; width:120px; text-align:left;">قیمت واحد (تومان)</th>
596
- <th style="border:1px solid #ccc; padding:6px; width:140px; text-align:left;">جمع کل (تومان)</th>
603
+ <th style="border:1px solid #777; padding:8px; width:40px; text-align:center;">ردیف</th>
604
+ <th style="border:1px solid #777; padding:8px; text-align:right;">شرح کالا یا خدمت (به همراه نوع/مشخصه)</th>
605
+ <th style="border:1px solid #777; padding:8px; width:70px; text-align:center;">تعداد</th>
606
+ <th style="border:1px solid #777; padding:8px; width:130px; text-align:left;">قیمت واحد (تومان)</th>
607
+ <th style="border:1px solid #777; padding:8px; width:150px; text-align:left;">جمع کل (تومان)</th>
608
</tr>
609
</thead>
610
<tbody id="p-target-items-table"></tbody>
611
</table>
612
613
<div style="display:flex; justify-content:space-between; margin-top:16px;">
603
- <div style="width:55%; font-size:11px;" id="p-doc-footer-note"></div>
604
- <div style="width:40%; font-size:12px;">
614
+ <div style="width:55%; font-size:12px;" id="p-doc-footer-note"></div>
615
+ <div style="width:40%; font-size:13px;">
616
<table style="width:100%; border-collapse:collapse;">
606
- <tr><td style="padding:4px;">جمع اقلام:</td><td style="padding:4px; text-align:left;"><span id="p-calc-subtotal"></span> تومان</td></tr>
607
- <tr><td style="padding:4px;">تخفیف:</td><td style="padding:4px; text-align:left;"><span id="p-calc-discount"></span> تومان</td></tr>
608
- <tr><td style="padding:4px;">مالیات ارزش افزوده (۱۰٪):</td><td style="padding:4px; text-align:left;"><span id="p-calc-tax"></span> تومان</td></tr>
609
- <tr style="border-top:1px solid #111; font-weight:bold; font-size:13px;">
610
- <td style="padding:6px 4px;">مبلغ نهایی:</td>
611
- <td style="padding:6px 4px; text-align:left;"><span id="p-calc-grandtotal"></span> تومان</td>
617
+ <tr><td style="padding:5px;">جمع اقلام:</td><td style="padding:5px; text-align:left;"><span id="p-calc-subtotal"></span> تومان</td></tr>
618
+ <tr><td style="padding:5px;">تخفیف:</td><td style="padding:5px; text-align:left;"><span id="p-calc-discount"></span> تومان</td></tr>
619
+ <tr id="p-tax-row"><td style="padding:5px;">مالیات ارزش افزوده (۱۰٪):</td><td style="padding:5px; text-align:left;"><span id="p-calc-tax"></span> تومان</td></tr>
620
+ <tr style="border-top:2px solid #222; font-weight:bold; font-size:14px;">
621
+ <td style="padding:8px 5px;">مبلغ نهایی:</td>
622
+ <td style="padding:8px 5px; text-align:left;"><span id="p-calc-grandtotal"></span> تومان</td>
623
</tr>
624
</table>
614
- <p style="font-size:10px; color:#555; margin-top:6px;">به حروف: <span id="p-calc-words"></span></p>
625
</div>
626
</div>
627
</div>
@@ -619,27 +629,27 @@
629
</main>
630
</div>
631
622
- <!-- منوی پایین ویژه آیفون -->
632
+ <!-- منوی لمسی پایین گوشی (بزرگ و راحت) -->
633
<nav class="mobile-dock">
634
<div class="dock-tab active" onclick="switchView('view-dashboard')">
625
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>
635
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>
636
<span>داشبورد</span>
637
</div>
638
<div class="dock-tab" onclick="switchView('view-invoices')">
629
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
639
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
640
<span>فاکتورها</span>
641
</div>
642
<div class="dock-tab" onclick="switchView('view-products')">
633
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
634
- <span>انبار کالا</span>
643
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
644
+ <span>کالاها</span>
645
</div>
646
<div class="dock-tab" onclick="switchView('view-contacts')">
637
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
647
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
648
<span>اشخاص</span>
649
</div>
650
<div class="dock-tab" onclick="switchView('view-cheques')">
641
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"></path></svg>
642
- <span>چک صیاد</span>
651
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"></path></svg>
652
+ <span>چکها</span>
653
</div>
654
</nav>
655
@@ -648,20 +658,18 @@
658
659
let datastore = {
660
settings: {
651
- store_name: 'فروشگاه آوانتک',
661
+ store_name: 'فروشگاه آرا بتن',
662
phone: '09120000000',
663
tax_number: '123456789',
654
- address: 'تهران، خیابان ولیعصر',
655
- footer: 'کالای فروخته شده تا ۲۴ ساعت با ارائه فاکتور تعویض میگردد.'
664
+ address: 'تهران',
665
+ footer: 'از خرید و اعتماد شما سپاسگزاریم.'
666
},
667
contacts: [
658
- { id: 'C-1', name: 'نادر بحری', mobile: '09121111111', national_id: '0012345678', address: 'تهران', balance: 2950000, role: 'customer' },
659
- { id: 'C-2', name: 'شرکت کیبیسی', mobile: '02188888888', national_id: '10102030405', address: 'تهران', balance: -5000000, role: 'supplier' }
668
+ { id: 'C-1', name: 'نادر بحری', mobile: '09121111111', national_id: '0012345678', postal_code: '1234567890', address: 'تهران - بازار آهن', balance: 2950000, role: 'customer' }
669
],
670
products: [
662
- { id: 'P-1', code: '101', name: 'کابل شارژ تایپسی اورجینال', unit: 'عدد', buy_price: 120000, sale_price: 190000, stock: 45, reorder: 10, type: 'good' },
663
- { id: 'P-2', code: '102', name: 'آداپتور ۲۰ وات اصل', unit: 'عدد', buy_price: 750000, sale_price: 1150000, stock: 8, reorder: 5, type: 'good' },
664
- { id: 'P-3', code: '103', name: 'سرویس نرمافزار و سختافزار', unit: 'مورد', buy_price: 0, sale_price: 350000, stock: 999, reorder: 0, type: 'service' }
671
+ { id: 'P-1', code: '101', name: 'بلوک سیمانی ۱۰', spec: 'سبک لیکا', unit: 'قالب', buy_price: 18000, sale_price: 26000, stock: 0, type: 'good' },
672
+ { id: 'P-2', code: '102', name: 'بلوک سیمانی ۱۵', spec: 'سنگین ته پر', unit: 'قالب', buy_price: 22000, sale_price: 32000, stock: 0, type: 'good' }
673
],
674
invoices: [],
675
cheques: [],
@@ -671,7 +679,7 @@
679
function initDatastore() {
680
const persisted = localStorage.getItem(STORAGE_KEY);
681
if (persisted) {
674
- try { datastore = JSON.parse(persisted); } catch(e) { console.error(e); }
682
+ try { datastore = JSON.parse(persisted); } catch(e) { console.error('Parse failure', e); }
683
}
684
persistDatastore();
685
refreshAllSurfaces();
@@ -727,6 +735,17 @@
735
renderSettings();
736
}
737
738
+ function onInvoiceKindChange() {
739
+ const kind = document.getElementById('invoice-kind').value;
740
+ const vatSelect = document.getElementById('invoice-vat-toggle');
741
+ if (kind === 'formal') {
742
+ vatSelect.value = '1';
743
+ } else {
744
+ vatSelect.value = '0';
745
+ }
746
+ recomputeTotals();
747
+ }
748
+
749
function renderDashboard() {
750
let salesSum = 0;
751
let debtorsSum = 0;
@@ -743,7 +762,7 @@
762
763
const recentTbody = document.getElementById('dashboard-recent-table');
764
if (datastore.invoices.length === 0) {
746
- recentTbody.innerHTML = '<tr><td colspan="6" style="text-align:center; color:var(--text-muted);">سندی ثبت نشده است.</td></tr>';
765
+ recentTbody.innerHTML = '<tr><td colspan="6" style="text-align:center; color:var(--text-muted); padding:20px;">هنوز فاکتوری ثبت نشده است.</td></tr>';
766
return;
767
}
768
@@ -751,10 +770,10 @@
770
<tr>
771
<td><strong>#${inv.number}</strong></td>
772
<td>${inv.contactName}</td>
754
- <td>${inv.date}</td>
773
+ <td>${inv.kindLabel}</td>
774
<td>${inv.grandTotal.toLocaleString('fa-IR')}</td>
775
<td>${inv.paymentMethodLabel}</td>
757
- <td><span class="badge badge-success">ثبت شده</span></td>
776
+ <td><button class="btn btn-secondary btn-inline" style="padding:4px 10px; font-size:12px;" onclick="renderAndPrintDirect('${inv.id}')">🖨️ چاپ</button></td>
777
</tr>
778
`).join('');
779
}
@@ -766,20 +785,20 @@
785
tr.id = rowKey;
786
787
const productOptions = datastore.products.map(p =>
769
- `<option value="${p.id}" data-price="${p.sale_price}">${p.name} (${p.unit}) - موجودی: ${p.stock}</option>`
788
+ `<option value="${p.id}" data-price="${p.sale_price}">${p.name} ${p.spec ? '(' + p.spec + ')' : ''} [${p.unit}]</option>`
789
).join('');
790
791
tr.innerHTML = `
792
<td>
793
<select class="form-control row-product-select" onchange="onRowProductChange('${rowKey}')">
775
- <option value="">-- انتخاب کالا / خدمات --</option>
794
+ <option value="">-- انتخاب کالا / خدمت --</option>
795
${productOptions}
796
</select>
797
</td>
798
<td><input type="number" class="form-control row-quantity" value="1" min="1" oninput="recomputeTotals()" /></td>
799
<td><input type="number" class="form-control row-price" value="0" oninput="recomputeTotals()" /></td>
781
- <td class="row-linetotal" style="font-weight:bold; padding-top:18px;">۰</td>
782
- <td><button class="btn btn-danger" style="padding:4px 8px; font-size:12px;" onclick="document.getElementById('${rowKey}').remove(); recomputeTotals();">✕</button></td>
800
+ <td class="row-linetotal" style="font-weight:bold; padding-top:16px;">۰</td>
801
+ <td><button class="btn btn-danger" style="min-height:40px; padding:4px 10px;" onclick="document.getElementById('${rowKey}').remove(); recomputeTotals();">✕</button></td>
802
`;
803
tbody.appendChild(tr);
804
}
@@ -818,13 +837,12 @@
837
const contactSelect = document.getElementById('invoice-contact-id');
838
const contactId = contactSelect.value;
839
const contactName = contactSelect.options[contactSelect.selectedIndex]?.text || 'مشتری آزاد';
821
- const number = document.getElementById('invoice-number').value || ('INV-' + (datastore.invoices.length + 1084));
840
+ const number = document.getElementById('invoice-number').value || ('INV-' + (datastore.invoices.length + 1085));
841
const date = document.getElementById('invoice-date-input').value;
842
const kind = document.getElementById('invoice-kind').value;
843
const paymentMethod = document.getElementById('invoice-payment-method').value;
844
845
const items = [];
827
- let stockValidationFailed = false;
846
847
document.querySelectorAll('#invoice-items-table-body tr').forEach(tr => {
848
const sel = tr.querySelector('.row-product-select');
@@ -834,41 +852,25 @@
852
const price = parseFloat(tr.querySelector('.row-price').value) || 0;
853
854
if (prodId && qty > 0) {
837
- const product = datastore.products.find(p => p.id === prodId);
838
- if (product && product.type === 'good') {
839
- if (product.stock < qty && kind === 'sale') {
840
- alert(`موجودی کالای "${product.name}" کافی نیست. موجودی: ${product.stock}`);
841
- stockValidationFailed = true;
842
- return;
843
- }
844
- }
855
items.push({ prodId, prodName, qty, price, lineTotal: qty * price });
856
}
857
});
858
849
- if (stockValidationFailed) return;
859
if (items.length === 0) {
851
- alert('افزودن حداقل یک ردیف کالا یا خدمات اجباری است.');
860
+ alert('لطفاً حداقل یک کالا یا خدمت را به جدول فاکتور اضافه کنید.');
861
return;
862
}
863
864
const totals = recomputeTotals();
865
const methodLabels = { cash: 'نقدی', credit: 'نسیه', cheque: 'چک صیاد', installment: 'اقساطی' };
857
-
858
- if (kind === 'sale') {
859
- items.forEach(it => {
860
- const product = datastore.products.find(p => p.id === it.prodId);
861
- if (product && product.type === 'good') {
862
- product.stock -= it.qty;
863
- }
864
- });
865
- }
866
+ const kindLabels = { formal: 'رسمی', non_formal: 'غیررسمی', pre_invoice: 'پیشفاکتور', receipt: 'رسید' };
867
868
const record = {
869
id: 'INV_' + Date.now(),
870
number,
871
date,
872
kind,
873
+ kindLabel: kindLabels[kind],
874
contactId,
875
contactName,
876
paymentMethod,
@@ -882,16 +884,17 @@
884
885
datastore.invoices.push(record);
886
persistDatastore();
885
- alert('فاکتور با موفقیت در سیستم ذخیره و موجودی انبار کسر شد.');
887
+ alert('فاکتور با موفقیت صادر و ثبت شد.');
888
document.getElementById('invoice-items-table-body').innerHTML = '';
889
addInvoiceItemRow();
890
refreshAllSurfaces();
891
+ renderAndPrintDirect(record.id);
892
}
893
894
function renderInvoices() {
895
const tbody = document.getElementById('invoice-archive-table-body');
896
if (datastore.invoices.length === 0) {
894
- tbody.innerHTML = '<tr><td colspan="6" style="text-align:center; color:var(--text-muted);">سابقهای موجود نیست.</td></tr>';
897
+ tbody.innerHTML = '<tr><td colspan="7" style="text-align:center; color:var(--text-muted); padding:20px;">هیچ فاکتوری ذخیره نشده است.</td></tr>';
898
return;
899
}
900
@@ -899,11 +902,12 @@
902
<tr>
903
<td><strong>#${inv.number}</strong></td>
904
<td>${inv.contactName}</td>
905
+ <td><span class="badge ${inv.kind === 'formal' ? 'badge-danger' : 'badge-success'}">${inv.kindLabel}</span></td>
906
<td>${inv.date}</td>
907
<td>${inv.grandTotal.toLocaleString('fa-IR')}</td>
908
<td>${inv.paymentMethodLabel}</td>
909
<td>
906
- <button class="btn btn-secondary" style="padding:4px 8px; font-size:12px;" onclick="renderAndPrintDirect('${inv.id}')">🖨️ چاپ</button>
910
+ <button class="btn btn-secondary btn-inline" style="padding:4px 10px; font-size:12px;" onclick="renderAndPrintDirect('${inv.id}')">🖨️ چاپ / PDF</button>
911
</td>
912
</tr>
913
`).join('');
@@ -913,76 +917,88 @@
917
const inv = datastore.invoices.find(i => i.id === invId);
918
if (!inv) return;
919
920
+ const contact = datastore.contacts.find(c => c.id === inv.contactId) || {};
921
+
922
document.getElementById('p-org-name').innerText = datastore.settings.store_name;
917
- document.getElementById('p-org-details').innerText = `شماره تماس: ${datastore.settings.phone} | نشانی: ${datastore.settings.address}`;
923
+ document.getElementById('p-org-details').innerText = `تلفن: ${datastore.settings.phone} | کد اقتصادی: ${datastore.settings.tax_number || '—'} | نشانی: ${datastore.settings.address}`;
924
+ document.getElementById('p-doc-kind').innerText = inv.kind === 'formal' ? 'صورتحساب رسمی فروش کالا و خدمات' : (inv.kind === 'pre_invoice' ? 'پیشفاکتور' : 'فاکتور فروش');
925
document.getElementById('p-doc-number').innerText = inv.number;
926
document.getElementById('p-doc-date').innerText = inv.date;
927
document.getElementById('p-target-name').innerText = inv.contactName;
928
+ document.getElementById('p-target-phone').innerText = contact.mobile || '—';
929
+ document.getElementById('p-target-postal').innerText = contact.postal_code || '—';
930
+ document.getElementById('p-target-address').innerText = contact.address || '—';
931
document.getElementById('p-doc-footer-note').innerText = datastore.settings.footer;
932
933
document.getElementById('p-target-items-table').innerHTML = inv.items.map((it, idx) => `
934
<tr>
925
- <td style="border:1px solid #ccc; padding:6px; text-align:center;">${idx + 1}</td>
926
- <td style="border:1px solid #ccc; padding:6px; text-align:right;">${it.prodName}</td>
927
- <td style="border:1px solid #ccc; padding:6px; text-align:center;">${it.qty}</td>
928
- <td style="border:1px solid #ccc; padding:6px; text-align:left;">${it.price.toLocaleString('fa-IR')}</td>
929
- <td style="border:1px solid #ccc; padding:6px; text-align:left;">${it.lineTotal.toLocaleString('fa-IR')}</td>
935
+ <td style="border:1px solid #777; padding:8px; text-align:center;">${idx + 1}</td>
936
+ <td style="border:1px solid #777; padding:8px; text-align:right;">${it.prodName}</td>
937
+ <td style="border:1px solid #777; padding:8px; text-align:center;">${it.qty}</td>
938
+ <td style="border:1px solid #777; padding:8px; text-align:left;">${it.price.toLocaleString('fa-IR')}</td>
939
+ <td style="border:1px solid #777; padding:8px; text-align:left;">${it.lineTotal.toLocaleString('fa-IR')}</td>
940
</tr>
941
`).join('');
942
943
document.getElementById('p-calc-subtotal').innerText = inv.subtotal.toLocaleString('fa-IR');
944
document.getElementById('p-calc-discount').innerText = inv.discount.toLocaleString('fa-IR');
935
- document.getElementById('p-calc-tax').innerText = inv.vat.toLocaleString('fa-IR');
945
+
946
+ const taxRow = document.getElementById('p-tax-row');
947
+ if (inv.vat > 0) {
948
+ taxRow.style.display = 'table-row';
949
+ document.getElementById('p-calc-tax').innerText = inv.vat.toLocaleString('fa-IR');
950
+ } else {
951
+ taxRow.style.display = 'none';
952
+ }
953
+
954
document.getElementById('p-calc-grandtotal').innerText = inv.grandTotal.toLocaleString('fa-IR');
937
- document.getElementById('p-calc-words').innerText = inv.grandTotal.toLocaleString('fa-IR') + ' تومان';
955
956
document.getElementById('printable-invoice').style.display = 'block';
957
window.print();
958
document.getElementById('printable-invoice').style.display = 'none';
959
}
960
944
- function printActiveInvoice() {
945
- alert('جهت چاپ و خروجی PDF، لطفاً ابتدا فاکتور را ثبت کنید.');
946
- }
947
-
961
function commitSaveProduct() {
962
const code = document.getElementById('prod-code-input').value || (datastore.products.length + 101).toString();
963
const name = document.getElementById('prod-name-input').value;
964
+ const spec = document.getElementById('prod-spec-input').value || '';
965
const type = document.getElementById('prod-type-input').value;
966
const unit = document.getElementById('prod-unit-input').value || 'عدد';
967
const buy_price = parseFloat(document.getElementById('prod-buy-input').value) || 0;
968
const sale_price = parseFloat(document.getElementById('prod-sale-input').value) || 0;
969
const stock = parseFloat(document.getElementById('prod-stock-input').value) || 0;
956
- const reorder = parseFloat(document.getElementById('prod-reorder-input').value) || 0;
970
958
- if (!name) { alert('وارد کردن عنوان کالا الزامی است.'); return; }
971
+ if (!name) { alert('عنوان کالا یا خدمت الزامی است.'); return; }
972
960
- datastore.products.push({ id: 'P_' + Date.now(), code, name, type, unit, buy_price, sale_price, stock, reorder });
973
+ datastore.products.push({ id: 'P_' + Date.now(), code, name, spec, type, unit, buy_price, sale_price, stock });
974
persistDatastore();
962
- alert('کالا با موفقیت ذخیره شد.');
975
+ alert('کالا / خدمت جدید با موفقیت ثبت شد.');
976
document.getElementById('prod-name-input').value = '';
977
+ document.getElementById('prod-spec-input').value = '';
978
refreshAllSurfaces();
979
}
980
981
function renderProducts() {
982
const tbody = document.getElementById('products-catalog-table-body');
969
- tbody.innerHTML = datastore.products.map(p => {
970
- let badge = '<span class="badge badge-success">کافی</span>';
971
- if (p.type === 'good' && p.stock <= p.reorder) {
972
- badge = '<span class="badge badge-danger">کمبود موجودی</span>';
973
- }
974
- return `
975
- <tr>
976
- <td>${p.code}</td>
977
- <td><strong>${p.name}</strong></td>
978
- <td>${p.unit}</td>
979
- <td>${p.buy_price.toLocaleString('fa-IR')}</td>
980
- <td>${p.sale_price.toLocaleString('fa-IR')}</td>
981
- <td>${p.type === 'good' ? p.stock.toLocaleString('fa-IR') : 'نامحدود'}</td>
982
- <td>${p.type === 'good' ? badge : '<span class="badge">خدمات</span>'}</td>
983
- </tr>
984
- `;
985
- }).join('');
983
+ tbody.innerHTML = datastore.products.map(p => `
984
+ <tr>
985
+ <td>${p.code}</td>
986
+ <td><strong>${p.name}</strong></td>
987
+ <td>${p.spec || '—'}</td>
988
+ <td>${p.unit}</td>
989
+ <td>${p.sale_price.toLocaleString('fa-IR')}</td>
990
+ <td>${p.type === 'good' ? p.stock.toLocaleString('fa-IR') : 'خدمات'}</td>
991
+ <td><button class="btn btn-danger btn-inline" style="padding:4px 10px; font-size:12px; min-height:34px;" onclick="deleteProduct('${p.id}')">حذف</button></td>
992
+ </tr>
993
+ `).join('');
994
+ }
995
+
996
+ function deleteProduct(id) {
997
+ if (confirm('آیا از حذف این ردیف مطمئن هستید؟')) {
998
+ datastore.products = datastore.products.filter(p => p.id !== id);
999
+ persistDatastore();
1000
+ refreshAllSurfaces();
1001
+ }
1002
}
1003
1004
function commitSaveContact() {
@@ -990,14 +1006,17 @@
1006
const role = document.getElementById('contact-role-input').value;
1007
const mobile = document.getElementById('contact-mobile-input').value;
1008
const national_id = document.getElementById('contact-national-input').value;
1009
+ const postal_code = document.getElementById('contact-postal-input').value;
1010
const address = document.getElementById('contact-address-input').value;
1011
995
- if (!name) { alert('ورود نام طرف حساب الزامی است.'); return; }
1012
+ if (!name) { alert('نام شخص یا شرکت الزامی است.'); return; }
1013
997
- datastore.contacts.push({ id: 'C_' + Date.now(), name, role, mobile, national_id, address, balance: 0 });
1014
+ datastore.contacts.push({ id: 'C_' + Date.now(), name, role, mobile, national_id, postal_code, address, balance: 0 });
1015
persistDatastore();
1016
alert('طرف حساب با موفقیت ثبت شد.');
1017
document.getElementById('contact-name-input').value = '';
1018
+ document.getElementById('contact-postal-input').value = '';
1019
+ document.getElementById('contact-address-input').value = '';
1020
refreshAllSurfaces();
1021
}
1022
@@ -1011,6 +1030,7 @@
1030
<td><strong>${c.name}</strong></td>
1031
<td>${c.role === 'customer' ? 'مشتری' : (c.role === 'supplier' ? 'تامینکننده' : 'دوگانه')}</td>
1032
<td>${c.mobile || '—'}</td>
1033
+ <td>${c.postal_code || '—'}</td>
1034
<td>${Math.abs(c.balance || 0).toLocaleString('fa-IR')}</td>
1035
<td>${c.balance > 0 ? '<span class="badge badge-warning">بدهکار</span>' : (c.balance < 0 ? '<span class="badge badge-success">بستانکار</span>' : '<span class="badge">تسویه</span>')}</td>
1036
</tr>
@@ -1038,14 +1058,14 @@
1058
1059
datastore.cheques.push({ id: 'CHQ_' + Date.now(), direction, contactName, sayad_id, bank, amount, due_date, status });
1060
persistDatastore();
1041
- alert('چک صیاد با موفقیت ذخیره شد.');
1061
+ alert('چک با موفقیت ذخیره شد.');
1062
refreshAllSurfaces();
1063
}
1064
1065
function renderCheques() {
1066
const tbody = document.getElementById('cheques-ledger-table-body');
1067
if (datastore.cheques.length === 0) {
1048
- tbody.innerHTML = '<tr><td colspan="6" style="text-align:center; color:var(--text-muted);">چک صیادی ثبت نشده است.</td></tr>';
1068
+ tbody.innerHTML = '<tr><td colspan="6" style="text-align:center; color:var(--text-muted); padding:20px;">چکی ثبت نشده است.</td></tr>';
1069
return;
1070
}
1071
@@ -1071,14 +1091,14 @@
1091
1092
datastore.expenses.push({ id: 'TRX_' + Date.now(), kind, category, amount, desc });
1093
persistDatastore();
1074
- alert('سند با موفقیت ذخیره شد.');
1094
+ alert('سند با موفقیت ذخیره گردید.');
1095
refreshAllSurfaces();
1096
}
1097
1098
function renderExpenses() {
1099
const tbody = document.getElementById('expenses-ledger-table-body');
1100
if (datastore.expenses.length === 0) {
1081
- tbody.innerHTML = '<tr><td colspan="4" style="text-align:center; color:var(--text-muted);">سندی ثبت نشده است.</td></tr>';
1101
+ tbody.innerHTML = '<tr><td colspan="4" style="text-align:center; color:var(--text-muted); padding:20px;">موردی ثبت نشده است.</td></tr>';
1102
return;
1103
}
1104
@@ -1099,7 +1119,7 @@
1119
datastore.settings.address = document.getElementById('set-address-input').value;
1120
datastore.settings.footer = document.getElementById('set-footer-text').value;
1121
persistDatastore();
1102
- alert('مشخصات با موفقیت ذخیره شد.');
1122
+ alert('مشخصات با موفقیت بهروزرسانی شد.');
1123
}
1124
1125
function renderSettings() {
@@ -1131,7 +1151,7 @@
1151
refreshAllSurfaces();
1152
alert('اطلاعات با موفقیت بازگردانی شد.');
1153
} catch(err) {
1134
- alert('فرمت فایل پشتیبان معتبر نیست.');
1154
+ alert('فایل پشتیبان نامعتبر است.');
1155
}
1156
};
1157
reader.readAsText(file);