سامانه صدور فاکتور و حسابداری
Bound restore preview file size
davoodmehraban89 committed
Sep 29, 2026 at 22:35 UTC
814ac6394e015819378f01c882b759ae3233187f
1 file changed
+1
-1
js/phase5-enterprise.js
+1
-1
@@ -90,7 +90,7 @@ function p5SaveCompanyOpsSettings(){const cid=p5Need();if(!cid)return;const s=ge
90
function p5BackupPayload(){const o={formatVersion:5,user:currentUser?.username,exportedAt:new Date().toISOString()};COLLS.forEach(k=>o[k]=(datastore[k]||[]).filter(x=>x.ownerUserId===currentUser?.id).map(x=>{const y={...x};delete y.ownerUserId;return y}));return o}
91
function p5ExportBackup(){const blob=new Blob([JSON.stringify(p5BackupPayload(),null,2)],{type:'application/json'}),a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download='finora-full-backup-'+Date.now()+'.json';a.click();setTimeout(()=>URL.revokeObjectURL(a.href),500)}
92
function p5PreviewRestore(event){
93
- const file=event.target.files[0];if(!file)return;const r=new FileReader();r.onload=()=>{try{const p=JSON.parse(r.result);P5Domain.validateRestore(p,COLLS);const counts=COLLS.filter(k=>Array.isArray(p[k])&&p[k].length).map(k=>k+': '+p[k].length);window.p5PendingRestore=p;document.getElementById('p5-import-preview').innerHTML='پیشنمایش معتبر — '+esc(counts.join(' | '))+' <button class="btn btn-danger btn-inline" onclick="p5ApplyRestore()">اعمال ادغام امن</button>';datastore.importBatches.push({id:p5Id('IMP'),ownerUserId:currentUser.id,companyId:afCompanyId(),fileName:file.name,mode:'preview',counts:Object.fromEntries(COLLS.map(k=>[k,(p[k]||[]).length])),status:'validated',createdAt:new Date().toISOString()});saveDatastore()}catch(e){document.getElementById('p5-import-preview').textContent='نامعتبر: '+e.message}};r.readAsText(file)
93
+ const file=event.target.files[0];if(!file)return;if(file.size>20*1024*1024){event.target.value='';return document.getElementById('p5-import-preview').textContent='نامعتبر: حجم فایل پشتیبان نباید بیشتر از ۲۰ مگابایت باشد.'}const r=new FileReader();r.onload=()=>{try{const p=JSON.parse(r.result);P5Domain.validateRestore(p,COLLS);const counts=COLLS.filter(k=>Array.isArray(p[k])&&p[k].length).map(k=>k+': '+p[k].length);window.p5PendingRestore=p;document.getElementById('p5-import-preview').innerHTML='پیشنمایش معتبر — '+esc(counts.join(' | '))+' <button class="btn btn-danger btn-inline" onclick="p5ApplyRestore()">اعمال ادغام امن</button>';datastore.importBatches.push({id:p5Id('IMP'),ownerUserId:currentUser.id,companyId:afCompanyId(),fileName:file.name,mode:'preview',counts:Object.fromEntries(COLLS.map(k=>[k,(p[k]||[]).length])),status:'validated',createdAt:new Date().toISOString()});saveDatastore()}catch(e){document.getElementById('p5-import-preview').textContent='نامعتبر: '+e.message}};r.readAsText(file)
94
}
95
function p5ApplyRestore(){
96
const p=window.p5PendingRestore;if(!p||!currentUser||!requireWrite())return;if(!confirm('فایل اعتبارسنجی شده با دادههای حساب شما ادغام شود؟ سابقه قطعی موجود بازنویسی نمیشود.'))return;