/** React to missing item @param $upc [string] UPC value @param $json [keyed array] formatted return value @return [keyed array] formatted return value The $json parameter and return value have the same format as Parser since this module interacts with input parsing. */ public function handle($upc, $json) { $opts = array('upc' => $upc, 'description' => 'BADSCAN'); TransRecord::add_log_record($opts); $json['output'] = DisplayLib::boxMsg(_('not a valid item'), _('UPC: ') . $upc, false, DisplayLib::standardClearButton()); return $json; }
function parse($str) { $ret = $this->default_json(); switch (strtoupper($str)) { case 'PLU': TransRecord::add_log_record(array('upc' => 'PLU', 'description' => 'MISKEY')); CoreLocal::set('plainmsg', 'PLU logged'); $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/pos2.php'; $ret['udpmsg'] = 'goodBeep'; break; } return $ret; }
/** Assign a member number to a transaction @param $member CardNo from custdata @param $personNumber personNum from custdata See memberID() for more information. */ public static function setMember($member, $personNumber, $row = array()) { $conn = Database::pDataConnect(); /** Look up the member information here. There's no good reason to have calling code pass in a specially formatted row of data */ $query = "\n SELECT \n CardNo,\n personNum,\n LastName,\n FirstName,\n CashBack,\n Balance,\n Discount,\n ChargeOk,\n WriteChecks,\n StoreCoupons,\n Type,\n memType,\n staff,\n SSI,\n Purchases,\n NumberOfChecks,\n memCoupons,\n blueLine,\n Shown,\n id \n FROM custdata \n WHERE CardNo = " . (int) $member . "\n AND personNum = " . (int) $personNumber; $result = $conn->query($query); $row = $conn->fetch_row($result); CoreLocal::set("memberID", $member); CoreLocal::set("memType", $row["memType"]); CoreLocal::set("lname", $row["LastName"]); CoreLocal::set("fname", $row["FirstName"]); CoreLocal::set("Type", $row["Type"]); CoreLocal::set("isStaff", $row["staff"]); CoreLocal::set("SSI", $row["SSI"]); if (CoreLocal::get("Type") == "PC") { CoreLocal::set("isMember", 1); } else { CoreLocal::set("isMember", 0); } /** Optinonally use memtype table to normalize attributes by member type */ if (CoreLocal::get('useMemTypeTable') == 1 && $conn->table_exists('memtype')) { $prep = $conn->prepare('SELECT discount, staff, ssi FROM memtype WHERE memtype=?'); $res = $conn->execute($prep, array((int) CoreLocal::get('memType'))); if ($conn->num_rows($res) > 0) { $mt_row = $conn->fetch_row($res); $row['Discount'] = $mt_row['discount']; CoreLocal::set('isStaff', $mt_row['staff']); CoreLocal::set('SSI', $mt_row['ssi']); } } if (CoreLocal::get("isStaff") == 0) { CoreLocal::set("staffSpecial", 0); } /** Determine what string is shown in the upper left of the screen to indicate the current member */ $memMsg = '#' . $member; if (!empty($row['blueLine'])) { $memMsg = $row['blueLine']; } $chargeOk = self::chargeOk(); if (CoreLocal::get("balance") != 0 && $member != CoreLocal::get("defaultNonMem")) { $memMsg .= _(" AR"); } if (CoreLocal::get("SSI") == 1) { $memMsg .= " #"; } if ($conn->tableExists('CustomerNotifications')) { $blQ = ' SELECT message FROM CustomerNotifications WHERE cardNo=' . (int) $member . ' AND type=\'blueline\' ORDER BY message'; $blR = $conn->query($blQ); while ($blW = $conn->fetchRow($blR)) { $memMsg .= ' ' . $blW['message']; } } CoreLocal::set("memMsg", $memMsg); self::setAltMemMsg(CoreLocal::get("store"), $member, $personNumber, $row, $chargeOk); /** Set member number and attributes in the current transaction */ $conn2 = Database::tDataConnect(); $memquery = "\n UPDATE localtemptrans \n SET card_no = '" . $member . "',\n memType = " . sprintf("%d", CoreLocal::get("memType")) . ",\n staff = " . sprintf("%d", CoreLocal::get("isStaff")); $conn2->query($memquery); /** Add the member discount */ if (CoreLocal::get('discountEnforced')) { // skip subtotaling automatically since that occurs farther down DiscountModule::updateDiscount(new DiscountModule($row['Discount'], 'custdata'), false); } /** Log the member entry */ CoreLocal::set("memberID", $member); $opts = array('upc' => 'MEMENTRY', 'description' => 'CARDNO IN NUMFLAG', 'numflag' => $member); TransRecord::add_log_record($opts); /** Optionally add a subtotal line depending on member_subtotal setting. */ if (CoreLocal::get('member_subtotal') === 0 || CoreLocal::get('member_subtotal') === '0') { $noop = ""; } else { self::ttl(); } }
function preprocess() { $this->box_color = "coloredArea"; $this->msg = _("enter admin password"); // get calling class (required) $class = isset($_REQUEST['class']) ? $_REQUEST['class'] : ''; $pos_home = MiscLib::base_url() . 'gui-modules/pos2.php'; if ($class === '' || !class_exists($class)) { $this->change_page($pos_home); return False; } // make sure calling class implements required // method and properties try { $method = new ReflectionMethod($class, 'adminLoginCallback'); if (!$method->isStatic() || !$method->isPublic()) { throw new Exception('bad method adminLoginCallback'); } $property = new ReflectionProperty($class, 'adminLoginMsg'); if (!$property->isStatic() || !$property->isPublic()) { throw new Exception('bad property adminLoginMsg'); } $property = new ReflectionProperty($class, 'adminLoginLevel'); if (!$property->isStatic() || !$property->isPublic()) { throw new Exception('bad property adminLoginLevel'); } } catch (Exception $e) { $this->change_page($pos_home); return False; } $this->heading = $class::$adminLoginMsg; if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) { $passwd = ''; if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) { $passwd = $_REQUEST['reginput']; } else { if (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) { $passwd = $_REQUEST['userPassword']; } } if (strtoupper($passwd) == "CL") { $class::adminLoginCallback(False); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } else { if (empty($passwd)) { $this->box_color = "errorColoredArea"; $this->msg = _("re-enter admin password"); } else { $db = Database::pDataConnect(); if (Authenticate::checkPermission($passwd, $class::$adminLoginLevel)) { $row = Authenticate::getEmployeeByPassword($passwd); TransRecord::add_log_record(array('upc' => $row['emp_no'], 'description' => substr($class::$adminLoginMsg . ' ' . $row['FirstName'], 0, 30), 'charflag' => 'PW', 'num_flag' => $row['emp_no'])); if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('twoPairs'); } $result = $class::adminLoginCallback(True); if ($result === True) { $this->change_page(MiscLib::base_url() . 'gui-modules/pos2.php'); } else { $this->change_page($result); } return False; } else { $this->box_color = "errorColoredArea"; $this->msg = _("re-enter admin password"); TransRecord::add_log_record(array('upc' => $passwd, 'description' => substr($class::$adminLoginMsg, 0, 30), 'charflag' => 'PW')); if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('errorBeep'); } } } } } else { // beep on initial page load if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('twoPairs'); } } return True; }
public function testTransRecord() { if (!class_exists('lttLib')) { include 'lttLib.php'; } lttLib::clear(); CoreLocal::set('infoRecordQueue', array()); TransRecord::addQueued('1234567890123', 'UNIT TEST', 1, 'UT', 1.99); $queue = CoreLocal::get('infoRecordQueue'); $this->assertInternalType('array', $queue); $this->assertEquals(1, count($queue)); $this->assertArrayHasKey(0, $queue); $this->assertInternalType('array', $queue[0]); $this->assertArrayHasKey('upc', $queue[0]); $this->assertEquals('1234567890123', $queue[0]['upc']); $this->assertArrayHasKey('description', $queue[0]); $this->assertEquals('UNIT TEST', $queue[0]['description']); $this->assertArrayHasKey('numflag', $queue[0]); $this->assertEquals(1, $queue[0]['numflag']); $this->assertArrayHasKey('charflag', $queue[0]); $this->assertEquals('UT', $queue[0]['charflag']); $this->assertArrayHasKey('regPrice', $queue[0]); $this->assertEquals(1.99, $queue[0]['regPrice']); TransRecord::emptyQueue(); $queue = CoreLocal::get('infoRecordQueue'); $this->assertInternalType('array', $queue); $this->assertEquals(0, count($queue)); $record = lttLib::genericRecord(); $record['upc'] = '1234567890123'; $record['description'] = 'UNIT TEST'; $record['numflag'] = 1; $record['charflag'] = 'UT'; $record['regPrice'] = 1.99; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); CoreLocal::set('taxTotal', 1.23); TransRecord::addtax(); $record = lttLib::genericRecord(); $record['upc'] = 'TAX'; $record['description'] = 'Tax'; $record['trans_type'] = 'A'; $record['total'] = 1.23; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addtender('UT TENDER', 'UT', 2.34); $record = lttLib::genericRecord(); $record['description'] = 'UT TENDER'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'UT'; $record['total'] = 2.34; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addcomment('UNIT TEST COMMENT'); $record = lttLib::genericRecord(); $record['description'] = 'UNIT TEST COMMENT'; $record['trans_type'] = 'C'; $record['trans_subtype'] = 'CM'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addchange(3.14, 'UT'); $record = lttLib::genericRecord(); $record['description'] = 'Change'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'UT'; $record['total'] = 3.14; $record['voided'] = 8; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addfsones(3); $record = lttLib::genericRecord(); $record['description'] = 'FS Change'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'FS'; $record['total'] = 3; $record['voided'] = 8; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::adddiscount(5.45, 25); $record = lttLib::genericRecord(); $record['description'] = '** YOU SAVED $5.45 **'; $record['trans_type'] = 'I'; $record['trans_status'] = 'D'; $record['department'] = 25; $record['voided'] = 2; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addfsTaxExempt(); $record = lttLib::genericRecord(); $record['upc'] = 'FS Tax Exempt'; $record['description'] = ' Fs Tax Exempt '; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['voided'] = 17; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::discountnotify(5); $record = lttLib::genericRecord(); $record['description'] = '** 5% Discount Applied **'; $record['trans_status'] = 'D'; $record['voided'] = 4; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addTaxExempt(); $record = lttLib::genericRecord(); $record['description'] = '** Order is Tax Exempt **'; $record['trans_status'] = 'D'; $record['voided'] = 10; $record['tax'] = 9; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(1, CoreLocal::get('TaxExempt')); lttLib::clear(); TransRecord::reverseTaxExempt(); $record = lttLib::genericRecord(); $record['description'] = '** Tax Exemption Reversed **'; $record['trans_status'] = 'D'; $record['voided'] = 10; $record['tax'] = 9; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(0, CoreLocal::get('TaxExempt')); lttLib::clear(); CoreLocal::set('casediscount', 7); TransRecord::addcdnotify(); $record = lttLib::genericRecord(); $record['description'] = '** 7% Case Discount Applied'; $record['trans_status'] = 'D'; $record['voided'] = 6; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addCoupon('0051234512345', 123, -1.23, 1); $record = lttLib::genericRecord(); $record['upc'] = '0051234512345'; $record['description'] = ' * Manufacturers Coupon'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'CP'; $record['trans_status'] = 'C'; $record['department'] = 123; $record['unitPrice'] = -1.23; $record['total'] = -1.23; $record['regPrice'] = -1.23; $record['foodstamp'] = 1; $record['quantity'] = 1; $record['ItemQtty'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addhousecoupon('0049999912345', 122, -1.22); $record = lttLib::genericRecord(); $record['upc'] = '0049999912345'; $record['description'] = ' * Store Coupon'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['department'] = 122; $record['unitPrice'] = -1.22; $record['total'] = -1.22; $record['regPrice'] = -1.22; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['discountable'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::additemdiscount(345, 3.45); $record = lttLib::genericRecord(); $record['upc'] = 'ITEMDISCOUNT'; $record['description'] = ' * Item Discount'; $record['trans_type'] = 'I'; $record['department'] = 345; $record['unitPrice'] = -3.45; $record['total'] = -3.45; $record['regPrice'] = -3.45; $record['quantity'] = 1; $record['ItemQtty'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addtare(5); $record = lttLib::genericRecord(); $record['description'] = '** Tare Weight 0.05 **'; $record['trans_status'] = 'D'; $record['voided'] = 6; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(0.05, CoreLocal::get('tare')); lttLib::clear(); CoreLocal::set('transDiscount', 3.24); TransRecord::addTransDiscount(); $record = lttLib::genericRecord(); $record['upc'] = 'DISCOUNT'; $record['description'] = 'Discount'; $record['trans_type'] = 'S'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -3.24; $record['total'] = -3.24; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addCashDrop('90.78'); $record = lttLib::genericRecord(); $record['upc'] = 'DROP'; $record['description'] = 'Cash Drop'; $record['trans_type'] = 'I'; $record['trans_status'] = 'X'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -90.78; $record['total'] = -90.78; $record['charflag'] = 'CD'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); $record = lttLib::genericRecord(); $record['upc'] = 'UNITTEST'; $record['description'] = 'Unit Test'; $record['department'] = 5; $record['numflag'] = 4; $record['charflag'] = 'UT'; $record['amount1'] = 1.23; $record['total'] = 1.23; $record['amount2'] = 1.24; $record['regPrice'] = 1.24; TransRecord::add_log_record($record); unset($record['amount1']); // not real column unset($record['amount2']); // not real column $record['trans_type'] = 'L'; $record['trans_subtype'] = 'OG'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); }