lokeshloki143 commited on
Commit
a6034d3
·
verified ·
1 Parent(s): 83701f1

Update templates/combined_summary.html

Browse files
Files changed (1) hide show
  1. templates/combined_summary.html +149 -172
templates/combined_summary.html CHANGED
@@ -149,7 +149,7 @@
149
  -webkit-text-fill-color: #333;
150
  }
151
  .fixed-top-bar {
152
- position: relative;
153
  top: 0;
154
  left: 0;
155
  width: 100%;
@@ -158,9 +158,18 @@
158
  color: white;
159
  padding: 15px;
160
  display: flex;
161
- justify-content: space-between;
162
  align-items: center;
163
  z-index: 1000;
 
 
 
 
 
 
 
 
 
164
  }
165
  .back-arrow-container {
166
  position: absolute;
@@ -338,23 +347,82 @@
338
  color: #6c757d;
339
  margin-top: 20px;
340
  }
341
- @media (max-width: 576px) {
342
  .fixed-top-bar {
343
- height: 60px;
 
344
  padding: 10px;
345
  }
346
  .back-arrow-container {
347
- left: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  }
349
  .back-arrow {
350
  width: 32px;
351
  height: 32px;
352
  font-size: 18px;
353
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  .search-bar-container {
355
- width: calc(80% - 50px);
356
- max-width: calc(100% - 50px);
357
- left: 50px;
358
  }
359
  .search-bar-container input {
360
  padding: 6px 35px 6px 35px;
@@ -369,20 +437,12 @@
369
  right: 12px;
370
  font-size: 16px;
371
  }
372
- .avatar-dropdown-container {
373
- right: 10px;
374
- }
375
- .avatar-icon {
376
- width: 40px;
377
- height: 40px;
378
- font-size: 20px;
379
- }
380
  .dropdown-menu {
381
- width: 220px;
382
  }
383
  .dropdown-menu .dropdown-item {
384
- padding: 12px 16px;
385
- font-size: 15px;
386
  }
387
  .menu-heading {
388
  font-size: 1.5rem;
@@ -435,6 +495,14 @@
435
  <a href="{{ url_for('menu.menu') }}" class="back-arrow" aria-label="Back to Menu">
436
  <i class="bi bi-arrow-left"></i>
437
  </a>
 
 
 
 
 
 
 
 
438
  </div>
439
  <div class="avatar-dropdown-container">
440
  <div class="avatar-icon">
@@ -444,21 +512,10 @@
444
  <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i> View Profile</a>
445
  <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i> Order History</a>
446
  <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-file-earmark-text"></i> MY Summary</a>
447
- <a href="{{ url_for('logout') }}" class="dropdown-item" id="logoutLink"><i class="bi bi-box-arrow-right"></i> Logout</a>
448
  </div>
449
  </div>
450
- <div class="search-bar-container">
451
- <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
452
- <i class="bi bi-search search-icon"></i>
453
- <i class="bi bi-mic mic-icon" id="micIcon"></i>
454
- <div class="search-popup" id="searchPopup"></div>
455
- </div>
456
- </div>
457
 
458
- <!-- Timer and Success Message Container -->
459
- <div id="orderTimerContainer" style="display: none; text-align: center; margin-top: 20px;">
460
- <div id="orderTimer" style="font-size: 1.5rem; font-weight: bold; color: #FFA07A;"></div>
461
- <div id="orderSuccessMessage" style="font-size: 1.5rem; font-weight: bold; color: #0FAA39; display: none;">Order Successfully Placed!</div>
462
  </div>
463
 
464
  <div class="container mt-4">
@@ -531,7 +588,7 @@
531
 
532
  function selectItem(itemName, section) {
533
  localStorage.setItem('selectedItem', JSON.stringify({ name: itemName, section: section }));
534
- window.location.href = '/menu';
535
  }
536
 
537
  function filterMenuItems(query) {
@@ -584,77 +641,6 @@
584
  searchPopup.style.display = 'block';
585
  }
586
 
587
- // Timer and Success Message Functions
588
- let orderTimerInterval;
589
- let orderDurationInSeconds = 0;
590
- let orderStartTime = null; // To store the start time for persistence
591
-
592
- function startOrderTimer(durationInSeconds) {
593
- orderDurationInSeconds = durationInSeconds;
594
- orderStartTime = Date.now(); // Record the start time
595
- localStorage.setItem('orderTimer', JSON.stringify({
596
- startTime: orderStartTime,
597
- duration: orderDurationInSeconds
598
- }));
599
-
600
- const timerElement = document.getElementById('orderTimer');
601
- const successMessageElement = document.getElementById('orderSuccessMessage');
602
- const timerContainer = document.getElementById('orderTimerContainer');
603
-
604
- if (!timerElement || !successMessageElement || !timerContainer) {
605
- console.error("Timer elements not found.");
606
- return;
607
- }
608
-
609
- timerContainer.style.display = 'block';
610
- successMessageElement.style.display = 'none';
611
- timerElement.style.display = 'block'; // Ensure timer is visible
612
-
613
- let secondsRemaining = orderDurationInSeconds;
614
-
615
- timerElement.innerText = formatTime(secondsRemaining);
616
-
617
- // Clear any existing interval before starting a new one
618
- if (orderTimerInterval) {
619
- clearInterval(orderTimerInterval);
620
- }
621
-
622
- orderTimerInterval = setInterval(() => {
623
- secondsRemaining--;
624
-
625
- if (secondsRemaining <= 0) {
626
- clearInterval(orderTimerInterval);
627
- timerElement.style.display = 'none';
628
- successMessageElement.style.display = 'block';
629
- // Hide the success message and container after a few seconds
630
- setTimeout(() => {
631
- timerContainer.style.display = 'none';
632
- successMessageElement.style.display = 'none';
633
- // We don't reset timerElement.style.display to 'block' here
634
- // because a new timer should only start with a new order.
635
- }, 5000); // Hide after 5 seconds
636
- localStorage.removeItem('orderTimer'); // Clear finished timer data
637
- } else {
638
- timerElement.innerText = formatTime(secondsRemaining);
639
- }
640
- }, 1000);
641
- }
642
-
643
- function formatTime(seconds) {
644
- const minutes = Math.floor(seconds / 60);
645
- const remainingSeconds = seconds % 60;
646
- const formattedMinutes = String(minutes).padStart(2, '0');
647
- const formattedSeconds = String(remainingSeconds).padStart(2, '0');
648
- return `${formattedMinutes}:${formattedSeconds}`;
649
- }
650
-
651
- // Function to handle a new order being successfully placed
652
- // This is the function you will call from your order placement logic.
653
- function handleNewOrderPlaced(estimatedCompletionTimeInSeconds) {
654
- console.log("New order successful, starting timer...");
655
- startOrderTimer(estimatedCompletionTimeInSeconds);
656
- }
657
-
658
  document.addEventListener('DOMContentLoaded', function () {
659
  // Avatar Dropdown
660
  const avatarContainer = document.querySelector('.avatar-dropdown-container');
@@ -675,15 +661,6 @@
675
  });
676
  });
677
 
678
- // Logout Link - Clear timer on logout
679
- const logoutLink = document.getElementById('logoutLink');
680
- if (logoutLink) {
681
- logoutLink.addEventListener('click', function() {
682
- localStorage.removeItem('orderTimer'); // Clear timer on logout
683
- });
684
- }
685
-
686
-
687
  // Search Bar Functionality
688
  const searchBar = document.getElementById('searchBar');
689
  const searchPopup = document.getElementById('searchPopup');
@@ -752,71 +729,71 @@
752
  updateCartUI(cart);
753
  });
754
 
755
- // --- Timer Logic Integration ---
756
- // Check local storage for an existing timer when the page loads.
757
- const savedOrderTimer = localStorage.getItem('orderTimer');
758
- if (savedOrderTimer) {
759
- const timerData = JSON.parse(savedOrderTimer);
760
- const now = Date.now();
761
- const elapsed = Math.floor((now - timerData.startTime) / 1000);
762
- const remaining = timerData.duration - elapsed;
763
-
764
- const timerElement = document.getElementById('orderTimer');
765
- const successMessageElement = document.getElementById('orderSuccessMessage');
766
- const timerContainer = document.getElementById('orderTimerContainer');
767
-
768
- if (remaining > 0) {
769
- // Resume the timer
770
- orderDurationInSeconds = timerData.duration; // Load duration
771
- orderStartTime = timerData.startTime; // Load start time
772
- timerContainer.style.display = 'block';
773
- successMessageElement.style.display = 'none';
774
- timerElement.style.display = 'block';
775
- let secondsRemaining = remaining;
776
- timerElement.innerText = formatTime(secondsRemaining);
777
-
778
- // Clear any existing interval before resuming
779
- if (orderTimerInterval) {
780
- clearInterval(orderTimerInterval);
781
- }
782
 
783
- orderTimerInterval = setInterval(() => {
784
- secondsRemaining--;
785
-
786
- if (secondsRemaining <= 0) {
787
- clearInterval(orderTimerInterval);
788
- timerElement.style.display = 'none';
789
- successMessageElement.style.display = 'block';
790
- setTimeout(() => {
791
- timerContainer.style.display = 'none';
792
- successMessageElement.style.display = 'none';
793
- }, 5000); // Hide success after 5 seconds
794
- localStorage.removeItem('orderTimer'); // Clear finished timer data
795
- } else {
796
- timerElement.innerText = formatTime(secondsRemaining);
797
- }
798
- }, 1000);
799
-
800
- } else {
801
- // Timer has already finished, show success message briefly
802
- if (timerContainer && successMessageElement && timerElement) {
803
- timerContainer.style.display = 'block';
804
- timerElement.style.display = 'none'; // Timer is finished
805
- successMessageElement.style.display = 'block';
806
  setTimeout(() => {
807
- timerContainer.style.display = 'none';
808
- successMessageElement.style.display = 'none';
809
- }, 3000); // Show success for 3 seconds
810
- localStorage.removeItem('orderTimer'); // Clear finished timer data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
811
  }
812
  }
813
  }
814
-
815
- // --- Example of how you would trigger the timer (replace with your actual logic) ---
816
- // This is for demonstration only. You should call handleNewOrderPlaced()
817
- // from your code that handles a successful order submission.
818
- // For example, after a successful API call to create an order.
819
- // handleNewOrderPlaced(45); // Simulate a new order with a 45-second timer
820
  });
821
  </script>
822
  </body>
 
149
  -webkit-text-fill-color: #333;
150
  }
151
  .fixed-top-bar {
152
+ position: relative; /* Change to relative to allow timer positioning */
153
  top: 0;
154
  left: 0;
155
  width: 100%;
 
158
  color: white;
159
  padding: 15px;
160
  display: flex;
161
+ justify-content: space-between; /* Space out items */
162
  align-items: center;
163
  z-index: 1000;
164
+ }
165
+ /* Style for the timer */
166
+ #orderTimer {
167
+ color: white;
168
+ font-weight: bold;
169
+ margin-left: auto; /* Push timer to the right */
170
+ margin-right: 80px; /* Add some space before avatar */
171
+ font-size: 1.1em;
172
+ display: none; /* Initially hidden */
173
  }
174
  .back-arrow-container {
175
  position: absolute;
 
347
  color: #6c757d;
348
  margin-top: 20px;
349
  }
350
+ @media (max-width: 768px) { /* Adjust breakpoint for better timer placement */
351
  .fixed-top-bar {
352
+ height: auto; /* Allow height to adjust */
353
+ flex-direction: column; /* Stack items vertically */
354
  padding: 10px;
355
  }
356
  .back-arrow-container {
357
+ position: relative; /* Adjust positioning for stacking */
358
+ left: auto;
359
+ top: auto;
360
+ transform: none;
361
+ width: 100%;
362
+ justify-content: flex-start;
363
+ margin-bottom: 10px;
364
+ }
365
+ .avatar-dropdown-container {
366
+ position: absolute; /* Keep avatar positioned */
367
+ right: 10px;
368
+ top: 10px; /* Adjust top position */
369
+ transform: none;
370
+ z-index: 1001; /* Ensure avatar is above others */
371
+ }
372
+ #orderTimer {
373
+ position: relative; /* Adjust positioning for stacking */
374
+ margin-left: 0;
375
+ margin-right: 0;
376
+ text-align: center;
377
+ width: 100%;
378
+ margin-bottom: 10px;
379
+ }
380
+ .search-bar-container {
381
+ position: relative; /* Adjust positioning for stacking */
382
+ left: auto;
383
+ top: auto;
384
+ transform: none;
385
+ width: 100%;
386
+ max-width: 100%;
387
+ margin-bottom: 10px;
388
+ }
389
+ .search-bar-container input {
390
+ padding: 8px 40px 8px 40px;
391
+ font-size: 16px;
392
+ border-radius: 25px;
393
+ }
394
+ .menu-heading {
395
+ font-size: 1.8rem; /* Adjust heading size */
396
+ }
397
+ }
398
+
399
+ @media (max-width: 576px) {
400
+ .fixed-top-bar {
401
+ padding: 8px; /* Reduce padding */
402
+ }
403
+ .back-arrow-container {
404
+ margin-bottom: 8px;
405
  }
406
  .back-arrow {
407
  width: 32px;
408
  height: 32px;
409
  font-size: 18px;
410
  }
411
+ .avatar-dropdown-container {
412
+ right: 8px;
413
+ top: 8px;
414
+ }
415
+ .avatar-icon {
416
+ width: 36px;
417
+ height: 36px;
418
+ font-size: 18px;
419
+ }
420
+ #orderTimer {
421
+ font-size: 1em; /* Further reduce timer font size */
422
+ margin-bottom: 8px;
423
+ }
424
  .search-bar-container {
425
+ margin-bottom: 8px;
 
 
426
  }
427
  .search-bar-container input {
428
  padding: 6px 35px 6px 35px;
 
437
  right: 12px;
438
  font-size: 16px;
439
  }
 
 
 
 
 
 
 
 
440
  .dropdown-menu {
441
+ width: 200px; /* Adjust dropdown width */
442
  }
443
  .dropdown-menu .dropdown-item {
444
+ padding: 10px 14px;
445
+ font-size: 14px;
446
  }
447
  .menu-heading {
448
  font-size: 1.5rem;
 
495
  <a href="{{ url_for('menu.menu') }}" class="back-arrow" aria-label="Back to Menu">
496
  <i class="bi bi-arrow-left"></i>
497
  </a>
498
+ </div>
499
+ <!-- Timer Display Area -->
500
+ <div id="orderTimer"></div>
501
+ <div class="search-bar-container">
502
+ <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
503
+ <i class="bi bi-search search-icon"></i>
504
+ <i class="bi bi-mic mic-icon" id="micIcon"></i>
505
+ <div class="search-popup" id="searchPopup"></div>
506
  </div>
507
  <div class="avatar-dropdown-container">
508
  <div class="avatar-icon">
 
512
  <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i> View Profile</a>
513
  <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i> Order History</a>
514
  <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-file-earmark-text"></i> MY Summary</a>
515
+ <a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i> Logout</a>
516
  </div>
517
  </div>
 
 
 
 
 
 
 
518
 
 
 
 
 
519
  </div>
520
 
521
  <div class="container mt-4">
 
588
 
589
  function selectItem(itemName, section) {
590
  localStorage.setItem('selectedItem', JSON.stringify({ name: itemName, section: section }));
591
+ window.location.href = '/menu'; // Assuming '/menu' is the detail page
592
  }
593
 
594
  function filterMenuItems(query) {
 
641
  searchPopup.style.display = 'block';
642
  }
643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  document.addEventListener('DOMContentLoaded', function () {
645
  // Avatar Dropdown
646
  const avatarContainer = document.querySelector('.avatar-dropdown-container');
 
661
  });
662
  });
663
 
 
 
 
 
 
 
 
 
 
664
  // Search Bar Functionality
665
  const searchBar = document.getElementById('searchBar');
666
  const searchPopup = document.getElementById('searchPopup');
 
729
  updateCartUI(cart);
730
  });
731
 
732
+ // --- Timer Logic ---
733
+ const orderTimerElement = document.getElementById('orderTimer');
734
+ // Get timestamp from Flask template (passed from server)
735
+ const completionTimeTimestamp = {{ order_completion_time | default('null') }};
736
+
737
+ let timerInterval = null; // Variable to hold the interval ID
738
+
739
+ function startTimer(timestamp) {
740
+ orderTimerElement.style.display = 'block';
741
+ const completionTime = new Date(timestamp * 1000); // Convert timestamp to Date object
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
 
743
+ function updateTimer() {
744
+ const now = new Date();
745
+ const timeRemaining = completionTime - now;
746
+
747
+ if (timeRemaining <= 0) {
748
+ orderTimerElement.innerText = 'Order Ready!';
749
+ // Clear timer and local storage
750
+ clearInterval(timerInterval);
751
+ localStorage.removeItem('orderCompletionTime');
752
+ // Refresh the page after a short delay
 
 
 
 
 
 
 
 
 
 
 
 
 
753
  setTimeout(() => {
754
+ window.location.reload();
755
+ }, 2000); // Refresh after 2 seconds
756
+ return;
757
+ }
758
+
759
+ const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
760
+ const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
761
+
762
+ // Add leading zeros if needed
763
+ const displayMinutes = String(minutes).padStart(2, '0');
764
+ const displaySeconds = String(seconds).padStart(2, '0');
765
+
766
+ orderTimerElement.innerText = `Ready In: ${displayMinutes}m ${displaySeconds}s`;
767
+ }
768
+
769
+ // Initial call to display the timer immediately
770
+ updateTimer();
771
+
772
+ // Update the timer every second
773
+ timerInterval = setInterval(updateTimer, 1000);
774
+
775
+ // Store completion time in local storage for persistence
776
+ localStorage.setItem('orderCompletionTime', timestamp);
777
+ }
778
+
779
+ // Check if a completion time was passed from the server (new order)
780
+ if (completionTimeTimestamp) {
781
+ startTimer(completionTimeTimestamp);
782
+ } else {
783
+ // If not from server, check local storage for an existing timer
784
+ const storedCompletionTime = localStorage.getItem('orderCompletionTime');
785
+ if (storedCompletionTime) {
786
+ const parsedCompletionTime = parseFloat(storedCompletionTime);
787
+ // Ensure stored time is valid and in the future
788
+ if (!isNaN(parsedCompletionTime) && new Date(parsedCompletionTime * 1000) > new Date()) {
789
+ startTimer(parsedCompletionTime);
790
+ } else {
791
+ // Clear invalid or past timestamp from local storage
792
+ localStorage.removeItem('orderCompletionTime');
793
  }
794
  }
795
  }
796
+ // --- End Timer Logic ---
 
 
 
 
 
797
  });
798
  </script>
799
  </body>