Skip to content

Commit

Permalink
update DID method
Browse files Browse the repository at this point in the history
  • Loading branch information
callcenter-magnus committed May 9, 2024
1 parent 4fedb35 commit 72bd8a0
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 59 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions classic/src/view/did/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Ext.define('MBilling.view.did.Form', {
}, {
title: t('Billing'),
reference: 'billingTab',
hidden: !App.user.isAdmin,
hidden: App.user.isClient,
items: [{
xtype: 'fieldset',
style: 'margin-top:5px; overflow: visible;',
Expand Down Expand Up @@ -221,7 +221,7 @@ Ext.define('MBilling.view.did.Form', {
xtype: 'moneyfield',
mask: App.user.currency + ' #9.999.990,' + App.user.decimalPrecision,
name: 'agent_client_rate_1',
fieldLabel: t('Agent\'s client price per min'),
fieldLabel: App.user.isAgent ? t('Sell price per min') : t('Agent\'s client price per min'),
value: '0',
hidden: App.user.isClient
}, {
Expand All @@ -241,7 +241,7 @@ Ext.define('MBilling.view.did.Form', {
title: t('DID billing per minute rate') + ' 2',
collapsible: false,
collapsed: false,
hidden: !App.user.isAdmin,
hidden: App.user.isClient,
defaults: {
labelWidth: 250,
anchor: '100%',
Expand Down Expand Up @@ -271,7 +271,7 @@ Ext.define('MBilling.view.did.Form', {
xtype: 'moneyfield',
mask: App.user.currency + ' #9.999.990,' + App.user.decimalPrecision,
name: 'agent_client_rate_2',
fieldLabel: t('Agent\'s client price per min'),
fieldLabel: App.user.isAgent ? t('Sell price per min') : t('Agent\'s client price per min'),
value: '0',
hidden: App.user.isClient
}, {
Expand All @@ -291,7 +291,7 @@ Ext.define('MBilling.view.did.Form', {
title: t('DID billing per minute rate') + ' 3',
collapsible: false,
collapsed: false,
hidden: !App.user.isAdmin,
hidden: App.user.isClient,
defaults: {
labelWidth: 250,
anchor: '100%',
Expand Down Expand Up @@ -321,7 +321,7 @@ Ext.define('MBilling.view.did.Form', {
xtype: 'moneyfield',
mask: App.user.currency + ' #9.999.990,' + App.user.decimalPrecision,
name: 'agent_client_rate_3',
fieldLabel: t('Agent\'s client price per min'),
fieldLabel: App.user.isAgent ? t('Sell price per min') : t('Agent\'s client price per min'),
value: '0',
hidden: App.user.isClient
}, {
Expand Down
5 changes: 5 additions & 0 deletions protected/commands/DidCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public function run($args)
$oneday = 60 * 60 * 24;

foreach ($modelDidUse as $didUse) {

if ( ! isset($didUse->idUser->id)) {
continue;
}

$id_agent = $didUse->idUser->id_user;

$day_remaining = 0;
Expand Down
28 changes: 0 additions & 28 deletions protected/components/AsteriskAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,34 +662,6 @@ public static function getCoreShowChannel($channel, $agi = null, $server = null)

}

public function generateSipDid()
{

$sipDidfile = '/etc/asterisk/mbilling_sip_did.conf';
$sipDid = '';

$modelSip = Sip::model()->findAll();
$modelDID = Did::model()->findAll('reserved = 1 AND activated = 1');

if (isset($modelDID[0]->id)) {
foreach ($modelDID as $key => $did) {
$sipDid .= "[" . $did->did . "]\n";
}
}

if (isset($modelSip[0]->id)) {
foreach ($modelSip as $key => $sip) {
$sipDid .= "[" . $sip->name . "]\n";
}
}

$fdSD = fopen($sipDidfile, "w");

fwrite($fdSD, $sipDid);
fclose($fdSD);

}

public function generateSipPeers()
{
$modelSip = Sip::model()->findAll();
Expand Down
92 changes: 77 additions & 15 deletions protected/controllers/DidController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,98 @@ class DidController extends Controller
],
];
public $fieldsInvisibleAgent = [
'did',
'id_user',
'id_didgroup',
'activated',
'connection_sell',
'minimal_time_buy',
'buyrateinitblock',
'buyrateincrement',
'minimal_time_charge',
'initblock',
'increment',
'charge_of',
'id_server',
'block_expression_1',
'block_expression_2',
'block_expression_3',
'send_to_callback_1',
'send_to_callback_2',
'send_to_callback_3',
'cbr',
'cbr_ua',
'cbr_total_try',
'cbr_time_try',
'cbr_em',
'TimeOfDay_monFri',
'TimeOfDay_sat',
'TimeOfDay_sun',
'workaudio',
'noworkaudio',
'fixrate',
'buy_rate_1',
'buy_rate_2',
'buy_rate_3',
'calllimit',
'expression_1',
'expression_2',
'expression_3',
'buy_rate_1',
'buy_rate_2',
'buy_rate_3',
'selling_rate_1',
'selling_rate_2',
'selling_rate_3',
];

public $fieldsInvisibleClient = [
'did',
'id_user',
'id_didgroup',
'activated',
'creationdate',
'startingdate',
'expirationdate',
'description',
'billingtype',
'selling_rate',
'connection_sell',
'minimal_time_buy',
'buyrateinitblock',
'buyrateincrement',
'minimal_time_charge',
'initblock',
'increment',
'charge_of',
'id_server',
'block_expression_1',
'block_expression_2',
'block_expression_3',
'send_to_callback_1',
'send_to_callback_2',
'send_to_callback_3',
'cbr',
'cbr_ua',
'cbr_total_try',
'cbr_time_try',
'cbr_em',
'TimeOfDay_monFri',
'TimeOfDay_sat',
'TimeOfDay_sun',
'workaudio',
'noworkaudio',
'fixrate',
'buy_rate_1',
'buy_rate_2',
'buy_rate_3',
'calllimit',
'expression_1',
'expression_2',
'expression_3',
'buy_rate_1',
'buy_rate_2',
'buy_rate_3',
'selling_rate_1',
'selling_rate_2',
'selling_rate_3',
'agent_client_rate_1',
'agent_client_rate_2',
'agent_client_rate_3',
'calllimit',
];

public function init()
Expand Down Expand Up @@ -316,8 +386,6 @@ public function beforeSave($values)
public function afterSave($model, $values)
{

AsteriskAccess::instance()->generateSipDid();

if (isset($_FILES["workaudio"]) && strlen($_FILES["workaudio"]["name"]) > 1) {
if (file_exists($this->uploaddir . 'idDidAudioProWork_' . $model->id . '.wav')) {
unlink($this->uploaddir . 'idDidAudioProWork_' . $model->id . '.wav');
Expand Down Expand Up @@ -448,12 +516,6 @@ public function actionLiberar()
}
}

public function afterDestroy($values)
{
AsteriskAccess::instance()->generateSipDid();
return;
}

public function beforeDestroy($values)
{

Expand Down
5 changes: 0 additions & 5 deletions protected/controllers/DiddestinationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ public function actionbulkdestinatintion()
}
}

AsteriskAccess::instance()->generateSipDid();
echo json_encode([
$this->nameSuccess => $this->success,
$this->nameMsg => $this->msg,
Expand All @@ -291,8 +290,6 @@ public function afterSave($model, $values)
$modelDid->id_user = $model->id_user;
$modelDid->save();

AsteriskAccess::instance()->generateSipDid();

//discount credit of customer
$priceDid = $modelDid->connection_charge + $modelDid->fixrate;

Expand Down Expand Up @@ -339,13 +336,11 @@ public function afterSave($model, $values)

}
}
AsteriskAccess::instance()->generateSipDid();
return;
}

public function afterDestroy($values)
{
AsteriskAccess::instance()->generateSipDid();
return;
}

Expand Down
2 changes: 0 additions & 2 deletions protected/controllers/SipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public function afterSave($model, $values)
{
if ($_SERVER['HTTP_HOST'] != 'localhost') {
AsteriskAccess::instance()->generateSipPeers();
AsteriskAccess::instance()->generateSipDid();
AsteriskAccess::instance()->generateQueueFile();
}

Expand All @@ -202,7 +201,6 @@ public function afterSave($model, $values)
public function afterDestroy($values)
{
AsteriskAccess::instance()->generateSipPeers();
AsteriskAccess::instance()->generateSipDid();
AsteriskAccess::instance()->generateQueueFile();

$this->siproxyServer($values, 'destroy');
Expand Down
3 changes: 0 additions & 3 deletions protected/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public function checkAgentEdit($values)
public function afterDestroy($values)
{
AsteriskAccess::instance()->generateSipPeers();
AsteriskAccess::instance()->generateSipDid();

return;
}
Expand Down Expand Up @@ -356,8 +355,6 @@ public function afterSave($model, $values)
$this->createCallshopRates($model, $values);
}

AsteriskAccess::instance()->generateSipDid();

return;
}

Expand Down

0 comments on commit 72bd8a0

Please sign in to comment.