CORE POS - IS4C
The CORE POS front end
Static Public Member Functions | List of all members
COREPOS\pos\lib\Database Class Reference

Static Public Member Functions

static tDataConnect ()
 
static pDataConnect ()
 
static mDataConnect ()
 
static mAltName ()
 
static getsubtotals ()
 
static LineItemTaxes ()
 
static gettransno ($CashierNo)
 
static testremote ()
 
static uploadtoServer ()
 
static getMatchingColumns ($connection, $table_name, $table2="")
 
static localMatchingColumns ($connection, $table1, $table2)
 
static uploadCCdata ()
 
static loadglobalvalues ()
 
static loadglobalvalue ($param, $val)
 
static setglobalvalue ($param, $value)
 
static setglobalvalues ($arr)
 
static setglobalflags ($value)
 
static changeLttTaxCode ($fromName, $toName)
 
static rotateTempData ()
 
static clearTempTables ()
 
static logger ($msg="")
 

Detailed Description

Functions related to the database

Member Function Documentation

static COREPOS\pos\lib\Database::changeLttTaxCode (   $fromName,
  $toName 
)
static

Change one tax code in all items of localtemptrans to a different one. Parameters are the names of the taxes, as in taxrates.description

Parameters
$fromNameThe name of the tax changed from.
$fromNameThe name of the tax changed to.
static COREPOS\pos\lib\Database::clearTempTables ( )
static

Truncate current transaction tables. Clears data from:

  • translog.localtemptrans
  • translog.couponApplied
Returns
[boolean] success or failure

Success or failure is based on whether translog.localtemptrans is cleared correctly.

static COREPOS\pos\lib\Database::getMatchingColumns (   $connection,
  $table_name,
  $table2 = "" 
)
static

Get a list of columns that exist on the local db and the server db for the given table.

Parameters
$connectiona SQLManager object that's already connected
$table_namethe table
$table2is provided, it match columns from local.table_name against remote.table2
Returns
[string] comma separated list of column names

Cache column information by table in the session In standalone mode, a transfer query likely failed and the cache may be wrong so always requery in that case.

static COREPOS\pos\lib\Database::getsubtotals ( )
static

Load values from subtotals view into session. Essentially refreshes totals in the session.

9May14 Andy I belive this query is equivalent to the old subtotals => lttsubtotals => lttsummary I've omitted tax since those are already calculated separately. A few conditions here should obviously be more configurable, but first I want to get rid of or simply the old nested views

fsEligible is the complicated one. That's:

  1. Total foodstampable items
  2. Minus transaction-level discount on those items
  3. Minus any foodstamp tenders already applied. localtemptrans.total is negative on tenders so the query uses an addition sign but in effect it's subracting. $replacementQ = " SELECT CASE WHEN MAX(trans_id) IS NULL THEN 0 ELSE MAX(trans_id) END AS LastID, MAX(card_no) AS card_no, SUM(total) AS runningTotal, SUM(CASE WHEN discounttype=1 THEN total ELSE 0 END) AS discountTTL, SUM(CASE WHEN discounttype IN (2,3) THEN total ELSE 0 END) AS staffSpecial, SUM(CASE WHEN discounttype=4 THEN total ELSE 0 END) AS discountTTL, SUM(CASE WHEN trans_type='T' THEN total ELSE 0 END) AS tenderTotal, MAX(percentDiscount) AS percentDiscount, SUM(CASE WHEN discountable=0 THEN 0 ELSE total END) as discountableTotal, SUM(CASE WHEN discountable=0 THEN 0 ELSE total END) * (MAX(percentDiscount)/100.00) AS transDiscount, SUM(CASE WHEN trans_subtype IN ('MI', 'CX') THEN total ELSE 0 END) AS chargeTotal, SUM(CASE WHEN department=990 THEN total ELSE 0 END) as paymentTotal, SUM(CASE WHEN numflag=1 THEN total ELSE 0 END) as localTotal, SUM(CASE WHEN trans_status='V' THEN total ELSE 0 END) as voidTotal, ( SUM(CASE WHEN foodstamp=1 THEN total ELSE 0 END)
    • ((MAX(percentDiscount)/100.00) SUM(CASE WHEN foodstamp=1 AND discountable=1 THEN total ELSE 0 END))
    • SUM(CASE WHEN trans_subtype IN ('EF','FS') THEN total ELSE 0 END) ) AS fsEligble FROM localtemptrans AS l WHERE trans_type <> 'L' ";

If FS eligible amount is greater than the current transaction total and total is positive, limit the eligible amount to the current total. This may not be technically correct but the resulting change causes a lot of headaches depending what kind of change is allowed for earlier tenders, if change is allowed for those tenders at all.

The other case is a refund to FS. Over-tendering on a refund doesn't make any sense.

static COREPOS\pos\lib\Database::gettransno (   $CashierNo)
static

Get the next transaction number for a given cashier

Parameters
$CashierNocashier number (emp_no in tables)
Returns
integer transaction number
static COREPOS\pos\lib\Database::LineItemTaxes ( )
static

Calculate taxes using new-style taxView.

Returns
an array of records each containing:
  • id
  • description
  • amount (taxes actually due)
  • exempt (taxes exempted because of foodstamps) There will always be one record for each existing tax rate.
static COREPOS\pos\lib\Database::loadglobalvalue (   $param,
  $val 
)
static

Set new value in session.

Parameters
$paramkeycode
$valnew value
static COREPOS\pos\lib\Database::loadglobalvalues ( )
static

Read globalvalues settings into session.

static COREPOS\pos\lib\Database::localMatchingColumns (   $connection,
  $table1,
  $table2 
)
static

Get a list of columns in both tables.

Parameters
$connectiona SQLManager object that's already connected
$table1a database table
$table2a database table
Returns
[string] comma separated list of column names
static COREPOS\pos\lib\Database::logger (   $msg = "")
static

Log a message to the lane log

Parameters
$msgA string containing the message to log.
Returns
True on success, False on failure
static COREPOS\pos\lib\Database::mAltName ( )
static

Get the name of the primary server database This is only relevant in multi-store setups where the lane is shipping data to a temporary holding database to be relayed to the master HQ server later. Most operations can work off this holding database but a few may need to reference the some overarching, all-location data.

Returns
database name w/ . separator or an empty string if no alternate is defined.
static COREPOS\pos\lib\Database::mDataConnect ( )
static

Connect to the remote server database

Returns
a SQLManager object
static COREPOS\pos\lib\Database::pDataConnect ( )
static

Connect to the operational database (local)

Returns
a SQLManager object
static COREPOS\pos\lib\Database::rotateTempData ( )
static

Rotate current transaction data Current data in translog.localtemptrans is inserted into:

  • translog.dtransactions
  • translog.localtrans
  • translog.localtranstoday (if not a view)
  • translog.localtrans_today (if present)
Returns
[boolean] success or failure

Success or failure is based on whether or not the insert into translog.dtransactions succeeds. That's the most important query in terms of ensuring data flows properly to the server.

If store_id column is present in lane dtransactions table and the lane's store_id has been configured, assign that value to the column. Otherwise it may be handled but some other mechanism such as triggers or column default values.

static COREPOS\pos\lib\Database::setglobalflags (   $value)
static

Sets TTLFlag and FntlFlag in globalvalues table

Parameters
$valuevalue for both fields.
static COREPOS\pos\lib\Database::setglobalvalue (   $param,
  $value 
)
static

Update setting in globalvalues table.

Parameters
$paramkeycode
$valuenew value
static COREPOS\pos\lib\Database::setglobalvalues (   $arr)
static

Update many settings in globalvalues table and in session

Parameters
$arrAn array of keys and values
static COREPOS\pos\lib\Database::tDataConnect ( )
static

Connect to the transaction database (local)

Returns
a SQLManager object
static COREPOS\pos\lib\Database::testremote ( )
static

See if the remote database is available This function calls uploadtoServer() if the initial test works.

Returns
integer
  • 1 server available
  • 0 server down
static COREPOS\pos\lib\Database::uploadCCdata ( )
static

Transfer credit card tables to the server. See uploadtoServer().

Returns
boolean success / failure
static COREPOS\pos\lib\Database::uploadtoServer ( )
static

Copy tables from the lane to the remote server The following tables are copied:

  • dtransactions
  • suspended
  • PaycardTransactions
  • CapturedSignature

On success the local tables are truncated. The Paycards tables are copied in the uploadCCdata() function but that gets called automatically.

Returns
  • 1 upload succeeded
  • 0 upload failed

The documentation for this class was generated from the following file: