mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding users to show Login Server total Users Count and new users this month
This commit is contained in:
parent
f2ea3dc5ef
commit
217dede358
@ -20,6 +20,7 @@ use Cake\Http\Client;
|
||||
use Cake\Routing\Router;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\I18n\Time;
|
||||
|
||||
/**
|
||||
* Application Controller
|
||||
@ -288,4 +289,14 @@ class AppController extends Controller
|
||||
$response = $this->response->withType('application/json');
|
||||
return $response->withStringBody(json_encode($array));
|
||||
}
|
||||
|
||||
public function getStartEndForMonth($month, $year)
|
||||
{
|
||||
$timeString = $year . '-' . $month . '-01 00:00';
|
||||
$firstDay = new Time($timeString);
|
||||
$lastDay = new Time($timeString);
|
||||
$lastDay = $lastDay->addMonth(1);
|
||||
return [$firstDay, $lastDay];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,11 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Controller\AppController;
|
||||
use Cake\Datasource\ConnectionManager;
|
||||
use Cake\I18n\Time;
|
||||
//use Cake\I18n\Date;
|
||||
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
* ElopageBuys Controller
|
||||
@ -20,12 +25,62 @@ class ElopageBuysController extends AppController
|
||||
public function index()
|
||||
{
|
||||
$this->paginate = [
|
||||
'contain' => ['ElopageUsers', 'AffiliatePrograms', 'Publishers', 'Orders', 'Products'],
|
||||
'contain' => false,
|
||||
];
|
||||
$elopageBuys = $this->paginate($this->ElopageBuys);
|
||||
|
||||
$this->set(compact('elopageBuys'));
|
||||
}
|
||||
|
||||
public function statistics()
|
||||
{
|
||||
$this->viewBuilder()->setLayout('frontend_ripple');
|
||||
$connection = ConnectionManager::get('loginServer');
|
||||
$dates = $connection->execute('SELECT success_date FROM elopage_buys group by CAST(success_date as DATE)')->fetchAll('assoc');
|
||||
|
||||
$datesTree = [];
|
||||
foreach($dates as $i => $date) {
|
||||
|
||||
$date = new Time($date['success_date']);
|
||||
if(!isset($datesTree[$date->year])) {
|
||||
$datesTree[$date->year] = [];
|
||||
}
|
||||
if(!isset($datesTree[$date->year][$date->month])) {
|
||||
$datesTree[$date->year][$date->month] = true;
|
||||
}
|
||||
}
|
||||
//var_dump($datesTree);
|
||||
|
||||
$now = Time::now();
|
||||
$lastDay = Time::now();
|
||||
$lastDay->day = 1;
|
||||
$now->day = 1;
|
||||
$lastDay->setTime(0,0,0,0);
|
||||
$now->setTime(0,0,0,0);
|
||||
// only for test
|
||||
$now->month = 11;
|
||||
$lastDay->month = 11;
|
||||
$now->year = 2019;
|
||||
$lastDay->year = 2019;
|
||||
// var_dump($now);
|
||||
|
||||
$lastDay = $lastDay->addMonth(1);
|
||||
$sortDate = $this->getStartEndForMonth(11, 2019);
|
||||
$elopageBuys = $this->ElopageBuys
|
||||
->find('all')
|
||||
->where(['success_date >=' => $sortDate[0], 'success_date <' => $sortDate[1]]);
|
||||
$users = [];
|
||||
foreach($elopageBuys as $elopageEntry) {
|
||||
array_push($users, $elopageEntry->payer_email);
|
||||
}
|
||||
$unique_users = array_unique($users);
|
||||
|
||||
$userTable = TableRegistry::getTableLocator()->get('Users');
|
||||
$users = $userTable->find('all')
|
||||
->where(['created >=' => $sortDate[0], 'created <' => $sortDate[1]]);
|
||||
|
||||
$this->set(compact('elopageBuys', 'users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* View method
|
||||
@ -37,7 +92,7 @@ class ElopageBuysController extends AppController
|
||||
public function view($id = null)
|
||||
{
|
||||
$elopageBuy = $this->ElopageBuys->get($id, [
|
||||
'contain' => ['ElopageUsers', 'AffiliatePrograms', 'Publishers', 'Orders', 'Products'],
|
||||
'contain' => false,
|
||||
]);
|
||||
|
||||
$this->set('elopageBuy', $elopageBuy);
|
||||
@ -60,12 +115,8 @@ class ElopageBuysController extends AppController
|
||||
}
|
||||
$this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
|
||||
}
|
||||
$elopageUsers = $this->ElopageBuys->ElopageUsers->find('list', ['limit' => 200]);
|
||||
$affiliatePrograms = $this->ElopageBuys->AffiliatePrograms->find('list', ['limit' => 200]);
|
||||
$publishers = $this->ElopageBuys->Publishers->find('list', ['limit' => 200]);
|
||||
$orders = $this->ElopageBuys->Orders->find('list', ['limit' => 200]);
|
||||
$products = $this->ElopageBuys->Products->find('list', ['limit' => 200]);
|
||||
$this->set(compact('elopageBuy', 'elopageUsers', 'affiliatePrograms', 'publishers', 'orders', 'products'));
|
||||
|
||||
$this->set(compact('elopageBuy'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +129,7 @@ class ElopageBuysController extends AppController
|
||||
public function edit($id = null)
|
||||
{
|
||||
$elopageBuy = $this->ElopageBuys->get($id, [
|
||||
'contain' => [],
|
||||
'contain' => false,
|
||||
]);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$elopageBuy = $this->ElopageBuys->patchEntity($elopageBuy, $this->request->getData());
|
||||
@ -89,12 +140,7 @@ class ElopageBuysController extends AppController
|
||||
}
|
||||
$this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
|
||||
}
|
||||
$elopageUsers = $this->ElopageBuys->ElopageUsers->find('list', ['limit' => 200]);
|
||||
$affiliatePrograms = $this->ElopageBuys->AffiliatePrograms->find('list', ['limit' => 200]);
|
||||
$publishers = $this->ElopageBuys->Publishers->find('list', ['limit' => 200]);
|
||||
$orders = $this->ElopageBuys->Orders->find('list', ['limit' => 200]);
|
||||
$products = $this->ElopageBuys->Products->find('list', ['limit' => 200]);
|
||||
$this->set(compact('elopageBuy', 'elopageUsers', 'affiliatePrograms', 'publishers', 'orders', 'products'));
|
||||
$this->set(compact('elopageBuy'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
127
src/Controller/UsersController.php
Normal file
127
src/Controller/UsersController.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Controller\AppController;
|
||||
use Cake\I18n\Time;
|
||||
|
||||
/**
|
||||
* Users Controller
|
||||
*
|
||||
* @property \App\Model\Table\UsersTable $Users
|
||||
*
|
||||
* @method \App\Model\Entity\User[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
|
||||
*/
|
||||
class UsersController extends AppController
|
||||
{
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return \Cake\Http\Response|null
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = $this->paginate($this->Users);
|
||||
|
||||
$this->set(compact('users'));
|
||||
}
|
||||
|
||||
public function statistics()
|
||||
{
|
||||
$this->viewBuilder()->setLayout('frontend_ripple');
|
||||
$users = $this->Users->find('all')->select(['id']);
|
||||
|
||||
//$newUsersThisMonth
|
||||
$now = new Time();
|
||||
$sortDate = $this->getStartEndForMonth($now->month, $now->year);
|
||||
$newUsersThisMonth = $this->Users->find('all')
|
||||
->select(['id'])
|
||||
->where(['created >=' => $sortDate[0], 'created <' => $sortDate[1]]);
|
||||
$lastMonth = new Time();
|
||||
$lastMonth = $lastMonth->subMonth(1);
|
||||
$prevSortDate = $this->getStartEndForMonth($lastMonth->month, $lastMonth->year);
|
||||
$newUsersLastMonth = $this->Users->find('all')
|
||||
->select(['id'])
|
||||
->where(['created >=' => $prevSortDate[0], 'created <' => $prevSortDate[1]]);
|
||||
$this->set(compact('users', 'newUsersThisMonth', 'newUsersLastMonth'));
|
||||
}
|
||||
|
||||
/**
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id User id.
|
||||
* @return \Cake\Http\Response|null
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$user = $this->Users->get($id, [
|
||||
'contain' => ['EmailOptIn', 'UserBackups', 'UserRoles'],
|
||||
]);
|
||||
|
||||
$this->set('user', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add method
|
||||
*
|
||||
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$user = $this->Users->newEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$user = $this->Users->patchEntity($user, $this->request->getData());
|
||||
if ($this->Users->save($user)) {
|
||||
$this->Flash->success(__('The user has been saved.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
$this->Flash->error(__('The user could not be saved. Please, try again.'));
|
||||
}
|
||||
$this->set(compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id User id.
|
||||
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$user = $this->Users->get($id, [
|
||||
'contain' => [],
|
||||
]);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$user = $this->Users->patchEntity($user, $this->request->getData());
|
||||
if ($this->Users->save($user)) {
|
||||
$this->Flash->success(__('The user has been saved.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
$this->Flash->error(__('The user could not be saved. Please, try again.'));
|
||||
}
|
||||
$this->set(compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id User id.
|
||||
* @return \Cake\Http\Response|null Redirects to index.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
*/
|
||||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$user = $this->Users->get($id);
|
||||
if ($this->Users->delete($user)) {
|
||||
$this->Flash->success(__('The user has been deleted.'));
|
||||
} else {
|
||||
$this->Flash->error(__('The user could not be deleted. Please, try again.'));
|
||||
}
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
}
|
||||
58
src/Model/Entity/User.php
Normal file
58
src/Model/Entity/User.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace App\Model\Entity;
|
||||
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
* User Entity
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $email
|
||||
* @property string $first_name
|
||||
* @property string|null $last_name
|
||||
* @property int $password
|
||||
* @property string|resource|null $pubkey
|
||||
* @property string|resource|null $privkey
|
||||
* @property \Cake\I18n\FrozenTime $created
|
||||
* @property bool $email_checked
|
||||
* @property string $language
|
||||
*
|
||||
* @property \App\Model\Entity\EmailOptIn[] $email_opt_in
|
||||
* @property \App\Model\Entity\UserBackup[] $user_backups
|
||||
* @property \App\Model\Entity\UserRole[] $user_roles
|
||||
*/
|
||||
class User extends Entity
|
||||
{
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
* Note that when '*' is set to true, this allows all unspecified fields to
|
||||
* be mass assigned. For security purposes, it is advised to set '*' to false
|
||||
* (or remove it), and explicitly make individual fields accessible as needed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_accessible = [
|
||||
'email' => true,
|
||||
'first_name' => true,
|
||||
'last_name' => true,
|
||||
'password' => true,
|
||||
'pubkey' => true,
|
||||
'privkey' => true,
|
||||
'created' => true,
|
||||
'email_checked' => true,
|
||||
'language' => true,
|
||||
'email_opt_in' => true,
|
||||
'user_backups' => true,
|
||||
'user_roles' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* Fields that are excluded from JSON versions of the entity.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_hidden = [
|
||||
'password',
|
||||
];
|
||||
}
|
||||
@ -37,30 +37,11 @@ class ElopageBuysTable extends Table
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('elopage_buys');
|
||||
$this->setDisplayField('id');
|
||||
$this->setDisplayField('payer_email');
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->belongsTo('ElopageUsers', [
|
||||
'foreignKey' => 'elopage_user_id',
|
||||
'joinType' => 'INNER',
|
||||
]);
|
||||
$this->belongsTo('AffiliatePrograms', [
|
||||
'foreignKey' => 'affiliate_program_id',
|
||||
'joinType' => 'INNER',
|
||||
]);
|
||||
$this->belongsTo('Publishers', [
|
||||
'foreignKey' => 'publisher_id',
|
||||
'joinType' => 'INNER',
|
||||
]);
|
||||
$this->belongsTo('Orders', [
|
||||
'foreignKey' => 'order_id',
|
||||
'joinType' => 'INNER',
|
||||
]);
|
||||
$this->belongsTo('Products', [
|
||||
'foreignKey' => 'product_id',
|
||||
'joinType' => 'INNER',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default validation rules.
|
||||
@ -119,11 +100,6 @@ class ElopageBuysTable extends Table
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules)
|
||||
{
|
||||
$rules->add($rules->existsIn(['elopage_user_id'], 'ElopageUsers'));
|
||||
$rules->add($rules->existsIn(['affiliate_program_id'], 'AffiliatePrograms'));
|
||||
$rules->add($rules->existsIn(['publisher_id'], 'Publishers'));
|
||||
$rules->add($rules->existsIn(['order_id'], 'Orders'));
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
130
src/Model/Table/UsersTable.php
Normal file
130
src/Model/Table/UsersTable.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
namespace App\Model\Table;
|
||||
|
||||
use Cake\ORM\Query;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Users Model
|
||||
*
|
||||
* @property \App\Model\Table\EmailOptInTable&\Cake\ORM\Association\HasMany $EmailOptIn
|
||||
* @property \App\Model\Table\UserBackupsTable&\Cake\ORM\Association\HasMany $UserBackups
|
||||
* @property \App\Model\Table\UserRolesTable&\Cake\ORM\Association\HasMany $UserRoles
|
||||
*
|
||||
* @method \App\Model\Entity\User get($primaryKey, $options = [])
|
||||
* @method \App\Model\Entity\User newEntity($data = null, array $options = [])
|
||||
* @method \App\Model\Entity\User[] newEntities(array $data, array $options = [])
|
||||
* @method \App\Model\Entity\User|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
|
||||
* @method \App\Model\Entity\User saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
|
||||
* @method \App\Model\Entity\User patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \App\Model\Entity\User[] patchEntities($entities, array $data, array $options = [])
|
||||
* @method \App\Model\Entity\User findOrCreate($search, callable $callback = null, $options = [])
|
||||
*
|
||||
* @mixin \Cake\ORM\Behavior\TimestampBehavior
|
||||
*/
|
||||
class UsersTable extends Table
|
||||
{
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config)
|
||||
{
|
||||
parent::initialize($config);
|
||||
|
||||
$this->setTable('users');
|
||||
$this->setDisplayField('id');
|
||||
$this->setPrimaryKey('id');
|
||||
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
$this->hasMany('EmailOptIn', [
|
||||
'foreignKey' => 'user_id',
|
||||
]);
|
||||
$this->hasMany('UserBackups', [
|
||||
'foreignKey' => 'user_id',
|
||||
]);
|
||||
$this->hasMany('UserRoles', [
|
||||
'foreignKey' => 'user_id',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default validation rules.
|
||||
*
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
*/
|
||||
public function validationDefault(Validator $validator)
|
||||
{
|
||||
$validator
|
||||
->integer('id')
|
||||
->allowEmptyString('id', null, 'create');
|
||||
|
||||
$validator
|
||||
->email('email')
|
||||
->requirePresence('email', 'create')
|
||||
->notEmptyString('email')
|
||||
->add('email', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
|
||||
|
||||
$validator
|
||||
->scalar('first_name')
|
||||
->maxLength('first_name', 150)
|
||||
->requirePresence('first_name', 'create')
|
||||
->notEmptyString('first_name');
|
||||
|
||||
$validator
|
||||
->scalar('last_name')
|
||||
->maxLength('last_name', 255)
|
||||
->allowEmptyString('last_name');
|
||||
|
||||
$validator
|
||||
->requirePresence('password', 'create')
|
||||
->notEmptyString('password');
|
||||
|
||||
$validator
|
||||
->allowEmptyString('pubkey');
|
||||
|
||||
$validator
|
||||
->allowEmptyString('privkey');
|
||||
|
||||
$validator
|
||||
->boolean('email_checked')
|
||||
->notEmptyString('email_checked');
|
||||
|
||||
$validator
|
||||
->scalar('language')
|
||||
->maxLength('language', 4)
|
||||
->notEmptyString('language');
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
*
|
||||
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
|
||||
* @return \Cake\ORM\RulesChecker
|
||||
*/
|
||||
public function buildRules(RulesChecker $rules)
|
||||
{
|
||||
$rules->add($rules->isUnique(['email']));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database connection name to use by default.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultConnectionName()
|
||||
{
|
||||
return 'loginServer';
|
||||
}
|
||||
}
|
||||
35
src/Template/ElopageBuys/statistics.ctp
Normal file
35
src/Template/ElopageBuys/statistics.ctp
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
//var_dump($elopageBuys->toArray());
|
||||
/*foreach($elopageBuys as $entry) {
|
||||
echo $entry->success_date . "<br>";
|
||||
}
|
||||
*
|
||||
*/
|
||||
/*foreach($users as $user) {
|
||||
//var_dump($user);
|
||||
echo $user->created;
|
||||
echo "<br>";
|
||||
}*/
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-5 order-md-0">
|
||||
<div class="row">
|
||||
<div class="col-6 equel-grid">
|
||||
<div class="grid d-flex flex-column align-items-center justify-content-center">
|
||||
<div class="grid-body text-center">
|
||||
<div class="profile-img img-rounded bg-inverse-primary no-avatar component-flat mx-auto mb-4"><i class="mdi mdi-account-group mdi-2x"></i></div>
|
||||
<h2 class="font-weight-medium"><span class="animated-count"><?= $users->count()?></span></h2>
|
||||
<small class="text-gray d-block mt-3"><?= __('Anmeldungen diesen Monat'); ?></small>
|
||||
<small class="font-weight-medium text-success"><i class="mdi mdi-menu-up"></i><span class="animated-count">12.01</span>%</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
28
src/Template/Users/add.ctp
Normal file
28
src/Template/Users/add.ctp
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\User $user
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Add User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('email');
|
||||
echo $this->Form->control('first_name');
|
||||
echo $this->Form->control('last_name');
|
||||
echo $this->Form->control('password');
|
||||
echo $this->Form->control('email_checked');
|
||||
echo $this->Form->control('language');
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
34
src/Template/Users/edit.ctp
Normal file
34
src/Template/Users/edit.ctp
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\User $user
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Form->postLink(
|
||||
__('Delete'),
|
||||
['action' => 'delete', $user->id],
|
||||
['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]
|
||||
)
|
||||
?></li>
|
||||
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Edit User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('email');
|
||||
echo $this->Form->control('first_name');
|
||||
echo $this->Form->control('last_name');
|
||||
echo $this->Form->control('password');
|
||||
echo $this->Form->control('email_checked');
|
||||
echo $this->Form->control('language');
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
59
src/Template/Users/index.ctp
Normal file
59
src/Template/Users/index.ctp
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\User[]|\Cake\Collection\CollectionInterface $users
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('New User'), ['action' => 'add']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users index large-9 medium-8 columns content">
|
||||
<h3><?= __('Users') ?></h3>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><?= $this->Paginator->sort('id') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('email') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('first_name') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('last_name') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('password') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('created') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('email_checked') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('language') ?></th>
|
||||
<th scope="col" class="actions"><?= __('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<tr>
|
||||
<td><?= $this->Number->format($user->id) ?></td>
|
||||
<td><?= h($user->email) ?></td>
|
||||
<td><?= h($user->first_name) ?></td>
|
||||
<td><?= h($user->last_name) ?></td>
|
||||
<td><?= $this->Number->format($user->password) ?></td>
|
||||
<td><?= h($user->created) ?></td>
|
||||
<td><?= h($user->email_checked) ?></td>
|
||||
<td><?= h($user->language) ?></td>
|
||||
<td class="actions">
|
||||
<?= $this->Html->link(__('View'), ['action' => 'view', $user->id]) ?>
|
||||
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $user->id]) ?>
|
||||
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $user->id], ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="paginator">
|
||||
<ul class="pagination">
|
||||
<?= $this->Paginator->first('<< ' . __('first')) ?>
|
||||
<?= $this->Paginator->prev('< ' . __('previous')) ?>
|
||||
<?= $this->Paginator->numbers() ?>
|
||||
<?= $this->Paginator->next(__('next') . ' >') ?>
|
||||
<?= $this->Paginator->last(__('last') . ' >>') ?>
|
||||
</ul>
|
||||
<p><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
59
src/Template/Users/statistics.ctp
Normal file
59
src/Template/Users/statistics.ctp
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
$this->assign('title', __('Benutzer Statistiken'));
|
||||
|
||||
//mdi mdi-account-multiple-plus
|
||||
//$newUserPercent = (1 - (b / a)) * 100
|
||||
$newUserPercent = 0;
|
||||
$percentColor = 'text-secondary';
|
||||
if($users->count() > 0 && $newUsersLastMonth->count()) {
|
||||
$newUserPercent = round((1 - ($users->count() / $newUsersLastMonth->count())) * 100.0, 2);
|
||||
if($newUserPercent > 0 ) {
|
||||
$percentColor = 'text-primary';
|
||||
} else if($newUserPercent < 0) {
|
||||
$percentColor = 'text-warning';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-5 order-md-0">
|
||||
<div class="row">
|
||||
<div class="col-6 equel-grid">
|
||||
<div class="grid d-flex flex-column align-items-center justify-content-center">
|
||||
<div class="grid-body text-center">
|
||||
<div class="profile-img img-rounded bg-inverse-primary no-avatar component-flat mx-auto mb-4"><i class="mdi mdi-account-group mdi-2x"></i></div>
|
||||
<h2 class="font-weight-medium"><span class="animated-count"><?= $users->count()?></span></h2>
|
||||
<small class="text-gray d-block mt-3"><?= __('Alle Anmeldungen'); ?><br> </small>
|
||||
<small class="font-weight-medium <?= $percentColor; ?>">
|
||||
<span class="animated-count" > </span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 equel-grid">
|
||||
<div class="grid d-flex flex-column align-items-center justify-content-center">
|
||||
<div class="grid-body text-center">
|
||||
<div class="profile-img img-rounded bg-inverse-warning no-avatar component-flat mx-auto mb-4"><i class="mdi mdi-account-multiple-plus mdi-2x"></i></div>
|
||||
<h2 class="font-weight-medium"><span class="animated-count"><?= $newUsersThisMonth->count() ?></span></h2>
|
||||
<small class="text-gray d-block mt-3"><?= __('Anmeldungen diesen Monat'); ?></small>
|
||||
<small class="font-weight-medium <?= $percentColor; ?>">
|
||||
<?php if($newUserPercent < 0) : ?>
|
||||
<i class="mdi mdi-menu-down"></i>
|
||||
<?php elseif($newUserPercent > 0) : ?>
|
||||
<i class="mdi mdi-menu-up"></i>
|
||||
<?php endif; ?>
|
||||
<span class="animated-count" title="<?= __('Anmeldungen im Vergleich zum letzten Monat, 0% = gleiche Anzahl') ?>"><?= $newUserPercent ?></span>%
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->Html->script(['core', 'vendor.addons']); ?>
|
||||
52
src/Template/Users/view.ctp
Normal file
52
src/Template/Users/view.ctp
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\User $user
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('Edit User'), ['action' => 'edit', $user->id]) ?> </li>
|
||||
<li><?= $this->Form->postLink(__('Delete User'), ['action' => 'delete', $user->id], ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?> </li>
|
||||
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?> </li>
|
||||
<li><?= $this->Html->link(__('New User'), ['action' => 'add']) ?> </li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users view large-9 medium-8 columns content">
|
||||
<h3><?= h($user->id) ?></h3>
|
||||
<table class="vertical-table">
|
||||
<tr>
|
||||
<th scope="row"><?= __('Email') ?></th>
|
||||
<td><?= h($user->email) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('First Name') ?></th>
|
||||
<td><?= h($user->first_name) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Last Name') ?></th>
|
||||
<td><?= h($user->last_name) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Language') ?></th>
|
||||
<td><?= h($user->language) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Id') ?></th>
|
||||
<td><?= $this->Number->format($user->id) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Password') ?></th>
|
||||
<td><?= $this->Number->format($user->password) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Created') ?></th>
|
||||
<td><?= h($user->created) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Email Checked') ?></th>
|
||||
<td><?= $user->email_checked ? __('Yes') : __('No'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user