ABS Marketing · Powered by AI
Enter Your PIN
Each team member has a unique PIN.
Contact CEO if you don't have one.
❌ Wrong PIN. Please try again.
"Whoever is conscious of Allah, He will make a way out and provide for them from where they do not expect." — Surah At-Talaq 65:2-3
CEO — Full Access

Dashboard

Supabase
`; window._cpCFData=null;window._cpCBData=null; } function openEditProfile(id){ const p=PROFILES.find(x=>x.id===id);if(!p)return; window._editProfileId=id; document.getElementById("mr").innerHTML=`

👤 Edit Customer Profile

${p.cnicFront?'':''}
${p.cnicBack?'':''}
`; const btn=document.getElementById("ep-save-btn"); if(btn)btn.onclick=()=>saveProfile(id,true); } function saveProfile(leadId,isEdit){ const name=document.getElementById("cp-nm").value.trim(); if(!name){notif("Full Name is required","red");return;} const cnicFront=window._cpCFData||(isEdit&&PROFILES.find(x=>x.id===window._editProfileId)?.cnicFront)||null; const cnicBack=window._cpCBData||(isEdit&&PROFILES.find(x=>x.id===window._editProfileId)?.cnicBack)||null; if(!cnicFront){notif("CNIC Front photo is required ⚠","red");return;} if(!cnicBack){notif("CNIC Back photo is required ⚠","red");return;} if(isEdit){ const p=PROFILES.find(x=>x.id===window._editProfileId);if(!p)return; p.name=name; p.cnic=document.getElementById("cp-cn").value.trim(); p.phone=document.getElementById("cp-ph").value.trim(); p.whatsapp=document.getElementById("cp-wa").value.trim(); p.email=document.getElementById("cp-em").value.trim(); p.city=document.getElementById("cp-ct").value.trim(); p.address=document.getElementById("cp-ad").value.trim(); p.budget=document.getElementById("cp-bg").value.trim(); p.sourceOfFunds=document.getElementById("cp-sf").value.trim(); p.project=document.getElementById("cp-pi").value.trim(); p.unitType=document.getElementById("cp-ut").value.trim(); p.purpose=document.getElementById("cp-pu").value; p.notes=document.getElementById("cp-no").value.trim(); if(window._cpCFData)p.cnicFront=window._cpCFData; if(window._cpCBData)p.cnicBack=window._cpCBData; saveToStorage();cm();rc();notif("Profile updated ✅"); } else { const prof={ id:NPI++, leadId:leadId||0, name, cnic:document.getElementById("cp-cn").value.trim(), phone:document.getElementById("cp-ph").value.trim(), whatsapp:document.getElementById("cp-wa").value.trim(), email:document.getElementById("cp-em").value.trim(), city:document.getElementById("cp-ct").value.trim(), address:document.getElementById("cp-ad").value.trim(), budget:document.getElementById("cp-bg").value.trim(), sourceOfFunds:document.getElementById("cp-sf").value.trim(), project:document.getElementById("cp-pi").value.trim(), unitType:document.getElementById("cp-ut").value.trim(), purpose:document.getElementById("cp-pu").value, notes:document.getElementById("cp-no").value.trim(), cnicFront, cnicBack, createdAt:new Date().toISOString() }; PROFILES.push(prof); saveToStorage();cm();rc();notif("Profile created ✅"); } } function delProfile(id){ if(!confirm("Delete this customer profile?"))return; const idx=PROFILES.findIndex(x=>x.id===id); if(idx>=0){PROFILES.splice(idx,1);saveToStorage();rc();notif("Profile deleted");} } function rc(){ const el=document.getElementById("ct");let html=""; if(S.role==="ceo"){ if(S.page==="dashboard")html=rdash(); else if(S.page==="team")html=rteam(); else if(S.page==="leads")html=rleads(); else if(S.page==="pipeline")html=rpipe(); else if(S.page==="deals")html=rdeals(); else if(S.page==="accounts")html=raccs(); else if(S.page==="chk")html=rAllChk(); else if(S.page==="chk_m")html=rchk(S._cm,true); else if(S.page==="tasks")html=rtasks(); else if(S.page==="reminders")html=rReminders();else if(S.page==="ai"){aiHistory=[];html=rAI();} else if(S.page==="settings")html=rSettings(); else if(S.page==="profiles")html=rProfiles(); } else { if(S.page==="sc_dash")html=rScDash(); else if(S.page==="sc_leads")html=rleads(S.uid); else if(S.page==="sc_pipeline")html=rpipe(S.uid); else if(S.page==="sc_deals")html=rdeals(S.uid); else if(S.page==="sc_accounts")html=raccs(S.uid); else if(S.page==="sc_chk")html=rchk(); else if(S.page==="sc_tasks")html=rtasks(S.uid); else if(S.page==="reminders")html=rReminders();else if(S.page==="ai"){aiHistory=[];html=rAI();} else if(S.page==="profiles")html=rProfiles(); } el.innerHTML=html;sbadge("idle"); } function ra(){rsb();rsw();rc();} // ═══════════════════════════════════════════ // LOCAL STORAGE // ═══════════════════════════════════════════ const STORAGE_KEY='abs_crm_data'; function saveToStorage(){ try{localStorage.setItem(STORAGE_KEY,JSON.stringify({leads:LEADS,deals:DEALS,tasks:TASKS,checklists:CL,customTasks:CT,cfg:CFG,nli:NLI,nti:NTI,ndi:NDI,profiles:PROFILES,npi:NPI}));}catch(e){} } function loadFromStorage(){ try{const raw=localStorage.getItem(STORAGE_KEY);if(!raw)return false;const data=JSON.parse(raw); if(data.leads)LEADS=data.leads;if(data.deals)DEALS=data.deals;if(data.tasks)TASKS=data.tasks; if(data.checklists)Object.assign(CL,data.checklists);if(data.customTasks)Object.assign(CT,data.customTasks); if(data.cfg)Object.assign(CFG,data.cfg);if(data.nli)NLI=data.nli;if(data.nti)NTI=data.nti;if(data.ndi)NDI=data.ndi;if(data.profiles)PROFILES=data.profiles;if(data.npi)NPI=data.npi; return true;}catch(e){return false;} } function clearStorage(){if(confirm("Clear all local data?")){localStorage.removeItem(STORAGE_KEY);location.reload();}} // ═══════════════════════════════════════════ // PIN LOGIN // ═══════════════════════════════════════════ const PINS={'098123':0,'AW2001':1,'HA2002':2,'UZ2003':3,'HM2004':4,'FN2005':5,'SH2006':6,'ZM2007':7,'MI2008':8,'HK2009':9,'MP2010':10,'ZZ2011':11,'AA2012':12,'AB2013':13,'AQ2014':14,'BS2015':15}; function logout(){S.role='ceo';S.uid=0;S.page='dashboard';document.getElementById('pin-screen').style.display='';const sw=document.getElementById('switcher');if(sw)sw.style.display='';const pi=document.getElementById('pin-input');if(pi)pi.value='';rc();} function checkPIN(){ const pin=document.getElementById('pin-input').value.trim(); const errEl=document.getElementById('pin-error'); if(PINS.hasOwnProperty(pin)){ const uid=PINS[pin];const member=TM.find(m=>m.id===uid); if(member){ if(uid===0){S.role='ceo';S.uid=0;}else{S.role='consultant';S.uid=uid;} loadFromStorage(); document.getElementById('pin-screen').style.display='none'; if(uid!==0){const sw=document.getElementById('switcher');if(sw)sw.style.display='none';} ra(); // Load from Supabase in background loadFromSupabase(); return; } } errEl.style.display='block'; document.getElementById('pin-input').value=''; document.getElementById('pin-input').style.borderColor='#a32d2d'; setTimeout(()=>{errEl.style.display='none';document.getElementById('pin-input').style.borderColor='#e0e0e0';},2000); } document.addEventListener('DOMContentLoaded',function(){ const inp=document.getElementById('pin-input');if(inp)inp.focus(); });