Stok
Bayi Girişi
Yetkili kullanıcı girişi gereklidir
VIP PARTSS
/* GİRİŞ BİLGİLERİ */
const USERNAME = "bayii"; const PASSWORD = "Bayii123";
/* GOOGLE SHEETS CSV */
const SHEET_URL = "https://docs.google.com/spreadsheets/d/e/2PACX-1vSwN8ZRUEJGGyXAZZrx142L887Je_B0KPtQP0QZtNX0VREV6KuX4XPvJp5Mbs-zn3Kt87cuZqaSmIcG/pub?output=csv";
/* GİRİŞ */
function login(){
const user = document.getElementById("username").value; const pass = document.getElementById("password").value;
if(user === USERNAME && pass === PASSWORD){
sessionStorage.setItem("vip_login","true");
document.getElementById("loginScreen").style.display = "none";
}else{
document.getElementById("error").style.display = "block"; } }
/* SAYFA YENİLENİNCE */
window.onload = function(){
if(sessionStorage.getItem("vip_login") === "true"){
document.getElementById("loginScreen").style.display = "none"; } }
/* ENTER TUŞU */
document.getElementById("searchInput").addEventListener("keypress",function(e){
if(e.key === "Enter"){
searchPart(); } });
/* STOK ARAMA */
async function searchPart(){
const input = document.getElementById("searchInput") .value .trim() .toLowerCase();
if(!input){
alert("Parça numarası giriniz"); return; }
document.getElementById("loading").style.display = "block"; document.getElementById("resultBox").style.display = "none";
try{
const response = await fetch(SHEET_URL);
const data = await response.text();
const rows = data.split("\n");
let found = false;
rows.forEach((row)=>{
const cols = row.split(",");
/* SÜTUNLAR */
const materialCode = cols[1]?.trim().toLowerCase();
const changedCode = cols[2]?.trim().toLowerCase();
const description = cols[4]?.trim();
const stock = cols[5]?.trim();
if( materialCode === input || changedCode === input ){
found = true;
document.getElementById("partNumber").innerText = cols[1];
document.getElementById("description").innerText = description || "-";
document.getElementById("stock").innerText = stock || "0";
const status = document.getElementById("status");
if(parseInt(stock) > 0){
status.innerHTML = "✅ STOK VAR";
status.className = "status success";
}else{
status.innerHTML = "❌ STOK YOK";
status.className = "status danger"; }
document.getElementById("resultBox").style.display = "block"; }
});
if(!found){
document.getElementById("partNumber").innerText = input.toUpperCase();
document.getElementById("description").innerText = "Ürün bulunamadı";
document.getElementById("stock").innerText = "0";
const status = document.getElementById("status");
status.innerHTML = "❌ STOK YOK";
status.className = "status danger";
document.getElementById("resultBox").style.display = "block"; }
}catch(error){
alert("Google Sheets bağlantı hatası");
console.log(error); }
document.getElementById("loading").style.display = "none"; }