| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- Lib::loadClass('RouteBase');
- Lib::loadClass('Request');
- Lib::loadClass('Response');
- Lib::loadClass('UI');
- class Route_UrlAction_PanelKlientaBiallNet extends RouteBase {
- static $PANEL_URL = "https://biuro.biall-net.pl/panel/pl/index.php?_route=UrlAction_ChangeUser&id_admin={id}";
- static $PANEL_DEV_URL = "https://biuro.biall-net.pl/dev-pl/se-projects/panel_biall_net/SE/index.php?_route=UrlAction_ChangeUser&id_admin={id}";
- function defaultAction() { UI::layout([ $this, 'defaultView' ]); }
- function defaultView() {
- $id = V::get('id', '', $_GET);
- if (!$id) throw new Exception("Missing id");
- $devPrefix = 'https://biuro.biall-net.pl/dev-pl';
- $panelUrl = str_replace('{id}', $id, self::$PANEL_URL);
- // Response::sendRedirect( str_replace('{id}', $id, $panelUrl) );
- $devPanelUrl = str_replace('{id}', $id, self::$PANEL_DEV_URL);
- $projectFolder = APP_PATH_ROOT . DS . 'projects' . DS . 'panel_biall_net';
- if (!file_exists($projectFolder)) throw new Exception("Project folder not exists! ('panel_biall_net')");
- if (!file_exists($projectFolder . DS . 'auth.php')) throw new Exception("Project auth file not exists! ('panel_biall_net')");
- require_once $projectFolder . DS . 'auth.php'; // Theme_Auth_panel_biall_net
- if (!class_exists('Theme_Auth_panel_biall_net')) throw new Exception("Project auth class not exists! ('panel_biall_net')");
- $company = DB::getPDO()->fetchFirst("
- select c.ID
- , c.user_mail_contact
- , c.P_NAME, c.P_NAME_SECOND
- from COMPANIES c
- where c.ID = :id
- ", [ ':id' => $id ]);
- if (!$company) throw new Exception("Company not exists! Nr {$id}.");
- if (!User::isAdmin()) throw new Exception("Access Denied");
- $email = $company['user_mail_contact'];
- $postTask = V::get('_postTask', '', $_POST);
- $_testUserInfo = null;
- switch ($postTask) {
- // case 'makeAccounts': {
- // Theme_Auth_panel_biall_net::makeActiveUsers($email);
- // } break;
- // case 'resetPasswd': {
- // Theme_Auth_panel_biall_net::makeActiveUsers($email);
- // $remindKey = Theme_Auth_panel_biall_net::generateRemindKey($email);
- // $resetLink = Router::getRoute('UrlAction_RemindPasswd')->getLink('rp', [ 'login' => $email, 'key' => $remindKey ]);
- // Theme_Auth_panel_biall_net::sendRemindPasswd($email, $resetLink, $recipient = "piotrl86+bn-test-remind@gmail.com");
- // } break;
- case 'testAuth': {
- $passwd = V::get('passwd', '', $_POST);
- $_testUserInfo = Theme_Auth_panel_biall_net::testAuth($email, $passwd);
- } break;
- }
- $activeUsers = Theme_Auth_panel_biall_net::makeActiveUsers($company['user_mail_contact']);
- echo UI::h('div', [ 'style' => "margin-top:24px" ], [
- UI::h('h3', [], "Klient: [{$company['ID']}] {$company['P_NAME']} {$company['P_NAME_SECOND']}"),
- UI::h('a', [ 'href' => $panelUrl, 'target' => "_blank", 'class' => "btn btn-primary" ], "Zobacz panel klienta"),
- ($devPrefix === substr(Request::getScriptUri(), 0, strlen($devPrefix)))
- ? UI::h('a', [ 'href' => $devPanelUrl, 'target' => "_blank", 'class' => "btn btn-warning" ], "DEV: panel klienta")
- : "",
- UI::h('form', [ 'method' => "POST", 'class' => "form-horizontal", 'style' => "margin:24px 0; padding: 24px; border:1px solid #eee" ], [
- UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
- UI::h('label', [ 'class' => "col-md-1 control-label" ], "Hasło:"),
- UI::h('div', [ 'method' => "POST", 'class' => "col-md-4" ], [
- UI::h('input', [ 'type' => "text", 'name' => "passwd", 'value' => '', 'class' => "form-control" ]),
- ]),
- UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'testAuth' ]),
- UI::h('input', [ 'type' => "submit", 'value' => "Testuj logowanie do panelu klienta", 'class' => "btn btn-default" ]),
- ($_testUserInfo)
- ? UI::h('div', [ 'class' => "alert alert-success" ], [
- UI::h('p', [], "Klient: [{$_testUserInfo['ID']}] '{$_testUserInfo['P_NAME']} {$_testUserInfo['P_NAME_SECOND']}'"),
- ])
- : UI::h('div', [], "..."),
- ]),
- UI::h('p', [], "All users:"),
- UI::hTable([
- 'rows' => array_map(function ($item) {
- return array_merge([
- 'ID' => $item['ID'],
- 'Akcja' => UI::h('a', [ 'href' => $this->getLink('', [ 'id' => $item['ID'] ]) ], "wybierz"),
- ], $item);
- }, Theme_Auth_panel_biall_net::test_fetchAllUsers($email))
- ]),
- UI::h('p', [], "Active BIALL-NET users (BILLING_OWNER: 1 BN, 3 NETDAY):"),
- UI::hTable([ 'rows' => Theme_Auth_panel_biall_net::fetchActiveUsers($email) ]),
- ]);
- }
- }
|