| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- Lib::loadClass('RouteBase');
- Lib::loadClass('ColumnDealsStatus');
- class Route_Test_Umowy extends RouteBase {
- function allAction() {
- UI::layout( [ $this, 'allView' ], [ 'showMenu' => false ] );
- }
- function allView() {
- ColumnDealsStatus::reinstall();
- ColumnDealsStatus::run_update($force = true);
- DBG::nicePrint($msgs, '$msgs');
- $items = DB::getPDO()->fetchAll("
- select d.ID, d.A_STATUS, t.SERVICES_STATUS
- , d.*, t.*
- from `temp_DEALS_STATUS` t
- left join DEALS_TABLE d on ( d.ID = t.ID_DEALS )
- ");
- }
- function defaultAction() {
- UI::layout( [ $this, 'defaultView' ], [ 'showMenu' => false ] );
- }
- function defaultView() {
- $id = V::get('id', 0, $_GET, 'int');
- if ($id <= 0) throw new Exception("Missing id company");
- echo UI::h('div', [], [
- "Klient {$id}: ",
- UI::h('a', [
- 'href' => "index.php?MENU_INIT=USERS2_WINDYKACJA_STATUS&q={$id}&_f=&_oby=ID&_odir=DESC&_user_id={$id}",
- 'target' => "_blank",
- ], "Windykacja"),
- " | ",
- UI::h('a', [
- 'href' => "index.php?MENU_INIT=POKAZ_OFERTY_AKTUALNE_FUNC&task=klient_umowy&id_user={$id}",
- 'target' => "_blank",
- ], "Umowy"),
- " | ",
- UI::h('a', [
- 'href' => "index.php?FUNCTION_INIT=bm_make_faktura&ARG1_VAL={$id}",
- 'target' => "_blank",
- ], "Faktury"),
- ]);
- $totalDeals = DB::getPDO()->fetchValue(" select count(*) from DEALS_TABLE ");
- $totalActivatedDeals = DB::getPDO()->fetchValue(" select count(*) from DEALS_TABLE where A_STATUS = 'NORMAL' ");
- $itemDealsTable = DB::getPDO()->fetchAll(" select * from DEALS_TABLE where ID_BILLING_USERS = :id ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemDealsTable, 'caption' => "`DEALS_TABLE`: itemDealsTable, Client = {$id}, total rows = {$totalDeals} (activated: {$totalActivatedDeals})" ]);
- UI::table([ 'rows' => array_map(function ($item) {
- return array_merge([
- 'ID' => '',
- 'A_STATUS' => '',
- 'P_DEALDATE' => '',
- 'P_DEALDATE_TERM' => '',
- 'USTALONA_DATA_PODLACZENIA' => '',
- 'DATA_WYK_PODLACZENIA' => '',
- 'TODO__DATA_WYK_PODLACZENIA' => DB::getPDO()->fetchValue("
- (
- select T_WHEN_CONNECTED, a.ID, s.ID_DEALS_TABLE
- from SES_USERS2_A a
- join SERVICES s on ( s.ID = a.ID_SERVICES )
- where a.ID_BILLING_USERS = :id_client
- and s.ID_DEALS_TABLE = :id_deal
- )
- union
- (
- select T_WHEN_CONNECTED, a.ID, s.ID_DEALS_TABLE
- from SES_TV_A a
- join SERVICES s on ( s.ID = a.ID_SERVICES )
- where a.ID_BILLING_USERS = :id_client
- and s.ID_DEALS_TABLE = :id_deal
- )
- union
- (
- select T_WHEN_CONNECTED, a.ID, s.ID_DEALS_TABLE
- from SES_VOIP_A a
- join SERVICES s on ( s.ID = a.ID_SERVICES )
- where a.ID_BILLING_USERS = :id_client
- and s.ID_DEALS_TABLE = :id_deal
- )
- order by T_WHEN_CONNECTED asc
- ", [
- ':id_client' => $item['ID_BILLING_USERS'],
- ':id_deal' => $item['ID'],
- ]),
- 'DEALDESC' => '',
- ], $item);
- }, $itemDealsTable), 'caption' => "`DEALS_TABLE`: itemDealsTable, Client = {$id}, total rows = {$totalDeals} (activated: {$totalActivatedDeals})" ]);
- $itemServices = DB::getPDO()->fetchAll(" select * from SERVICES where ID_BILLING_USERS = :id ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemServices, 'caption' => "`SERVICES`: itemServices, Client = {$id}" ]);
- $itemSesNET = DB::getPDO()->fetchAll("
- select *
- , '***' as P_SERVICE_QUOTA_PROFILE
- , '***' as N_AVG_TRAFFIC
- from SES_USERS2_A
- where ID_BILLING_USERS = :id
- ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemSesNET, 'caption' => "`SES_USERS2_A`: itemSesNET, Client = {$id}" ]);
- $itemSesTV = DB::getPDO()->fetchAll(" select * from SES_TV_A where ID_BILLING_USERS = :id ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemSesTV, 'caption' => "`SES_TV_A`: itemSesTV, Client = {$id}" ]);
- $itemSesVOIP = DB::getPDO()->fetchAll(" select * from SES_VOIP_A where ID_BILLING_USERS = :id ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemSesVOIP, 'caption' => "`SES_VOIP_A`: itemSesVOIP, Client = {$id}" ]);
- // `SES_*_A`: `T_WHEN_CONNECTED`, `T_WHO_CONNECTED`
- echo UI::h('div', [ 'style' => "padding:3px 12px; background-color:#eee" ], [
- UI::h('h3', [], "Daty podłączenia (Aktywacji?):"),
- UI::h('div', [ 'style' => "padding: 12px; background-color:#eee" ], [
- UI::h('div', [ 'style' => "background-color:#fff" ], [
- UI::hTable([ 'rows' => array_map([ $this, 'whenConnectedTableRowView' ], $itemSesNET), 'caption' => "SES_USERS2_A" ]),
- UI::hTable([ 'rows' => array_map([ $this, 'whenConnectedTableRowView' ], $itemSesTV), 'caption' => "SES_TV_A" ]),
- UI::hTable([ 'rows' => array_map([ $this, 'whenConnectedTableRowView' ], $itemSesVOIP), 'caption' => "SES_VOIP_A" ]),
- ]),
- ]),
- ]);
- $itemDbTasks = DB::getPDO()->fetchAll("
- select t.*
- from DEALS_TABLE d
- left join _DB_TASKS t on ( t.TRANSACTION_ID = concat('DEALS_TABLE-', d.ID) )
- where d.ID_BILLING_USERS = :id
- ", [ ':id' => $id ]);
- UI::table([ 'rows' => $itemDbTasks, 'caption' => "`_DB_TASKS`: itemDbTasks, Client = {$id}" ]);
- DBG::nicePrint(null, "memory_get_usage: " . round(memory_get_usage() / 1024) . " KB");
- die('.EOF');
- }
- function whenConnectedTableRowView($item) { // ID, T_WHEN_CONNECTED, T_WHO_CONNECTED
- return array_merge([
- 'ID' => '',
- 'ID_DEALS_TABLE' => DB::getPDO()->fetchValue(" select ID_DEALS_TABLE from SERVICES where ID = :id ", [ ':id' => $item['ID_SERVICES'] ]),
- 'T_WHEN_CONNECTED' => '',
- 'T_WHO_CONNECTED' => '',
- ], $item);
- }
- }
- class RelatedFeatureTagReader {
- function __construct() {
- $this->_parsedTags = [];
- }
- function findRelatedFeatureRecurse($tag, $parentTagId = 0, $parsedTags = []) {
- if (!is_array($tag)) return $parsedTags; // string
- DBG::nicePrint([ 'tag' => $tag[0], 'attrs' => $tag[1], '$parsedTags' => $parsedTags ], "findRelatedFeatureRecurse({$tag[0]})");
- if (empty($tag)) return [];
- if ('RelatedFeature' === $tag[0]) {
- $parsedTags[] = [ 'tag' => $tag[0], 'attrs' => $tag[1], 'parentTagId' => $parentTagId ];
- $parentTagId = count($parsedTags) - 1;
- }
- else if (!empty($tag[1]['xpath'])) $parsedTags[] = [ 'tag' => $tag[0], 'attrs' => $tag[1], 'parentTagId' => $parentTagId ];
- if (empty($tag[2])) return $parsedTags;
- return array_reduce($tag[2], function ($ret, $childTag) use ($parentTagId) {
- return $this->findRelatedFeatureRecurse($childTag, $parentTagId, $ret);
- }, $parsedTags);
- }
- }
|