Skip to content

Commit

Permalink
User history menu
Browse files Browse the repository at this point in the history
  • Loading branch information
magnussolution committed Jul 7, 2022
1 parent 48ade80 commit aabda84
Show file tree
Hide file tree
Showing 28 changed files with 512 additions and 10 deletions.
38 changes: 38 additions & 0 deletions app/model/UserHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Classe que define a model "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
* =======================================
* Magnusbilling.com <[email protected]>
* 06/06/2022
*/
Ext.define('MBilling.model.UserHistory', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'date',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
}, {
name: 'id_user',
type: 'int'
}, 'description', 'idUserusername'],
proxy: {
type: 'uxproxy',
module: 'userHistory'
}
});
24 changes: 24 additions & 0 deletions app/store/UserHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Classe que define o store "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
* =======================================
* Magnusbilling.com <[email protected]>
* 06/06/2022
*/
Ext.define('MBilling.store.UserHistory', {
extend: 'Ext.data.Store',
model: 'MBilling.model.UserHistory'
});
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions classic/src/Application.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions classic/src/view/userHistory/Controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Classe que define a lista de "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
* =======================================
* Magnusbilling.org <[email protected]>
* 22/06/2022
*/
Ext.define('MBilling.view.userHistory.Controller', {
extend: 'Ext.ux.app.ViewController',
alias: 'controller.userhistory'
});
52 changes: 52 additions & 0 deletions classic/src/view/userHistory/Form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Classe que define a lista de "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
* =======================================
* Magnusbilling.org <[email protected]>
* 22/06/2022
*/
Ext.define('MBilling.view.userHistory.Form', {
extend: 'Ext.ux.form.Panel',
alias: 'widget.userhistoryform',
initComponent: function() {
var me = this;
me.items = [{
xtype: 'userlookup',
ownerForm: me,
name: 'id_user',
fieldLabel: t('Username'),
hidden: App.user.isClient
}, {
xtype: 'datetimefield',
name: 'date',
fieldLabel: t('Date'),
format: 'Y-m-d H:i:s',
hidden: !App.user.isAdmin,
allowBlank: true,
value: new Date()
}, {
xtype: 'textareafield',
name: 'description',
fieldLabel: t(''),
readOnly: App.user.isClient,
height: 400,
anchor: '100%',
labelWidth: '100%',
labelAlign: 'left'
}];
me.callParent(arguments);
}
});
58 changes: 58 additions & 0 deletions classic/src/view/userHistory/List.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Classe que define a lista de "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
* =======================================
* Magnusbilling.org <[email protected]>
* 22/06/2022
*/
Ext.define('MBilling.view.userHistory.List', {
extend: 'Ext.ux.grid.Panel',
alias: 'widget.userhistorylist',
store: 'UserHistory',
fieldSearch: 'idUser.username',
initComponent: function() {
var me = this;
me.columns = [{
header: t('ID'),
dataIndex: 'id',
flex: 1,
hidden: true,
hideable: App.user.isAdmin
}, {
header: t('Username'),
dataIndex: 'idUserusername',
filter: {
type: 'string',
field: 'idUser.username'
},
flex: 3,
hidden: App.user.isClient,
hideable: !App.user.isClient
}, {
header: t('Description'),
dataIndex: 'description',
flex: 5,
hidden: window.isTablet
}, {
header: t('Date'),
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
dataIndex: 'date',
flex: 4,
hidden: window.isTablet
}];
me.callParent(arguments);
}
});
25 changes: 25 additions & 0 deletions classic/src/view/userHistory/Module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Classe que define a lista de "UserHistory"
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
* ###################################
*
* This software is released under the terms of the GNU Lesser General Public License v3
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
*
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
* =======================================
* Magnusbilling.org <[email protected]>
* 22/06/2022
*/
Ext.define('MBilling.view.userHistory.Module', {
extend: 'Ext.ux.panel.Module',
alias: 'widget.userhistorymodule',
controller: 'userhistory'
});
37 changes: 37 additions & 0 deletions protected/commands/UpdateMysqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,43 @@ public function run($args)
Yii::app()->db->createCommand($sql)->execute();
}

//2022-05-25
if ($version == '7.8.1.4') {

$sql = "SELECT priority FROM pkg_module WHERE id_module = 1 ORDER BY priority DESC";
$result = Yii::app()->db->createCommand($sql)->queryAll();
if (isset($result[0]['priority'])) {
$sql = "INSERT INTO pkg_module VALUES (NULL, 't(''User History'')', 'userhistory', 'x-fa fa-desktop', 1," . ($result[0]['priority'] + 1) . ")";
$this->executeDB($sql);
$idServiceModule = Yii::app()->db->lastInsertID;

$sql = "INSERT INTO pkg_group_module VALUES ((SELECT id FROM pkg_group_user WHERE id_user_type = 1 LIMIT 1), '" . $idServiceModule . "', 'crud', '1', '1', '1');";
$this->executeDB($sql);
}

$version = '7.8.1.5';
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
Yii::app()->db->createCommand($sql)->execute();
}

//2022-05-25
if ($version == '7.8.1.5') {
$sql = "CREATE TABLE `pkg_user_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_user` int(11) NOT NULL,
`description` mediumtext,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `fk_pkg_user_pkg_user_history` (`id_user`),
CONSTRAINT `fk_pkg_user_pkg_user_history` FOREIGN KEY (`id_user`) REFERENCES `pkg_user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
";
$this->executeDB($sql);

$version = '7.8.1.6';
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
Yii::app()->db->createCommand($sql)->execute();
}
}

public function executeDB($sql)
Expand Down
9 changes: 9 additions & 0 deletions protected/components/ServicesProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public static function release($id_services)
//have days yet.
$modelUser = User::model()->findByPk((int) $modelServicesUse->id_user);
$modelServicesUse->idServices->price = $priceToreturn;

$description = Yii::t('zii', 'Return credit after cancellation') . '. ' . Yii::t('zii', 'Service') . ' ' . Yii::t('zii', 'name') . ' ' . $modelServicesUse->idServices->name;
$modelRefill = new Refill();
$modelRefill->id_user = $modelServicesUse->id_user;
$modelRefill->credit = $priceToreturn;
$modelRefill->description = $description;
$modelRefill->payment = 1;
$modelRefill->save();

ServicesProcess::updateUser('release', $modelServicesUse);
}
}
Expand Down
39 changes: 39 additions & 0 deletions protected/controllers/UserHistoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Acoes do modulo "UserHistory".
*
* =======================================
* ###################################
* MagnusBilling
*
* @package MagnusBilling
* @author Adilson Leffa Magnus.
* @copyright Todos os direitos reservados.
* ###################################
* =======================================
* Magnusbilling.com <[email protected]>
* 06/06/2022
*/

class UserHistoryController extends Controller
{
public $attributeOrder = 'date DESC';
public $extraValues = array('idUser' => 'username');

public $fieldsFkReport = array(
'id_user' => array(
'table' => 'pkg_user',
'pk' => 'id',
'fieldReport' => 'username',
),
);

public function init()
{
$this->instanceModel = new UserHistory;
$this->abstractModel = UserHistory::model();
$this->titleReport = Yii::t('zii', 'User History');

parent::init();
}
}
Loading

0 comments on commit aabda84

Please sign in to comment.