updating sku generartor
This commit is contained in:
parent
739a0d397f
commit
0649b20627
Binary file not shown.
@ -186,13 +186,16 @@
|
|||||||
overflow: visible !important;
|
overflow: visible !important;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
background: white;
|
background: white;
|
||||||
|
text-align: left !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: white !important;
|
background: white !important;
|
||||||
-webkit-print-color-adjust: exact;
|
-webkit-print-color-adjust: exact;
|
||||||
|
text-align: left !important;
|
||||||
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@page {
|
@page {
|
||||||
@ -208,21 +211,27 @@
|
|||||||
|
|
||||||
.label-sheet {
|
.label-sheet {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 210mm;
|
width: 210mm !important; /* Force A4 width */
|
||||||
min-height: 297mm; /* Ensure full page height for sheets */
|
min-height: 297mm;
|
||||||
margin: 0 auto;
|
margin: 0 !important; /* Strict Left align */
|
||||||
|
padding: 0;
|
||||||
background: white;
|
background: white;
|
||||||
page-break-after: always;
|
page-break-after: always;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: block; /* Default fallback */
|
|
||||||
|
/* Use Flexbox for Grid Layout - More reliable for print */
|
||||||
|
display: flex !important;
|
||||||
|
flex-wrap: wrap !important;
|
||||||
|
justify-content: flex-start !important;
|
||||||
|
align-items: flex-start !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Direct print container override */
|
/* Direct print container override */
|
||||||
body.direct-print-mode .label-sheet {
|
body.direct-print-mode .label-sheet {
|
||||||
width: auto;
|
width: auto !important;
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
page-break-after: auto;
|
page-break-after: auto;
|
||||||
display: block;
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label-item {
|
.label-item {
|
||||||
@ -233,32 +242,33 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%; /* Fills the grid cell or container */
|
/* REMOVED width: 100% to prevent full-width expansion */
|
||||||
height: 100%;
|
|
||||||
page-break-inside: avoid;
|
page-break-inside: avoid;
|
||||||
|
float: left; /* Fallback */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- SHEET GRIDS --- */
|
/* --- SHEET CONFIGURATIONS (Flexbox + Explicit Dimensions) --- */
|
||||||
|
|
||||||
/* Avery L7651 (5x13 = 65) */
|
/* Avery L7651 (5x13 = 65) */
|
||||||
.sheet-l7651 {
|
.sheet-l7651 {
|
||||||
display: grid !important;
|
|
||||||
grid-template-columns: repeat(5, 38.1mm) !important;
|
|
||||||
grid-auto-rows: 21.2mm !important;
|
|
||||||
padding: 10.7mm 9.75mm !important;
|
padding: 10.7mm 9.75mm !important;
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
.label-l7651 { padding: 1mm; }
|
.label-l7651 {
|
||||||
|
width: 38.1mm !important;
|
||||||
|
height: 21.2mm !important;
|
||||||
|
padding: 1mm;
|
||||||
|
border: none; /* Debug: add border: 1px solid #eee if needed */
|
||||||
|
}
|
||||||
|
|
||||||
/* Avery L7656 (4x21 = 84) */
|
/* Avery L7656 (4x21 = 84) */
|
||||||
.sheet-l7656 {
|
.sheet-l7656 {
|
||||||
display: grid !important;
|
|
||||||
grid-template-columns: repeat(4, 46mm) !important;
|
|
||||||
grid-auto-rows: 11.1mm !important;
|
|
||||||
padding: 31.95mm 13mm !important;
|
padding: 31.95mm 13mm !important;
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
.label-l7656 { padding: 0.5mm; }
|
.label-l7656 {
|
||||||
|
width: 46mm !important;
|
||||||
|
height: 11.1mm !important;
|
||||||
|
padding: 0.5mm;
|
||||||
|
}
|
||||||
.label-l7656 .inner-flex {
|
.label-l7656 .inner-flex {
|
||||||
display: flex; flex-direction: row; justify-content: space-around; align-items: center; height: 100%; width: 100%;
|
display: flex; flex-direction: row; justify-content: space-around; align-items: center; height: 100%; width: 100%;
|
||||||
}
|
}
|
||||||
@ -267,36 +277,46 @@
|
|||||||
|
|
||||||
/* Avery L7156 (3x7 = 21) */
|
/* Avery L7156 (3x7 = 21) */
|
||||||
.sheet-l7156 {
|
.sheet-l7156 {
|
||||||
display: grid !important;
|
|
||||||
grid-template-columns: repeat(3, 63.5mm) !important;
|
|
||||||
grid-auto-rows: 38.1mm !important;
|
|
||||||
padding: 15.15mm 9.75mm !important;
|
padding: 15.15mm 9.75mm !important;
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
.label-l7156 { padding: 2mm; }
|
.label-l7156 {
|
||||||
|
width: 63.5mm !important;
|
||||||
|
height: 38.1mm !important;
|
||||||
|
padding: 2mm;
|
||||||
|
}
|
||||||
|
|
||||||
/* A4 24 (3x8) */
|
/* A4 24 (3x8) */
|
||||||
.sheet-a4-24 {
|
.sheet-a4-24 {
|
||||||
display: grid !important;
|
|
||||||
grid-template-columns: repeat(3, 63.5mm) !important;
|
|
||||||
grid-auto-rows: 33.9mm !important;
|
|
||||||
padding: 12.9mm 9.75mm !important;
|
padding: 12.9mm 9.75mm !important;
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
.label-a4-24 { padding: 2mm; }
|
.label-a4-24 {
|
||||||
|
width: 63.5mm !important;
|
||||||
|
height: 33.9mm !important;
|
||||||
|
padding: 2mm;
|
||||||
|
}
|
||||||
|
|
||||||
/* A4 40 (4x10) */
|
/* A4 40 (4x10) */
|
||||||
.sheet-a4-40 {
|
.sheet-a4-40 {
|
||||||
display: grid !important;
|
|
||||||
grid-template-columns: repeat(4, 48.5mm) !important;
|
|
||||||
grid-auto-rows: 25.4mm !important;
|
|
||||||
padding: 21.5mm 8mm !important;
|
padding: 21.5mm 8mm !important;
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
.label-a4-40 { padding: 1mm; }
|
.label-a4-40 {
|
||||||
|
width: 48.5mm !important;
|
||||||
|
height: 25.4mm !important;
|
||||||
|
padding: 1mm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Standard / Small / Price Tag */
|
||||||
|
.sheet-standard, .sheet-small {
|
||||||
|
padding: 5mm !important;
|
||||||
|
gap: 2mm !important;
|
||||||
|
}
|
||||||
|
.label-standard { width: 50mm !important; height: 25mm !important; border: 1px dotted #ccc; }
|
||||||
|
.label-small { width: 38mm !important; height: 25mm !important; border: 1px dotted #ccc; }
|
||||||
|
.label-price-tag { width: 25mm !important; height: 15mm !important; border: 1px dotted #ccc; }
|
||||||
|
|
||||||
|
/* Inner Content Styling */
|
||||||
.label-item svg {
|
.label-item svg {
|
||||||
max-width: 100%;
|
max-width: 95%;
|
||||||
height: auto;
|
height: auto;
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@ -635,13 +655,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
const sheetLabels = allLabels.slice(s, s + labelsPerSheet);
|
const sheetLabels = allLabels.slice(s, s + labelsPerSheet);
|
||||||
const sheet = document.createElement('div');
|
const sheet = document.createElement('div');
|
||||||
|
|
||||||
// Add specific classes
|
|
||||||
if (labelType === 'a4-24') sheet.classList.add('sheet-a4-24');
|
|
||||||
else if (labelType === 'a4-40') sheet.classList.add('sheet-a4-40');
|
|
||||||
else if (labelType === 'l7651') sheet.classList.add('sheet-l7651');
|
|
||||||
else if (labelType === 'l7656') sheet.classList.add('sheet-l7656');
|
|
||||||
else if (labelType === 'l7156') sheet.classList.add('sheet-l7156');
|
|
||||||
|
|
||||||
sheet.classList.add('label-sheet');
|
sheet.classList.add('label-sheet');
|
||||||
sheet.classList.add('sheet-' + labelType);
|
sheet.classList.add('sheet-' + labelType);
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
from django.conf import settings as django_settings
|
from django.conf import settings as django_settings
|
||||||
from django.contrib.auth.models import User, Group, Permission
|
from django.contrib.auth.models import User, Group, Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@ -1153,7 +1154,13 @@ def barcode_labels(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def suggest_sku(request):
|
def suggest_sku(request):
|
||||||
return JsonResponse({'sku': f"SKU-{int(timezone.now().timestamp())}"})
|
while True:
|
||||||
|
# Generate 7 random digits
|
||||||
|
digits = ''.join([str(random.randint(0, 9)) for _ in range(7)])
|
||||||
|
new_sku = f"{digits}"
|
||||||
|
# Ensure it does not exist
|
||||||
|
if not Product.objects.filter(sku=new_sku).exists():
|
||||||
|
return JsonResponse({'sku': new_sku})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def add_category(request):
|
def add_category(request):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user