コード例 #1
0
ファイル: adminlist.php プロジェクト: phpsmith/IS4C
 function preprocess()
 {
     $me = CoreLocal::get('CashierNo');
     $this->security = Authenticate::getPermission($me);
     if (isset($_REQUEST['selectlist'])) {
         if (!FormLib::validateToken()) {
             return false;
         }
         if (empty($_REQUEST['selectlist'])) {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         } elseif ($_REQUEST['selectlist'] == 'SUSPEND') {
             Database::getsubtotals();
             if (CoreLocal::get("LastID") == 0) {
                 CoreLocal::set("boxMsg", _("no transaction in progress"));
                 CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
                 $this->change_page($this->page_url . "gui-modules/boxMsg2.php");
                 return False;
             } else {
                 // ajax call to end transaction
                 // and print receipt
                 $ref = SuspendLib::suspendorder();
                 $this->add_onload_command("\$.ajax({\n                        type:'post',\n                        url:'{$this->page_url}ajax-callbacks/ajax-end.php',\n                        cache: false,\n                        data: 'receiptType=suspended&ref={$ref}',\n                        dataType: 'json',\n                        success: function(data){\n                            \$.ajax({\n                            type:'post',\n                            url:'{$this->page_url}ajax-callbacks/ajax-transaction-sync.php',\n                            cache: false,\n                            success: function(data){\n                                location='{$this->page_url}gui-modules/pos2.php';\n                            },\n                            error: function(e1){\n                                location='{$this->page_url}gui-modules/pos2.php';\n                            }\n                            });\n                        },\n                        error: function(e1){\n                            location='{$this->page_url}gui-modules/pos2.php';\n                        }\n                        });");
                 return True;
             }
         } else {
             if ($_REQUEST['selectlist'] == 'RESUME') {
                 Database::getsubtotals();
                 if (CoreLocal::get("LastID") != 0) {
                     CoreLocal::set("boxMsg", _("transaction in progress"));
                     CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
                     $this->change_page($this->page_url . "gui-modules/boxMsg2.php");
                 } elseif (SuspendLib::checksuspended() == 0) {
                     CoreLocal::set("boxMsg", _("no suspended transaction"));
                     CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
                     CoreLocal::set("strRemembered", "");
                     $this->change_page($this->page_url . "gui-modules/boxMsg2.php");
                 } else {
                     $this->change_page($this->page_url . "gui-modules/suspendedlist.php");
                 }
                 return False;
             } else {
                 if ($_REQUEST['selectlist'] == 'TR') {
                     TenderReport::printReport();
                     $this->change_page($this->page_url . "gui-modules/pos2.php");
                     return False;
                 } else {
                     if ($_REQUEST['selectlist'] == 'OTR' && $this->security >= 30) {
                         $this->change_page($this->page_url . 'gui-modules/requestInfo.php?class=AnyTenderReportRequest');
                         return False;
                     } elseif ($_REQUEST['selectlist'] == 'UNDO' && $this->security >= 30) {
                         $this->change_page($this->page_url . 'gui-modules/undo.php');
                         return false;
                     }
                 }
             }
         }
     }
     return True;
 }
コード例 #2
0
ファイル: BaseLibsTest.php プロジェクト: phpsmith/IS4C
 public function testDatabase()
 {
     $db = Database::tDataConnect();
     $this->assertInstanceOf('\\COREPOS\\pos\\lib\\SQLManager', $db);
     $this->assertEquals(CoreLocal::get('tDatabase'), $db->default_db);
     $db = Database::pDataConnect();
     $this->assertInstanceOf('\\COREPOS\\pos\\lib\\SQLManager', $db);
     $this->assertEquals(CoreLocal::get('pDatabase'), $db->default_db);
     $this->assertEquals(1, Database::gettransno(-1));
     // not a real emp_no
     $db = Database::tDataConnect();
     $matches = Database::localMatchingColumns($db, 'localtrans', 'localtemptrans');
     $this->assertInternalType('string', $matches);
     $this->assertRegExp('/(.+)/', $matches);
     $globals = array('CashierNo' => 9999, 'cashier' => 'TRAINING', 'LoggedIn' => 0, 'TransNo' => 1, 'TTLFlag' => 0, 'FntlFlag' => 0, 'TaxExempt' => 0);
     Database::setglobalvalues($globals);
     $this->assertEquals(9999, CoreLocal::get('CashierNo'));
     $this->assertEquals('TRAINING', CoreLocal::get('cashier'));
     $this->assertEquals(0, CoreLocal::get('LoggedIn'));
     $this->assertEquals(1, CoreLocal::get('transno'));
     $this->assertEquals(0, CoreLocal::get('ttlflag'));
     $this->assertEquals(0, CoreLocal::get('fntlflag'));
     $this->assertEquals(0, CoreLocal::get('TaxExempt'));
     Database::loadglobalvalues();
     // reload session from db. shouldn't change.
     $this->assertEquals(9999, CoreLocal::get('CashierNo'));
     $this->assertEquals('TRAINING', CoreLocal::get('cashier'));
     $this->assertEquals(0, CoreLocal::get('LoggedIn'));
     $this->assertEquals(1, CoreLocal::get('transno'));
     $this->assertEquals(0, CoreLocal::get('ttlflag'));
     $this->assertEquals(0, CoreLocal::get('fntlflag'));
     $this->assertEquals(0, CoreLocal::get('TaxExempt'));
     Database::setglobalvalue('TTLFlag', 1);
     Database::loadglobalvalues();
     $this->assertEquals(1, CoreLocal::get('ttlflag'));
     Database::setglobalflags(0);
     Database::loadglobalvalues();
     $this->assertEquals(0, CoreLocal::get('ttlflag'));
     $this->assertEquals(0, CoreLocal::get('fntlflag'));
     if (!class_exists('lttLib')) {
         include dirname(__FILE__) . '/lttLib.php';
     }
     lttLib::clear();
     $record = lttLib::genericRecord();
     $record['upc'] = '0000000000000';
     $record['description'] = uniqid('TEST-');
     TransRecord::addRecord($record);
     SuspendLib::suspendorder();
     $db = Database::mDataConnect();
     $query = "\n            SELECT *\n            FROM suspended\n            WHERE upc='{$record['upc']}'\n                AND description='{$record['description']}'\n                AND datetime >= " . $db->curdate();
     $result = $db->query($query);
     $this->assertNotEquals(false, $result, 'Could not query suspended record');
     $this->assertEquals(1, $db->num_rows($result), 'Could not find suspended record');
     $row = $db->fetch_row($result);
     $this->assertInternalType('array', $row, 'Invalid suspended record');
     foreach ($record as $column => $value) {
         $this->assertArrayHasKey($column, $row, 'Suspended missing ' . $column);
         $this->assertEquals($value, $row[$column], 'Suspended mismatch on column ' . $column);
     }
 }