GoogleCalc commited on
Commit
22b81d5
·
verified ·
1 Parent(s): 98d9cb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +113 -81
app.py CHANGED
@@ -684,94 +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.6;">
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;">Quick Answer</div>
692
- <div style="font-size: 22px; font-weight: 800; color: #1f4f2d;">
693
- Exact feed needed: <span style="font-size: 26px;">{total_bags:.1f}</span> bags of {bag_size:g} kg feed
694
- </div>
695
- <div style="font-size: 24px; font-weight: 800; color: #1e40af; margin: 4px 0;">
696
- Approximately {rounded_bags} bags
697
- </div>
698
- <div style="color: #374151; font-size: 16px;">
699
- To raise <strong>{birds:,}</strong> broilers from Day Old to <strong>{age_text} ({total_days} days)</strong>
700
- </div>
701
- <div style="margin-top: 8px; font-size: 13px;">
702
- <span style="background: {breed_color}; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600;">{breed}</span>
703
- <span style="background: #6b7280; color: white; padding: 3px 12px; border-radius: 14px; font-weight: 600; margin-left: 8px;">{country_name}</span>
704
- </div>
705
- </div>
706
 
707
- <div style="margin-bottom: 16px;">
708
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Breakdown</div>
709
- <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px;">
710
- <tr style="border-bottom: 1px solid #e5e7eb;">
711
- <td style="padding: 8px 4px;"><strong>Starter</strong></td>
712
- <td style="padding: 8px 4px; text-align: right;">{starter_kg:,.1f} kg</td>
713
- <td style="padding: 8px 4px; text-align: right; font-weight: 600;">{starter_bags_display} bags</td>
714
- </tr>
715
- <tr style="border-bottom: 1px solid #e5e7eb;">
716
- <td style="padding: 8px 4px;"><strong>Finisher</strong></td>
717
- <td style="padding: 8px 4px; text-align: right;">{finisher_kg:,.1f} kg</td>
718
- <td style="padding: 8px 4px; text-align: right; font-weight: 600;">{finisher_bags_display} bags</td>
719
- </tr>
720
- <tr>
721
- <td style="padding: 8px 4px; font-weight: 700;">TOTAL</td>
722
- <td style="padding: 8px 4px; text-align: right; font-weight: 700;">{total_feed_kg:,.1f} kg</td>
723
- <td style="padding: 8px 4px; text-align: right; font-weight: 700;">{total_bags:.1f}</td>
724
- </tr>
725
- </table>
726
  </div>
727
-
728
- <div style="margin-bottom: 16px; background: #eff6ff; padding: 14px 18px; border-radius: 10px; border-left: 4px solid #3b82f6;">
729
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Feed Cost</div>
730
- <div style="font-size: 30px; font-weight: 800; color: #1e40af;">
731
- {currency_symbol}{total_cost:,.0f}
732
- </div>
733
- <div style="color: #6b7280; font-size: 14px;">
734
- Approximately {rounded_bags} bags x {currency_symbol}{price_per_bag:,.0f} per bag
735
- </div>
736
  </div>
737
-
738
- <div style="border-top: 1px solid #e5e7eb; padding-top: 14px;">
739
- <div style="font-size: 13px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Expected Performance</div>
740
- <table style="width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px;">
741
- <tr style="border-bottom: 1px solid #e5e7eb;">
742
- <td style="padding: 6px 4px;">Body weight per bird</td>
743
- <td style="padding: 6px 4px; text-align: right; font-weight: 600;">{expected_weight:.3f} kg</td>
744
- </tr>
745
- <tr>
746
- <td style="padding: 6px 4px;">Flock live weight</td>
747
- <td style="padding: 6px 4px; text-align: right; font-weight: 600;">{flock_weight:,.1f} kg</td>
748
- </tr>
749
- </table>
750
  </div>
751
-
752
- <div style="margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 14px;">
753
- <div style="font-size: 13px; color: #6b7280; font-weight: 600; margin-bottom: 8px;">Share Results:</div>
754
- <div style="display: flex; gap: 10px; flex-wrap: wrap;">
755
- <a href="{share_links['whatsapp']}" target="_blank" style="text-decoration: none;">
756
- <button style="background: #25D366; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">WhatsApp</button>
757
- </a>
758
- <a href="{share_links['email']}" target="_blank" style="text-decoration: none;">
759
- <button style="background: #ea4335; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Email</button>
760
- </a>
761
- <a href="{share_links['facebook']}" target="_blank" style="text-decoration: none;">
762
- <button style="background: #1877f2; color: white; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;">Facebook</button>
763
- </a>
764
- <a href="{share_links['twitter']}" target="_blank" style="text-decoration: none;">
765
- <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>
766
- </a>
767
- </div>
768
  </div>
769
-
770
- <div style="margin-top: 14px; font-size: 12px; color: #9ca3af; border-top: 1px solid #f3f4f6; padding-top: 10px;">
771
- Estimate based on {breed} benchmark. Actual results may vary.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  </div>
 
 
773
  </div>
774
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
775
 
776
  return html, f"✅ Calculation saved for {email.strip().lower()}."
777
 
 
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