Esempio n. 1
0
 /**
   Remove member number from current transaction
 */
 public static function clearMember()
 {
     CoreState::memberReset();
     $dbc = Database::tDataConnect();
     $dbc->query("UPDATE localtemptrans SET card_no=0,percentDiscount=NULL");
     CoreLocal::set("ttlflag", 0);
     $opts = array('upc' => 'DEL_MEMENTRY');
     TransRecord::add_log_record($opts);
 }
Esempio n. 2
0
 public function hookAddColumnTenderModule()
 {
     CoreLocal::refresh();
     CoreState::loadParams();
     $current_map = CoreLocal::get('TenderMap');
     $update = $this->connection->prepare('
         UPDATE tenders
         SET TenderModule=?
         WHERE TenderCode=?
     ');
     foreach ($current_map as $code => $module) {
         $this->connection->execute($update, array($module, $code));
     }
 }
Esempio n. 3
0
 /**
   Set up state and redirect if needed
   @return True or a URL to redirect
 */
 public function preReqCheck()
 {
     $pref = CoreState::getCustomerPref('store_charge_see_id');
     if ($pref == 'yes') {
         if (CoreLocal::get('msgrepeat') == 0) {
             CoreLocal::set("boxMsg", "<BR>please verify member ID</B><BR>press [enter] to continue<P><FONT size='-1'>[clear] to cancel</FONT>");
             CoreLocal::set('lastRepeat', 'storeChargeSeeID');
             return MiscLib::base_url() . 'gui-modules/boxMsg2.php?quiet=1';
         } else {
             if (CoreLocal::get('msgrepeat') == 1 && CoreLocal::get('lastRepeat') == 'storeChargeSeeID') {
                 CoreLocal::set('msgrepeat', 0);
                 CoreLocal::set('lastRepeat', '');
             }
         }
     }
     return true;
 }
Esempio n. 4
0
<?php

include realpath(dirname(__FILE__) . '/../lib/AutoLoader.php');
AutoLoader::loadMap();
include '../ini.php';
CoreState::loadParams();
include 'InstallUtilities.php';
?>
<html>
<head>
<title>Debug Settings</title>
<style type="text/css">
body {
    line-height: 1.5em;
}
</style>
</head>
<body>
<?php 
include 'tabs.php';
?>
<div id="wrapper">
<h2>IT CORE Lane Installation: Debug Settings</h2>
<b>Logs</b><br />
Default logs:
<ul>
    <li><i>php-errors.log</i> contains PHP errors, warnings, notices, etc depending on error reporting settings for PHP installation.</li>
    <li><i>queries.log</i> lists failed queries</li>
</ul>
<div class="alert"><?php 
InstallUtilities::checkWritable('../log/php-errors.log');
Esempio n. 5
0
function uploadAndReset($type)
{
    if (CoreLocal::get("testremote") == 0) {
        Database::testremote();
    }
    if (CoreLocal::get("TaxExempt") != 0) {
        CoreLocal::set("TaxExempt", 0);
        Database::setglobalvalue("TaxExempt", 0);
    }
    CoreState::memberReset();
    CoreState::transReset();
    CoreState::printReset();
    Database::getsubtotals();
    return 1;
}
Esempio n. 6
0
 /**
   Create opdata tables and views
   @param $db [SQLManager] database connection
   @param $name [string] database name
   @return [array] of error messages
 */
 public static function createOpDBs($db, $name)
 {
     $errors = array();
     if (CoreLocal::get('laneno') == 0) {
         $errors[] = array('struct' => 'No structures created for lane #0', 'query' => 'None', 'details' => 'Zero is reserved for server');
         return $errors;
     }
     $models = array('\\COREPOS\\pos\\lib\\models\\op\\AutoCouponsModel', '\\COREPOS\\pos\\lib\\models\\op\\CouponCodesModel', '\\COREPOS\\pos\\lib\\models\\op\\CustdataModel', '\\COREPOS\\pos\\lib\\models\\op\\CustomerNotificationsModel', '\\COREPOS\\pos\\lib\\models\\op\\CustPreferencesModel', '\\COREPOS\\pos\\lib\\models\\op\\CustReceiptMessageModel', '\\COREPOS\\pos\\lib\\models\\op\\CustomReceiptModel', '\\COREPOS\\pos\\lib\\models\\op\\DateRestrictModel', '\\COREPOS\\pos\\lib\\models\\op\\DepartmentsModel', '\\COREPOS\\pos\\lib\\models\\op\\DisableCouponModel', '\\COREPOS\\pos\\lib\\models\\op\\DrawerOwnerModel', '\\COREPOS\\pos\\lib\\models\\op\\EmployeesModel', '\\COREPOS\\pos\\lib\\models\\op\\GlobalValuesModel', '\\COREPOS\\pos\\lib\\models\\op\\HouseCouponsModel', '\\COREPOS\\pos\\lib\\models\\op\\HouseCouponItemsModel', '\\COREPOS\\pos\\lib\\models\\op\\HouseVirtualCouponsModel', '\\COREPOS\\pos\\lib\\models\\op\\IgnoredBarcodesModel', '\\COREPOS\\pos\\lib\\models\\op\\MasterSuperDeptsModel', '\\COREPOS\\pos\\lib\\models\\op\\MemberCardsModel', '\\COREPOS\\pos\\lib\\models\\op\\MemtypeModel', '\\COREPOS\\pos\\lib\\models\\op\\ParametersModel', '\\COREPOS\\pos\\lib\\models\\op\\ProductsModel', '\\COREPOS\\pos\\lib\\models\\op\\ShrinkReasonsModel', '\\COREPOS\\pos\\lib\\models\\op\\SpecialDeptMapModel', '\\COREPOS\\pos\\lib\\models\\op\\SubDeptsModel', '\\COREPOS\\pos\\lib\\models\\op\\TendersModel', '\\COREPOS\\pos\\lib\\models\\op\\UnpaidArTodayModel', '\\COREPOS\\pos\\lib\\models\\op\\MemberCardsViewModel');
     foreach ($models as $class) {
         $obj = new $class($db);
         $errors[] = $obj->createIfNeeded($name);
     }
     $sample_data = array('couponcodes', 'globalvalues', 'parameters', 'tenders');
     foreach ($sample_data as $table) {
         $chk = $db->query('SELECT * FROM ' . $table, $name);
         if (!$db->fetch_row($chk)) {
             $loaded = self::loadSampleData($db, $table, true);
             if (!$loaded) {
                 $errors[] = array('struct' => $table, 'query' => 'None', 'details' => 'Failed loading sample data');
             }
         } else {
             $db->end_query($chk);
         }
     }
     $chk = $db->query('SELECT drawer_no FROM drawerowner', $name);
     if ($db->num_rows($chk) == 0) {
         $db->query('INSERT INTO drawerowner (drawer_no) VALUES (1)', $name);
         $db->query('INSERT INTO drawerowner (drawer_no) VALUES (2)', $name);
     }
     CoreState::loadParams();
     return $errors;
 }
Esempio n. 7
0
 public function testScreenDisplay()
 {
     lttLib::clear();
     $u = new UPC();
     $u->check('666');
     $u->parse('666');
     $records = DisplayLib::screenDisplay(0, 1);
     $item = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => 0.05, 'status' => 'T', 'lineColor' => '004080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 1);
     $spec = array(1 => $item);
     $this->assertEquals(count($records), count($spec));
     $view = $this->getViewVersion(0, 2);
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     $t = new TenderModule('CA', 1.0);
     $t->add();
     $tender = array('description' => '', 'comment' => 'Cash', 'total' => -1.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'T', 'trans_status' => '', 'voided' => 0, 'trans_id' => 2);
     $spec[2] = $tender;
     $records = DisplayLib::screenDisplay(0, 2);
     $view = $this->getViewVersion(0, 2);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('memberID', 1);
     CoreLocal::set('isMember', 1);
     CoreLocal::set('percentDiscount', 10);
     CoreLocal::set('memType', 1);
     PrehLib::ttl();
     $notify = array('description' => '** 10% Discount Applied **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => '0', 'trans_status' => 'D', 'voided' => 4, 'trans_id' => 3);
     $discount = array('description' => '', 'comment' => 'Discount', 'total' => 0.0, 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 5, 'trans_id' => 4);
     $subtotal = array('description' => 'Subtotal -0.95, Tax0.00 #1', 'comment' => 'Total ', 'total' => -0.95, 'status' => '', 'lineColor' => '000000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 3, 'trans_id' => 5);
     $spec[3] = $notify;
     $spec[4] = $discount;
     $spec[5] = $subtotal;
     $records = DisplayLib::screenDisplay(0, 5);
     $view = $this->getViewVersion(0, 5);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('quantity', 2);
     CoreLocal::set('multiple', 1);
     $u = new UPC();
     $u->check('4627');
     $u->parse('4627');
     $item = array('description' => 'PKALE', 'comment' => '2 @ 1.99', 'total' => 3.98, 'status' => 'F', 'lineColor' => '408080', 'discounttype' => 1, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 6);
     $notice = array('description' => '** YOU SAVED $0.60 **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'D', 'voided' => 2, 'trans_id' => 7);
     $spec[6] = $item;
     $spec[7] = $notice;
     $records = DisplayLib::screenDisplay(0, 7);
     $view = $this->getViewVersion(0, 7);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('quantity', 0);
     CoreLocal::set('multiple', 0);
     CoreLocal::set('currentid', 1);
     $v = new Void();
     $v->check('VD');
     $v->parse('VD');
     $void = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => -0.05, 'status' => 'VD', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'V', 'voided' => 1, 'trans_id' => 8);
     $spec[8] = $void;
     $spec[1]['voided'] = 1;
     $records = DisplayLib::screenDisplay(0, 8);
     $view = $this->getViewVersion(0, 8);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     TransRecord::addFsTaxExempt();
     $fs = array('description' => '', 'comment' => 'FS Tax Exempt', 'total' => 0.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 17, 'trans_id' => 9);
     $spec[9] = $fs;
     $records = DisplayLib::screenDisplay(0, 9);
     $view = $this->getViewVersion(0, 9);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
         $this->compareArrays($spec[$i], $view[$i]);
     }
     CoreState::memberReset();
     lttLib::clear();
 }
Esempio n. 8
0
<?php

/**
  Initialize environment & session so testing behaves
  correctly
*/
if (!class_exists('AutoLoader')) {
    include dirname(__FILE__) . '/../lib/AutoLoader.php';
}
CoreLocal::set("parse_chain", '');
CoreLocal::set("preparse_chain", '');
CoreLocal::set("postparse_chain", '');
AutoLoader::loadMap();
CoreState::initiate_session();
Esempio n. 9
0
 /**
   Show some items and farewell message
   @param $readOnly don't update totals
   @return An HTML string
 
   Show a few recent items and the 
   "Thank you for shopping" messaging.
 
   Yes, this function should be renamed. It
   has nothing to do with receipts.
 */
 public static function printReceiptfooter($readOnly = False)
 {
     if (!$readOnly) {
         Database::getsubtotals();
     }
     $last_id = CoreLocal::get("LastID");
     if ($last_id - 7 < 0) {
         $top_id = 1;
     } else {
         $top_id = $last_id - 7;
     }
     $ret = self::drawitems($top_id, 7, 0);
     $ret .= "<div class=\"farewellMsg coloredText\">";
     for ($i = 0; $i <= CoreLocal::get("farewellMsgCount"); $i++) {
         $ret .= CoreLocal::get("farewellMsg" . $i) . "<br />";
     }
     $email = CoreState::getCustomerPref('email_receipt');
     $doEmail = filter_var($email, FILTER_VALIDATE_EMAIL);
     if ($doEmail) {
         $ret .= 'receipt emailed';
     }
     $ret .= "</div>";
     return $ret;
 }
Esempio n. 10
0
 /**
   Authenticate an employee by password
   @param $password password from employee table
   @param $activity activity identifier to log
   @return True or False
 
   If no one is currently logged in, any valid
   password will be accepted. If someone is logged
   in, then only passwords for that user <i>or</i>
   a user with frontendsecurity >= 30 in the
   employee table will be accepted.
 */
 public static function checkPassword($password, $activity = 1)
 {
     $password = strtoupper($password);
     $password = str_replace("'", "", $password);
     $password = str_replace(",", "", $password);
     $paswword = str_replace("+", "", $password);
     if ($password == "TRAINING") {
         $password = 9999;
         // if password is training, change to '9999'
     }
     $query_g = "select LoggedIn,CashierNo from globalvalues";
     $db_g = Database::pDataConnect();
     $result_g = $db_g->query($query_g);
     $row_g = $db_g->fetch_array($result_g);
     if ($row_g["LoggedIn"] == 0) {
         $query_q = '
         SELECT emp_no, 
             FirstName, 
             LastName, ' . $db_g->yeardiff($db_g->now(), 'birthdate') . ' AS age
         FROM employees 
         WHERE EmpActive = 1 
             AND CashierPassword = ?';
         $prep_q = $db_g->prepare($query_q);
         $result_q = $db_g->execute($prep_q, array($password));
         $num_rows_q = $db_g->num_rows($result_q);
         if ($num_rows_q > 0) {
             $row_q = $db_g->fetch_array($result_q);
             Database::loadglobalvalues();
             $transno = Database::gettransno($row_q["emp_no"]);
             $globals = array("CashierNo" => $row_q["emp_no"], "Cashier" => $row_q["FirstName"] . " " . substr($row_q["LastName"], 0, 1) . ".", "TransNo" => $transno, "LoggedIn" => 1);
             Database::setglobalvalues($globals);
             CoreState::cashierLogin($transno, $row_q['age']);
         } elseif ($password == 9999) {
             Database::loadglobalvalues();
             $transno = Database::gettransno(9999);
             $globals = array("CashierNo" => 9999, "Cashier" => "Training Mode", "TransNo" => $transno, "LoggedIn" => 1);
             Database::setglobalvalues($globals);
             CoreState::cashierLogin($transno, 0);
         } else {
             return False;
         }
     } else {
         // longer query but simpler. since someone is logged in already,
         // only accept password from that person OR someone with a high
         // frontendsecurity setting
         $query_a = '
         SELECT emp_no, 
             FirstName, 
             LastName, ' . $db_g->yeardiff($db_g->now(), 'birthdate') . ' AS age
         FROM employees 
         WHERE EmpActive = 1 
             AND (frontendsecurity >= 30 OR emp_no = ?)
             AND (CashierPassword = ? OR AdminPassword = ?)';
         $args = array($row_g['CashierNo'], $password, $password);
         $prep_a = $db_g->prepare($query_a);
         $result_a = $db_g->execute($prep_a, $args);
         $num_rows_a = $db_g->num_rows($result_a);
         if ($num_rows_a > 0) {
             Database::loadglobalvalues();
             $row = $db_g->fetch_row($result_a);
             CoreState::cashierLogin(False, $row['age']);
         } elseif ($row_g["CashierNo"] == "9999" && $password == "9999") {
             Database::loadglobalvalues();
             CoreState::cashierLogin(False, 0);
         } else {
             return false;
         }
     }
     return true;
 }
Esempio n. 11
0
 public function testCoreState()
 {
     // normal session init attempts to recover state
     // transaction info - e.g., after a browser crash
     // or reboot. Clear the table so that doesn't
     // happen
     $db = Database::tDataConnect();
     $db->query('TRUNCATE TABLE localtemptrans');
     /**
       This will trigger any syntax or run-time errors
       Testing all the invidual values of session
       might be worthwhile is anyone wants to write
       all those tests out. They're mostly static values
       so the test would only catch changes to the
       defaults.
     */
     CoreState::initiate_session();
     $str = CoreState::getCustomerPref('asdf');
     $this->assertInternalType('string', $str);
     $this->assertEquals('', $str);
     // non-numeric age converts to zero
     CoreState::cashierLogin(false, 'z');
     $this->assertEquals(0, CoreLocal::get('cashierAge'));
 }