GoogleCalc commited on
Commit
6b843a5
·
verified ·
1 Parent(s): 22b81d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +114 -180
app.py CHANGED
@@ -597,7 +597,7 @@ Click and share to calculate your Poultry feed needs:
597
 
598
 
599
  # ============================================================
600
- # FEED CALCULATION
601
  # ============================================================
602
 
603
  def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_code, breed, request: gr.Request):
@@ -676,7 +676,7 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
676
  currency_symbol, expected_weight, flock_weight
677
  )
678
 
679
- # Output HTML
680
  starter_bags_display = f"{starter_bags:.1f}"
681
  finisher_bags_display = f"{finisher_bags:.1f}"
682
 
@@ -684,126 +684,126 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
684
  if days:
685
  age_text += f" + {days} day{'s' if days != 1 else ''}"
686
 
687
- html = f"""
688
- <div style="font-size: 17px; line-height: 1.8;">
689
 
690
- <div style="background: #f0fdf4; padding: 18px 22px; border-radius: 14px; border-left: 6px solid #22c55e; margin-bottom: 20px;">
691
- <div style="font-size: 13px; color: #16a34a; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;">Quick Answer</div>
692
-
693
- <!-- EXACT FEED - Boxed -->
694
- <div style="font-size: 20px; font-weight: 700; color: #166534;">
695
- Exact feed needed:
696
- <span style="display: inline-block; background: #166534; color: white; border-radius: 12px; padding: 4px 18px; font-size: 30px; font-weight: 900;">
697
- {total_bags:.1f}
698
- </span>
699
- bags of {bag_size:g} kg feed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
  </div>
701
-
702
- <!-- APPROXIMATE BAGS - Boxed -->
703
- <div style="font-size: 20px; font-weight: 700; color: #1e40af; margin-top: 6px;">
704
- Approximately:
705
- <span style="display: inline-block; background: #1e40af; color: white; border-radius: 12px; padding: 4px 18px; font-size: 26px; font-weight: 800;">
706
- {rounded_bags}
707
- </span>
708
- bags to purchase (rounded up)
 
 
 
 
 
 
 
 
 
 
 
 
709
  </div>
710
-
711
- <!-- BIRD COUNT - Boxed -->
712
- <div style="color: #374151; font-size: 16px; margin-top: 8px;">
713
- To raise
714
- <span style="display: inline-block; background: #fef3c7; border: 2px solid #f59e0b; border-radius: 10px; padding: 2px 14px; font-size: 18px; font-weight: 700; color: #92400e;">
715
- {birds:,}
716
- </span>
717
- {breed} broilers to
718
- <span style="display: inline-block; background: #fce4ec; border: 2px solid #ef4444; border-radius: 10px; padding: 2px 14px; font-size: 18px; font-weight: 700; color: #991b1b;">
719
- {age_text} ({total_days} days)
720
- </span>
721
  </div>
722
-
723
- <div style="margin-top: 8px; font-size: 13px;">
724
- <span style="background: {breed_color}; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600;">{breed}</span>
725
- <span style="background: #6b7280; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600; margin-left: 8px;">{country_name}</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
  </div>
727
- </div>
728
-
729
- <div style="margin-bottom: 16px;">
730
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Breakdown</div>
731
- <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 16px;">
732
- <tr style="border-bottom: 1px solid #e5e7eb;">
733
- <td style="padding: 10px 4px;"><strong>Starter</strong></td>
734
- <td style="padding: 10px 4px; text-align: right;">{starter_kg:,.1f} kg</td>
735
- <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #1e293b;">{starter_bags_display} bags</td>
736
- </tr>
737
- <tr style="border-bottom: 1px solid #e5e7eb;">
738
- <td style="padding: 10px 4px;"><strong>Finisher</strong></td>
739
- <td style="padding: 10px 4px; text-align: right;">{finisher_kg:,.1f} kg</td>
740
- <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #1e293b;">{finisher_bags_display} bags</td>
741
- </tr>
742
- <tr>
743
- <td style="padding: 10px 4px; font-weight: 700;">TOTAL</td>
744
- <td style="padding: 10px 4px; text-align: right; font-weight: 700;">{total_feed_kg:,.1f} kg</td>
745
- <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #166534;">{total_bags:.1f}</td>
746
- </tr>
747
- </table>
748
- </div>
749
-
750
- <div style="margin-bottom: 16px; background: #eff6ff; padding: 14px 18px; border-radius: 10px; border-left: 4px solid #3b82f6;">
751
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Cost</div>
752
- <div style="font-size: 32px; font-weight: 900; color: white;">
753
- <span style="display: inline-block; background: #1e40af; color: white; border-radius: 12px; padding: 4px 20px;">
754
- {currency_symbol}{total_cost:,.0f}
755
- </span>
756
  </div>
757
- <div style="color: #6b7280; font-size: 14px; margin-top: 4px;">
758
- Approximately {rounded_bags} bags x {currency_symbol}{price_per_bag:,.0f} per bag
 
759
  </div>
760
- </div>
761
-
762
- <div style="border-top: 1px solid #e5e7eb; padding-top: 14px;">
763
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Expected Performance</div>
764
- <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 16px;">
765
- <tr style="border-bottom: 1px solid #e5e7eb;">
766
- <td style="padding: 8px 4px;">Body weight per bird</td>
767
- <td style="padding: 8px 4px; text-align: right; font-weight: 700; font-size: 18px;">
768
- <span style="display: inline-block; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px 14px;">
769
- {expected_weight:.3f} kg
770
- </span>
771
- </td>
772
- </tr>
773
- <tr>
774
- <td style="padding: 8px 4px;">Flock live weight</td>
775
- <td style="padding: 8px 4px; text-align: right; font-weight: 700; font-size: 18px;">
776
- <span style="display: inline-block; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px 14px;">
777
- {flock_weight:,.1f} kg
778
- </span>
779
- </td>
780
- </tr>
781
- </table>
782
- </div>
783
-
784
- <div style="margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 14px;">
785
- <div style="font-size: 13px; color: #6b7280; font-weight: 600; margin-bottom: 8px;">Share Results:</div>
786
- <div style="display: flex; gap: 10px; flex-wrap: wrap;">
787
- <a href="{share_links['whatsapp']}" target="_blank" style="text-decoration: none;">
788
- <button style="background: #25D366; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">WhatsApp</button>
789
- </a>
790
- <a href="{share_links['email']}" target="_blank" style="text-decoration: none;">
791
- <button style="background: #ea4335; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Email</button>
792
- </a>
793
- <a href="{share_links['facebook']}" target="_blank" style="text-decoration: none;">
794
- <button style="background: #1877f2; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Facebook</button>
795
- </a>
796
- <a href="{share_links['twitter']}" target="_blank" style="text-decoration: none;">
797
- <button style="background: #000000; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Twitter/X</button>
798
- </a>
799
  </div>
800
- </div>
801
-
802
- <div style="margin-top: 14px; font-size: 12px; color: #9ca3af; border-top: 1px solid #f3f4f6; padding-top: 10px;">
803
- Estimate based on {breed} benchmark. Actual results may vary.
804
- </div>
805
- </div>
806
- """
807
 
808
  return html, f"✅ Calculation saved for {email.strip().lower()}."
809
 
@@ -1053,72 +1053,6 @@ button { min-height: 48px !important; }
1053
  padding: 15px;
1054
  background: #fffbeb;
1055
  }
1056
-
1057
- /* ============================================================
1058
- MOBILE VISIBILITY FIX - Make numbers bold and dark
1059
- ============================================================ */
1060
-
1061
- /* Quick Answer numbers */
1062
- .quick-answer-number {
1063
- font-size: 28px !important;
1064
- font-weight: 900 !important;
1065
- color: #166534 !important;
1066
- }
1067
-
1068
- .quick-answer-approx {
1069
- font-size: 24px !important;
1070
- font-weight: 800 !important;
1071
- color: #1e40af !important;
1072
- }
1073
-
1074
- /* Feed Breakdown numbers */
1075
- .feed-table td:last-child {
1076
- font-weight: 700 !important;
1077
- color: #1e293b !important;
1078
- }
1079
-
1080
- /* Feed Cost number */
1081
- .feed-cost-value {
1082
- font-size: 30px !important;
1083
- font-weight: 900 !important;
1084
- color: #1e40af !important;
1085
- }
1086
-
1087
- /* Expected Performance numbers */
1088
- .performance-value {
1089
- font-weight: 700 !important;
1090
- color: #1e293b !important;
1091
- }
1092
-
1093
- /* All number values in results */
1094
- .answer-box strong,
1095
- .answer-box b {
1096
- font-weight: 700 !important;
1097
- color: #1e293b !important;
1098
- }
1099
-
1100
- /* Make all table values darker */
1101
- table td {
1102
- color: #1e293b !important;
1103
- }
1104
-
1105
- /* Specific to the quick answer area */
1106
- div[style*="background: #f0fdf4"] strong,
1107
- div[style*="background: #f0fdf4"] b {
1108
- color: #166534 !important;
1109
- font-weight: 700 !important;
1110
- }
1111
-
1112
- div[style*="background: #f0fdf4"] .big-number {
1113
- color: #166534 !important;
1114
- font-weight: 800 !important;
1115
- }
1116
-
1117
- /* The approx purchase number */
1118
- div[style*="color: #1e40af"] {
1119
- color: #1e40af !important;
1120
- font-weight: 800 !important;
1121
- }
1122
  """
1123
 
1124
  # ============================================================
 
597
 
598
 
599
  # ============================================================
600
+ # FEED CALCULATION - WITH BOXED NUMBERS
601
  # ============================================================
602
 
603
  def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_code, breed, request: gr.Request):
 
676
  currency_symbol, expected_weight, flock_weight
677
  )
678
 
679
+ # Output HTML with BOXED NUMBERS
680
  starter_bags_display = f"{starter_bags:.1f}"
681
  finisher_bags_display = f"{finisher_bags:.1f}"
682
 
 
684
  if days:
685
  age_text += f" + {days} day{'s' if days != 1 else ''}"
686
 
687
+ html = f"""
688
+ <div style="font-size: 17px; line-height: 1.8; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
689
 
690
+ <div style="background: #f0fdf4; padding: 18px 22px; border-radius: 14px; border-left: 6px solid #22c55e; margin-bottom: 20px;">
691
+ <div style="font-size: 13px; color: #16a34a; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;">Quick Answer</div>
692
+
693
+ <!-- EXACT FEED - Boxed -->
694
+ <div style="font-size: 20px; font-weight: 700; color: #166534;">
695
+ Exact feed needed:
696
+ <span style="display: inline-block; background: #166534; color: white; border-radius: 12px; padding: 4px 18px; font-size: 30px; font-weight: 900; box-shadow: 0 2px 8px rgba(22, 101, 52, 0.3);">
697
+ {total_bags:.1f}
698
+ </span>
699
+ bags of {bag_size:g} kg feed
700
+ </div>
701
+
702
+ <!-- APPROXIMATE BAGS - Boxed -->
703
+ <div style="font-size: 20px; font-weight: 700; color: #1e40af; margin-top: 6px;">
704
+ Approximately:
705
+ <span style="display: inline-block; background: #1e40af; color: white; border-radius: 12px; padding: 4px 18px; font-size: 26px; font-weight: 800; box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);">
706
+ {rounded_bags}
707
+ </span>
708
+ bags to purchase (rounded up)
709
+ </div>
710
+
711
+ <!-- BIRD COUNT - Boxed -->
712
+ <div style="color: #374151; font-size: 16px; margin-top: 8px;">
713
+ To raise
714
+ <span style="display: inline-block; background: #fef3c7; border: 2px solid #f59e0b; border-radius: 10px; padding: 2px 14px; font-size: 18px; font-weight: 700; color: #92400e;">
715
+ {birds:,}
716
+ </span>
717
+ {breed} broilers to
718
+ <span style="display: inline-block; background: #fce4ec; border: 2px solid #ef4444; border-radius: 10px; padding: 2px 14px; font-size: 18px; font-weight: 700; color: #991b1b;">
719
+ {age_text} ({total_days} days)
720
+ </span>
721
+ </div>
722
+
723
+ <div style="margin-top: 8px; font-size: 13px;">
724
+ <span style="background: {breed_color}; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600;">{breed}</span>
725
+ <span style="background: #6b7280; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600; margin-left: 8px;">{country_name}</span>
726
+ </div>
727
  </div>
728
+
729
+ <div style="margin-bottom: 16px;">
730
+ <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Breakdown</div>
731
+ <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 16px;">
732
+ <tr style="border-bottom: 1px solid #e5e7eb;">
733
+ <td style="padding: 10px 4px;"><strong>Starter</strong></td>
734
+ <td style="padding: 10px 4px; text-align: right;">{starter_kg:,.1f} kg</td>
735
+ <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #1e293b;">{starter_bags_display} bags</td>
736
+ </tr>
737
+ <tr style="border-bottom: 1px solid #e5e7eb;">
738
+ <td style="padding: 10px 4px;"><strong>Finisher</strong></td>
739
+ <td style="padding: 10px 4px; text-align: right;">{finisher_kg:,.1f} kg</td>
740
+ <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #1e293b;">{finisher_bags_display} bags</td>
741
+ </tr>
742
+ <tr>
743
+ <td style="padding: 10px 4px; font-weight: 700;">TOTAL</td>
744
+ <td style="padding: 10px 4px; text-align: right; font-weight: 700;">{total_feed_kg:,.1f} kg</td>
745
+ <td style="padding: 10px 4px; text-align: right; font-weight: 700; font-size: 18px; color: #166534;">{total_bags:.1f}</td>
746
+ </tr>
747
+ </table>
748
  </div>
749
+
750
+ <div style="margin-bottom: 16px; background: #eff6ff; padding: 14px 18px; border-radius: 10px; border-left: 4px solid #3b82f6;">
751
+ <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Cost</div>
752
+ <div style="font-size: 32px; font-weight: 900; color: white;">
753
+ <span style="display: inline-block; background: #1e40af; color: white; border-radius: 12px; padding: 6px 22px; box-shadow: 0 2px 10px rgba(30, 64, 175, 0.3);">
754
+ {currency_symbol}{total_cost:,.0f}
755
+ </span>
756
+ </div>
757
+ <div style="color: #6b7280; font-size: 14px; margin-top: 4px;">
758
+ Approximately {rounded_bags} bags x {currency_symbol}{price_per_bag:,.0f} per bag
759
+ </div>
760
  </div>
761
+
762
+ <div style="border-top: 1px solid #e5e7eb; padding-top: 14px;">
763
+ <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Expected Performance</div>
764
+ <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 16px;">
765
+ <tr style="border-bottom: 1px solid #e5e7eb;">
766
+ <td style="padding: 8px 4px;">Body weight per bird</td>
767
+ <td style="padding: 8px 4px; text-align: right; font-weight: 700; font-size: 18px;">
768
+ <span style="display: inline-block; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px 14px;">
769
+ {expected_weight:.3f} kg
770
+ </span>
771
+ </td>
772
+ </tr>
773
+ <tr>
774
+ <td style="padding: 8px 4px;">Flock live weight</td>
775
+ <td style="padding: 8px 4px; text-align: right; font-weight: 700; font-size: 18px;">
776
+ <span style="display: inline-block; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px 14px;">
777
+ {flock_weight:,.1f} kg
778
+ </span>
779
+ </td>
780
+ </tr>
781
+ </table>
782
  </div>
783
+
784
+ <div style="margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 14px;">
785
+ <div style="font-size: 13px; color: #6b7280; font-weight: 600; margin-bottom: 8px;">Share Results:</div>
786
+ <div style="display: flex; gap: 10px; flex-wrap: wrap;">
787
+ <a href="{share_links['whatsapp']}" target="_blank" style="text-decoration: none;">
788
+ <button style="background: #25D366; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">WhatsApp</button>
789
+ </a>
790
+ <a href="{share_links['email']}" target="_blank" style="text-decoration: none;">
791
+ <button style="background: #ea4335; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Email</button>
792
+ </a>
793
+ <a href="{share_links['facebook']}" target="_blank" style="text-decoration: none;">
794
+ <button style="background: #1877f2; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Facebook</button>
795
+ </a>
796
+ <a href="{share_links['twitter']}" target="_blank" style="text-decoration: none;">
797
+ <button style="background: #000000; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Twitter/X</button>
798
+ </a>
799
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
800
  </div>
801
+
802
+ <div style="margin-top: 14px; font-size: 12px; color: #9ca3af; border-top: 1px solid #f3f4f6; padding-top: 10px;">
803
+ Estimate based on {breed} benchmark. Actual results may vary.
804
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
805
  </div>
806
+ """
 
 
 
 
 
 
807
 
808
  return html, f"✅ Calculation saved for {email.strip().lower()}."
809
 
 
1053
  padding: 15px;
1054
  background: #fffbeb;
1055
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
  """
1057
 
1058
  # ============================================================