예제 #1
0
 /**
   Get the standard footer with total and
   amount(s) saved
   @param $readOnly don't update any session info
    This would be set when rendering a separate,
    different customer display
   @return A string of HTML
 */
 public static function printfooter($readOnly = False)
 {
     $FOOTER_MODULES = CoreLocal::get("FooterModules");
     // use defaults if modules haven't been configured
     // properly
     if (!is_array($FOOTER_MODULES) || count($FOOTER_MODULES) != 5) {
         $FOOTER_MODULES = array('SavedOrCouldHave', 'TransPercentDiscount', 'MemSales', 'EveryoneSales', 'MultiTotal');
     }
     $modchain = array_map(function ($class) {
         return new $class();
     }, $FOOTER_MODULES);
     if (!$readOnly) {
         CoreLocal::set("runningTotal", CoreLocal::get("amtdue"));
     }
     if (CoreLocal::get("End") == 1 && !$readOnly) {
         CoreLocal::set("runningTotal", -1 * CoreLocal::get("change"));
     }
     if (CoreLocal::get("scale") == 1) {
         $weight = number_format(CoreLocal::get("weight"), 2) . "lb.";
     } else {
         $weight = "_ _ _ _";
     }
     $ret = "<table>";
     $ret .= "<tr class=\"heading\">";
     $classes = array('first', 'reg', 'reg', 'reg', 'total');
     for ($i = 0; $i < count($modchain); $i++) {
         $label = $modchain[$i]->header_content();
         $ret .= sprintf('<td class="%s %s" style="%s">%s</td>', $classes[$i], $modchain[$i]->header_css_class, $modchain[$i]->header_css, $label);
     }
     $ret .= "</tr>";
     $special = CoreLocal::get("memSpecial") + CoreLocal::get("staffSpecial");
     $dbldiscounttotal = 0.0;
     if (is_numeric(CoreLocal::get('discounttotal'))) {
         $dbldiscounttotal = number_format(CoreLocal::get("discounttotal"), 2);
     }
     if (CoreLocal::get("isMember") == 1) {
         $dblyousaved = number_format(CoreLocal::get("transDiscount") + $dbldiscounttotal + $special, 2);
         if (!$readOnly) {
             CoreLocal::set("yousaved", $dblyousaved);
             CoreLocal::set("couldhavesaved", 0);
             CoreLocal::set("specials", number_format($dbldiscounttotal + $special, 2));
         }
     } else {
         $dblyousaved = 0.0;
         if (is_numeric(CoreLocal::get('memSpecial'))) {
             $dblyousaved = number_format(CoreLocal::get("memSpecial"), 2);
         }
         if (!$readOnly) {
             CoreLocal::set("yousaved", $dbldiscounttotal + CoreLocal::get("staffSpecial"));
             CoreLocal::set("couldhavesaved", $dblyousaved);
             CoreLocal::set("specials", $dbldiscounttotal + CoreLocal::get("staffSpecial"));
         }
     }
     if (!$readOnly) {
         if (CoreLocal::get("End") == 1) {
             MiscLib::rePoll();
         }
         if (CoreLocal::get("scale") == 0 && CoreLocal::get("SNR") != 0) {
             MiscLib::rePoll();
         }
     }
     $ret .= "<tr class=\"values\">";
     for ($i = 0; $i < count($modchain); $i++) {
         $box = $modchain[$i]->display_content();
         $ret .= sprintf('<td class="%s %s" style="%s">%s</td>', $classes[$i], $modchain[$i]->display_css_class, $modchain[$i]->display_css, $box);
     }
     $ret .= "</tr>";
     $ret .= "</table>";
     return $ret;
 }