Skip to content

Commit aabda84

Browse files
author
magnussolution
committed
User history menu
1 parent 48ade80 commit aabda84

File tree

28 files changed

+512
-10
lines changed

28 files changed

+512
-10
lines changed

app/model/UserHistory.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Classe que define a model "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
17+
* =======================================
18+
* Magnusbilling.com <[email protected]>
19+
* 06/06/2022
20+
*/
21+
Ext.define('MBilling.model.UserHistory', {
22+
extend: 'Ext.data.Model',
23+
fields: [{
24+
name: 'id',
25+
type: 'int'
26+
}, {
27+
name: 'date',
28+
type: 'date',
29+
dateFormat: 'Y-m-d H:i:s'
30+
}, {
31+
name: 'id_user',
32+
type: 'int'
33+
}, 'description', 'idUserusername'],
34+
proxy: {
35+
type: 'uxproxy',
36+
module: 'userHistory'
37+
}
38+
});

app/store/UserHistory.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Classe que define o store "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
17+
* =======================================
18+
* Magnusbilling.com <[email protected]>
19+
* 06/06/2022
20+
*/
21+
Ext.define('MBilling.store.UserHistory', {
22+
extend: 'Ext.data.Store',
23+
model: 'MBilling.model.UserHistory'
24+
});

build/MagnusBilling-current.tar.gz

7 Bytes
Binary file not shown.

classic/src/Application.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Classe que define a lista de "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
17+
* =======================================
18+
* Magnusbilling.org <[email protected]>
19+
* 22/06/2022
20+
*/
21+
Ext.define('MBilling.view.userHistory.Controller', {
22+
extend: 'Ext.ux.app.ViewController',
23+
alias: 'controller.userhistory'
24+
});

classic/src/view/userHistory/Form.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Classe que define a lista de "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
17+
* =======================================
18+
* Magnusbilling.org <[email protected]>
19+
* 22/06/2022
20+
*/
21+
Ext.define('MBilling.view.userHistory.Form', {
22+
extend: 'Ext.ux.form.Panel',
23+
alias: 'widget.userhistoryform',
24+
initComponent: function() {
25+
var me = this;
26+
me.items = [{
27+
xtype: 'userlookup',
28+
ownerForm: me,
29+
name: 'id_user',
30+
fieldLabel: t('Username'),
31+
hidden: App.user.isClient
32+
}, {
33+
xtype: 'datetimefield',
34+
name: 'date',
35+
fieldLabel: t('Date'),
36+
format: 'Y-m-d H:i:s',
37+
hidden: !App.user.isAdmin,
38+
allowBlank: true,
39+
value: new Date()
40+
}, {
41+
xtype: 'textareafield',
42+
name: 'description',
43+
fieldLabel: t(''),
44+
readOnly: App.user.isClient,
45+
height: 400,
46+
anchor: '100%',
47+
labelWidth: '100%',
48+
labelAlign: 'left'
49+
}];
50+
me.callParent(arguments);
51+
}
52+
});

classic/src/view/userHistory/List.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Classe que define a lista de "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
17+
* =======================================
18+
* Magnusbilling.org <[email protected]>
19+
* 22/06/2022
20+
*/
21+
Ext.define('MBilling.view.userHistory.List', {
22+
extend: 'Ext.ux.grid.Panel',
23+
alias: 'widget.userhistorylist',
24+
store: 'UserHistory',
25+
fieldSearch: 'idUser.username',
26+
initComponent: function() {
27+
var me = this;
28+
me.columns = [{
29+
header: t('ID'),
30+
dataIndex: 'id',
31+
flex: 1,
32+
hidden: true,
33+
hideable: App.user.isAdmin
34+
}, {
35+
header: t('Username'),
36+
dataIndex: 'idUserusername',
37+
filter: {
38+
type: 'string',
39+
field: 'idUser.username'
40+
},
41+
flex: 3,
42+
hidden: App.user.isClient,
43+
hideable: !App.user.isClient
44+
}, {
45+
header: t('Description'),
46+
dataIndex: 'description',
47+
flex: 5,
48+
hidden: window.isTablet
49+
}, {
50+
header: t('Date'),
51+
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
52+
dataIndex: 'date',
53+
flex: 4,
54+
hidden: window.isTablet
55+
}];
56+
me.callParent(arguments);
57+
}
58+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Classe que define a lista de "UserHistory"
3+
*
4+
* =======================================
5+
* ###################################
6+
* MagnusBilling
7+
*
8+
* @package MagnusBilling
9+
* @author Adilson Leffa Magnus.
10+
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved.
11+
* ###################################
12+
*
13+
* This software is released under the terms of the GNU Lesser General Public License v3
14+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
15+
*
16+
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues
17+
* =======================================
18+
* Magnusbilling.org <[email protected]>
19+
* 22/06/2022
20+
*/
21+
Ext.define('MBilling.view.userHistory.Module', {
22+
extend: 'Ext.ux.panel.Module',
23+
alias: 'widget.userhistorymodule',
24+
controller: 'userhistory'
25+
});

protected/commands/UpdateMysqlCommand.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,43 @@ public function run($args)
17281728
Yii::app()->db->createCommand($sql)->execute();
17291729
}
17301730

1731+
//2022-05-25
1732+
if ($version == '7.8.1.4') {
1733+
1734+
$sql = "SELECT priority FROM pkg_module WHERE id_module = 1 ORDER BY priority DESC";
1735+
$result = Yii::app()->db->createCommand($sql)->queryAll();
1736+
if (isset($result[0]['priority'])) {
1737+
$sql = "INSERT INTO pkg_module VALUES (NULL, 't(''User History'')', 'userhistory', 'x-fa fa-desktop', 1," . ($result[0]['priority'] + 1) . ")";
1738+
$this->executeDB($sql);
1739+
$idServiceModule = Yii::app()->db->lastInsertID;
1740+
1741+
$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');";
1742+
$this->executeDB($sql);
1743+
}
1744+
1745+
$version = '7.8.1.5';
1746+
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
1747+
Yii::app()->db->createCommand($sql)->execute();
1748+
}
1749+
1750+
//2022-05-25
1751+
if ($version == '7.8.1.5') {
1752+
$sql = "CREATE TABLE `pkg_user_history` (
1753+
`id` int(11) NOT NULL AUTO_INCREMENT,
1754+
`id_user` int(11) NOT NULL,
1755+
`description` mediumtext,
1756+
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1757+
PRIMARY KEY (`id`),
1758+
KEY `fk_pkg_user_pkg_user_history` (`id_user`),
1759+
CONSTRAINT `fk_pkg_user_pkg_user_history` FOREIGN KEY (`id_user`) REFERENCES `pkg_user` (`id`) ON DELETE CASCADE
1760+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1761+
";
1762+
$this->executeDB($sql);
1763+
1764+
$version = '7.8.1.6';
1765+
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
1766+
Yii::app()->db->createCommand($sql)->execute();
1767+
}
17311768
}
17321769

17331770
public function executeDB($sql)

protected/components/ServicesProcess.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ public static function release($id_services)
6767
//have days yet.
6868
$modelUser = User::model()->findByPk((int) $modelServicesUse->id_user);
6969
$modelServicesUse->idServices->price = $priceToreturn;
70+
71+
$description = Yii::t('zii', 'Return credit after cancellation') . '. ' . Yii::t('zii', 'Service') . ' ' . Yii::t('zii', 'name') . ' ' . $modelServicesUse->idServices->name;
72+
$modelRefill = new Refill();
73+
$modelRefill->id_user = $modelServicesUse->id_user;
74+
$modelRefill->credit = $priceToreturn;
75+
$modelRefill->description = $description;
76+
$modelRefill->payment = 1;
77+
$modelRefill->save();
78+
7079
ServicesProcess::updateUser('release', $modelServicesUse);
7180
}
7281
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Acoes do modulo "UserHistory".
4+
*
5+
* =======================================
6+
* ###################################
7+
* MagnusBilling
8+
*
9+
* @package MagnusBilling
10+
* @author Adilson Leffa Magnus.
11+
* @copyright Todos os direitos reservados.
12+
* ###################################
13+
* =======================================
14+
* Magnusbilling.com <[email protected]>
15+
* 06/06/2022
16+
*/
17+
18+
class UserHistoryController extends Controller
19+
{
20+
public $attributeOrder = 'date DESC';
21+
public $extraValues = array('idUser' => 'username');
22+
23+
public $fieldsFkReport = array(
24+
'id_user' => array(
25+
'table' => 'pkg_user',
26+
'pk' => 'id',
27+
'fieldReport' => 'username',
28+
),
29+
);
30+
31+
public function init()
32+
{
33+
$this->instanceModel = new UserHistory;
34+
$this->abstractModel = UserHistory::model();
35+
$this->titleReport = Yii::t('zii', 'User History');
36+
37+
parent::init();
38+
}
39+
}

0 commit comments

Comments
 (0)