📊 דשבורד
➕ הכנסת נתונים
✏️ עריכת יום
📅 תקופות
📋 רשימה
➕ הוסף
🔄 השוואה
🔄 השוואות
📅 יומי
📆 שבועי
💬 דוחות וואטסאפ
📅 יומי
📆 שבועי
📆 חודשי
תצוגה מקדימה
בחר תאריכים ולחץ "צור דוח"...
📥 ייבוא קומקס
📤 ייבוא
📋 היסטוריה
לחץ לבחירת קובץ קומקס — או גרור לכאן
XLS / HTML — דוח Z קומקס
👥 ניהול משתמשים
| משתמש | אימייל | תפקיד | סניף | פעולות |
|---|
⚙️ SQL ראשוני — הרץ פעם אחת ב-Supabase
הרץ את ה-SQL הבא ב-Supabase SQL Editor לאתחול המערכת:
-- === KT Market — SQL Setup (v1.0) ===
-- 1. PROFILES TABLE
CREATE TABLE IF NOT EXISTS public.profiles (
id uuid references auth.users on delete cascade primary key,
email text,
full_name text,
role text default 'branch_manager',
branch text,
suppliers_data jsonb default '[]',
suppliers_updated_at timestamptz,
created_at timestamptz default now()
);
-- Migration (run once if table already exists):
-- ALTER TABLE profiles ADD COLUMN IF NOT EXISTS suppliers_data jsonb DEFAULT '[]';
-- ALTER TABLE profiles ADD COLUMN IF NOT EXISTS suppliers_updated_at timestamptz;
-- 2. SALES TABLE
CREATE TABLE IF NOT EXISTS public.sales (
id bigserial primary key,
date date not null,
branch text not null,
tickets integer,
avg_basket numeric(10,2),
total numeric(12,2),
comax_gross numeric(12,2),
comax_net numeric(12,2),
comax_vat numeric(12,2),
comax_discount numeric(12,2),
created_by uuid references auth.users,
created_at timestamptz default now(),
UNIQUE(date, branch)
);
-- 3. PERIODS TABLE
CREATE TABLE IF NOT EXISTS public.periods (
id bigserial primary key,
name text not null,
type text,
date_from date not null,
date_to date not null,
note text,
created_by uuid references auth.users,
created_at timestamptz default now()
);
-- 4. ENABLE RLS
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE sales ENABLE ROW LEVEL SECURITY;
ALTER TABLE periods ENABLE ROW LEVEL SECURITY;
-- 5. PROFILES POLICY
DROP POLICY IF EXISTS "profiles_self" ON profiles;
CREATE POLICY "profiles_self" ON profiles FOR ALL USING (auth.uid() = id);
-- 6. SALES POLICIES
DROP POLICY IF EXISTS "sales_read_admin" ON sales;
CREATE POLICY "sales_read_admin" ON sales FOR SELECT
USING (EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role IN ('super_admin','network_manager')));
DROP POLICY IF EXISTS "sales_read_branch" ON sales;
CREATE POLICY "sales_read_branch" ON sales FOR SELECT
USING (EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role='branch_manager' AND branch=sales.branch));
DROP POLICY IF EXISTS "sales_insert_admin" ON sales;
CREATE POLICY "sales_insert_admin" ON sales FOR INSERT WITH CHECK
(EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role IN ('super_admin','network_manager')));
DROP POLICY IF EXISTS "sales_insert_branch" ON sales;
CREATE POLICY "sales_insert_branch" ON sales FOR INSERT WITH CHECK
(EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role='branch_manager' AND branch=sales.branch));
DROP POLICY IF EXISTS "sales_update_all" ON sales;
CREATE POLICY "sales_update_all" ON sales FOR UPDATE
USING (EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role IN ('super_admin','network_manager','branch_manager')));
DROP POLICY IF EXISTS "sales_delete_admin" ON sales;
CREATE POLICY "sales_delete_admin" ON sales FOR DELETE
USING (EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role IN ('super_admin','network_manager')));
-- 7. PERIODS POLICIES
DROP POLICY IF EXISTS "periods_read" ON periods;
CREATE POLICY "periods_read" ON periods FOR SELECT USING (true);
DROP POLICY IF EXISTS "periods_write" ON periods;
CREATE POLICY "periods_write" ON periods FOR ALL
USING (EXISTS (SELECT 1 FROM profiles WHERE id=auth.uid() AND role IN ('super_admin','network_manager')));
-- 8. AUTO-CREATE PROFILE ON SIGNUP
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS trigger AS $$
BEGIN
INSERT INTO public.profiles (id, email, full_name)
VALUES (new.id, new.email, new.raw_user_meta_data->>'full_name')
ON CONFLICT (id) DO NOTHING;
RETURN new;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
DROP TRIGGER IF EXISTS on_auth_user_created ON auth.users;
CREATE TRIGGER on_auth_user_created
AFTER INSERT ON auth.users
FOR EACH ROW EXECUTE PROCEDURE public.handle_new_user();
🔧
Migration — הוספת עמודות קומקס
אם הרצת את Setup לפני שנוספו עמודות קומקס — הרץ את זה ב-SQL Editor
ALTER TABLE sales
ADD COLUMN IF NOT EXISTS comax_gross numeric(12,2),
ADD COLUMN IF NOT EXISTS comax_net numeric(12,2),
ADD COLUMN IF NOT EXISTS comax_vat numeric(12,2),
ADD COLUMN IF NOT EXISTS comax_discount numeric(12,2);
🏦 הצלבה — נייאקס מול קומקס
ייבא קובץ Excel מנייאקס להתחיל
הורד מ-MoMa: דוח פעילות לקוח → ייצא Excel
📦 הזמנות ומלאי