Florist Flower Calculator
/* KEEP ALL YOUR EXISTING STYLES */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, ‘Segoe UI’, Roboto, sans-serif;
line-height: 1.6;
color: #333;
background-color: #f5f5f5;
padding: 20px;
max-width: 1200px;
margin: 0 auto;
}
.container {
background: white;
border-radius: 10px;
padding: 20px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #2c5530;
margin-bottom: 30px;
font-size: 28px;
}
.input-section {
margin-bottom: 30px;
}
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #555;
}
textarea, select, input {
width: 100%;
padding: 12px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s;
}
textarea:focus, select:focus, input:focus {
outline: none;
border-color: #4CAF50;
}
textarea {
height: 120px;
resize: vertical;
font-family: inherit;
}
.button-group {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 15px;
}
button {
padding: 12px 24px;
background: #4CAF50;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s;
flex: 1;
min-width: 120px;
}
button:hover {
background: #45a049;
}
button.secondary {
background: #6c757d;
}
button.secondary:hover {
background: #5a6268;
}
button.help {
background: #17a2b8;
}
button.help:hover {
background: #138496;
}
.quick-actions {
background: #e3f2fd;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #2196F3;
}
.quick-actions h3 {
color: #1976d2;
margin-bottom: 10px;
}
.product-list {
max-height: 200px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 8px;
padding: 10px;
background: #f9f9f9;
margin-top: 10px;
}
.product-item {
padding: 8px;
border-bottom: 1px solid #eee;
cursor: pointer;
}
.product-item:hover {
background: #e9ecef;
}
.product-item:last-child {
border-bottom: none;
}
.copy-hint {
font-size: 14px;
color: #666;
margin-top: 5px;
}
.results-section {
margin-top: 30px;
}
.summary {
background: #e8f5e8;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #4CAF50;
}
.flower-table {
width: 100%;
border-collapse: collapse;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.flower-table th {
background: #2c5530;
color: white;
padding: 12px;
text-align: left;
font-weight: 600;
}
.flower-table td {
padding: 12px;
border-bottom: 1px solid #eee;
}
.flower-table tr:hover {
background: #f9f9f9;
}
.total-row {
background: #e8f5e8 !important;
font-weight: bold;
}
.hidden {
display: none;
}
.instructions {
background: #fff3cd;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #ffc107;
}
.instructions h3 {
color: #856404;
margin-bottom: 10px;
}
/* NEW STYLES – SIMPLE AND CLEAN */
.warning-message {
background: #fff3cd;
border: 1px solid #ffc107;
border-radius: 8px;
padding: 12px;
margin-top: 10px;
display: none;
}
.warning-message h4 {
color: #856404;
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 8px;
}
.unknown-list {
color: #721c24;
background: #f8d7da;
border-radius: 5px;
padding: 8px;
margin-top: 8px;
font-size: 14px;
}
.stats-info {
font-size: 14px;
color: #666;
margin-top: 5px;
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.stat-item {
background: #f8f9fa;
padding: 4px 8px;
border-radius: 4px;
border: 1px solid #e9ecef;
}
@media (max-width: 768px) {
body {
padding: 10px;
}
.container {
padding: 15px;
}
h1 {
font-size: 24px;
}
button {
flex: 100%;
}
.flower-table {
font-size: 14px;
}
.stats-info {
flex-direction: column;
gap: 5px;
}
}
🌺 Florist Flower Calculator
📋 How to Use:
1. GET ORDERS: Export CSV from your system β Open in Numbers/Excel on iPad
2. COPY NAMES: Use the quick methods below to copy all bouquet names quickly
3. PASTE & CALCULATE: Paste here and click “Calculate”
🚀 Quick Copy Methods for iPad:
Method 1 – Numbers App:
- Open CSV in Numbers app
- Tap the column with bouquet names
- Choose “Select All” β “Copy”
- Paste below
Method 2 – Select Multiple:
- Tap first name, then drag to select all
- Use “Select All” from menu
- Copy and paste
Method 3 – File Preview:
- Open CSV file
- Tap “Share” β “Copy” (sometimes copies entire content)
📊 Order Summary
Total Orders: 0
Unique Bouquet Types: 0
(different designs only)
⚠️ Unknown bouquets: 0
| Flower Type |
Total Quantity Needed |
// Your flower data – KEEP EXACTLY AS IS
const flowerData = {
“Apricot”: {
“White Rose”: 5,
“Peach Rose”: 3,
“Orange Rose Spray”: 3,
“Peach Mathiola”: 1,
“White Caspia”: 3,
“Populos”: 2
},
“Apricot”: {
“White Rose”: 5,
“Peach Rose”: 3,
“Orange Rose Spray”: 3,
“Peach Mathiola”: 1,
“White Caspia”: 3,
“Populos”: 2
},
“Elegant”: {
“Blue Hydrangea”: 1,
“Pink Rose”: 5,
“Purple Carnation”: 4,
“Pink Mathiola”: 3,
“Wax Flower”: 3,
“Yellow Mini Pom”: 3,
“Baby’s Breath”: 3,
“Cordyline”: 2
},
“Jazreel”: {
“Pink Tulip”: 7,
“White Tulip”: 7,
“Purple Tulip”: 7,
“Blue Star”: 4,
“Baby’s Breath”: 5
},
“Sunday”: {
“Sunflower”: 1,
“Yellow Rose”: 4,
“Yellow Tulip”: 5,
“White Mathiola”: 2,
“Blue Star”: 3,
“Ruscus”: 2,
“Yellow Mini Pom”: 3
},
“Blue Star”: {
“Red Rose”: 5,
“Pink Rose Spray”: 3,
“White Mini Pom”: 3,
“Blue Star”: 3,
“Eucalyptus”: 2
},
“Cala”: {
“White Cala”: 5,
“White Rose”: 10,
“Champagne Eustoma”: 7,
“Wax Flower”: 3,
“Blue Star”: 5,
“Eucalyptus”: 4
},
“Jade”: {
“Green Carnation”: 5,
“White Rose”: 4,
“Green Anthurium”: 2,
“White Mathiola”: 1,
“Silver Moss”: 4,
“Populos”: 1
},
“Venice Red – 12”: {
“Red Rose”: 12,
“Baby’s Breath”: 5
},
“Venice Red – 24”: {
“Red Rose”: 24,
“Baby’s Breath”: 8
},
“Venice Pink – 12”: {
“Pink Rose”: 12,
“Baby’s Breath”: 5
},
“Venice Pink – 24”: {
“Pink Rose”: 24,
“Baby’s Breath”: 8
},
“Venice Champagne – 12”: {
“Champagne Rose”: 12,
“Baby’s Breath”: 5
},
“Venice Champagne – 24”: {
“Champagne Rose”: 24,
“Baby’s Breath”: 8
},
“Venice Yellow – 12”: {
“Yellow Rose”: 12,
“Baby’s Breath”: 5
},
“Venice Yellow – 24”: {
“Yellow Rose”: 24,
“Baby’s Breath”: 8
},
“Venice Purple – 12”: {
“Purple Rose”: 12,
“Baby’s Breath”: 5
},
“Venice Purple – 24”: {
“Purple Rose”: 24,
“Baby’s Breath”: 8
},
“Venice White – 12”: {
“White Rose”: 12,
“Baby’s Breath”: 5
},
“Venice White – 24”: {
“White Rose”: 24,
“Baby’s Breath”: 8
},
“Nutella”: {
“Red Rose”: 5,
“Cappuccino Rose”: 5,
“White Caspia”: 4,
“Populos”: 3
},
“Sherry”: {
“Pink Tulip”: 9,
“Champagne Rose”: 9,
“Baby’s Breath”: 5
},
“Brianna”: {
“Pink Tulip”: 30,
“Purple Tulip”: 20
},
“Brielle – 6”: {
“Pink Rose”: 6,
“Pink Carnation”: 3,
“Pink Rose Spray”: 2,
“Wax Flower”: 2,
“White Caspia”: 2,
“Yellow Phoenix”: 3,
“Coin Leaf Mini”: 3
},
“Brielle – 12”: {
“Pink Rose”: 12,
“Pink Carnation”: 3,
“Pink Rose Spray”: 3,
“Wax Flower”: 3,
“White Caspia”: 3,
“Yellow Phoenix”: 3,
“Coin Leaf Mini”: 3
},
“Brielle – 24”: {
“Pink Rose”: 24,
“Pink Carnation”: 3,
“Pink Rose Spray”: 5,
“Wax Flower”: 4,
“White Caspia”: 4,
“Yellow Phoenix”: 3,
“Coin Leaf Mini”: 4
},
“Cora Pink – 9”: {
“Pink Tulip”: 9
},
“Cora Pink – 18”: {
“Pink Tulip”: 18
},
“Cora Yellow – 9”: {
“Yellow Tulip”: 9
},
“Cora Yellow – 18”: {
“Yellow Tulip”: 18
},
“Cora Orange – 9”: {
“Orange Tulip”: 9
},
“Cora Orange – 18”: {
“Orange Tulip”: 18
},
“Cora Red – 9”: {
“Red Tulip”: 9
},
“Cora Red – 18”: {
“Red Tulip”: 18
},
“Harmony”: {
“Orange Rose”: 6,
“Red Rose”: 4,
“Sunflower”: 2,
“White Statice”: 5,
“Yellow Caspia”: 5,
“Yellow Mini Pom”: 6,
“Johor Fern”: 6
},
“Helia”: {
“Champagne Rose”: 3,
“Cappuccino Rose”: 2,
“Yellow Mini Pom”: 4,
“White Mathiola”: 2,
“Dusty Miller”: 4,
“Purple Caspia”: 2,
“Baby’s Breath”: 3
},
“Lowen”: {
“Menta Rose”: 4,
“White Rose”: 2,
“White Mathiola”: 2,
“White Carnation Spray”: 3,
“White Eustoma”: 3,
“Dusty Miller”: 4,
“Populos”: 2
},
“Orange Pop”: {
“Orange Tulip”: 10,
“White Tulip”: 10
},
“Perk-Me-Up – Pink”: {
“Pink Rose”: 3,
“Green Mini Pom”: 1,
“Orange Mini Pom”: 1,
“Purple Mini Pom”: 1,
“Red Hypericum”: 1,
“Purple Statice”: 3,
“Eucalyptus”: 2,
“Baby’s Breath”: 2
},
“Perk-Me-Up – Red”: {
“Red Rose”: 3,
“Green Mini Pom”: 1,
“Orange Mini Pom”: 1,
“Purple Mini Pom”: 1,
“Red Hypericum”: 1,
“Purple Statice”: 3,
“Eucalyptus”: 2,
“Baby’s Breath”: 2
},
“Raspberry”: {
“Pink Rose Spray”: 5,
“Red Orchid”: 6,
“Wax Flower”: 4,
“Ruscus”: 3
},
“Vanessa”: {
“Pink Hydrangea”: 1,
“Pink Tulip”: 7,
“Peach Mathiola”: 3,
“Dusty Miller”: 4,
“Coin Leaf Mini”: 3,
“Purple Mini Pom”: 4,
“Baby’s Breath”: 4
},
“Beauty Queen”: {
“Red Rose”: 6,
“Baby’s Breath”: 5
},
“Chloe”: {
“Peach Garden Rose”: 5,
“Brenda Protea”: 1,
“White Eustoma”: 5,
“White Caspia”: 3,
“Populos”: 3,
“Thyme Foliage”: 3
},
“Enchant”: {
“Red Rose”: 3,
“Pink Rose”: 3,
“White Mini Pom”: 3,
“Wax Flower”: 3,
“Baby’s Breath”: 3
},
“Heather”: {
“Pink Rose”: 6,
“Baby’s Breath”: 5
},
“99 Rose Bouquet – Red”: {
“Red Rose”: 99,
“Baby’s Breath”: 10
},
“99 Rose Bouquet – Pink”: {
“Pink Rose”: 99,
“Baby’s Breath”: 10
},
“99 Rose Bouquet – Champagne”: {
“Champagne Rose”: 99,
“Baby’s Breath”: 10
},
“Caramel Latte”: {
“Cappuccino Rose”: 10,
“Pink Rose Spray”: 4,
“White Caspia”: 5,
“Wax Flower”: 3,
“Coin Leaf Mini”: 3
},
“Carrie”: {
“Red Rose”: 9,
“White Eustoma”: 4,
“Eucalyptus”: 3
},
“Mono”: {
“Cappuccino Rose”: 6,
“White Eustoma”: 5,
“Populos”: 4,
“Yellow Phoenix”: 3,
“Ruscus”: 3,
“Eucalyptus Seed”: 3
},
“Sage”: {
“Sunflower”: 1,
“Pink Gerbera”: 2,
“White Eustoma”: 3,
“Yellow Phoenix”: 3,
“Blue Star”: 3,
“Eucalyptus”: 2,
“White Mini Pom”: 2
},
“Lina”: {
“Sunflower”: 3,
“Red Rose”: 10,
“Baby’s Breath”: 7
},
“Scarlett”: {
“Sunflower”: 1,
“Yellow Rose”: 3,
“Red Orchid”: 3,
“Red Hypericum”: 2,
“Orange Mini Pom”: 3,
“Coin Leaf Mini”: 2,
“Johor Fern”: 3
},
“Iris”: {
“Pink Gerbera”: 3,
“Purple Carnation”: 3,
“Purple Eustoma”: 4,
“Blue Star”: 3,
“Purple Mini Pom”: 3,
“Purple Caspia”: 2
},
“Ivory”: {
“White Rose”: 18,
“Pink Statice”: 5,
“Baby’s Breath”: 5,
“Purple Caspia”: 3
},
“Millie”: {
“Champagne Rose”: 5,
“Baby’s Breath”: 5
},
“Stella – 9”: {
“Pink Tulip”: 9,
“Baby’s Breath”: 4
},
“Stella – 18”: {
“Pink Tulip”: 18,
“Baby’s Breath”: 6
},
“Splendour – Blue”: {
“Blue Hydrangea”: 1,
“Baby’s Breath”: 5
},
“Splendour – Pink”: {
“Pink Hydrangea”: 1,
“Baby’s Breath”: 5
},
“Splendour – Green”: {
“Green Hydrangea”: 1,
“Baby’s Breath”: 5
},
“Melody”: {
“Baby’s Breath”: 6
},
“Luminance”: {
“Sunflower”: 1,
“Red Rose”: 3,
“Pink Carnation”: 2,
“Orange Mini Pom”: 1,
“Green Mini Pom”: 1,
“Yellow Mini Pom”: 1,
“White Caspia”: 3,
“Eucalyptus”: 2
},
“Adelaide”: {
“Champagne Rose”: 9,
“White Eustoma”: 5,
“Baby’s Breath”: 3,
“Coin Leaf Mini”: 3,
“Ruscus”: 2
},
“Sunrise”: {
“Sunflower”: 3,
“Orange Mini Pom”: 3,
“Purple Mini Pom”: 2,
“White Caspia”: 2,
“Baby’s Breath”: 3,
“Yellow Phoenix”: 3,
“Ruscus”: 3,
“Coin Leaf Mini”: 2
},
“Sunflower Canopy”: {
“Sunflower”: 5,
“Yellow Phoenix”: 8
},
“Sunflower Field – 2”: {
“Sunflower”: 2,
“Baby’s Breath”: 5
},
“Sunflower Field – 3”: {
“Sunflower”: 3,
“Baby’s Breath”: 6
},
“Suntiago”: {
“Sunflower”: 1,
“Baby’s Breath”: 3,
“Eucalyptus”: 2
},
“Giselle”: {
“Red Rose”: 6,
“Pink Lily”: 3,
“Pink Carnation”: 3,
“Yellow Mini Pom”: 5,
“Baby’s Breath”: 4,
“Coin Leaf Mini”: 3,
“Purple Caspia”: 2
},
“Gabrielle – 6”: {
“Red Rose”: 6,
“Baby’s Breath”: 4,
“Ruscus”: 3
},
“Gabrielle – 12”: {
“Red Rose”: 12,
“Baby’s Breath”: 5,
“Ruscus”: 3
},
“Gabrielle – 24”: {
“Red Rose”: 24,
“Baby’s Breath”: 6,
“Ruscus”: 5
},
“Lush”: {
“Red Rose”: 6,
“Pink Rose”: 6,
“Yellow Phoenix”: 5,
“Baby’s Breath”: 3
},
“Perfect 10”: {
“Red Rose”: 10,
“Yellow Phoenix”: 5,
“Baby’s Breath”: 3
},
“Blush – 12”: {
“Pink Rose”: 12,
“Purple Statice”: 5,
“Baby’s Breath”: 5,
“Purple Caspia”: 3
},
“Blush – 24”: {
“Pink Rose”: 24,
“Purple Statice”: 7,
“Baby’s Breath”: 6,
“Purple Caspia”: 3
},
“Hazelnut Latte”: {
“Cappuccino Rose”: 6,
“Orange Mini Pom”: 4,
“Red Hypericum”: 3,
“White Caspia”: 3,
“Wax Flower”: 2,
“Eucalyptus”: 3
},
“Rosabelle – Red”: {
“Red Rose”: 6,
“Baby’s Breath”: 3,
“Johor Fern”: 2
},
“Rosabelle – Pink”: {
“Pink Rose”: 6,
“Baby’s Breath”: 3,
“Johor Fern”: 2
},
“Bliss”: {
“Red Rose”: 6,
“Pink Rose”: 6,
“White Mini Pom”: 2,
“Purple Mini Pom”: 2,
“Ruscus”: 3,
“Yellow Phoenix”: 3,
“Baby’s Breath”: 3
},
“Geneva”: {
“Pink Tulip”: 9,
“White Cala”: 5
},
“Americano”: {
“Black Cala Lily”: 3,
“Cappuccino Rose”: 5,
“Red Orchid”: 6,
“Wax Flower”: 4,
“Ruscus”: 3
},
“Euphoria”: {
“Sunflower”: 3,
“Baby’s Breath”: 6
},
“Valentine’s Carrie”: {
“White Eustoma”: 4,
“Red Rose”: 9,
“Eucalyptus”: 2
},
“Valentine’s Eve”: {
“Red Rose”: 6,
“Red Rose Spray”: 3,
“Red Gerbera”: 2,
“White Mini Pom”: 3,
“Eucalyptus”: 2
},
“Valentine’s Tiffany Blue”: {
“Blue Rose”: 9,
“White Eustoma”: 4,
“Eucalyptus”: 2
},
“Valentine’s BB”: {
“Red Rose”: 3,
“White Eustoma”: 1,
“Eryngium”: 2,
“Eucalyptus”: 1,
“Dusty Miller”: 2
},
“Valentine’s Beauty Queen”: {
“Red Rose”: 6,
“Baby’s Breath”: 5
},
“Valentine’s Blue Star”: {
“Red Rose”: 5,
“Blue Star”: 3,
“Pink Rose Spray”: 3,
“White Mini Pom”: 3,
“Eucalyptus”: 2
},
“Valentine’s Blush – 12”: {
“Pink Rose”: 12,
“Baby’s Breath”: 5,
“Purple Statice”: 5,
“Purple Caspia”: 3
},
“Valentine’s Blush – 24”: {
“Pink Rose”: 24,
“Baby’s Breath”: 7,
“Purple Statice”: 7,
“Purple Caspia”: 5
},
“Valentine’s Heather”: {
“Pink Rose”: 6,
“Baby’s Breath”: 5
},
“Valentine’s Juliet”: {
“Red Rose”: 6,
“Pink Rose”: 6,
“Wax Flower”: 3,
“Coin Leaf Mini”: 3,
“Purple Caspia”: 3
},
“Valentine’s Romeo”: {
“Red Rose”: 12,
“Eucalyptus”: 5,
“White Caspia”: 5
},
“Valentine’s Rosabelle”: {
“Red Rose”: 5,
“Baby’s Breath”: 4,
“Johor Fern”: 3
},
“Valentine’s Sweetheart”: {
“Red Rose”: 3,
“Pink Rose Spray”: 3,
“Wax Flower”: 2,
“Eucalyptus”: 1
},
“Valentine’s Venice Pink – 12”: {
“Pink Rose”: 12,
“Baby’s Breath”: 5
},
“Valentine’s Venice Pink – 24”: {
“Pink Rose”: 24,
“Baby’s Breath”: 7
},
“Valentine’s Venice Red – 12”: {
“Red Rose”: 12,
“Baby’s Breath”: 5
},
“Valentine’s Venice Red – 24”: {
“Red Rose”: 24,
“Baby’s Breath”: 7
},
// … [ALL YOUR OTHER BOUQUETS STAY EXACTLY THE SAME] …
// I’m showing just one to save space, but keep ALL your bouquets here
};
// ========== NEW FUNCTIONS ==========
// Update stats as user types
document.getElementById(‘orderInput’).addEventListener(‘input’, updateStats);
function updateStats() {
const text = document.getElementById(‘orderInput’).value;
const lines = text.split(‘n’).filter(line => line.trim().length > 0);
const warningBox = document.getElementById(‘warningBox’);
const unknownList = document.getElementById(‘unknownList’);
let recognized = 0;
let unknown = [];
lines.forEach(line => {
const trimmed = line.trim();
if (flowerData[trimmed]) {
recognized++;
} else if (trimmed !== ”) {
if (!unknown.includes(trimmed)) {
unknown.push(trimmed);
}
}
});
// Update counts
document.getElementById(‘lineCount’).textContent = lines.length;
document.getElementById(‘recognizedCount’).textContent = recognized;
document.getElementById(‘unknownCount’).textContent = unknown.length;
// Show/hide warning
if (unknown.length > 0) {
warningBox.style.display = ‘block’;
unknownList.innerHTML = unknown.map(b => `β’ ${b}`).join(‘
‘);
} else {
warningBox.style.display = ‘none’;
}
}
// ========== MODIFIED CALCULATE FUNCTION ==========
function calculateFlowers() {
const orderInput = document.getElementById(‘orderInput’).value.trim();
if (!orderInput) {
alert(‘Please paste your bouquet orders first!’);
return;
}
const orders = orderInput.split(‘n’)
.map(line => line.trim())
.filter(line => line.length > 0);
const bouquetCounts = {};
const unknownBouquets = [];
// Count bouquets and identify unknowns
orders.forEach(bouquet => {
if (flowerData[bouquet]) {
bouquetCounts[bouquet] = (bouquetCounts[bouquet] || 0) + 1;
} else {
if (!unknownBouquets.includes(bouquet)) {
unknownBouquets.push(bouquet);
}
}
});
// Alert about unknown bouquets
if (unknownBouquets.length > 0) {
const unknownCount = unknownBouquets.length;
const knownCount = Object.keys(bouquetCounts).length;
let message = `Found ${unknownCount} unknown bouquet(s):nn`;
message += unknownBouquets.slice(0, 5).join(‘n’);
if (unknownBouquets.length > 5) {
message += `n… and ${unknownBouquets.length – 5} more`;
}
message += `nnOnly ${knownCount} recognized bouquet(s) will be calculated.`;
message += `nnClick OK to continue or Cancel to fix the names.`;
const proceed = confirm(message);
if (!proceed) {
return;
}
}
// Calculate flower totals
const flowerTotals = {};
let totalFlowers = 0;
Object.entries(bouquetCounts).forEach(([bouquetName, count]) => {
Object.entries(flowerData[bouquetName]).forEach(([flower, quantity]) => {
const totalNeeded = quantity * count;
flowerTotals[flower] = (flowerTotals[flower] || 0) + totalNeeded;
totalFlowers += totalNeeded;
});
});
// Display results with unknown count
displayResults(orders, bouquetCounts, flowerTotals, totalFlowers, unknownBouquets.length);
}
// ========== MODIFIED DISPLAY RESULTS ==========
function displayResults(orders, bouquetCounts, flowerTotals, totalFlowers, unknownCount) {
const resultsSection = document.getElementById(‘resultsSection’);
const orderCount = document.getElementById(‘orderCount’);
const uniqueBouquets = document.getElementById(‘uniqueBouquets’);
const unknownOrders = document.getElementById(‘unknownOrders’);
const unknownOrdersCount = document.getElementById(‘unknownOrdersCount’);
const tableBody = document.getElementById(‘flowerTableBody’);
// Calculate statistics
const totalOrders = orders.length;
const uniqueKnownBouquets = Object.keys(bouquetCounts).length;
const knownOrders = Object.values(bouquetCounts).reduce((a, b) => a + b, 0);
// Update display
orderCount.textContent = `Total Orders: ${totalOrders}`;
uniqueBouquets.textContent = `Unique Bouquet Types: ${uniqueKnownBouquets}`;
// Show unknown count if any
if (unknownCount > 0) {
unknownOrders.style.display = ‘block’;
unknownOrdersCount.textContent = unknownCount;
} else {
unknownOrders.style.display = ‘none’;
}
// Clear and populate table
tableBody.innerHTML = ”;
const sortedFlowers = Object.entries(flowerTotals)
.sort(([,a], [,b]) => b – a);
sortedFlowers.forEach(([flower, total]) => {
const row = document.createElement(‘tr’);
row.innerHTML = `
${flower} |
${total} |
`;
tableBody.appendChild(row);
});
// Add total row
const totalRow = document.createElement(‘tr’);
totalRow.className = ‘total-row’;
totalRow.innerHTML = `
Total Flowers Needed |
${totalFlowers} |
`;
tableBody.appendChild(totalRow);
// Show results section
resultsSection.classList.remove(‘hidden’);
// Scroll to results
resultsSection.scrollIntoView({ behavior: ‘smooth’ });
}
// ========== KEEP ALL YOUR EXISTING FUNCTIONS ==========
// All your original functions stay exactly the same
function showCopyMethods() {
const copyMethods = document.getElementById(‘copyMethods’);
const allProducts = document.getElementById(‘allProducts’);
copyMethods.classList.toggle(‘hidden’);
allProducts.classList.add(‘hidden’);
}
function showAllProducts() {
const allProducts = document.getElementById(‘allProducts’);
const copyMethods = document.getElementById(‘copyMethods’);
allProducts.innerHTML = ‘
Available Products (Tap to Copy):
‘;
Object.keys(flowerData).forEach(product => {
const productItem = document.createElement(‘div’);
productItem.className = ‘product-item’;
productItem.textContent = product;
productItem.onclick = function() {
copyToClipboard(product);
alert(`Copied: ${product}`);
};
allProducts.appendChild(productItem);
});
allProducts.classList.toggle(‘hidden’);
copyMethods.classList.add(‘hidden’);
}
function copyToClipboard(text) {
const textarea = document.createElement(‘textarea’);
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand(‘copy’);
document.body.removeChild(textarea);
}
function cleanInput() {
const input = document.getElementById(‘orderInput’);
let text = input.value;
text = text.replace(/r/g, ”)
.split(‘n’)
.map(line => line.trim())
.filter(line => line.length > 0)
.join(‘n’);
input.value = text;
updateStats(); // Update stats after cleaning
alert(‘Text cleaned and formatted!’);
}
function extractProductNames() {
const input = document.getElementById(‘orderInput’);
let text = input.value;
const lines = text.split(‘n’).filter(line => line.trim().length > 0);
const productNames = Object.keys(flowerData);
const foundProducts = [];
lines.forEach(line => {
productNames.forEach(product => {
if (line.includes(product)) {
foundProducts.push(product);
}
});
});
if (foundProducts.length > 0) {
input.value = foundProducts.join(‘n’);
updateStats(); // Update stats
alert(`Found and extracted ${foundProducts.length} product names!`);
} else {
alert(‘No recognizable product names found. Please check your input format.’);
}
}
function copyResults() {
const rows = document.querySelectorAll(‘#flowerTableBody tr’);
let text = ‘Flower TypetQuantity Neededn’;
rows.forEach(row => {
if (row.style.display !== ‘none’) {
const cells = row.querySelectorAll(‘td’);
if (cells.length === 2) {
text += `${cells[0].textContent}t${cells[1].textContent}n`;
}
}
});
copyToClipboard(text);
alert(‘Results copied to clipboard!’);
}
function filterFlowers() {
const filter = document.getElementById(‘flowerFilter’).value.toLowerCase();
const rows = document.querySelectorAll(‘#flowerTableBody tr’);
rows.forEach(row => {
const flowerName = row.cells[0].textContent.toLowerCase();
if (flowerName.includes(filter) || row.classList.contains(‘total-row’)) {
row.style.display = ”;
} else {
row.style.display = ‘none’;
}
});
}
function clearAll() {
document.getElementById(‘orderInput’).value = ”;
document.getElementById(‘resultsSection’).classList.add(‘hidden’);
document.getElementById(‘flowerFilter’).value = ”;
updateStats(); // Reset stats
}
function loadSampleData() {
const sampleData = `Apricot
Elegant
Jazreel
Sunday
Valentine’s Carrie
Valentine’s BB
Valentine’s Beauty Queen`;
document.getElementById(‘orderInput’).value = sampleData;
updateStats(); // Update stats for sample data
}
function exportToCSV() {
const rows = document.querySelectorAll(‘#flowerTableBody tr’);
let csv = ‘Flower Type,Quantity Neededn’;
rows.forEach(row => {
if (row.style.display !== ‘none’) {
const cells = row.querySelectorAll(‘td’);
if (cells.length === 2) {
csv += `”${cells[0].textContent}”,”${cells[1].textContent}”n`;
}
}
});
const blob = new Blob([csv], { type: ‘text/csv’ });
const url = window.URL.createObjectURL(blob);
const a = document.createElement(‘a’);
a.setAttribute(‘hidden’, ”);
a.setAttribute(‘href’, url);
a.setAttribute(‘download’, ‘flower_requirements.csv’);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
function printResults() {
const printContent = document.getElementById(‘resultsSection’).innerHTML;
const originalContent = document.body.innerHTML;
document.body.innerHTML = `
Florist Flower Calculator – Order Summary
${printContent}
`;
window.print();
document.body.innerHTML = originalContent;
window.location.reload();
}
// Keyboard shortcut
document.addEventListener(‘keydown’, function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === ‘Enter’) {
calculateFlowers();
}
});
// Initialize stats on page load
document.addEventListener(‘DOMContentLoaded’, function() {
updateStats();
// Add tooltip explanation for Unique Bouquet Types
const uniqueElement = document.getElementById(‘uniqueBouquets’);
uniqueElement.title = “Example: If you have ‘Apricot, Apricot, Elegant’ β Unique Bouquet Types = 2 (counts each different design only once)”;
});