مشتریان

صدور فاکتور فروش

اقلام فاکتور

جمع اقلام۰
بدهی قبلی۰
مانده با این فاکتور۰

۵ فاکتور آخر

فهرست تمام فاکتورهای فروش

صدور پیش‌فاکتور

اقلام پیش‌فاکتور

جمع پیش‌فاکتور۰

۵ پیش‌فاکتور آخر

فهرست تمام پیش‌فاکتورها

ثبت کار جدید

این فرم «فاکتور رسمی» نیست. پس از تکمیل، برای مدیر ارسال می‌شود و فقط پس از تأیید مدیر به فاکتور اصلی تبدیل خواهد شد.

اقلام / خدمات

مجموع۰

لیست کارهای انجام‌شده

صورتحساب کارمند

گردش حساب مربوط به کارمند واردشده؛ شامل دستمزد کارهای تأییدشده و پرداخت‌های ثبت‌شده.

درخواست‌های منتظر تأیید

مدیر می‌تواند تمام اطلاعات، شماره فاکتور و ردیف‌های کالا/خدمات را ویرایش کند و سپس تأیید نهایی را انجام دهد.

لیست مشتریان

ثبت مشتری جدید

۵ مشتری آخر ثبت‌شده

ثبت تأمین‌کننده / ارائه‌دهنده خدمات

صورت‌حساب تأمین‌کنندگان

ثبت دریافت یا پرداخت وجه

تراکنش‌های ثبت‌شده

تقویم سررسیدها

صورت حساب اشخاص

فاکتورها، خریدها و دریافت/پرداخت‌های شخص انتخاب‌شده به ترتیب تاریخ نمایش داده می‌شود.

یک شخص را انتخاب کنید.

بدهکاران

فقط اشخاصی که مانده بدهی دارند نمایش داده می‌شوند. با ثبت فاکتور فروش یا رسید دریافت، این فهرست به‌صورت خودکار به‌روز می‌شود.

ثبت کالا و خدمات

فهرست و تاریخچه قیمت

کاربران و سطح دسترسی

این صفحه در نسخه اولیه نمایشی است. تنظیمات در اینجا برای طراحی پنل است؛ اعمال امنیت واقعی نیازمند نسخه سروری با ورود کاربران و کنترل دسترسی سمت سرور است.

دسترسی به بخش‌ها

اطلاعات فروشگاه در سربرگ چاپ

تنظیمات قالب چاپ صورت‌حساب

این بخش عیناً مانند قالب چاپ فاکتور است؛ فیلدها، خطوط، لوگو و امضا با همان روش تنظیم می‌شوند.

الف) صورت‌حساب A4

ب) صورت‌حساب A5

تنظیمات چاپ

متغیرهای عمومی

`);win.document.close()}; function addInvoiceActions(id,type,records){let box=$(id);if(!box)return;let th=box.querySelector('thead tr');if(th&&!th.querySelector('.v3-action')){let h=document.createElement('th');h.className='v3-action';h.textContent='عملیات';th.appendChild(h)}box.querySelectorAll('tbody tr').forEach((tr,i)=>{if(tr.querySelector('.v3-action-cell'))return;let r=records[i];if(!r)return;let td=document.createElement('td');td.className='v3-action-cell';td.innerHTML=` `;tr.appendChild(td)})} // Registered party selection on payments; no free-text unknown party allowed. $('payParty').setAttribute('list','payPartyList');let partyList=document.createElement('datalist');partyList.id='payPartyList';$('payParty').parentElement.appendChild(partyList);function fillParty(){let dir=$('payDirection').value,arr=dir==='receive'?db.customers:dir==='pay_employee'?db.users:db.suppliers;partyList.innerHTML=arr.map(p=>``).join('');$('payParty').placeholder=dir==='receive'?'انتخاب مشتری ثبت‌شده':dir==='pay_employee'?'انتخاب کارمند ثبت‌شده':'انتخاب تأمین‌کننده ثبت‌شده'};$('payDirection').addEventListener('change',fillParty);fillParty();const paymentOriginal=window.savePayment;window.savePayment=function(){let dir=$('payDirection').value,party=$('payParty').value.trim(),arr=dir==='receive'?db.customers:dir==='pay_employee'?db.users:db.suppliers;if(!arr.some(p=>String(p.name||'').trim()===party)){alert(dir==='receive'?'مشتری ابتدا ثبت شود.':dir==='pay_employee'?'کارمند ابتدا ثبت شود.':'تأمین‌کننده ابتدا ثبت شود.');return}paymentOriginal()}; // Password field and user edit/delete. let userForm=$('userLogin').closest('.formgrid');let pass=document.createElement('div');pass.className='field';pass.innerHTML='';userForm.appendChild(pass);const renderUsers=window.renderAll;window.editUser=id=>{let u=db.users.find(x=>x.id===id);if(!u)return;$('userName').value=u.name;$('userRole').value=u.role;$('userLogin').value=u.login;$('userPassword').value=u.password||'';document.querySelectorAll('#permissionChecks input').forEach(c=>c.checked=(u.permissions||[]).includes(c.value));let b=$('userName').closest('.panel').querySelector('button');b.textContent='ذخیره ویرایش';b.onclick=()=>{u.name=$('userName').value.trim();u.role=$('userRole').value;u.login=$('userLogin').value.trim();u.password=$('userPassword').value;u.permissions=[...document.querySelectorAll('#permissionChecks input:checked')].map(x=>x.value);b.textContent='ذخیره کاربر نمایشی';b.onclick=window.saveUser;['userName','userLogin','userPassword'].forEach(k=>$(k).value='');persist()}};window.deleteUser=id=>{if(confirm('کاربر حذف شود؟')){db.users=db.users.filter(x=>x.id!==id);persist()}};window.saveUser=function(){if(!$('userName').value.trim()||!$('userLogin').value.trim()||!$('userPassword').value){alert('نام، نام کاربری و رمز عبور الزامی است.');return}db.users.push({id:Date.now(),name:$('userName').value.trim(),role:$('userRole').value,login:$('userLogin').value.trim(),password:$('userPassword').value,permissions:[...document.querySelectorAll('#permissionChecks input:checked')].map(x=>x.value)});['userName','userLogin','userPassword'].forEach(k=>$(k).value='');persist()}; // Separate A4/A5 invoice template canvases with image uploads. let settingsPanel=$('settings').querySelector('.panel'); let imageSettings=document.createElement('div');imageSettings.className='panel';imageSettings.innerHTML='
'; let design=document.createElement('div');design.className='panel'; design.innerHTML='

تنظیمات قالب چاپ فاکتور

الف) فاکتور A4

ب) فاکتور A5

'; settingsPanel.appendChild(imageSettings);settingsPanel.appendChild(design); const canvasA4=$('templateCanvas'),canvasA5=$('templateCanvasA5'); const defaultTemplate=[{id:'brand',text:'نام فروشگاه',left:8,top:4},{id:'title',text:'عنوان فاکتور',left:42,top:12},{id:'meta',text:'شماره و تاریخ',left:8,top:22},{id:'party',text:'طرف حساب',left:8,top:30},{id:'items',text:'جدول اقلام',left:8,top:42},{id:'sum',text:'جمع کل',left:60,top:78},{id:'footer',text:'پایین فاکتور',left:8,top:90}]; const getTemplate=(size)=>db.settings[size==='A5'?'printLayoutA5':'printLayoutA4']||db.settings.printLayout||defaultTemplate; function dragTemplate(el,canvas){el.addEventListener('pointerdown',e=>{if(e.target.classList.contains('resize-handle'))return;let sx=e.clientX,sy=e.clientY,ox=parseFloat(el.style.left)||0,oy=parseFloat(el.style.top)||0,rect=canvas.getBoundingClientRect();const mv=ev=>{el.style.left=Math.max(0,Math.min(96,ox+(ev.clientX-sx)/rect.width*100))+'%';el.style.top=Math.max(0,Math.min(96,oy+(ev.clientY-sy)/rect.height*100))+'%'};const up=()=>{document.removeEventListener('pointermove',mv);document.removeEventListener('pointerup',up)};document.addEventListener('pointermove',mv);document.addEventListener('pointerup',up)});} function buildTemplate(canvas,size){canvas.innerHTML='';let safe=document.createElement('div');safe.className='print-safe-margin';canvas.appendChild(safe);const addImage=(src,cls,pos)=>{if(!src)return;let img=document.createElement('img');img.src=src;img.className='print-element '+cls;img.style.left=(pos?.left??(cls==='print-logo'?40:60))+'%';img.style.top=(pos?.top??2)+'%';img.style.maxWidth='22%';img.style.maxHeight='12%';img.style.objectFit='contain';img.style.cursor='move';canvas.appendChild(img);dragTemplate(img,canvas)}; addImage(db.settings.printLogo,'print-logo',db.settings.logoPositionBySize?.[size]||db.settings.logoPosition);addImage(db.settings.signatureImage,'print-signature',db.settings.signaturePositionBySize?.[size]||db.settings.signaturePosition); getTemplate(size).forEach(x=>{let el=document.createElement('div');el.className='print-element';el.textContent=x.text;el.contentEditable='true';el.dataset.id=x.id;el.style.left=(x.left||0)+'%';el.style.top=(x.top||0)+'%';if(x.widthPct)el.style.width=x.widthPct+'%';if(x.heightPct)el.style.height=x.heightPct+'%';if(x.fontSize)el.style.fontSize=x.fontSize;if(x.color)el.style.color=x.color;if(x.fontFamily)el.style.fontFamily=x.fontFamily;canvas.appendChild(el);dragTemplate(el,canvas)}); } buildTemplate(canvasA4,'A4');buildTemplate(canvasA5,'A5'); function uploadTemplateImage(inputId,setting){$(inputId).onchange=e=>{let f=e.target.files?.[0];if(!f)return;let rd=new FileReader();rd.onload=()=>{db.settings[setting]=rd.result;persist();buildTemplate(canvasA4,'A4');buildTemplate(canvasA5,'A5')};rd.readAsDataURL(f)}}; uploadTemplateImage('logoUpload','printLogo');uploadTemplateImage('signatureUpload','signatureImage'); function saveTemplate(canvas,size){let key=size==='A4'?'printLayoutA4':'printLayoutA5';db.settings[key]=[...canvas.querySelectorAll('.print-element:not(.print-logo):not(.print-signature)')].map(e=>({id:e.dataset.id,text:e.textContent,left:parseFloat(e.style.left)||0,top:parseFloat(e.style.top)||0,widthPct:e.style.width?e.getBoundingClientRect().width/canvas.getBoundingClientRect().width*100:0,heightPct:e.style.height?e.getBoundingClientRect().height/canvas.getBoundingClientRect().height*100:0,fontSize:e.style.fontSize||'',color:e.style.color||'',fontFamily:e.style.fontFamily||''}));let lp=canvas.querySelector('.print-logo'),sp=canvas.querySelector('.print-signature');db.settings.logoPositionBySize=db.settings.logoPositionBySize||{};db.settings.signaturePositionBySize=db.settings.signaturePositionBySize||{};if(lp)db.settings.logoPositionBySize[size]={left:parseFloat(lp.style.left)||0,top:parseFloat(lp.style.top)||0};if(sp)db.settings.signaturePositionBySize[size]={left:parseFloat(sp.style.left)||0,top:parseFloat(sp.style.top)||0};persist();alert('چیدمان '+size+' ذخیره شد')} $('saveTemplateLayout').onclick=()=>saveTemplate(canvasA4,'A4');$('saveTemplateLayoutA5').onclick=()=>saveTemplate(canvasA5,'A5'); // Login is local-demo only, with visible default demo credentials. let login=document.createElement('div');login.className='login-overlay';login.id='loginOverlay';login.innerHTML='

ورود به حساب

';document.body.appendChild(login);$('demoLogin').onclick=function(e){if(e)e.preventDefault();return false;}; // final rendering hooks, preserve base render function // One stable render hook: render the original ledgers first, then add the supplemental views. const stableRender=window.renderAll; window.renderAll=function(){ stableRender(); const purchaseBox=$('purchaseInvoicesList'); if(purchaseBox) purchaseBox.innerHTML=table(['شماره','تاریخ','تأمین‌کننده','اقلام','جمع','عملیات'],db.purchases.map(p=>[ escapeHTML(p.number),escapeHTML(p.date),escapeHTML(p.supplier), (p.items||[]).map(i=>escapeHTML(i.name)+' × '+i.qty).join('، '),money(p.total||p.amount), ` ` ])); addInvoiceActions('invoiceList','invoice',db.invoices); addInvoiceActions('estimateList','estimate',db.estimates); const approval=$('approvalList'); if(approval) approval.querySelectorAll('.panel').forEach(card=>{ if(card.querySelector('.detail-btn,.work-details')) return; const b=card.querySelector('button[onclick*="approveWork"]'); const m=(b?.getAttribute('onclick')||'').match(/approveWork\((\d+)/); if(!m) return; const btn=document.createElement('button');btn.className='secondary small detail-btn';btn.textContent='مشاهده جزئیات'; btn.onclick=()=>window.viewWorkDetail(Number(m[1]));card.querySelector('.row')?.appendChild(btn); }); const users=$('usersList'); if(users){ users.querySelectorAll('tbody tr').forEach((tr,i)=>{ if(tr.querySelector('.user-ops')) return;const u=db.users[i];if(!u)return; const td=document.createElement('td');td.className='user-ops'; const edit=document.createElement('button');edit.className='secondary small';edit.textContent='ویرایش';edit.onclick=()=>window.editUser(u.id); const del=document.createElement('button');del.className='danger small';del.textContent='حذف';del.onclick=()=>window.deleteUser(u.id); td.append(edit,del);tr.appendChild(td); }); const head=users.querySelector('thead tr');if(head&&!head.querySelector('.user-ops-head')){const th=document.createElement('th');th.className='user-ops-head';th.textContent='عملیات';head.appendChild(th)} } }; // Put the separately navigable purchase screen in the same section flow, not below the footer. const main=$('.main'), footer=main?.querySelector(':scope > .foot'); if(main&&purchase.parentElement===main&&footer) main.insertBefore(purchase,footer); // Make sure every list is populated on first load, not only after the first save. window.renderAll(); })(); \n