CORE POS - Fannie
The CORE POS back end
Static Public Member Functions | Static Public Attributes | List of all members
DTrans Class Reference

Static Public Member Functions

static parameterize ($arr, $datecol='', $datefunc='')
 
static isTesting ($prefix='')
 
static isNotTesting ($prefix='')
 
static isCanceled ($prefix='')
 
static isValid ($prefix='')
 
static isStoreID ($store_id, $prefix='')
 
static sumQuantity ($prefix='')
 
static joinProducts ($dlog_alias='t', $product_alias='p', $join_type='left')
 
static joinDepartments ($dlog_alias='t', $dept_alias='d')
 
static joinCustdata ($dlog_alias='t', $cust_alias='c')
 
static joinTenders ($dlog_alias='t', $tender_alias='n')
 
static getTransNo (SQLManager $connection, $emp_no=false, $register_no=false)
 
static addItem (SQLManager $connection, $trans_no, $params)
 
static addOpenRing (SQLManager $connection, $department, $amount, $trans_no, $params=array())
 

Static Public Attributes

static $DEFAULTS
 

Detailed Description

Helper class for generating useful bits of transaction SQL

Member Function Documentation

static DTrans::addItem ( SQLManager  $connection,
  $trans_no,
  $params 
)
static

Add a transaction record directly to dtransactions on the backend

Parameters
$connection[SQLManager] database connection
$trans_no[integer] transaction number (dtransactions.trans_no)
$params[array] of column_name => value

If emp_no and register_no values are not specified, the defaults are the configuration settings FANNIE_EMP_NO and FANNIE_REGISTER_NO.

The following columns are always calculated by addItem() and values set in $params will be ignored:

  • datetime (always current)
  • trans_id (assigned based on existing records) Additionally, the following values are looked up if $params['card_no'] is specified:
  • memType
  • staff
static DTrans::addOpenRing ( SQLManager  $connection,
  $department,
  $amount,
  $trans_no,
  $params = array() 
)
static

Add an open ring record to dtransactions on the backend

Parameters
$connection[SQLManager] database connection
$department[integer] department number $param $amount [number] ring amount
$trans_no[integer] transaction number (dtransactions.trans_no)
$params[array] of column_name => value

If emp_no and register_no values are not specified, the defaults are the configuration settings FANNIE_EMP_NO and FANNIE_REGISTER_NO.

The following columns are automatically calculated based on department number and amount:

  • upc
  • description
  • trans_type
  • trans_status
  • unitPrice
  • total
  • regPrice
  • quantity
  • ItemQtty Negative amounts result in a refund trans_status

This method calls DTrans::addItem() so columns datetime and trans_id are also automatically assigned.

static DTrans::getTransNo ( SQLManager  $connection,
  $emp_no = false,
  $register_no = false 
)
static

Get an available dtransactions.trans_no value

Parameters
$connection[SQLManager] database connection
$emp_no[int] employee number
$register_no[int] register number
Returns
[int] trans_no
static DTrans::isCanceled (   $prefix = '')
static

Get SQL condition to select canceled transactions

Parameters
$prefix[optional] table alias
Returns
string SQL snippet
static DTrans::isNotTesting (   $prefix = '')
static

Get SQL condition to select non-testing transactions

Parameters
$prefix[optional] table alias
Returns
string SQL snippet
static DTrans::isStoreID (   $store_id,
  $prefix = '' 
)
static

Get SQL condition to select transactions with the given store ID. Store ID must be passed to the resulting prepared statement as an argument

static DTrans::isTesting (   $prefix = '')
static

Get SQL condition to select testing transactions

Parameters
$prefix[optional] table alias
Returns
string SQL snippet
static DTrans::isValid (   $prefix = '')
static

Get SQL condition to select valid transactions This is essentially the opposite of "isCanceled" but excludes some additional informational rows that provide commentary but do not impact numeric totals

Parameters
$prefix[optional] table alias
Returns
string SQL snippet
static DTrans::joinCustdata (   $dlog_alias = 't',
  $cust_alias = 'c' 
)
static

Get join statement for custdata table

Parameters
$dlog_alias[optional] alias for the transaction table (default 't')
$cust_alias[optional] alias for the custdata table (default 'c')
Returns
string SQL snippet
static DTrans::joinDepartments (   $dlog_alias = 't',
  $dept_alias = 'd' 
)
static

Get join statement for departments table

Parameters
$dlog_alias[optional] alias for the transaction table (default 't')
$dept_alias[optional] alias for the departments table (default 'd')
Returns
string SQL snippet
static DTrans::joinProducts (   $dlog_alias = 't',
  $product_alias = 'p',
  $join_type = 'left' 
)
static

Get join statement for products table

Parameters
$dlog_alias[optional] alias for the transaction table (default 't')
$product_alias[optional] alias for the products table (default 'p')
Returns
string SQL snippet
static DTrans::joinTenders (   $dlog_alias = 't',
  $tender_alias = 'n' 
)
static

Get join statement for tenders table

Parameters
$dlog_alias[optional] alias for the transaction table (default 't')
$tender_alias[optional] alias for the tenders table (default 'n')
Returns
string SQL snippet
static DTrans::parameterize (   $arr,
  $datecol = '',
  $datefunc = '' 
)
static

Turn an key=>value array into useful SQL bits

Parameters
$arrarray of column_name => column_value
$datecol[optional] name of datetime column
$datefunc[optional] string database function for current datetime
Returns
keyed array
  • columnString => comma separated list of columns
  • valueString => comma separated list of ? placeholders
  • arguments => array of query parameters
static DTrans::sumQuantity (   $prefix = '')
static

Get standard quantity sum. Member-discount line items are excluded and quasi-scalabe items with a unitPrice of a penny are counted as one instead of whatever value is in the quantity field.

Parameters
$prefix[optional] table alias
Returns
string SQL snippet

Member Data Documentation

DTrans::$DEFAULTS
static

Array of default values for dtransaction-style tables The column 'datetime' is ommitted. Normally an SQL function like NOW() is used there and cannot be a parameter


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