Exemple #1
0
 function check($str)
 {
     $this->ret = $this->default_json();
     if (substr($str, -2) == "DA") {
         $strl = substr($str, 0, strlen($str) - 2);
         if (substr($str, 0, 2) == "VD") {
             $this->ret = PrehLib::percentDiscount(0, $this->ret);
         } elseif (!is_numeric($strl)) {
             return false;
         } elseif (CoreLocal::get("tenderTotal") != 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl > 50) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 50 and $strl > 0) {
             $this->ret = PrehLib::percentDiscount($strl, $this->ret);
             $this->ret['redraw_footer'] = true;
         } else {
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #2
0
 function check($str)
 {
     $this->ret = $this->default_json();
     if (substr($str, -2) == "SD") {
         $strl = substr($str, 0, strlen($str) - 2);
         if (!is_numeric($strl)) {
             return False;
         } elseif (CoreLocal::get("tenderTotal") != 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl > 50) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 50 and $strl > 0) {
             $existingPD = CoreLocal::get("percentDiscount");
             $stackablePD = $strl;
             $equivalentPD = $existingPD + $stackablePD;
             //    sum discounts
             $this->ret = PrehLib::percentDiscount($equivalentPD, $this->ret);
         } else {
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #3
0
 public function parse($str)
 {
     $ret = $this->default_json();
     if (is_numeric(CoreLocal::get('VoidLimit')) && CoreLocal::get('VoidLimit') > 0) {
         Database::getsubtotals();
         if (CoreLocal::get('voidTotal') > CoreLocal::get('VoidLimit') && CoreLocal::get('voidOverride') != 1) {
             CoreLocal::set('strRemembered', CoreLocal::get('strEntered'));
             CoreLocal::set('voidOverride', 0);
             $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/adminlogin.php?class=Void';
             return $ret;
         }
     }
     if (strlen($str) > 2) {
         $ret = $this->voidupc(substr($str, 2), $ret);
     } elseif (CoreLocal::get("currentid") == 0) {
         $ret['output'] = DisplayLib::boxMsg(_("No Item on Order"), '', false, DisplayLib::standardClearButton());
     } else {
         $id = CoreLocal::get("currentid");
         $status = PrehLib::checkstatus($id);
         $this->discounttype = $status['discounttype'];
         $this->discountable = $status['discountable'];
         $this->caseprice = $status['caseprice'];
         $this->scaleprice = $status['scaleprice'];
         /**
           Voided values:
             2 => "you saved" line
             3 => subtotal line
             4 => discount notice
             5 => % Discount line
             6 => tare weight, case disc notice,
             8 => FS change, regular change
             10 => tax exempt
         */
         if ($status['voided'] == 2) {
             // void preceeding item
             $ret = $this->voiditem($id - 1, $ret);
         } else {
             if ($status['voided'] == 3 || $status['voided'] == 6 || $status['voided'] == 8) {
                 $ret['output'] = DisplayLib::boxMsg(_("Cannot void this entry"), '', false, DisplayLib::standardClearButton());
             } else {
                 if ($status['voided'] == 4 || $status['voided'] == 5) {
                     PrehLib::percentDiscount(0);
                 } else {
                     if ($status['voided'] == 10) {
                         TransRecord::reverseTaxExempt();
                     } else {
                         if ($status['status'] == "V") {
                             $ret['output'] = DisplayLib::boxMsg(_("Item already voided"), '', false, DisplayLib::standardClearButton());
                         } else {
                             $ret = $this->voiditem($id, $ret);
                         }
                     }
                 }
             }
         }
     }
     if (empty($ret['output']) && empty($ret['main_frame'])) {
         $ret['output'] = DisplayLib::lastpage();
         $ret['redraw_footer'] = true;
         $ret['udpmsg'] = 'goodBeep';
     } elseif (empty($ret['main_frame'])) {
         $ret['udpmsg'] = 'errorBeep';
     }
     return $ret;
 }