function fetch_report_data() { global $FANNIE_OP_DB, $FANNIE_PLUGIN_SETTINGS; $dbc = FannieDB::get($FANNIE_OP_DB); $warehouseDB = $FANNIE_PLUGIN_SETTINGS['WarehouseDatabase'] . $dbc->sep(); $query = ' SELECT COUNT(*) AS numTransactions, AVG(-tenderTotal) AS avgTenderTotal, AVG(retailQty+nonRetailQty) AS avgItemQty, AVG(retailTotal+nonRetailtotal) AS avgItemTotal, AVG(retailQty) AS avgRetailQty, AVG(retailTotal) AS avgRetailTotal, m.memDesc, m.custdataType FROM ' . $warehouseDB . 'transactionSummary AS t LEFT JOIN memtype AS m ON t.memType=m.memType WHERE date_id BETWEEN ? AND ? GROUP BY t.memType, m.memDesc, m.custdataType'; $prep = $dbc->prepare($query); $date1 = FormLib::getDate('date1', date('Ymd'), 'Ymd'); $date2 = FormLib::getDate('date2', date('Ymd'), 'Ymd'); $result = $dbc->execute($prep, array($date1, $date2)); $report = array(); while ($w = $dbc->fetch_row($result)) { $report[] = array($w['memDesc'], $w['custdataType'] == 'PC' ? 'Yes' : 'No', sprintf('%d', $w['numTransactions']), sprintf('%.2f', $w['avgTenderTotal']), sprintf('%.2f', $w['avgItemQty']), sprintf('%.2f', $w['avgItemTotal']), sprintf('%.2f', $w['avgRetailQty']), sprintf('%.2f', $w['avgRetailTotal'])); } return $report; }
public function testFormLib() { $val = FormLib::get('someKey'); $this->assertEquals('', $val); $val = FormLib::get('someKey', 'someVal'); $this->assertEquals('someVal', $val); $val = FormLib::get('otherVal', 'someVal'); $this->assertEquals('someVal', $val); $val = FormLib::getDate('someKey'); $this->assertEquals('', $val); $val = FormLib::getDate('someKey', '2000-01-01'); $this->assertEquals('2000-01-01', $val); $val = FormLib::getDate('someKey', '1/1/2000', 'n/j/Y'); $this->assertEquals('1/1/2000', $val); }
public function SaveFormData($upc) { $local = $this->db(); $upc = BarcodeLib::padUPC($upc); $pu = new ProductUserModel($local); $pu->upc($upc); $pu->enableOnline(FormLib::get('u_online') == 1 ? 1 : 0); $pu->soldOut(FormLib::get('u_soldout') == 1 ? 1 : 0); $pu->save(); include dirname(__FILE__) . '/../../src/Credentials/OutsideDB.tunneled.php'; $remote = $dbc; $pu->load(); if ($pu->enableOnline() && $remote->isConnected()) { $pu->setConnection($remote); $pu->save(); $prod = new ProductsModel($local); $prod->upc($upc); $prod->load(); $prod->setConnection($remote); $prod->save(); } elseif (FormLib::get('u_already_online') && $remote->isConnected()) { $prod = new ProductsModel($remote); $prod->upc($upc); $prod->delete(); } if ($local->tableExists('productExpires')) { $e = new ProductExpiresModel($local); $e->upc($upc); $e->expires(FormLib::getDate('u_expires', date('Y-m-d'))); $e->save(); if ($e->expires() && $remote->isConnected()) { $e->setConnection($remote); $e->save(); } } }