Skip to content

Commit d627700

Browse files
author
info@magnusbilling.com
committed
Customer can receive daily balance notification email
1 parent e68bc0c commit d627700

31 files changed

Lines changed: 166 additions & 14 deletions

File tree

build/MagnusBilling-current.tar.gz

789 Bytes
Binary file not shown.

classic/src/view/Plan/Controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ Ext.define('MBilling.view.plan.Controller', {
9797
}
9898
});
9999
//delete me.params['id_services_array'];
100-
},
100+
}
101101
});

classic/src/view/user/Form.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ Ext.define('MBilling.view.user.Form', {
263263
fieldLabel: t('Type paid'),
264264
allowBlank: true,
265265
readOnly: App.user.isClient
266+
}, {
267+
xtype: 'noyescombo',
268+
name: 'credit_notification_daily',
269+
fieldLabel: t('Credit notification daily')
266270
}, {
267271
xtype: 'fieldcontainer',
268272
layout: 'hbox',
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2021 MagnusSolution. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <info@magnusbilling.com>
18+
*
19+
*/
20+
class NotifyClientDailyCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
25+
$modelUser = User::model()->findAll(array(
26+
'condition' => 'credit_notification_daily = 1',
27+
));
28+
29+
foreach ($modelUser as $user) {
30+
31+
$modelSmtp = Smtps::model()->find('id_user = :key', array(':key' => $user->id_user));
32+
33+
if (!isset($modelSmtp->id)) {
34+
continue;
35+
}
36+
37+
if (strlen($user->email) > 0) {
38+
$mail = new Mail(Mail::$TYPE_CREDIT_DAILY, $user->id);
39+
try {
40+
$mail->send();
41+
} catch (Exception $e) {
42+
//error SMTP
43+
}
44+
45+
if ($this->config['global']['admin_received_email'] == 1 && strlen($this->config['global']['admin_email'])) {
46+
try {
47+
$mail->send($this->config['global']['admin_email']);
48+
} catch (Exception $e) {
49+
50+
}
51+
}
52+
53+
echo ("Notifique email " . $user->email . "\n");
54+
}
55+
56+
}
57+
sleep(1);
58+
}
59+
}

protected/commands/UpdateMysqlCommand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,27 @@ public function run($args)
14861486
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
14871487
Yii::app()->db->createCommand($sql)->execute();
14881488
}
1489+
1490+
//2021-10-22
1491+
if ($version == '7.7.6') {
1492+
$sql = "INSERT INTO `pkg_templatemail` VALUES (NULL, '1', 'credit', 'noreply@site.com', 'VoIP', 'Crédito atual da sua cuenta VoIP ( \$credit\$ \$currency\$)', '<p>Olá \$firstname\$ \$lastname\$, </p> <br> <p>Seu saldo atual é de R$ \$credit\$.</p> <br> <p>Observação: Você pode desativar o recebimento deste email no seu painel de cliente.</p> <br> <p>Atenciosamente,<br>', 'br', '1');";
1493+
$this->executeDB($sql);
1494+
1495+
$sql = "INSERT INTO `pkg_templatemail` VALUES (NULL, '1', 'credit', 'noreply@site.com', 'VoIP', 'Credito actual de su cuenta VoIP ( \$credit\$ \$currency\$)', '<p>Hola \$firstname\$ \$lastname\$, </p> <br> <p>Su credito actual es de \$credit\$.</p> <br> <p>OBS: Puedes desactivar el envio de este email en su panel de cliente.</p> <br> <p>Saludos,<br>', 'es', '1');";
1496+
$this->executeDB($sql);
1497+
1498+
$sql = "INSERT INTO `pkg_templatemail` VALUES (NULL, '1', 'credit', 'noreply@site.com', 'VoIP', 'You actual credit is ( \$credit\$ \$currency\$)', '<p>Hello \$firstname\$ \$lastname\$, </p> <br> <p>Your credit is \$credit\$.</p> <br> <p>OBS: You can disable this email on your VoIP panel.</p> <br> <p>Atenciosamente,<br>', 'en', '1');";
1499+
$this->executeDB($sql);
1500+
1501+
$sql = "ALTER TABLE `pkg_user` ADD `credit_notification_daily` INT(1) NOT NULL DEFAULT '0' AFTER `credit_notification`;";
1502+
$this->executeDB($sql);
1503+
1504+
exec("echo '\n59 23 * * * php /var/www/html/mbilling/cron.php NotifyClientDaily' >> $CRONPATH");
1505+
1506+
$version = '7.7.7';
1507+
$sql = "UPDATE pkg_configuration SET config_value = '" . $version . "' WHERE config_key = 'version' ";
1508+
Yii::app()->db->createCommand($sql)->execute();
1509+
}
14891510
}
14901511

14911512
public function executeDB($sql)

protected/components/Mail.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Mail
4141
public static $TYPE_PAYMENT = 'payment';
4242
public static $TYPE_REFILL = 'refill';
4343
public static $TYPE_REMINDER = 'reminder';
44+
public static $TYPE_CREDIT_DAILY = 'credit';
4445
public static $TYPE_SIGNUP = 'signup';
4546
public static $TYPE_FORGETPASSWORD = 'forgetpassword';
4647
public static $TYPE_SIGNUPCONFIRM = 'signupconfirmed';

protected/models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function rules()
6868
boleto_day, calllimit, disk_space,id_group_agent,transfer_dbbl_rocket_profit,
6969
transfer_bkash_profit,transfer_flexiload_profit,transfer_international_profit,
7070
transfer_dbbl_rocket,transfer_bkash,transfer_flexiload,transfer_international,
71-
transfer_bdservice_rate,transfer_show_selling_price,cpslimit
71+
transfer_bdservice_rate,transfer_show_selling_price,cpslimit,credit_notification_daily
7272
', 'numerical', 'integerOnly' => true),
7373
array('language,mix_monitor_format,calllimit_error', 'length', 'max' => 5),
7474
array('username, zipcode, phone, mobile, vat', 'length', 'max' => 20),

resources/help/help_en.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ You can use the button "process" to reactivate the numbers with pending status.`
489489
'plan.play_audio': `Execute audios to the client from this plan or just send the error only? For example, the audios that theres no more credit.`,
490490
'plan.techprefix': `Techprefix is like a password to the client, that allows the use of more plans.`,
491491
'plan.id_service': `Select here the services that will be avaible to the users of this plan.`,
492+
'plan.id_services': ``,
492493
//PREFIXES
493494
'prefix.prefix': `Prefix code. Prefix will be used to tariff and bill the calls.`,
494495
'prefix.destination': `Destination name.`,
@@ -845,6 +846,7 @@ MagnusBilling will try to send the calls to the next trunk of the group as long
845846
'user.transfer_show_selling_price': `This function is not avaible in Brazil. It's only used to mobile refills in some countries.`,
846847
'user.contract_value': ``,
847848
'user.dist': ``,
849+
'user.credit_notification_daily': `Enable this option to customer receive daily balance notification Email. You can customize the email on Configuration menu, submenu Email Templates`,
848850
//USER CUSTOM RATES
849851
'userrate.id_prefix': `Select the prefix that you want to subscribe.`,
850852
'userrate.rateinitial': `New sell price for this prefix.`,

resources/help/help_pt_BR.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ Você pode usar o botão processar para reativar os números que estão com stat
576576
'plan.play_audio': `Executar áudios para os cliente deste plano ou mandar somente erro? Por exemplo os áudios que acabou o crédito.`,
577577
'plan.techprefix': `Techprefix é como uma senha para o cliente poder usar mais de uma plano. Por exemplo, digamos que você tem 3 tipos de planos,GSM, TDM e CLI, e quer deixar seu cliente escolher qual plano ele deseja usar. Então coloque techprefix nos planos e solicite ao seu cliente que para usar cada um dos planos e.`,
578578
'plan.id_service': `Selecione aqui os serviços que estarão disponível para os usuários deste plano.`,
579+
'plan.id_services': ``,
579580
//PREFIXOS
580581
'prefix.prefix': `Prefixo. Prefixos serão usados para criar as tarifas. EX. 5511.`,
581582
'prefix.destination': `Nome do destino. EX: Brasil SP.`,
@@ -957,6 +958,7 @@ Regra 5 -> números que iniciam com qualquer valor e tem 11 dígitos, será adic
957958
'user.transfer_show_selling_price': `Esta função não está disponível no Brasil. Somente usado para recarga de celulares em alguns países.`,
958959
'user.contract_value': ``,
959960
'user.dist': ``,
961+
'user.credit_notification_daily': `Se ativar esta opção o MagnusBilling vai enviar um email diariamente com o saldo do cliente. Você pode editar o email que será enviado no menu Configurações submenu Modelo de Emails.`,
960962
//TARIFAS PARA CLIENTES
961963
'userrate.id_prefix': `Selecione o prefixo que você deseja subscrever.`,
962964
'userrate.rateinitial': `Novo preço de venda para este prefixo.`,

resources/locale/de.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Locale.load({
240240
'Credit control': 'Guthabenkontrolle',
241241
'Credit limit': 'Guthaben limit',
242242
'Credit notification': 'Guthaben Benachrichtigung',
243+
'Credit notification daily': '',
243244
'CreditCard number': 'Kreditkartennummer',
244245
'Currency': 'Währung',
245246
'Currency destination': 'Wärhungsziel',
@@ -830,7 +831,8 @@ Locale.load({
830831
'SIP Call': 'SIP-Anruf',
831832
'SIP Code': 'SIP Code',
832833
'SIP To': 'SIP an',
833-
'SIP Users': 'SIP-Benutzer',
834+
'SIP User': '',
835+
'SIP Users': '',
834836
'SIP account limit': 'SIP-Kontolimit',
835837
'SIP code': '',
836838
'SIP group': 'SIP-Gruppe',
@@ -1073,6 +1075,7 @@ Locale.load({
10731075
'Username need start with numbers or letters': 'Benutzername muss mit Zahlen oder Buchstaben beginnen',
10741076
'Username or email': 'Benutzername oder E-Mail-Adresse',
10751077
'Users': 'Benutzer',
1078+
'Usuários': '',
10761079
'VAT': 'MwSt',
10771080
'Value': 'Wert',
10781081
'Variables': 'Variablen',

0 commit comments

Comments
 (0)