コード例 #1
0
ファイル: CoreState.php プロジェクト: phpsmith/IS4C
 /**
   Initialize transaction variable in session.
   This function is called after the end of every
   transaction so these values will be the
   the defaults every time.
 */
 public static function transReset()
 {
     /**
       @var End
       Indicates transaction has ended
       0 => transaction in progress
       1 => transaction is complete
     */
     CoreLocal::set("End", 0);
     /**
       @var memberID
       Current member number
     */
     CoreLocal::set("memberID", "0");
     /**
       @var TaxExempt
       Tax exempt status flag
       0 => transaction is taxable
       1 => transaction is tax exempt
     */
     CoreLocal::set("TaxExempt", 0);
     /**
       @var yousaved
       Total savings on the transaction (as float).
       Includes any if applicable:
       - transaction level percent discount
       - sale prices (localtemptrans.discount)
       - member prices (localtemptrans.memDiscount)
     */
     CoreLocal::set("yousaved", 0);
     /**
       @var couldhavesaved
       Total member savings that were not applied.
       Consists of localtemptrans.memDiscount on
       non-member purchases
     */
     CoreLocal::set("couldhavesaved", 0);
     /**
       @var specials
       Total saving via sale prices. Consists
       of localtemptrans.discount and when applicable
       localtemptrans.memDiscount
     */
     CoreLocal::set("specials", 0);
     /**
       @var tare
       Current tare setting (as float)
     */
     CoreLocal::set("tare", 0);
     /**
       @var change
       Amount of change due (as float)
     */
     CoreLocal::set("change", 0);
     /**
       @var toggletax
       Alter the next item's tax status
       - 0 => do nothing
       - 1 => change next tax status    
     */
     CoreLocal::set("toggletax", 0);
     /**
       @var togglefoodstamp
       Alter the next item's foodstamp status
       - 0 => do nothing
       - 1 => change next foodstamp status    
     */
     CoreLocal::set("togglefoodstamp", 0);
     /**
       @var toggleDiscountable
       Alter the next item's discount status
       - 0 => do nothing
       - 1 => change next discount status    
     */
     CoreLocal::set("toggleDiscountable", 0);
     /**
       @var refund
       Indicates current ring is a refund. This
       is set as a session variable as it could
       apply to items, open rings, or potentially
       other kinds of input.
       - 0 => not a refund
       - 1 => refund
     */
     CoreLocal::set("refund", 0);
     /**
       @var casediscount
       Line item case discount percentage (as
       integer; 5 = 5%). This feature may be redundant
       in that it could be handled with the generic
       line-item discount. It more or less just differs
       in that the messages say "Case".
     */
     CoreLocal::set("casediscount", 0);
     /**
       @var multiple
       Cashier used the "*" key to enter
       a multiplier. This currently makes the
       products.qttyEnforced flag work. This may
       be redundant and the quantity setting below
       is likely sufficient to determine whether
       a multiplier was used.
     */
     CoreLocal::set("multiple", 0);
     /**
       @var quantity
       Quantity for the current ring. A non-zero
       value usually means the cashier used "*" 
       to enter a multiplier. A value of zero
       gets converted to one unless the item requires
       a quantity via products.scale or
       products.qttyEnforced.
     */
     CoreLocal::set("quantity", 0);
     /**
       @var strEntered
       Stores the last user input from the main
       POS screen. Used in conjunction with the
       msgrepeat option.
     */
     CoreLocal::set("strEntered", "");
     /**
       @var strRemembered
       Value to use as input the next time
       the main POS screen loads. Used in
       conjunction with the msgrepeat
       option.
     */
     CoreLocal::set("strRemembered", "");
     /**
           @var msgrepeat
           Controls repeat input behavior
           - 0 => do nothing
           - 1 => set POS input to the value
              in strRemembered
     
           strEntered, strRemembered, and msgrepeat
           are strongly interrelated.
     
           When parsing user input on the main POS screen,
           the entered value is always stored as strEntered.
     
           msgrepeat gets used in two slightly different
           ways. If you're on a page other than the main
           screen, set msgrepeat to 1 and strRemembered to
           the desired input, then redirect to pos2.php. This
           will run the chosen value through standard input
           processing.
     
           The other way msgrepeat is used is with boxMsg2.php.
           This page is a generic enter to continue, clear to
           cancel prompt. If you redirect to boxMsg2.php and the
           user presses enter, POS will set msgrepeat to 1 and
           copy strEntered into strRemembered effectively repeating
           the last input. Code using this feature will interpret
           a msgrepeat value of 1 to indicate the user has given
           confirmation.
     
           msgrepeat is always cleared back to zero when input
           processing finishes.
     */
     CoreLocal::set("msgrepeat", 0);
     /**
       @var lastRepeat
       [Optional] Reason for the last repeated message
       Useful to set & check in situations where multiple
       confirmations may be required.
     */
     CoreLocal::set('lastRepeat', '');
     /**
       @var boxMsg
       Message string to display on the boxMsg2.php page
     */
     CoreLocal::set("boxMsg", "");
     /**
       @var itemPD
       Line item percent discount (as integer; 5 = 5%).
       Applies a percent discount to the current ring.
     */
     CoreLocal::set("itemPD", 0);
     /**
       @var cashierAgeOverride
       This flag indicates a manager has given approval
       for the cashier to sell age-restricted items. This
       setting only comes into effect if the cashier is
       too young. The value persists for the remainder of
       the transaction so the manager does not have to give
       approval for each individual item.
       - 0 => no manager approval
       - 1 => manager has given approval
     */
     CoreLocal::set("cashierAgeOverride", 0);
     /**
       @var voidOverride
       This flag indicates a manager has given approval
       for the cashier to void items beyond the per
       transaction limit.
       The value persists for the remainder of
       the transaction so the manager does not have to give
       approval for each individual item.
       - 0 => no manager approval
       - 1 => manager has given approval
     */
     CoreLocal::set("voidOverride", 0);
     /**
       @var lastWeight
       The weight of the last by-weight item entered into
       the transaction. It's used to monitor for scale 
       problems. Consecutive items with the exact same
       weight often indicate the scale is stuck or not
       responding properly.
     */
     CoreLocal::set("lastWeight", 0.0);
     /**
       @var CachePanEncBlcok
       Stores the encrypted string of card information
       provided by the CC terminal. If the terminal is
       facing the customer, the customer may swipe their
       card before the cashier is done ringing in items
       so the value is stored in session until the
       cashier is ready to process payment
     */
     CoreLocal::set("CachePanEncBlock", "");
     /**
       @var CachePinEncBlock
       Stores the encrypted string of PIN data.
       Similar to CachePanEncBlock.
     */
     CoreLocal::set("CachePinEncBlock", "");
     /**
       @var CacheCardType
       Stores the selected card type.
       Similar to CachePanEncBlock.
       Known values are:
       - CREDIT
       - DEBIT
       - EBTFOOD
       - EBTCASH
     */
     CoreLocal::set("CacheCardType", "");
     /**
       @var CacheCardCashBack
       Stores the select cashback amount.
       Similar to CachePanEncBlock.
     */
     CoreLocal::set("CacheCardCashBack", 0);
     /**
       @var ccTermState
       Stores a string representing the CC 
       terminals current display. This drives
       an optional on-screen icon to let the 
       cashier know what the CC terminal is
       doing if they cannot see its screen.
     */
     CoreLocal::set('ccTermState', 'swipe');
     /**
       @var paycard_voiceauthcode
       Stores a voice authorization code for use
       with a paycard transaction. Not normally used
       but required to pass Mercury's certification
       script.
     */
     CoreLocal::set("paycard_voiceauthcode", "");
     /**
       @var ebt_authcode
       Stores a foodstamp authorization code.
       Similar to paycard_voiceauthcode.
     */
     CoreLocal::set("ebt_authcode", "");
     /**
       @var ebt_vnum
       Stores a foodstamp voucher number.
       Similar to paycard_voiceauthcode.
     */
     CoreLocal::set("ebt_vnum", "");
     /**
       @var paycard_keyed
       - True => card number was hand keyed
       - False => card was swiped
     
       Normally POS figures this out automatically
       but it has to be overriden to pass Mercury's
       certification script. They require some
       keyed transactions even though the CC terminal
       is only capable of producing swipe-style data.
     */
     CoreLocal::set("paycard_keyed", False);
     if (!is_array(CoreLocal::get('PluginList'))) {
         CoreLocal::set('PluginList', array());
     }
     if (is_array(CoreLocal::get('PluginList'))) {
         foreach (CoreLocal::get('PluginList') as $p) {
             if (!class_exists($p)) {
                 continue;
             }
             $obj = new $p();
             $obj->plugin_transaction_reset();
         }
     }
     if (is_array(CoreLocal::get('Notifiers'))) {
         foreach (CoreLocal::get('Notifiers') as $n) {
             if (!class_exists($n)) {
                 continue;
             }
             $obj = new $n();
             $obj->transactionReset();
         }
     }
     FormLib::clearTokens();
     DiscountModule::transReset();
 }
コード例 #2
0
ファイル: BaseLibsTest.php プロジェクト: phpsmith/IS4C
 public function testDiscountModules()
 {
     $ten = new DiscountModule(10, 'ten');
     $fifteen = new DiscountModule(15, 'fifteen');
     // verify stacking discounts
     CoreLocal::set('percentDiscount', 0);
     CoreLocal::set('NonStackingDiscounts', 0);
     DiscountModule::updateDiscount($ten, false);
     $this->assertEquals(10, CoreLocal::get('percentDiscount'));
     DiscountModule::updateDiscount($fifteen, false);
     $this->assertEquals(25, CoreLocal::get('percentDiscount'));
     DiscountModule::transReset();
     // verify non-stacking discounts
     CoreLocal::set('percentDiscount', 0);
     CoreLocal::set('NonStackingDiscounts', 1);
     DiscountModule::updateDiscount($ten, false);
     $this->assertEquals(10, CoreLocal::get('percentDiscount'));
     DiscountModule::updateDiscount($fifteen, false);
     $this->assertEquals(15, CoreLocal::get('percentDiscount'));
     DiscountModule::transReset();
     // verify best non-stacking discount wins
     CoreLocal::set('percentDiscount', 0);
     DiscountModule::updateDiscount($fifteen, false);
     $this->assertEquals(15, CoreLocal::get('percentDiscount'));
     DiscountModule::updateDiscount($ten, false);
     $this->assertEquals(15, CoreLocal::get('percentDiscount'));
     DiscountModule::transReset();
     // verify same-name discounts overwrite
     $one = new DiscountModule(1, 'custdata');
     $two = new DiscountModule(2, 'custdata');
     CoreLocal::set('percentDiscount', 0);
     CoreLocal::set('NonStackingDiscounts', 0);
     DiscountModule::updateDiscount($one, false);
     $this->assertEquals(1, CoreLocal::get('percentDiscount'));
     DiscountModule::updateDiscount($two, false);
     $this->assertEquals(2, CoreLocal::get('percentDiscount'));
     DiscountModule::transReset();
     // same-name should overwrite in the order called
     CoreLocal::set('percentDiscount', 0);
     DiscountModule::updateDiscount($two, false);
     $this->assertEquals(2, CoreLocal::get('percentDiscount'));
     DiscountModule::updateDiscount($one, false);
     $this->assertEquals(1, CoreLocal::get('percentDiscount'));
 }