\SwitchCash
Switches profitability implementation
Synopsis
class SwitchCash
{
- // constants
- const TABLE_FINANCE = 'swcash';
- const FILESTORAGE_SCOPE = 'SWCASH';
- const REPORT_MASK = 'SWCASH';
- const URL_ME = '?module=swcash';
- const URL_SWITCHPROFILE = '?module=switches&edit=';
- const ROUTE_EDIT = 'switchid';
- const ROUTE_REPORT = 'renderreport';
- const ROUTE_EXCEL = 'excelexport';
- const ROUTE_USERS = 'renderswusers';
- const PROUTE_CREATE = 'createswitchid';
- const PROUTE_SAVE = 'saveswitchid';
- const PROUTE_RECORD = 'swcashrecordid';
- const PROUTE_PLACECONTRACT = 'newplacecontract';
- const PROUTE_PLACEPRICE = 'newplaceprice';
- const PROUTE_POWERCONTRACT = 'newpowercontract';
- const PROUTE_POWERPRICE = 'newpoweprice';
- const PROUTE_TRANSPORTCONTRACT = 'newtransportcontract';
- const PROUTE_TRANSPORTPRICE = 'newtransportprice';
- const PROUTE_SWITCHPRICE = 'newswitchprice';
- const PROUTE_SWITCHDATE = 'newswitchdate';
- const COLOR_BAD = 'bc0000';
- const COLOR_GOOD = '007603';
- const COLOR_EQUAL = 'f47900';
- // members
- protected array $altCfg = ;
- protected array $allCashData = ;
- protected $swCashDb = '';
- protected $messages = '';
- protected $filestorage = '';
- protected objecr $excelReport = '';
- protected array $allUsersData = ;
- protected array $allSwitchAssigns = ;
- protected array $allReportSwitches = ;
- protected array $allTariffPrices = ;
- protected integer $counterBad = 0;
- protected integer $counterGood = 0;
- protected integer $counterEqual = 0;
- // methods
- public void __construct()
- protected void initDatabase()
- protected void initMessages()
- protected void initFilestorage()
- protected void loadAlter()
- protected void loadAllCashData()
- protected void loadReportData()
- protected void loadUserData()
- protected void loadTariffPrices()
- protected void loadSwitchesData()
- protected void loadSwitchPortAssigns()
- protected void initExcelLib()
- public bool haveFinancialData()
- public void/string catchCreate()
- public void/string catchSave()
- public string renderCreateForm()
- public string renderEditForm()
- protected float getSwitchPrice()
- protected float getSwitchExpenses()
- protected float getSwitchProfit()
- protected string colorizeSwitch()
- protected string renderCharts()
- protected exportBasicReport()
- public string renderBasicReport()
- public string renderUsersReport()
Constants
Name | Value |
---|---|
TABLE_FINANCE | 'swcash' |
FILESTORAGE_SCOPE | 'SWCASH' |
REPORT_MASK | 'SWCASH' |
URL_ME | '?module=swcash' |
URL_SWITCHPROFILE | '?module=switches&edit=' |
ROUTE_EDIT | 'switchid' |
ROUTE_REPORT | 'renderreport' |
ROUTE_EXCEL | 'excelexport' |
ROUTE_USERS | 'renderswusers' |
PROUTE_CREATE | 'createswitchid' |
PROUTE_SAVE | 'saveswitchid' |
PROUTE_RECORD | 'swcashrecordid' |
PROUTE_PLACECONTRACT | 'newplacecontract' |
PROUTE_PLACEPRICE | 'newplaceprice' |
PROUTE_POWERCONTRACT | 'newpowercontract' |
PROUTE_POWERPRICE | 'newpoweprice' |
PROUTE_TRANSPORTCONTRACT | 'newtransportcontract' |
PROUTE_TRANSPORTPRICE | 'newtransportprice' |
PROUTE_SWITCHPRICE | 'newswitchprice' |
PROUTE_SWITCHDATE | 'newswitchdate' |
COLOR_BAD | 'bc0000' |
COLOR_GOOD | '007603' |
COLOR_EQUAL | 'f47900' |
Members
protected
- $allCashData
—
array
Contains all available switches financial data as switchId=>data - $allReportSwitches
—
array
Contains all switches that contains report mark as switchId=>switchData - $allSwitchAssigns
—
array
Contains all switch assigns as login=>assignData - $allTariffPrices
—
array
Contains all available tariff prices as tariffname=>Fee - $allUsersData
—
array
Contains all user data as login=>userdata - $altCfg
—
array
Contains system alter config as key=>value - $counterBad
—
int
Contains bad colored switches count - $counterEqual
—
int
Contains equal colored switches count - $counterGood
—
int
Contains good colored switches count - $excelReport
—
objecr
Excel report placeholder - $filestorage
—
Filestorage instance object placeholder - $messages
—
System message helper object placeholder - $swCashDb
—
Contains database abstraction layer for financial data
Methods
protected
- colorizeSwitch() — Colorize switch name based on profit
- exportBasicReport() — Performs report exporting in MS Excel format
- getSwitchExpenses() — Returns total of switch expenses per month
- getSwitchPrice() — Returns switch month price for the first year
- getSwitchProfit() — Returns total switch profit per month
- initDatabase() — Inits database abstraction layer for further usage
- initExcelLib() — Inits excel export library
- initFilestorage() — Inits filestorage instance if enabled
- initMessages() — Inits system message helper object
- loadAllCashData() — Performs loading and preprocessing of available financial data
- loadAlter() — Loads system alter.ini config into protected prop
- loadReportData() — Loads all data required for basic report.
- loadSwitchPortAssigns() — Loads all available switchport assigns into protected prop
- loadSwitchesData() — Loads switches data into protected property
- loadTariffPrices() — Loads all available tariff fees
- loadUserData() — Loads all users data into protected prop
- renderCharts() — Renders chart of switches profitability percents
public
- __construct() — ___ ___ (o o) (o o) ( V ) ( V ) /--m-m- /--m-m-
- catchCreate() — Creates new database record on request
- catchSave() — Saves database record on request
- haveFinancialData() — Checks have some switch some financial data or not?
- renderBasicReport() — Renders basic report with switches profitability
- renderCreateForm() — Renders switch financial data creation form
- renderEditForm() — Renders switch financial data editing form
- renderUsersReport() — Renders users list assigned for some switch