SmartCane/webapps/sugar_mill_locator/index.html
2026-01-27 10:32:39 +01:00

574 lines
19 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sugar Cane Mills - East & South Africa & Mexico</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw@1.0.4/dist/leaflet.draw.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-measure@3.1.0/dist/leaflet-measure.css" />
<link rel="stylesheet" href="../theme.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #faf8f3;
height: 100vh;
display: flex;
flex-direction: column;
}
header {
background: linear-gradient(135deg, var(--sc-primary) 0%, var(--sc-primary-light) 100%);
color: white;
padding: 15px 20px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
display: flex;
justify-content: space-between;
align-items: center;
}
h1 {
font-size: 24px;
font-weight: 600;
flex: 1;
text-align: center;
}
.back-btn {
background: rgba(255,255,255,0.2);
color: white;
border: 1px solid rgba(255,255,255,0.3);
padding: 8px 12px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background 0.3s ease;
}
.back-btn:hover {
background: rgba(255,255,255,0.3);
}
.header-controls {
display: flex;
gap: 10px;
align-items: center;
}
.mode-toggle {
display: flex;
gap: 5px;
background: rgba(255,255,255,0.2);
padding: 5px;
border-radius: 5px;
}
.tools-group {
display: flex;
gap: 8px;
background: rgba(255,255,255,0.2);
padding: 5px;
border-radius: 5px;
}
.mode-btn {
padding: 8px 12px;
border: none;
background: rgba(255,255,255,0.1);
color: white;
border-radius: 3px;
cursor: pointer;
font-size: 13px;
transition: all 0.3s;
}
.mode-btn.active {
background: rgba(255,255,255,0.3);
font-weight: 600;
}
.mode-btn:hover {
background: rgba(255,255,255,0.2);
}
.container {
display: flex;
flex: 1;
overflow: hidden;
height: 100%;
background: white;
}
#map {
flex: 1;
position: relative;
background: white;
width: 100%;
height: 100%;
}
.panel {
width: 340px;
background: var(--sc-light);
border-left: 1px solid var(--sc-border);
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: -2px 0 8px rgba(0,0,0,0.08);
}
.panel-header {
background: linear-gradient(135deg, var(--sc-primary) 0%, var(--sc-primary-light) 100%);
color: white;
padding: 15px;
font-weight: 600;
font-size: 14px;
flex-shrink: 0;
}
.panel-content {
flex: 1;
overflow-y: auto;
padding: 15px;
display: flex;
flex-direction: column;
}
.panel-section {
margin-bottom: 20px;
}
.panel-section:last-child {
margin-bottom: 0;
}
.section-title {
font-weight: 600;
font-size: 13px;
color: var(--sc-text);
margin-bottom: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.country-item {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
font-size: 13px;
color: var(--sc-text);
}
.country-color {
width: 14px;
height: 14px;
border-radius: 50%;
flex-shrink: 0;
border: 1px solid rgba(0,0,0,0.2);
}
.country-count {
font-size: 11px;
color: #999;
margin-left: auto;
flex-shrink: 0;
}
.size-legend {
padding-top: 12px;
border-top: 1px solid #ddd;
}
.size-item {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
font-size: 12px;
color: #555;
}
.size-circle {
border-radius: 50%;
background: var(--sc-primary);
opacity: 0.6;
flex-shrink: 0;
}
.alert {
padding: 12px;
border-radius: 5px;
margin-bottom: 12px;
font-size: 12px;
line-height: 1.5;
}
.alert-info {
background: #e7f3ff;
color: #004085;
border: 1px solid #b3d9ff;
}
.btn-group {
display: flex;
flex-direction: column;
gap: 8px;
}
button {
padding: 10px 12px;
border: none;
border-radius: 5px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background: var(--sc-primary-light);
color: white;
}
.btn-primary:hover {
background: var(--sc-primary);
}
.btn-secondary {
background: #f0f0f0;
color: #333;
border: 1px solid #ddd;
}
.btn-secondary:hover {
background: #e8e8e8;
}
.btn-danger {
background: #ff6b6b;
color: white;
}
.btn-danger:hover {
background: #ee5a52;
}
#showFormBtn, #exportBtn, #clearDrawnBtn {
display: none !important;
}
#showFormBtn.visible, #exportBtn.visible, #clearDrawnBtn.visible {
display: block !important;
}
.drawn-items-list {
background: #f8f9fa;
border-radius: 4px;
padding: 10px;
max-height: 150px;
overflow-y: auto;
margin-bottom: 10px;
font-size: 12px;
border: 1px solid #e0e0e0;
}
.drawn-item {
background: white;
padding: 8px;
margin-bottom: 5px;
border-radius: 3px;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
border-left: 3px solid var(--sc-primary-light);
}
.drawn-item-btn {
background: none;
border: none;
color: #ff6b6b;
cursor: pointer;
padding: 0;
font-size: 14px;
line-height: 1;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 2000;
align-items: center;
justify-content: center;
}
.modal.active {
display: flex;
}
.modal-content {
background: white;
border-radius: 8px;
padding: 25px;
width: 90%;
max-width: 500px;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 5px 25px rgba(0,0,0,0.3);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.modal-header h2 {
font-size: 20px;
color: #333;
}
.close-btn {
background: none;
border: none;
font-size: 28px;
color: #666;
cursor: pointer;
padding: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
font-weight: 500;
margin-bottom: 5px;
color: #333;
font-size: 13px;
}
input, select, textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 13px;
font-family: inherit;
}
textarea {
resize: vertical;
min-height: 60px;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: var(--sc-primary-light);
box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.1);
}
.form-actions {
display: flex;
gap: 10px;
margin-top: 20px;
}
.form-actions button {
flex: 1;
}
.alert-success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.divider {
height: 1px;
background: #ddd;
margin: 10px 0;
}
</style>
</head>
<body>
<script>
if (sessionStorage.getItem('authenticated') !== 'true') {
window.location.href = '../login.html';
}
</script>
<header>
<button class="back-btn" onclick="window.location.href='../';" title="Back to main tools">← Back</button>
<h1>🗺️ Sugar Cane Mills - East & South Africa & Mexico</h1>
<div class="header-controls">
<div class="mode-toggle">
<button class="mode-btn active" data-mode="view">View</button>
<button class="mode-btn" data-mode="draw">Draw & Add</button>
</div>
<div class="tools-group">
<button class="mode-btn" id="measureBtn" title="Measure distance between points">📏 Measure</button>
<button class="mode-btn" id="mapToggleBtn" title="Switch between map and satellite">🛰️ Satellite</button>
</div>
</div>
</header>
<div class="container">
<div id="map"></div>
<div class="panel">
<div class="panel-header">Controls & Information</div>
<div class="panel-content">
<!-- Legend Section (View Mode) -->
<div id="viewModePanel" class="panel-section">
<div class="section-title">🔍 Search & Filter</div>
<div style="margin-bottom: 12px;">
<input type="text" id="searchInput" placeholder="Search mill name..." style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; margin-bottom: 8px;">
<select id="countryFilter" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; margin-bottom: 8px;">
<option value="">All Countries</option>
</select>
<input type="number" id="minProduction" placeholder="Min production (tons/year)" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; margin-bottom: 8px;">
<button class="btn-secondary" id="resetFiltersBtn" style="width: 100%; padding: 8px;">Reset Filters</button>
</div>
<div class="section-title" style="margin-top: 15px;">Mills by Country</div>
<div id="legendContainer"></div>
<div class="size-legend">
<div class="section-title" style="margin-bottom: 12px; margin-top: 15px;">Circle Size: Annual Production</div>
<div class="size-item">
<div class="size-circle" style="width: 12px; height: 12px;"></div>
<span>Small: &lt;50k tons</span>
</div>
<div class="size-item">
<div class="size-circle" style="width: 20px; height: 20px;"></div>
<span>Medium: 50-150k tons</span>
</div>
<div class="size-item">
<div class="size-circle" style="width: 30px; height: 30px;"></div>
<span>Large: &gt;150k tons</span>
</div>
</div>
</div>
<!-- Measurement Panel -->
<div id="measurementPanel" class="panel-section" style="display: none !important; border: 2px solid #2596be; padding: 12px; border-radius: 4px; background: #f0f8ff; flex-direction: column;">
<div class="section-title" style="color: #2596be; margin-bottom: 12px;">📏 Measurement Points</div>
<div id="measurementList" style="background: white; border-radius: 4px; padding: 10px; margin-bottom: 12px; flex: 1; overflow-y: auto; font-size: 12px;">
<p style="color: #999;">Click on the map to add measurement points</p>
</div>
<div class="section-title" style="color: #2596be; font-size: 12px; margin-bottom: 8px;">Total Distance</div>
<div id="totalDistance" style="background: white; padding: 10px; border-radius: 4px; font-size: 14px; font-weight: 600; color: #2596be; text-align: center; margin-bottom: 12px;">
0.00 km
</div>
<button class="btn-secondary" id="resetMeasurementBtn" style="width: 100%; background: #ff6b6b; color: white; border: none;">Reset Measurement</button>
</div>
<!-- Draw Mode Section -->
<div id="drawModePanel" class="panel-section" style="display: none;">
<div class="alert alert-info">
Use the drawing tools to add new mill locations. Click "Show Form" to enter details.
</div>
<div class="section-title">Drawn Points</div>
<div id="drawnItemsList" class="drawn-items-list">
<p style="color: #999; font-size: 12px;">No items drawn yet</p>
</div>
<div class="btn-group">
<button class="btn-secondary" id="showFormBtn">Show Form</button>
<button class="btn-secondary" id="exportBtn">Submit New Mills</button>
<button class="btn-danger" id="clearDrawnBtn">Clear All</button>
</div>
</div>
</div>
</div>
</div>
<!-- Edit Modal -->
<div id="editModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Edit Mill Details</h2>
<button class="close-btn" onclick="closeModal('editModal')">&times;</button>
</div>
<form id="editForm">
<div class="form-group">
<label>Mill/Factory Name *</label>
<input type="text" id="editMill" required>
</div>
<div class="form-group">
<label>Country *</label>
<input type="text" id="editCountry" required>
</div>
<div class="form-group">
<label>Company</label>
<input type="text" id="editCompany">
</div>
<div class="form-group">
<label>Province/Region</label>
<input type="text" id="editProvince">
</div>
<div class="form-group">
<label>Latitude *</label>
<input type="number" id="editLat" step="0.0001" required>
</div>
<div class="form-group">
<label>Longitude *</label>
<input type="number" id="editLng" step="0.0001" required>
</div>
<div class="form-group">
<label>Crushing Capacity (tons/year)</label>
<input type="number" id="editCapacity">
</div>
<div class="form-group">
<label>Annual Sugar Production (tons)</label>
<input type="number" id="editProduction">
</div>
<div class="form-group">
<label>Notes</label>
<textarea id="editNotes"></textarea>
</div>
<div class="form-group">
<label>Data Year</label>
<input type="number" id="editYear" min="2000" max="2099">
</div>
<div class="form-group">
<label>📝 Annotations (for internal use)</label>
<textarea id="editAnnotations" style="min-height: 80px; font-size: 12px; color: #666;"></textarea>
<small style="color: #999;">Add any internal notes, verification status, or observations</small>
</div>
<div class="form-actions">
<button type="button" class="btn-secondary" onclick="closeModal('editModal')">Cancel</button>
<button type="submit" class="btn-primary">Save</button>
</div>
</form>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-draw@1.0.4/dist/leaflet.draw.js"></script>
<script src="https://unpkg.com/leaflet-measure@3.1.0/dist/leaflet-measure.umd.js"></script>
<script src="google-sheets-config.js"></script>
<script src="app.js"></script>
</body>
</html>