Difference between revisions of "VbzCart/archive/code/SpecialVbzAdmin"
(version from Rizzo -- not the latest, but need to compare) |
(2009-10-04 version) |
||
Line 10: | Line 10: | ||
rewrote menu functions as classes | rewrote menu functions as classes | ||
started on Shipments | started on Shipments | ||
+ | 2009-10-04 (Wzl) | ||
+ | menu classes now in separate file; removed from here | ||
+ | added 'orders' and 'order' pages/classes | ||
*/ | */ | ||
$wgSpecialPages['VbzAdmin'] = 'SpecialVbzAdmin'; # Let MediaWiki know about your new special page. | $wgSpecialPages['VbzAdmin'] = 'SpecialVbzAdmin'; # Let MediaWiki know about your new special page. | ||
Line 17: | Line 20: | ||
'description' => 'special page for VbzCart administration', | 'description' => 'special page for VbzCart administration', | ||
'author' => 'Woozle (Nick) Staddon', | 'author' => 'Woozle (Nick) Staddon', | ||
− | 'version' => '0.0 2009- | + | 'version' => '0.0 2009-10-04 alpha' |
); | ); | ||
global $dbgShowLibs; | global $dbgShowLibs; | ||
Line 32: | Line 35: | ||
clsLibMgr::Add('vbz.shop', kfpLib.'/dev/shop.php'); // development | clsLibMgr::Add('vbz.shop', kfpLib.'/dev/shop.php'); // development | ||
clsLibMgr::Add('forms', kfpLib.'/dev/forms.php'); // development | clsLibMgr::Add('forms', kfpLib.'/dev/forms.php'); // development | ||
+ | clsLibMgr::Add('menus', 'menu.php'); | ||
clsLibMgr::Load('vbz.store'); | clsLibMgr::Load('vbz.store'); | ||
clsLibMgr::Load('vbz.shop'); | clsLibMgr::Load('vbz.shop'); | ||
clsLibMgr::Load('forms'); | clsLibMgr::Load('forms'); | ||
+ | clsLibMgr::Load('menus'); | ||
define('kwp_DocTblPfx','htyp:VbzCart/tables/'); | define('kwp_DocTblPfx','htyp:VbzCart/tables/'); | ||
Line 69: | Line 74: | ||
$objDb = new clsVbzAdminData(KS_DB_VBZCART); | $objDb = new clsVbzAdminData(KS_DB_VBZCART); | ||
$objDb->Open(); | $objDb->Open(); | ||
− | |||
} | } | ||
return $objDb; | return $objDb; | ||
} | } | ||
+ | class SpecialVbzAdmin extends SpecialPage { | ||
+ | //======= | ||
+ | // STATIC | ||
− | + | //======= | |
− | + | // DYNAMIC | |
− | |||
− | |||
− | |||
− | |||
− | + | protected $args; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | public function __construct() { | |
− | + | global $wgMessageCache,$wgUser; | |
− | + | global $vgUsername; | |
− | |||
− | |||
− | |||
− | + | parent::__construct( 'VbzAdmin' ); | |
− | + | $this->includable( false ); | |
− | $this-> | + | $wgMessageCache->addMessage('vbzadmin', 'VbzCart administration'); |
− | + | $vgUsername = 'wiki:'.$wgUser->getName(); | |
− | + | } | |
− | + | function execute( $par ) { | |
− | + | global $wgUser; | |
− | + | ||
− | + | $this->setHeaders(); | |
− | + | $this->GetArgs($par); | |
− | $ | + | |
− | + | if ($wgUser->isAllowed('editinterface')) { | |
− | + | $this->doAdmin(); | |
− | |||
− | $ | ||
− | |||
− | |||
− | if ($ | ||
− | |||
− | |||
} else { | } else { | ||
− | + | $this->doUser(); | |
} | } | ||
− | + | } | |
− | + | private function GetArgs($par) { | |
− | |||
− | + | /* | |
− | + | PURPOSE: Parses variable arguments from the URL | |
− | + | The URL is formatted as a series of arguments /arg=val/arg=val/..., so that we can always refer directly | |
− | $ | + | to any particular item as a wiki page title while also not worrying about hierarchy/order. |
− | + | */ | |
− | + | $args_raw = split('/',$par); | |
− | + | foreach($args_raw as $arg_raw) { | |
− | + | if (strpos($arg_raw,KS_CHAR_URL_ASSIGN) !== FALSE) { | |
− | + | list($key,$val) = split(KS_CHAR_URL_ASSIGN,$arg_raw); | |
− | + | $this->args[$key] = $val; | |
− | + | } | |
} | } | ||
− | } | + | } |
− | + | public function doAdmin() { | |
− | + | global $wgOut; | |
− | + | /* | |
− | + | PURPOSE: do stuff that only admins are allowed to do | |
− | + | */ | |
− | + | if (isset($this->args['page'])) { | |
− | + | $page = $this->args['page']; | |
− | |||
− | |||
− | |||
− | public function | ||
− | global $ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} else { | } else { | ||
− | + | $page = NULL; | |
} | } | ||
− | + | // display menu | |
− | + | $wtSelf = 'Special:'.$this->name(); | |
+ | |||
+ | $objMenu = new clsMenu($wtSelf); | ||
+ | $objMenu->Add($objRow = new clsMenuRow('Stock','menu.stock')); | ||
+ | $objRow->Add(new clsMenuItem('stock places','places')); | ||
+ | $objRow->Add(new clsMenuItem('stock bins','bins')); | ||
+ | $objRow->Add(new clsMenuItem('cache tables','cache')); | ||
+ | $objRow->Add(new clsMenuItem('suppliers','supp')); | ||
+ | $objMenu->Add($objRow = new clsMenuRow('Ship','menu.ship')); | ||
+ | $objRow->Add(new clsMenuItem('items to ship','toship')); | ||
+ | $objRow->Add(new clsMenuItem('shipments','shmpts')); | ||
+ | $objMenu->Add($objRow = new clsMenuRow('Orders','menu.orders')); | ||
+ | $objRow->Add(new clsMenuItem('carts','carts')); | ||
+ | $objRow->Add(new clsMenuItem('orders','orders')); | ||
+ | |||
+ | $out = $objMenu->WikiText($page); | ||
+ | $out .= $objMenu->Execute(); | ||
+ | |||
+ | $wgOut->addHTML('<table style="background: #ccffcc;"><tr><td>'); | ||
+ | $wgOut->addWikiText($out,TRUE); $out = ''; | ||
+ | $wgOut->addHTML('</td></tr></table>'); | ||
− | + | if (!is_null($page)) { | |
− | + | $dbVBZ = VbzDb(); | |
− | + | $id = isset($this->args['id'])?$this->args['id']:NULL; | |
− | + | switch ($page) { | |
− | + | case 'places': | |
− | + | $objPlaces = $dbVBZ->Places(); | |
− | + | $objPlaces->ListPage(); | |
− | if ( | + | break; |
− | + | case 'place': | |
− | $ | + | $objPlaces = $dbVBZ->Places(); |
− | + | $objPlace = $objPlaces->GetItem($id); | |
− | + | $objPlace->InfoPage(); | |
− | + | break; | |
− | + | case 'bins': | |
− | + | $objBins = $dbVBZ->Bins(); | |
− | + | $objBins->ListPage(); | |
− | + | break; | |
− | + | case 'bin': | |
− | + | $objBins = $dbVBZ->Bins(); | |
− | + | $objBin = $objBins->GetItem($id); | |
− | + | $objBin->InfoPage(); | |
− | $page | + | break; |
− | + | case 'cache': | |
− | + | $this->doCacheTables(); | |
− | + | break; | |
− | + | case 'supp': | |
− | + | if (is_null($id)) { | |
− | + | $this->doSuppliers(); | |
− | + | } else { | |
− | + | $this->doSupplier($id); | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
break; | break; | ||
− | + | case 'dept': | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | case 'dept': | ||
$this->doDept($id); | $this->doDept($id); | ||
break; | break; | ||
Line 305: | Line 214: | ||
$objCart->InfoPage(); | $objCart->InfoPage(); | ||
break; | break; | ||
− | } | + | case 'orders': |
+ | $objOrders = new VbzAdminOrders($dbVBZ); | ||
+ | $objOrders->ListPage(); | ||
+ | break; | ||
+ | case 'order': | ||
+ | $objOrders = new VbzAdminOrders($dbVBZ); | ||
+ | $objOrder = $objOrders->GetItem($id); | ||
+ | $objOrder->InfoPage(); | ||
+ | break; | ||
+ | |||
+ | } | ||
} | } | ||
} | } | ||
Line 1,487: | Line 1,406: | ||
$isOdd = TRUE; | $isOdd = TRUE; | ||
while ($objRecs->NextRow()) { | while ($objRecs->NextRow()) { | ||
− | $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; | + | $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; |
− | $isOdd = !$isOdd; | + | $isOdd = !$isOdd; |
− | + | ||
− | $wtType = $objRecs->ValueText(); | + | $wtType = $objRecs->ValueText(); |
− | $wtVal = $objRecs->Val; | + | $wtVal = $objRecs->Val; |
− | + | ||
− | $out .= "\n|- style=\"$wtStyle\"\n| $wtType || $wtVal"; | + | $out .= "\n|- style=\"$wtStyle\"\n| $wtType || $wtVal"; |
− | } | + | } |
− | } else { | + | } else { |
− | $out = "\n''No data in cart''"; | + | $out = "\n''No data in cart''"; |
− | } | + | } |
− | return $out; | + | return $out; |
+ | } | ||
+ | } | ||
+ | class VbzAdminCartDatum extends clsDataSet { | ||
+ | public function ValueText() { | ||
+ | global $vgaCartDataType; | ||
+ | |||
+ | $strType = $this->Type; | ||
+ | if (isset($vgaCartDataType[$strType])) { | ||
+ | $wtType = $vgaCartDataType[$strType]; | ||
+ | } else { | ||
+ | $wtType = "'''?'''$strType"; | ||
+ | } | ||
+ | return $wtType; | ||
+ | } | ||
+ | } | ||
+ | /* ========================== *\ | ||
+ | - CUSTOMER ORDER classes | ||
+ | \* ========================== */ | ||
+ | class VbzAdminOrders extends clsOrders { | ||
+ | public function __construct($iDB) { | ||
+ | parent::__construct($iDB); | ||
+ | $this->ClassSng('VbzAdminOrder'); // override parent | ||
+ | } | ||
+ | public function ListPage() { | ||
+ | global $wgOut; | ||
+ | |||
+ | $out = '==Orders=='."\n"; | ||
+ | $wgOut->addWikiText($out,TRUE); $out = ''; | ||
+ | |||
+ | $out = $this->Listing(); | ||
+ | $wgOut->addWikiText($out,TRUE); $out = ''; | ||
+ | } | ||
+ | protected function Listing() { | ||
+ | $objRow = $this->GetData(NULL,NULL,'SortPfx, Number DESC'); | ||
+ | if ($objRow->hasRows()) { | ||
+ | $out = "{| class=sortable \n|-\n! ID || Number || Status || Total Amt || created || closed"; | ||
+ | $isOdd = TRUE; | ||
+ | while ($objRow->NextRow()) { | ||
+ | $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; | ||
+ | $isOdd = !$isOdd; | ||
+ | |||
+ | $row = $objRow->Row; | ||
+ | |||
+ | $id = $row['ID']; | ||
+ | $strNum = $row['Number']; | ||
+ | $idPull = $row['ID_Pull']; | ||
+ | $mnyTotal = $row['WebTotal_Final']; | ||
+ | $dtCreate = $row['WhenStarted']; | ||
+ | $dtClosed = $row['WhenClosed']; | ||
+ | |||
+ | $wtNum = SelfLink('order','id',$id,$strNum); | ||
+ | $strTotal = DataCurr($mnyTotal); | ||
+ | $strWhenCreated = DataDate($dtCreate); | ||
+ | $strWhenClosed = DataDate($dtClosed); | ||
+ | |||
+ | $out .= "\n|- style=\"$wtStyle\""; | ||
+ | $out .= "\n| $id || $wtNum || $idPull || align=right | $strTotal || $strWhenCreated || $strWhenClosed"; | ||
+ | } | ||
+ | $out .= "\n|}\n"; | ||
+ | } else { | ||
+ | $out = 'There do not seem to be any order records yet.'; | ||
+ | } | ||
+ | return $out; | ||
+ | } | ||
+ | } | ||
+ | class VbzAdminOrder extends clsOrder { | ||
+ | public function InfoPage() { | ||
+ | global $wgOut; | ||
+ | |||
+ | $wtSess = SelfLink('sess','id',$this->ID_Sess); | ||
+ | $wtOrd = SelfLink('ord','id',$this->ID_Order); | ||
+ | $wtCust = SelfLink('cust','id',$this->ID_Cust); | ||
+ | |||
+ | $out = '==Order=='."\n"; | ||
+ | $out .= "\n* '''ID''': ".$this->ID.' - #'.$this->Number; | ||
+ | $out .= "\n* '''When Created''': ".$this->WhenStarted; | ||
+ | $out .= "\n* '''When Closed''': ".$this->WhenClosed; | ||
+ | $wgOut->addWikiText($out,TRUE); $out = ''; | ||
+ | $out .= "\n===Items==="; | ||
+ | $out .= $this->ItemTable(); | ||
+ | $wgOut->addWikiText($out,TRUE); $out = ''; | ||
+ | $out .= "\n===Transactions==="; | ||
+ | $out .= "\n===Messages==="; | ||
+ | $out .= "\n===Charges==="; | ||
+ | } | ||
+ | public function ItemTable() { | ||
+ | $objItems = new VbzAdminOrderItems($this->objDB); | ||
+ | return $objItems->Table_forOrder($this->ID); | ||
+ | } | ||
+ | } | ||
+ | class VbzAdminOrderItems extends clsOrderLines { | ||
+ | public function __construct($iDB) { | ||
+ | parent::__construct($iDB); | ||
+ | $this->ClassSng('VbzAdminOrderItem'); // override parent | ||
} | } | ||
− | + | public function Table_forOrder() { | |
− | |||
− | public function | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
− | + | class VbzAdminOrderItem extends clsOrderLine { | |
− | class | ||
} | } | ||
− | |||
</php> | </php> |
Revision as of 11:22, 5 October 2009
<php><?php /*
NAME: SpecialVbzAdmin PURPOSE: Special page for administering VbzCart AUTHOR: Woozle (Nick) Staddon VERSION:
2009-03-10 0.0 (Wzl) Started writing had a few functions implemented by June or so, but not enough to process anything 2009-07-09 (Wzl) rewrote menu functions as classes started on Shipments 2009-10-04 (Wzl) menu classes now in separate file; removed from here added 'orders' and 'order' pages/classes
- /
$wgSpecialPages['VbzAdmin'] = 'SpecialVbzAdmin'; # Let MediaWiki know about your new special page. $wgExtensionCredits['other'][] = array(
'name' => 'Special:VbzAdmin',
'url' => 'http://htyp.org/VbzCart',
'description' => 'special page for VbzCart administration', 'author' => 'Woozle (Nick) Staddon',
'version' => '0.0 2009-10-04 alpha' ); global $dbgShowLibs; $dbgShowLibs = TRUE;
//require_once KFP_LIB_VBZ.'site.php'; //require_once KFP_VBZ_LIBS.'store.php'; // normal location //require_once kfpLib.'/dev/data.php'; // development if (!defined('LIBMGR')) {
require('libmgr.php');
} //clsLibMgr::$doDebug = TRUE; clsLibMgr::Add('vbz.store', kfpLib.'/dev/store.php'); // development clsLibMgr::Add('vbz.shop', kfpLib.'/dev/shop.php'); // development clsLibMgr::Add('forms', kfpLib.'/dev/forms.php'); // development clsLibMgr::Add('menus', 'menu.php'); clsLibMgr::Load('vbz.store'); clsLibMgr::Load('vbz.shop'); clsLibMgr::Load('forms'); clsLibMgr::Load('menus');
define('kwp_DocTblPfx','htyp:VbzCart/tables/');
/* //require_once KFP_LIB.'libmgr.php';
clsLibMgr::AddLib('datamgr',KFP_LIB.'dev/datamgr.php'); clsLibMgr::AddLib('data',KFP_LIB.'dev/data.php'); clsLibMgr::AddLib('store',KFP_LIB.'dev/store.php');
//clsLibMgr::UseLib('datamgr'); clsLibMgr::UseLib('store');
- /
define('KS_CHAR_URL_ASSIGN',':'); // character used for encoding values in wiki-internal URLs
// data source names -- these are used only by admin functions; general tables are in store.php define('KSQL_DS_ITEMS_TO_SHIP','qryStock_forOpenOrders');
function wfSpecialVbzAdmin() { // This registers the page's class. I think. global $wgRequest;
$app = new SpecialVbzAdmin($wgRequest); }
require_once( $wgScriptPath.'includes/SpecialPage.php' );
function VbzDb() {
static $objDb;
if (!isset($objDb)) {
$objDb = new clsVbzAdminData(KS_DB_VBZCART); $objDb->Open();
} return $objDb;
} class SpecialVbzAdmin extends SpecialPage { //======= // STATIC
//======= // DYNAMIC
protected $args;
public function __construct() {
global $wgMessageCache,$wgUser; global $vgUsername;
parent::__construct( 'VbzAdmin' ); $this->includable( false );
$wgMessageCache->addMessage('vbzadmin', 'VbzCart administration');
$vgUsername = 'wiki:'.$wgUser->getName();
} function execute( $par ) {
global $wgUser;
$this->setHeaders(); $this->GetArgs($par);
if ($wgUser->isAllowed('editinterface')) { $this->doAdmin(); } else { $this->doUser(); }
} private function GetArgs($par) {
/*
PURPOSE: Parses variable arguments from the URL The URL is formatted as a series of arguments /arg=val/arg=val/..., so that we can always refer directly to any particular item as a wiki page title while also not worrying about hierarchy/order.
- /
$args_raw = split('/',$par); foreach($args_raw as $arg_raw) {
if (strpos($arg_raw,KS_CHAR_URL_ASSIGN) !== FALSE) { list($key,$val) = split(KS_CHAR_URL_ASSIGN,$arg_raw); $this->args[$key] = $val; }
} } public function doAdmin() {
global $wgOut; /* PURPOSE: do stuff that only admins are allowed to do
- /
if (isset($this->args['page'])) { $page = $this->args['page']; } else { $page = NULL; } // display menu $wtSelf = 'Special:'.$this->name();
$objMenu = new clsMenu($wtSelf); $objMenu->Add($objRow = new clsMenuRow('Stock','menu.stock')); $objRow->Add(new clsMenuItem('stock places','places')); $objRow->Add(new clsMenuItem('stock bins','bins')); $objRow->Add(new clsMenuItem('cache tables','cache')); $objRow->Add(new clsMenuItem('suppliers','supp')); $objMenu->Add($objRow = new clsMenuRow('Ship','menu.ship')); $objRow->Add(new clsMenuItem('items to ship','toship')); $objRow->Add(new clsMenuItem('shipments','shmpts')); $objMenu->Add($objRow = new clsMenuRow('Orders','menu.orders')); $objRow->Add(new clsMenuItem('carts','carts')); $objRow->Add(new clsMenuItem('orders','orders'));
$out = $objMenu->WikiText($page); $out .= $objMenu->Execute();
$wgOut->addHTML('
');
$wgOut->addWikiText($out,TRUE); $out = ; $wgOut->addHTML(' |
');
if (!is_null($page)) { $dbVBZ = VbzDb(); $id = isset($this->args['id'])?$this->args['id']:NULL; switch ($page) { case 'places': $objPlaces = $dbVBZ->Places(); $objPlaces->ListPage(); break; case 'place': $objPlaces = $dbVBZ->Places(); $objPlace = $objPlaces->GetItem($id); $objPlace->InfoPage(); break; case 'bins': $objBins = $dbVBZ->Bins(); $objBins->ListPage(); break; case 'bin': $objBins = $dbVBZ->Bins(); $objBin = $objBins->GetItem($id); $objBin->InfoPage(); break; case 'cache': $this->doCacheTables(); break; case 'supp': if (is_null($id)) { $this->doSuppliers(); } else { $this->doSupplier($id); } break; case 'dept': $this->doDept($id); break; case 'title': $this->doTitle($id); break; case 'toship': $this->doStockToShip(); break; case 'shmpts': $objShpmts = new clsShipments($dbVBZ); $objShpmts->ListPage(); break; case 'shipmt': $objShpmts = new clsShipments($dbVBZ); $objShipmt = $objShpmts->GetItem($id); $objShipmt->InfoPage(); break; case 'carts': $objCarts = new VbzAdminCarts($dbVBZ); $objCarts->ListPage(); break; case 'cart': $objCarts = new VbzAdminCarts($dbVBZ); $objCart = $objCarts->GetItem($id); $objCart->InfoPage(); break; case 'orders': $objOrders = new VbzAdminOrders($dbVBZ); $objOrders->ListPage(); break; case 'order': $objOrders = new VbzAdminOrders($dbVBZ); $objOrder = $objOrders->GetItem($id); $objOrder->InfoPage(); break;
} }
} public function doUser() {
global $wgOut; /* PURPOSE: do only stuff that regular users are allowed to do
- /
$wgOut->AddWikiText('Hello regular user! I haven\'t written anything for you yet, but soon (Josh permitting).');
}
// individual admin functions
public function doStockToShip() {
global $wgOut;
$dbVBZ = VbzDb(); $out = '==Stock to Ship=='."\n"; $wgOut->addWikiText($out,TRUE); $out = ; $objRows = $dbVBZ->DataSet('SELECT * FROM '.KSQL_DS_ITEMS_TO_SHIP); if ($objRows->hasRows()) { $out = "{| class=sortable \n|-\n! item || order || # needed || # avail || bin"; while ($objRows->NextRow()) { $idItem = $objRows->ID_Item; $idOrd = $objRows->ID_Order; $idBin = $objRows->ID_Bin; $strOrd = $objRows->OrdText?$objRows->OrdText:'?ord#?'; $wtItem = ''.$idItem.' '.SelfLink('item','id',$idItem,$objRows->ItemText); $wtOrder = ''.$idOrd.' '.SelfLink('ord','id',$idOrd,$strOrd); $wtBin = ''.$idBin.' '.SelfLink('bin','id',$idBin,$objRows->BinText); $wtQtyNeed = $objRows->QtyOpen; $intQtyForShip = $objRows->QtyForSale; $intQtyForSale = $objRows->QtyForSale; $wtQtyAvail = $intQtyForShip; if ($intQtyForShip != $intQtyForSale) { $wtQtyAvail .= ' ('.$intQtyForSale.')'; } $out .= "\n|-\n| $wtItem || $wtOrder || $wtQtyNeed || $wtQtyAvail || $wtBin"; } $out .= "\n|}\n(Retrieval complete.)";
} else {
$out = 'No stock items available for open orders.';
} $wgOut->addWikiText($out,TRUE); $out = ; } public function doCacheTables() {
global $wgRequest, $wgOut; global $objDataMgr;
$out = '==Cache Tables=='."\n"; $wgOut->addWikiText($out,TRUE); $out = ;
$dbVBZ = VbzDb();
// check for action requests $strDo = $wgRequest->getVal('do'); $strTbls = $wgRequest->getVal('table-info'); $objDataMgr = new clsDataMgr($dbVBZ,ksTbl_cache_tables,ksTbl_cache_procs,ksTbl_cache_flow,ksTbl_cache_log); if ($strDo != ) { $idTbl = $wgRequest->getVal('table'); switch ($strDo) { case 'table-update': $out = $dbVBZ->UpdateTable($idTbl,'Special:VbzAdmin'); break; case 'table-stamp'; $out = $dbVBZ->StampTable($idTbl,'Special:VbzAdmin'); break; } $wgOut->addWikiText($out,TRUE); $out = ; }
// display the current status $out = $dbVBZ->ShowTables($strTbls); $wgOut->addWikiText($out,TRUE); $out = ; $dbVBZ->Shut();
// $wgOut->addHTML($out);
} public function doSuppliers() {
$dbVBZ = VbzDb(); $objSupps = $dbVBZ->Suppliers(); $objSupps->ListPage();
} public function doSupplier($iID) {
$dbVBZ = VbzDb(); $objSupps = $dbVBZ->Suppliers(); $objSupp = $objSupps->GetItem($iID); $objSupp->InfoPage();
} public function doDept($iID) {
$dbVBZ = VbzDb(); $objDepts = $dbVBZ->Depts(); $objDept = $objDepts->GetItem($iID); $objDept->InfoPage();
} public function doTitle($iID) {
$dbVBZ = VbzDb(); $objTitles = $dbVBZ->Titles(); $objTitle = $objTitles->GetItem($iID); $objTitle->InfoPage();
}
}
class clsVbzAdminData extends clsVbzData {
public function Suppliers() {
return $this->Make('VbzAdminSuppliers');
} public function Depts() {
return $this->Make('VbzAdminDepts');
} public function Titles() {
return $this->Make('VbzAdminTitles');
} public function Items() {
return $this->Make('VbzAdminItems');
} public function Places() {
return $this->Make('VbzStockPlaces');
} public function Bins() {
return $this->Make('VbzStockBins');
} public function StkLines() {
return $this->Make('VbzAdminStkItems');
} public function CartLines() {
return $this->Make('clsShopCartLines');
} public function UpdateTable($iID,$iCaller) {
/*
ACTION: Update the table by running all the procs which target it
- /
global $objDataMgr;
$out = ;
$arDone = $objDataMgr->Update_byID($iID,$iCaller);
$out .= $objDataMgr->strMsgs;
if (is_array($arDone)) {
foreach($arDone AS $ID=>$obj) {
$out .= "\n* ".$obj->Name;
}
} else {
$out .= '
No tables updated.';
}
/*
$sql =
'SELECT df.ID_Dest, dp.Name, dp.doesClear'.
' FROM data_flow AS df LEFT JOIN data_procs AS dp ON df.ID_Proc=dp.ID'.
' WHERE ID_Dest='.$this->SafeParam($iID).
' ORDER BY df.ID_Dest, IF(dp.doesClear,0,1)';
// $out = $sql;
$objProcs = $this->DataSet($sql); if ($objProcs->hasRows()) { $out = 'Running update procedures:'; while ($objProcs->hasRow()) { $out .= "\n* ".$objProcs->Name.'()'; $objProcs->NextRow(); }
} else { $out = 'Nothing to update.'; }
- /
return $out;
} public function StampTable($iID,$iCaller) {
/*
ACTION: Update the table's timestamp so that dependent tables will get updated as needed
- /
$sql = 'UPDATE '.ksTbl_cache_tables.' SET WhenUpdated=NOW() WHERE ID='.$iID; $this->Open(); $this->Exec($sql);
$objLogger = VbzDb()->Events(); $objLogger->LogEvent(__CLASS__.'.'.__METHOD__,'ID='.$iID,'stamp table',NULL,FALSE,FALSE); $this->Shut();
} public function ShowTables($iTbls) {
global $objDataMgr;
assert('is_object($objDataMgr)'); assert('is_object($objDataMgr->Tables)');
$objTbls = $this->DataSet('SELECT * FROM '.ksTbl_cache_tables.' WHERE Name != "" ORDER BY Name');
// convert table info string-list to an array: $tok = substr ( $iTbls, 0, 1); // token for splitting if ($tok) { $tks = substr ( $iTbls, 1 ); // tokenized string $tkl = explode ( $tok, $tks ); // split the string foreach ($tkl as $value) { if ($value) { $lstTbls[$value] = $value; } } } else { $lstTbls = NULL; }
if ($objTbls->hasRows()) { $out = "{| class=sortable \n|-\n! table name || last update || targets || sources || notes"; while ($objTbls->NextRow()) { if ($objTbls->isActive) { $strTbl = $objTbls->Name; $idTbl = $objTbls->ID;
$objSrces = $this->DataSet('SELECT * FROM '.ksTbl_cache_flow.' WHERE ID_Dest='.$objTbls->ID); $objTargs = $this->DataSet('SELECT * FROM '.ksTbl_cache_flow.' WHERE ID_Srce='.$objTbls->ID); $cntSrces = $objSrces->RowCount(); $cntTargs = $objTargs->RowCount();
// table info open/shut calculations $doInfo = isset($lstTbls[$idTbl]); $lstTblsThis = $lstTbls; if ($doInfo) { // remove this table from the list unset($lstTblsThis[$idTbl]); } else { // add this table to the list $lstTblsThis[$idTbl] = $idTbl; } // rebuild the string-list if (count($lstTblsThis) > 0) { $strTbls = ':'.implode(':',$lstTblsThis); $htTblName = WikiSelfLink('table-info='.$strTbls,$strTbl); } else { $strTbls = NULL; $htTblName = WikiSelfLink(,$strTbl); } // build the table name HTML if ($doInfo) { $htTblName = ''.$htTblName.''; }
$txtSrces = ; $htTblLink = '&table='.$idTbl;
if ($cntSrces) { $txtSrces .= WikiSelfLink('do=table-update'.$htTblLink,'update').' ('.$cntSrces.')'; } $txtTargs = ; if ($cntTargs) { $txtTargs .= WikiSelfLink('do=table-stamp'.$htTblLink,'stamp').' ('.$cntTargs.')'; }
$out .= "\n|-\n| ".$htTblName. ' || ' . $objTbls->WhenUpdated . ' || '.$txtTargs. ' || '.$txtSrces. ' || '.$objTbls->Notes;
// if table is selected to show info, add a row for that: if ($doInfo) { $out .= "\n|-\n| colspan=5 |"; if ($objSrces->hasRows()) { $out .= "\n* Sources:"; while ($objSrces->NextRow()) { $objSrce = $objDataMgr->Tables->GetItem($objSrces->ID_Srce); if ($objSrce->isActive) { $strName = $objSrce->Name; $out .= ' '.$strName.''; } else { $out .= " N/A id=".$objSrces->ID_Srce.""; } } } if ($objTargs->hasRows()) { $out .= "\n* Targets:"; while ($objTargs->NextRow()) { $objTarg = $objDataMgr->Tables->GetItem($objTargs->ID_Dest); if ($objTarg->isActive) { $strName = $objTarg->Name; $out .= ' '.$strName.''; } else { $out .= " N/A id=".$objTargs->ID_Dest.""; } } } } } } $out .= "\n|}"; } else { $out .= 'ERROR: Mysterious lack of data'; } return $out;
}
} function SelfLink($iPage,$iKey,$iVal,$iText=NULL) {
$strText = (is_null($iText))?$iVal:$iText; if (is_null($strText)) {
return NULL;
} else {
return ''.$strText.'';
}
} function WikiSelfLink($iArgs,$iText) { // this function is deprecated; gradually convert to SelfLink and then rename it
return ''.$iText.'';
} function TimeStamp_HideTime($iStamp) {
if (is_string($iStamp)) {
$intStamp = strtotime($iStamp);
} else if (is_int($iStamp)) {
$intStamp = $iStamp;
} else {
$intStamp = NULL;
} if (!is_null($intStamp)) {
return date('Y-m-d',$intStamp);
} else {
return NULL;
}
}
class VbzStockPlaces extends clsTable {
public function __construct($iDB) {
parent::__construct($iDB); $this->Name(ksTbl_stock_places); $this->KeyName('ID'); $this->ClassSng('VbzStockPlace');
} public function ListPage() {
global $wgOut;
$out = '==Stock Locations=='."\n"; $wgOut->addWikiText($out,TRUE); $out = ;
$out = $this->Listing(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function Listing($iParent=0) {
$dbVBZ = VbzDb();
// if (!is_null($iParent)) { // $sqlFilt = ' WHERE ID_Parent='.$iParent; // } else { $sqlFilt = ; // } $sql = 'SELECT * FROM '.ksTbl_stock_places.' ORDER BY Name'; $objRow = $dbVBZ->DataSet($sql); if ($objRow->hasRows()) { while ($objRow->NextRow()) { //$arRows[$objRow->ID] = $objRow->Row; $idParent = $objRow->ID_Parent; $idRow = $objRow->ID; $arData[$idRow] = $objRow->Row; if (is_null($idParent)) { $arTree[0][] = $idRow; } else { $arTree[$idParent][] = $idRow; } } $out = "{| class=sortable \n|-\n! ID || name || description"; $out .= $this->ListSubStkPlaces($arData,$arTree,$iParent); $out .= "\n|}"; } else { $out = NULL; } return $out;
} private function ListSubStkPlaces($iData, $iTree, $iBranch=0, $iInd=0) { $ind = $iInd+1; $out = ;
if (isset($iTree[$iBranch])) {
foreach($iTree[$iBranch] AS $key=>$ID) { $row = $iData[$ID]; $htPlacePfx = ''; $htPlaceName = $htPlacePfx.$row['Name'].''; $out .= "\n|-\n| ".$ID.' || '.str_repeat('+ ',$iInd).''.$htPlaceName.' || '.$row['Descr']; $out .= $this->ListSubStkPlaces($iData,$iTree,$ID,$ind); }
} return $out; }
} class VbzStockPlace extends clsDataSet {
public function HasParent() {
return !is_null($this->ID_Parent);
} public function ParentObj() {
if ($this->HasParent()) { $objPlaces = new VbzStockPlaces($this->objDB); $obj = $objPlaces->GetItem($this->ID_Parent); } else { $obj = NULL; } return $obj;
} public function InfoPage() {
global $wgOut;
$out = '==Stock Location '.$this->ID.'=='."\n"; $out .= "\n* Name: ".$this->InfoLink(); if (!is_null($this->Descr)) { $out .= "\n* Description: ".$this->Descr; } if ($this->HasParent()) { $out .= "\n* Parent: ".$this->ParentObj()->InfoLink(); } $wgOut->addWikiText($out,TRUE); $out = ; $out = "===Sub-Locations===\n"; $out .= $this->SubsList(); $wgOut->addWikiText($out,TRUE); $out = ; $out = "\n===Bins===\n"; $out .= $this->BinsList(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function InfoLink() {
return '[[VbzCart/archive/code/SpecialVbzAdmin/page'.KS_CHAR_URL_ASSIGN.'place/id'.KS_CHAR_URL_ASSIGN.$this->ID.'|'.$this->Name.']]';
} public function SubsList() {
$objPlaces = new VbzStockPlaces($this->objDB); $out = $objPlaces->Listing($this->ID); return $out;
} public function BinsList() {
$objBins = new VbzStockBins($this->objDB); $out = $objBins->Listing($this->ID); /* $objRow = $objBins->GetData('ID_Place='.$this->ID,'VbzStockBin','code'); if ($objRow->hasRows()) { $out = "{| class=sortable \n|-\n! ID || code || description"; while ($objRow->NextRow()) { $id = $objRow->ID; $out .= "\n|-\n| $id || ".$objRow->Code." || ".$objRow->Descr; } $out .= "\n|}"; } else { $out = 'This stock location does not contain any bins.'; }
- /
return $out;
}
} class VbzStockBins extends clsTable {
public function __construct($iDB) {
parent::__construct($iDB); $this->Name(ksTbl_stock_bins); $this->KeyName('ID'); $this->ClassSng('VbzStockBin');
} public function ListPage() {
global $wgOut;
$out = '==Stock Bins=='."\n"; $wgOut->addWikiText($out,TRUE); $out = ;
// Open the VbzCart database /* $dbVBZ = new clsVbzData(KS_DB_VBZCART); $dbVBZ->Open(); VbzClasses::DB($dbVBZ);
- /
$out = $this->Listing(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function Listing($iPlace=NULL) {
$dbVBZ = $this->objDB; if (is_null($iPlace)) { $sqlFilt = ; $htPlaceHdr = ' where ||'; $doPlace = TRUE; } else { $sqlFilt = ' WHERE ID_Place='.$iPlace; $htPlaceHdr = ; $doPlace = FALSE; }
$objRow = $dbVBZ->DataSet('SELECT * FROM '.ksQry_stock_bins_wInfo.$sqlFilt.' ORDER BY Code');
$out = "{| class=sortable \n|-\n! ID || A? ||code || qtys ||$htPlaceHdr description || when
created || when
voided";
if ($objRow->hasRows()) {
while ($objRow->NextRow()) {
$row = $objRow->Row;
$qtySale = $row['QtyForSale'];
$qtyShip = $row['QtyForShip'];
$qtyRec = $row['QtyExisting'];
$strQty = NULL;
if ($qtySale+$qtyShip+$qtyRec) {
if ($qtySale) {
$strQty .= "$qtySale";
}
if ($qtyShip <> $qtySale) {
$strQty .= '+'.$qtyShip-$qtySale;
}
if ($qtyRec <> $qtyShip) {
$strQty .= '+'.($qtyRec-$qtyShip).'';
}
}
if ($doPlace) {
$htPlace =
'[[VbzCart/archive/code/SpecialVbzAdmin/page'.KS_CHAR_URL_ASSIGN.
'place/place'.KS_CHAR_URL_ASSIGN.
$row['ID_Place'].'|'.$row['PlaceName'].']] || ';
} else {
$htPlace = ;
}
$isActive = is_null($row['WhenVoided']);
if ($isActive) {
$htCellPfx = ;
$htCellSfx = ;
$htActive = '√';
} else {
$htCellPfx = '';
$htCellSfx = '';
$htActive = ;
}
$id = $row['ID'];
$htCode = ''.$row['Code'].'';
$out .= "\n|-\n| "
.$htCellPfx.$id.$htCellSfx.' || '
.$htActive.' || '
.$htCellPfx.$htCode.$htCellSfx.' || '
.$htCellPfx.$strQty.$htCellSfx.' || '
.$htCellPfx.$htPlace.$htCellSfx
.$htCellPfx.''.$row['Descr'].''.$htCellSfx.' || '
.$htCellPfx.TimeStamp_HideTime($row['WhenCreated']).$htCellSfx.' || '
.TimeStamp_HideTime($row['WhenVoided']);
// $out .= '
'.var_export($row,TRUE).'
';
} } return $out;
}
} class VbzStockBin extends clsDataSet {
public function PlaceObj() {
$objPlaces = new VbzStockPlaces($this->objDB); $obj = $objPlaces->GetItem($this->ID_Place); return $obj;
} public function SelfLink($iText) {
return SelfLink('bin','id',$this->ID,$iText);
} public function InfoPage() {
global $wgOut;
$out = '==Stock Bin '.$this->ID.'=='."\n"; $out .= "\n* Code: ".$this->Code; $objPlace = $this->PlaceObj(); $out .= "\n* Where: ".$objPlace->InfoLink(); if (!is_null($this->Descr)) { $out .= "\n* Description: ".$this->Descr; } if (!is_null($this->Notes)) { $out .= "\n* Notes: ".$this->Notes; } $wgOut->addWikiText($out,TRUE); $out = ; $out = "===Stock Lines===\n"; $out .= $this->StockList(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function StockList() {
$sqlSource = ksTbl_stock_items.' AS si LEFT JOIN qryCat_Items AS ci ON si.ID_Item=ci.ID';
$sqlCols = 'si.*, ci.CatNum AS ItCatNum, ci.ID_Title, ci.Title_Name AS TiName';
$objRow = $this->objDB->DataSet(
'SELECT '.$sqlCols.
' FROM '.$sqlSource.
' WHERE ID_Bin='.$this->ID.
' ORDER BY WhenRemoved,ItCatNum',
'VbzAdminItem');
if ($objRow->hasRows()) {
$out = "{| class=sortable \n|-".
"\n! ID || A? || CatNum || qty || title || when
added || when
changed || when
counted || when
removed || notes";
$isOdd = TRUE;
while ($objRow->NextRow()) {
$row = $objRow->Row;
$wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isOdd = !$isOdd;
$isActive = is_null($row['WhenRemoved']) && ($row['Qty'] > 0); if (!$isActive) { $wtStyle .= ' color: #888888;'; $wtStyle .= ' text-decoration: line-through;'; }
$id = $row['ID']; $htID = $objRow->AdminLink($id); // $htID = $objRow->AdminLink('A').' '.$id; $idItem = $row['ID_Item']; $wtCatNum = is_null($row['CatNum'])?"".$row['ItCatNum']."":$row['CatNum']; $isActive = is_null($row['WhenRemoved']); $htActive = $isActive?'√':; $txtQty = $row['Qty']; $txtTitle = $objRow->StoreLink($row['TiName']); $txtWhenAdded = TimeStamp_HideTime($row['WhenAdded']); $txtWhenChged = TimeStamp_HideTime($row['WhenChanged']); $txtWhenCnted = TimeStamp_HideTime($row['WhenCounted']); $txtWhenRmved = TimeStamp_HideTime($row['WhenRemoved']); $txtNotes = $row['Notes']; $out .= "\n|- style=\"$wtStyle\"\n| $htID || $htActive || $wtCatNum || $txtQty || $txtTitle || $txtWhenAdded || $txtWhenChged || $txtWhenCnted || $txtWhenRmved"; } } return $out;
}
}
class VbzAdminSuppliers extends clsSuppliers {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminSupplier');
} public function ListPage() {
global $wgOut;
$out = '==Suppliers=='; $wgOut->addWikiText($out,TRUE); $out = ; $objRecs = $this->GetData(); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || A? || Code || Name"; $isOdd = TRUE; while ($objRecs->NextRow()) { $strCatKey = $objRecs->CatKey; $id = $objRecs->ID; $strCol2 = "C [[VbzCart/archive/code/SpecialVbzAdmin/page". KS_CHAR_URL_ASSIGN."supp/id". KS_CHAR_URL_ASSIGN.$id."|A]] "; $strCol2 .= $strCatKey; $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isActive = $objRecs->isActive; if ($isActive) { $wtName = '[['.$objRecs->Name.']]'; } else { $wtName = $objRecs->Name; $wtStyle .= ' color: #888888;'; } $out .= "\n|- style=\"$wtStyle\"\n| ".$id.' || '.($isActive?'√':).' || '.$strCol2.' || '.$wtName; $isOdd = !$isOdd; } $out .= "\n|}"; } else { $out = 'No suppliers have been created yet.'; } $wgOut->addWikiText($out,TRUE); $out = ;
}
} class VbzAdminSupplier extends clsSupplier {
public function InfoPage() {
global $wgOut;
$strCatKey = $this->CatKey; $out = '==Supplier=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* CatKey: '.$strCatKey.''; $out .= "\n* Name: [[".$this->Name.']]'; $out .= "\n===Departments==="; $wgOut->addWikiText($out,TRUE); $out = ; $out = $this->DeptsListing(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function DeptsListing() {
$out = $this->objDB->Depts()->Listing_forSupp($this->ID,$this); return $out;
}
}
class VbzAdminDepts extends clsDepts {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminDept');
} public function Listing_forSupp($iSuppID,$iSuppObj=NULL) {
global $wgOut;
if (is_null($iSuppObj)) { $objSupp = $this->objDB->Suppliers()->GetItem($iSuppID); } else { $objSupp = $iSuppObj; } $strSuppKey = strtolower($objSupp->CatKey);
$objRecs = $this->GetData('ID_Supplier='.$iSuppID,'VbzAdminDept','Sort'); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || A? || Cat || Page || Sort || Name || Description"; $isOdd = TRUE; while ($objRecs->NextRow()) { $strPageCode = $objRecs->PageKey; if (is_null($strPageCode)) { $wtPageCode = $strPageCode; } else { $strPagePath = $strSuppKey.'/'.strtolower($strPageCode); $wtPageCode = ''.$strPageCode.''; } $id = $objRecs->ID; $wtID = SelfLink('dept','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isActive = $objRecs->isActive; if (!$isActive) { $wtStyle .= ' color: #888888;'; } $out .= "\n|- style=\"$wtStyle\"". "\n| ".$wtID. ' || '.($isActive?'√':). ' || '.$objRecs->CatKey. ' || '.$wtPageCode. ' || '.$objRecs->Sort. ' || '.$objRecs->Name. ' || '.$objRecs->Descr; $isOdd = !$isOdd; } $out .= "\n|}"; } else { $out = 'This supplier has no departments.'; } $wgOut->addWikiText($out,TRUE); $out = ;
}
} class VbzAdminDept extends clsDept {
public function InfoPage() {
global $wgOut;
$strCatKey = $this->CatKey; $strPageKey = $this->PageKey; $out = '==Department=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* CatKey: ".$strCatKey; $out .= "\n* PageKey: '.$strPageKey.''; $out .= "\n* Name: [[".$this->Name.']]'; $out .= "\n===Titles==="; $wgOut->addWikiText($out,TRUE); $out = ; $out = $this->TitleListing(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function TitleListing() {
$out = $this->objDB->Titles()->Listing_forDept($this); return $out;
}
} class VbzAdminTitles extends clsTitles {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminTitle');
} public function Listing_forDept($iDeptObj) {
global $wgOut; global $sql;
$objDept = $iDeptObj; $idDept = $objDept->ID; // $strSuppKey = strtolower($objSupp->CatKey);
$objRecs = $this->GetData('ID_Dept='.$idDept,'VbzAdminTitle','CatKey'); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || Cat # || Name || Discont."; $isOdd = TRUE; while ($objRecs->NextRow()) { // $wtPageCode = ''.$strPageCode.''; $id = $objRecs->ID; $wtID = SelfLink('title','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isActive = $objRecs->IsActive(); if (!$isActive) { $wtStyle .= ' color: #888888;'; } $out .= "\n|- style=\"$wtStyle\"". "\n| ".$wtID. ' || '.$objRecs->CatKey. ' || '.$objRecs->Name. ' || '.DataDate($objRecs->DateUnavail); if (!is_null($objRecs->Descr)) { $out .= "\n|- style=\"$wtStyle\"\n| colspan=4 | ".$objRecs->Descr; }
$isOdd = !$isOdd; } $out .= "\n|}"; } else { $out = 'This department has no titles. (SQL='.$sql.')'; } $wgOut->addWikiText($out,TRUE); $out = ;
}
} class VbzAdminTitle extends clsTitle {
public function InfoPage() {
global $wgOut;
$strCatNum = $this->CatNum(); $strCatPage = $this->CatNum('/'); $out = '==Title=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* Cat #: '.$strCatNum.''; $out .= "\n* Name: ".$this->Name; $out .= "\n===Items==="; $wgOut->addWikiText($out,TRUE); $out = ; $out = $this->ItemListing(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function ItemListing() {
$out = $this->objDB->Items()->Listing_forTitle($this); return $out;
}
} class VbzAdminItems extends clsItems {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminItem');
} public function Listing_forTitle($iTitleObj) {
global $wgOut; global $sql;
$objTitle = $iTitleObj; $idTitle = $objTitle->ID; $cntRow = 0;
$objRecs = $this->GetData('(NOT isDumped) AND (ID_Title='.$idTitle.')','VbzAdminItem','ItOpt_Sort'); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || Cat # || Description || $ buy || $ sell."; $isOdd = TRUE; while ($objRecs->NextRow()) { // $wtPageCode = ''.$strPageCode.''; $id = $objRecs->ID; $wtID = SelfLink('item','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isActive = $objRecs->isForSale; $isInPrint = $objRecs->isInPrint; $isPulled = $objRecs->isPulled; if ($isActive) { $cntRow++; } else { $wtStyle .= ' color: #888888;'; } if (!$isInPrint) { $wtStyle .= ' font-style: italic;'; } if ($isPulled) { $wtStyle .= ' text-decoration: line-through;'; } $out .= "\n|- style=\"$wtStyle\"". "\n| ".$wtID. ' || '.$objRecs->CatNum. ' || '.$objRecs->ItOpt_Descr. ' || '.DataCurr($objRecs->PriceBuy). ' || '.DataCurr($objRecs->PriceSell); if (!is_null($objRecs->Descr)) { $out .= "\n|- style=\"$wtStyle\"\n| colspan=4 | ".$objRecs->Descr; }
$isOdd = !$isOdd;
//$objLine = $objRecs->CloneFields();
$objLine = clone $objRecs;
}
$out .= "\n|}\n";
/*
$inf = get_included_files();
foreach ($inf as $fn) {
echo $fn."
";
}
- /
if ($cntRow == 1) { $out .= $objLine->InfoPage(TRUE); }
} else {
$out = 'This title has no items. (SQL='.$sql.')';
}
$wgOut->addWikiText($out,TRUE); $out = ;
}
} class VbzAdminItem extends clsItem {
public function InfoPage($iAsSub=FALSE) {
global $wgOut;
$strCatNum = $this->CatNum; if ($iAsSub) { $out = "==Item: $strCatNum ({$this->ID}) - {$this->ItOpt_Descr}==\n"; } else { $out = '==Item=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* Cat #: $strCatNum"; $out .= "\n* Descr: ".$this->ItOpt_Descr; } $out .= "\n===Stock===\n"; $out .= $this->StockListing(); return $out;
} public function StockListing() {
$out = $this->objDB->StkLines()->Listing_forItem($this); return $out;
} public function StoreLink($iText) {
/*
RETURNS: wikitext which links to the catalog page for the item NOTE: Since the store doesn't yet have pages for each item,
this returns a link to the item's Title page
- /
return '[[vbznet:cat/'.$this->Title()->URL_part().'|'.$iText.']]'; } public function AdminLink($iText) { return '[[VbzCart/archive/code/SpecialVbzAdmin/page'.KS_CHAR_URL_ASSIGN.'item/id'.KS_CHAR_URL_ASSIGN.$this->ID.'|'.$iText.']]'; }
}
class VbzAdminStkItems extends clsStkItems {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminStkItem');
} public function Listing_forItem($iObj) {
global $wgOut; global $sql;
$obj = $iObj; $id = $obj->ID;
$objRecs = $this->GetData('ID_Item='.$id,NULL,'WhenRemoved,WhenAdded,WhenChanged'); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || Bin || Qty || Added || Changed || Counted || Removed"; $isOdd = TRUE; while ($objRecs->NextRow()) { $id = $objRecs->ID;
$objBin = $objRecs->Bin(); $htBin = $objBin->SelfLink($objBin->Code);
$wtID = SelfLink('stk-line','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $isActive = is_null($objRecs->WhenRemoved) && ($objRecs->Qty > 0); if (!$isActive) { $wtStyle .= ' color: #888888;'; $wtStyle .= ' text-decoration: line-through;'; } $out .= "\n|- style=\"$wtStyle\"". "\n| ".$wtID. ' || '.$htBin. ' || '.$objRecs->Qty. ' || '.DataDate($objRecs->WhenAdded). ' || '.DataDate($objRecs->WhenChanged). ' || '.DataDate($objRecs->WhenCounted). ' || '.DataDate($objRecs->WhenRemoved); if (!is_null($objRecs->Descr)) { $out .= "\n|- style=\"$wtStyle\"\n| colspan=4 | ".$objRecs->Descr; }
$isOdd = !$isOdd; } $out .= "\n|}"; } else { $out = 'This title has no items. (SQL='.$sql.')'; } return $out;
}
} class VbzAdminStkItem extends clsDataSet {
public function Bin() {
$objBins = $this->objDB->Bins(); return $objBins->GetItem($this->ID_Bin);
}
}
class clsShipments extends clsVbzTable {
public function __construct($iDB) {
parent::__construct($iDB); $this->Name('ord_shipmt'); $this->KeyName('ID'); $this->ClassSng('clsShipment');
} protected function _newItem() { return new clsCatPage($this); } public function ListPage() {
global $wgOut;
$out = '==Shipments=='; $wgOut->addWikiText($out,TRUE); $out = ; $objRecs = $this->GetData(NULL,NULL,'ID DESC'); if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || Code || Status || Created || Shipped || Closed || Descr/Notes"; $isOdd = TRUE; while ($objRecs->NextRow()) { $id = $objRecs->ID; $wtID = SelfLink('shipmt','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;'; $wtCode = $objRecs->Abbr; // $wtStatus = ($objRecs->isDedicated==TRUE?'D':) . ($objRecs->isOnHold==TRUE?'H':); $wtStatus = (ord($objRecs->isDedicated)=='1'?'D':) . (ord($objRecs->isOnHold)=='1'?'H':); $wtWhenCre = TimeStamp_HideTime($objRecs->WhenCreated); $wtWhenShp = TimeStamp_HideTime($objRecs->WhenShipped); $wtWhenCls = TimeStamp_HideTime($objRecs->WhenClosed); $wtDescr = $objRecs->Descr; if (!is_null($objRecs->Notes)) { $wtDescr .= " ".$objRecs->Notes.""; } $isActive = is_null($objRecs->WhenShipped); if ($isActive) { //later: show link to ship/close it $wtStyle .= ' color: #006600;'; } else { } $out .= "\n|- style=\"$wtStyle\"\n| ".$wtID.' || '.$wtCode.' || '.$wtStatus.' || '.$wtWhenCre.' || '.$wtWhenShp.' || '.$wtWhenCls.' || '.$wtDescr; $isOdd = !$isOdd; } $out .= "\n|}"; } else { $out = 'No shipments have been created yet.'; } $wgOut->addWikiText($out,TRUE); $out = ;
}
} class clsShipment extends clsDataSet {
public function InfoPage() {
global $wgOut;
$out = '==Shipment=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* Code: ".$this->Code; $out .= "\n* Status: ".(ord($objRecs->isDedicated)=='1'?'Dedicated':) . (ord($objRecs->isOnHold)=='1'?' OnHold':); $out .= "\n===Packages==="; $wgOut->addWikiText($out,TRUE); $out = ; $out = $this->PkgTable(); $wgOut->addWikiText($out,TRUE); $out = ;
} public function PkgTable() {
$objPkgs = new clsPackages($this->objDB); $out = $objPkgs->WikiTable_forShipmtPkgs($this->ID); return $out;
}
} class clsPackages extends clsVbzTable {
public function __construct($iDB) {
parent::__construct($iDB); $this->Name('ord_pkgs'); $this->KeyName('ID'); $this->ClassSng('clsPackage');
} public function WikiTable_forShipmtPkgs($iID) {
//$objRecs = $this->GetData('ID_Shipment='.$iID,'clsPackage'); $objRecs = $this->objDB->DataSet('SELECT * FROM qryPkgs_status WHERE ID_Shipment='.$iID);
$isOdd = FALSE; if ($objRecs->HasRows()) { $out = "{| class=sortable\n|-\n! ID || ord/seq || Status || Created || Shipped || Closed || Descr/Notes"; while ($objRecs->NextRow()) { $wtID = SelfLink('shipmt','id',$id,$id); $wtStyle = $isOdd?'background:#ffffff;':'background:#cccccc;';
$keyDept = $objDepts->PageKey(); $out .= "\n|- style=\"$wtStyle\"\n| ".$wtID.' || '.$wtCode.' || '.$wtStatus.' || '.$wtWhenCre.' || '.$wtWhenShp.' || '.$wtWhenCls.' || '.$wtDescr; $isOdd = !$isOdd; } } $out .= "\n|}"; return $out;
}
} class clsPackage extends clsDataSet { } /* ========================== *\ - SHOPPING CART classes \* ========================== */ class VbzAdminCarts extends clsShopCarts {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminCart');
} public function ListPage() {
global $wgOut;
$out = '==Carts=='; $wgOut->addWikiText($out,TRUE); $out = ; $this->Name('qryCarts_info'); $objRecs = $this->GetData(NULL,NULL,'ID DESC'); if ($objRecs->HasRows()) { $out = "S=Session | O=Order | C=Customer | #D= # of Data lines | #I = # of Items in cart"; $out .= "\n{| class=sortable\n|-\n! ID || Created || Ordered || S || O || C || #D || #I"; $isOdd = TRUE; while ($objRecs->NextRow()) { $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; $isOdd = !$isOdd;
$id = $objRecs->ID; $wtID = SelfLink('cart','id',$id,$id); $wtWhenCre = $objRecs->WhenCreated; $wtWhenShp = $objRecs->WhenOrdered; $wtSess = SelfLink('sess','id',$objRecs->ID_Sess); $wtOrd = SelfLink('ord','id',$objRecs->ID_Order); $wtCust = SelfLink('cust','id',$objRecs->ID_Cust); $out .= "\n|- style=\"$wtStyle\"\n" ."| $wtID || $wtWhenCre || $wtWhenShp || $wtSess || $wtOrd || $wtCust" ."|| {$objRecs->DataCount} || {$objRecs->ItemCount}"; } $out .= "\n|}"; } else { $out = 'No carts have been created yet.'; } $wgOut->addWikiText($out,TRUE); $out = ;
}
} class VbzAdminCart extends clsShopCart {
public function InfoPage() {
global $wgOut;
$wtSess = SelfLink('sess','id',$this->ID_Sess); $wtOrd = SelfLink('ord','id',$this->ID_Order); $wtCust = SelfLink('cust','id',$this->ID_Cust);
$out = '==Cart=='."\n"; $out .= "\n* ID: ".$this->ID; $out .= "\n* When Created: ".$this->WhenCreated; $out .= "\n* When Ordered: ".$this->WhenOrdered; $out .= "\n* Session: ".$wtSess; $out .= "\n* Order: ".$wtOrd; $out .= "\n* Customer: ".$wtCust; $wgOut->addWikiText($out,TRUE); $out = ; $out .= "\n===Items==="; $out .= $this->ItemTable(); $wgOut->addWikiText($out,TRUE); $out = ; $out .= "\n===Data==="; $out .= $this->DataTable(); $wgOut->addWikiText($out,TRUE); $out = ;
}
/*
PURPOSE: Display the cart's items as a table
- /
public function ItemTable() {
$objItems = new VbzAdminCartLines($this->objDB); return $objItems->Table_forCart($this->ID);
}
/*
PURPOSE: Display the cart's data lines as a table
- /
public function DataTable() {
$objItems = new VbzAdminCartData($this->objDB); return $objItems->Table_forCart($this->ID);
}
} // SHOPPING CART ITEMS class VbzAdminCartLines extends clsShopCartLines {
public function Table_forCart($iCart) {
$objRecs = $this->GetData('ID_Cart='.$iCart,NULL,'Seq'); if ($objRecs->HasRows()) { $out = "\n{| class=sortable\n|-\n! ID || # || Item || Qty || Added || Changed"; $isOdd = TRUE; while ($objRecs->NextRow()) { $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; $isOdd = !$isOdd;
$id = $objRecs->ID; $wtID = SelfLink('cart','id',$id,$id); $wtItem = $objRecs->ItemDesc_wt(); /* $wtAdded = DataDateTime($objRecs->WhenAdded); $wtEdited = DataDateTime($objRecs->WhenEdited);
- /
$wtAdded = var_export($objRecs->WhenAdded, TRUE); $wtEdited = var_export($objRecs->WhenEdited, TRUE);
$out .= "\n|- style=\"$wtStyle\"\n" ."| $wtID " ."|| {$objRecs->Seq}" ."|| $wtItem" ."|| {$objRecs->Qty}" ."|| $wtAdded" ."|| $wtEdited" ; } } else { $out = "No items in cart"; } return $out;
}
} // SHOPPING CART DATA class VbzAdminCartData extends clsTable {
public function __construct($iDB) { parent::__construct($iDB);
$this->Name('shop_cart_data'); $this->ClassSng('VbzAdminCartDatum');
}
public function Table_forCart($iCart) {
$objRecs = $this->GetData('ID_Cart='.$iCart); if ($objRecs->HasRows()) { $out = "\n{| class=sortable\n|-\n! Type || Value"; $isOdd = TRUE; while ($objRecs->NextRow()) { $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; $isOdd = !$isOdd;
$wtType = $objRecs->ValueText(); $wtVal = $objRecs->Val;
$out .= "\n|- style=\"$wtStyle\"\n| $wtType || $wtVal"; } } else { $out = "\nNo data in cart"; } return $out;
}
} class VbzAdminCartDatum extends clsDataSet {
public function ValueText() {
global $vgaCartDataType;
$strType = $this->Type; if (isset($vgaCartDataType[$strType])) { $wtType = $vgaCartDataType[$strType]; } else { $wtType = "?$strType"; } return $wtType;
}
} /* ========================== *\ - CUSTOMER ORDER classes \* ========================== */ class VbzAdminOrders extends clsOrders {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminOrder'); // override parent
} public function ListPage() { global $wgOut;
$out = '==Orders=='."\n"; $wgOut->addWikiText($out,TRUE); $out = ;
$out = $this->Listing(); $wgOut->addWikiText($out,TRUE); $out = ;
} protected function Listing() {
$objRow = $this->GetData(NULL,NULL,'SortPfx, Number DESC'); if ($objRow->hasRows()) { $out = "{| class=sortable \n|-\n! ID || Number || Status || Total Amt || created || closed"; $isOdd = TRUE; while ($objRow->NextRow()) { $wtStyle = $isOdd?'background:#ffffff;':'background:#eeeeee;'; $isOdd = !$isOdd;
$row = $objRow->Row;
$id = $row['ID']; $strNum = $row['Number']; $idPull = $row['ID_Pull']; $mnyTotal = $row['WebTotal_Final']; $dtCreate = $row['WhenStarted']; $dtClosed = $row['WhenClosed'];
$wtNum = SelfLink('order','id',$id,$strNum); $strTotal = DataCurr($mnyTotal); $strWhenCreated = DataDate($dtCreate); $strWhenClosed = DataDate($dtClosed);
$out .= "\n|- style=\"$wtStyle\""; $out .= "\n| $id || $wtNum || $idPull || align=right | $strTotal || $strWhenCreated || $strWhenClosed"; } $out .= "\n|}\n"; } else { $out = 'There do not seem to be any order records yet.'; } return $out;
}
} class VbzAdminOrder extends clsOrder {
public function InfoPage() {
global $wgOut;
$wtSess = SelfLink('sess','id',$this->ID_Sess); $wtOrd = SelfLink('ord','id',$this->ID_Order); $wtCust = SelfLink('cust','id',$this->ID_Cust);
$out = '==Order=='."\n"; $out .= "\n* ID: ".$this->ID.' - #'.$this->Number; $out .= "\n* When Created: ".$this->WhenStarted; $out .= "\n* When Closed: ".$this->WhenClosed; $wgOut->addWikiText($out,TRUE); $out = ; $out .= "\n===Items==="; $out .= $this->ItemTable(); $wgOut->addWikiText($out,TRUE); $out = ; $out .= "\n===Transactions==="; $out .= "\n===Messages==="; $out .= "\n===Charges===";
} public function ItemTable() {
$objItems = new VbzAdminOrderItems($this->objDB); return $objItems->Table_forOrder($this->ID);
}
} class VbzAdminOrderItems extends clsOrderLines {
public function __construct($iDB) {
parent::__construct($iDB); $this->ClassSng('VbzAdminOrderItem'); // override parent
} public function Table_forOrder() { }
} class VbzAdminOrderItem extends clsOrderLine { } </php>