Posted By

jerryvig on 10/12/10


Tagged

cost minimization usps


Versions (?)

Print Output of USPS Box Cost Minimization


 / Published in: PHP
 

This is a formatted HTML output of the code for my cost minimization algo for USPS flat rate boxes. Marisolio.com

  1. <?php
  2. error_reporting( E_ALL );
  3.  
  4. if ( isset($_POST["numberOf750ml"]) && isset($_POST["numberOf375ml"]) && isset($_POST["numberOf200ml"]) ) {
  5.  
  6. require_once("./include/MinimizeUSPSCost.php");
  7. setlocale(LC_MONETARY, 'en_US');
  8.  
  9. $boxSet = MinimizeUSPSCost( trim($_POST["numberOf750ml"]), trim($_POST["numberOf375ml"]), trim($_POST["numberOf200ml"]) );
  10.  
  11. echo '<table align="center" border="1" cellspacing="1" cellpadding="3" rules="all">';
  12. echo '<tr><td style="color:#3C3B1B;font-weight:bold;">Box #</td><td style="color:#3C3B1B;font-weight:bold;">Size</td><td style="color:#3C3B1B;font-weight:bold;"># of 750 ml bottles</td><td style="color:#3C3B1B;font-weight:bold;"># of 375 ml bottles</td><td style="color:#3C3B1B;font-weight:bold;"># of 250 ml bottles</td></tr>';
  13.  
  14. $boxCount = 1;
  15. foreach ( $boxSet[0] as $myBox ) {
  16.  
  17. $boxSize = "Large";
  18. if ( $myBox[3] == 10.7 ) {
  19. $boxSize = "Medium";
  20. }
  21.  
  22. echo '<tr><td style="color:#3C3B1B;">Box# ' . $boxCount . '</td>';
  23. echo '<td style="color:#3C3B1B;">' . $boxSize . '</td>';
  24. echo '<td style="color:#3C3B1B;">' . $myBox[0] . '</td>';
  25. echo '<td style="color:#3C3B1B;">' . $myBox[1] . '</td>';
  26. echo '<td style="color:#3C3B1B;">' . $myBox[2] . '</td></tr>';
  27. $boxCount++;
  28. }
  29.  
  30. echo '<tr><td colspan="5" style="color:#3C3B1B;" align="center"><b>Total Shipping Cost = ' . money_format( '%i', $boxSet[1] ) . '</b></td></tr></table>';
  31.  
  32. }
  33. ?>

Report this snippet  

You need to login to post a comment.