Skip to content

Commit 46f7bd2

Browse files
author
magnussolution
committed
fix refill sum when have filter
1 parent a764682 commit 46f7bd2

6 files changed

Lines changed: 36 additions & 30 deletions

File tree

build/MagnusBilling-current.tar.gz

407 Bytes
Binary file not shown.

protected/commands/SipProxyAccountsCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function run($args)
8080
//
8181
}
8282
foreach ($modelSip as $key => $sip) {
83-
83+
if ($sip->idUser->active == 0) {
84+
continue;
85+
}
8486
if ($sip->host == 'dynamic') {
8587
$sqlproxy .= " ('" . $sip->defaultuser . "', '$remoteProxyIP','" . $sip->secret . "','" . md5($sip->defaultuser . ':' . $remoteProxyIP . ':' . $sip->secret) . "', '" . $sip->idUser->username . "', '" . $sip->trace . "','" . $sip->idUser->cpslimit . "'),";
8688
} else {

protected/components/BaseController.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class BaseController extends CController
3838
public $extraFieldsRelated = array();
3939
public $titleReport;
4040
public $subTitleReport;
41+
public $addAuthorizedNoSession;
4142
public $attributes = array();
4243
public $extraValues = array();
4344
public $mapErrorsMySql = array(
@@ -95,7 +96,7 @@ public function init()
9596
}
9697

9798
if (!Yii::app()->session['id_user']) {
98-
if (!$this->authorizedNoSession()) {
99+
if (!$this->authorizedNoSession($this->addAuthorizedNoSession)) {
99100
exit("Access denied to All action in All modules");
100101
}
101102
}
@@ -221,14 +222,6 @@ public function getActions($modules)
221222
return $actions;
222223
}
223224

224-
public function authorizedNoSession()
225-
{
226-
$allow = array(
227-
'site',
228-
'authentication',
229-
);
230-
return in_array($this->controllerName, $allow);
231-
}
232225
private function getOverride()
233226
{
234227
if (!file_exists('protected/config/overrides.php')) {

protected/components/Controller.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class Controller extends BaseController
3131
'invoices',
3232
'statusSystem',
3333
'firewall',
34-
'trunkGroup',
35-
'callSummaryPerDay',
3634
);
3735

3836
//Allowed controllers to no admin users use updateall
@@ -41,8 +39,9 @@ class Controller extends BaseController
4139
'sendCreditRates',
4240
);
4341

44-
public function authorizedNoSession()
42+
public function authorizedNoSession($value = false)
4543
{
44+
4645
$allow = array(
4746
'site',
4847
'authentication',
@@ -68,6 +67,11 @@ public function authorizedNoSession()
6867
'molPay',
6968
'sms',
7069
);
70+
71+
if ($value) {
72+
73+
$allow[] = $value;
74+
}
7175
return in_array($this->controllerName, $allow);
7276
}
7377

protected/controllers/RefillController.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,31 @@ public function recordsExtraSum($records)
202202
public function setAttributesModels($attributes, $models)
203203
{
204204

205-
$modelRefill = $this->abstractModel->find(array(
206-
'select' => 'SUM(t.credit) AS credit',
207-
'join' => $this->join,
208-
'condition' => $this->filter == '' ? 1 : $this->filter,
209-
'params' => $this->paramsFilter,
210-
'with' => $this->relationFilter,
211-
));
205+
$criteria = new CDbCriteria();
206+
$criteria->addCondition($this->filter);
207+
208+
$criteria->select = 'SUM(t.credit) AS credit';
209+
$criteria->join = $this->join;
210+
$criteria->params = $this->paramsFilter;
211+
$criteria->with = $this->relationFilter;
212+
$criteria->order = $this->order;
213+
$criteria->limit = $this->limit;
214+
$criteria->offset = $this->start;
215+
216+
if (count($this->addInCondition)) {
217+
$criteria->addInCondition($this->addInCondition[0], $this->addInCondition[1]);
218+
}
212219

213-
$modelRefillSumm2 = $this->abstractModel->findAll(array(
214-
'select' => 'EXTRACT(YEAR_MONTH FROM date) AS CreditMonth , SUM(t.credit) AS sumCreditMonth',
215-
'join' => $this->join,
216-
'condition' => $this->filter == '' ? 1 : $this->filter,
217-
'params' => $this->paramsFilter,
218-
'with' => $this->relationFilter,
219-
'group' => 'CreditMonth',
220-
));
220+
$modelRefill = $this->abstractModel->find($criteria);
221+
222+
$criteria->select = 'EXTRACT(YEAR_MONTH FROM date) AS CreditMonth , SUM(t.credit) AS sumCreditMonth';
223+
224+
$criteria->group = 'CreditMonth';
225+
226+
if (count($this->addInCondition)) {
227+
$criteria->addInCondition($this->addInCondition[0], $this->addInCondition[1]);
228+
}
229+
$modelRefillSumm2 = $this->abstractModel->findAll($criteria);
221230

222231
$pkCount = is_array($attributes) || is_object($attributes) ? $attributes : [];
223232
for ($i = 0; $i < count($pkCount); $i++) {

protected/controllers/UserController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class UserController extends Controller
8686
'credit',
8787
'id_user',
8888
'id_group_agent',
89-
'typepaid',
90-
'creditlimit',
9189
'calllimit',
9290
'restriction',
9391
'restriction_use',

0 commit comments

Comments
 (0)