Initial commit: Product Slip Manager

This commit is contained in:
2026-09-30 14:17:30 +03:30
commit 0af10dde9d
35 changed files with 2341 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
const translations = {
'en': {
'app_title': 'Product Slip Manager',
'data_entry': 'Data Entry',
'print_queue': 'Print Queue',
'calibrate': 'Calibrate',
'new_order': 'New Order',
'product': 'Product',
'add_product': '+ Add New Product',
'product_code': 'Product Code',
'description': 'Description',
'default_weight': 'Default Weight',
'save': 'Save',
'cancel': 'Cancel',
'batch_number': 'Batch #',
'date': 'Date',
'next_control': 'Next Control Date',
'net_weight': 'Net Weight (kg)',
'total_weight': 'Total Weight (kg)',
'canister_weight': 'Canister Weight (kg)',
'canisters_per_box': 'Canisters per Box',
'labels_preview': 'Labels Generated',
'canisters': 'Canisters',
'boxes': 'Boxes',
'pages_needed': 'Pages Needed',
'total_pages': 'Pages',
'add_to_queue': 'Add to Print Queue',
'recent_orders': 'Recent Orders',
'status': 'Status',
'no_orders': 'No orders yet',
'no_pending_orders': 'No pending orders to print.',
'print': 'Print',
'mark_done': 'Mark Done',
'print_history': 'Print History',
'printed_at': 'Printed At',
'no_history': 'No print history'
},
'fa': {
'app_title': 'مدیریت برچسب محصول',
'data_entry': 'ثبت اطلاعات',
'print_queue': 'صف چاپ',
'calibrate': 'کالیبراسیون',
'new_order': 'سفارش جدید',
'product': 'محصول',
'add_product': '+ افزودن محصول جدید',
'product_code': 'کد محصول',
'description': 'شرح',
'default_weight': 'وزن پیش‌فرض',
'save': 'ذخیره',
'cancel': 'لغو',
'batch_number': 'شماره بچ',
'date': 'تاریخ',
'next_control': 'تاریخ کنترل بعدی',
'net_weight': 'وزن خالص (کیلوگرم)',
'total_weight': 'وزن کل (کیلوگرم)',
'canister_weight': 'وزن قوطی (کیلوگرم)',
'canisters_per_box': 'تعداد قوطی در هر کارتن',
'labels_preview': 'برچسب‌های تولیدی',
'canisters': 'تعداد قوطی',
'boxes': 'تعداد کارتن',
'pages_needed': 'تعداد صفحات',
'total_pages': 'صفحات',
'add_to_queue': 'افزودن به صف چاپ',
'recent_orders': 'سفارشات اخیر',
'status': 'وضعیت',
'no_orders': 'سفارشی ثبت نشده',
'no_pending_orders': 'سفارشی در انتظار چاپ نیست.',
'print': 'چاپ',
'mark_done': 'تایید چاپ',
'print_history': 'سابقه چاپ',
'printed_at': 'زمان چاپ',
'no_history': 'سابقه‌ای وجود ندارد'
}
};
let currentLang = localStorage.getItem('slip_lang') || 'en';
function applyLanguage(lang) {
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
if (translations[lang][key]) {
el.textContent = translations[lang][key];
}
});
const toggleBtn = document.getElementById('lang-label');
if (toggleBtn) {
toggleBtn.textContent = lang === 'en' ? '🇮🇷 FA' : '🇬🇧 EN';
}
// User requested Persian to be LTR, so we don't change the dir attribute
// document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
}
function toggleLanguage() {
currentLang = currentLang === 'en' ? 'fa' : 'en';
localStorage.setItem('slip_lang', currentLang);
applyLanguage(currentLang);
}
// Common Toast notification
function showToast(message, isError = false) {
const toast = document.getElementById('toast');
if (!toast) return;
toast.textContent = message;
if (isError) {
toast.classList.add('error');
} else {
toast.classList.remove('error');
}
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 3000);
}
// Initialize on load
document.addEventListener('DOMContentLoaded', () => {
applyLanguage(currentLang);
});