Skip to content

Commit

Permalink
fix refill sum when have filter
Browse files Browse the repository at this point in the history
  • Loading branch information
magnussolution committed Jun 17, 2023
1 parent a764682 commit d98ca62
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
4 changes: 3 additions & 1 deletion protected/commands/SipProxyAccountsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public function run($args)
//
}
foreach ($modelSip as $key => $sip) {

if ($sip->idUser->active == 0) {
continue;
}
if ($sip->host == 'dynamic') {
$sqlproxy .= " ('" . $sip->defaultuser . "', '$remoteProxyIP','" . $sip->secret . "','" . md5($sip->defaultuser . ':' . $remoteProxyIP . ':' . $sip->secret) . "', '" . $sip->idUser->username . "', '" . $sip->trace . "','" . $sip->idUser->cpslimit . "'),";
} else {
Expand Down
11 changes: 2 additions & 9 deletions protected/components/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BaseController extends CController
public $extraFieldsRelated = array();
public $titleReport;
public $subTitleReport;
public $addAuthorizedNoSession;
public $attributes = array();
public $extraValues = array();
public $mapErrorsMySql = array(
Expand Down Expand Up @@ -95,7 +96,7 @@ public function init()
}

if (!Yii::app()->session['id_user']) {
if (!$this->authorizedNoSession()) {
if (!$this->authorizedNoSession($this->addAuthorizedNoSession)) {
exit("Access denied to All action in All modules");
}
}
Expand Down Expand Up @@ -221,14 +222,6 @@ public function getActions($modules)
return $actions;
}

public function authorizedNoSession()
{
$allow = array(
'site',
'authentication',
);
return in_array($this->controllerName, $allow);
}
private function getOverride()
{
if (!file_exists('protected/config/overrides.php')) {
Expand Down
10 changes: 7 additions & 3 deletions protected/components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class Controller extends BaseController
'invoices',
'statusSystem',
'firewall',
'trunkGroup',
'callSummaryPerDay',
);

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

public function authorizedNoSession()
public function authorizedNoSession($value = false)
{

$allow = array(
'site',
'authentication',
Expand All @@ -68,6 +67,11 @@ public function authorizedNoSession()
'molPay',
'sms',
);

if ($value) {

$allow[] = $value;
}
return in_array($this->controllerName, $allow);
}

Expand Down
40 changes: 22 additions & 18 deletions protected/controllers/RefillController.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ public function recordsExtraSum($records)
'condition' => $this->filter == '' ? 1 : $this->filter,
'params' => $this->paramsFilter,
'with' => $this->relationFilter,
'order' => $this->order,
'limit' => $this->limit,
'offset' => $this->start,
'group' => 'CreditMonth',
));

Expand All @@ -202,22 +199,29 @@ public function recordsExtraSum($records)
public function setAttributesModels($attributes, $models)
{

$modelRefill = $this->abstractModel->find(array(
'select' => 'SUM(t.credit) AS credit',
'join' => $this->join,
'condition' => $this->filter == '' ? 1 : $this->filter,
'params' => $this->paramsFilter,
'with' => $this->relationFilter,
));
$criteria = new CDbCriteria();
if (strlen($this->filter)) {
$criteria->addCondition($this->filter);
}
$criteria->select = 'SUM(t.credit) AS credit';
$criteria->join = $this->join;
$criteria->params = $this->paramsFilter;
$criteria->with = $this->relationFilter;

$modelRefillSumm2 = $this->abstractModel->findAll(array(
'select' => 'EXTRACT(YEAR_MONTH FROM date) AS CreditMonth , SUM(t.credit) AS sumCreditMonth',
'join' => $this->join,
'condition' => $this->filter == '' ? 1 : $this->filter,
'params' => $this->paramsFilter,
'with' => $this->relationFilter,
'group' => 'CreditMonth',
));
if (count($this->addInCondition)) {
$criteria->addInCondition($this->addInCondition[0], $this->addInCondition[1]);
}

$modelRefill = $this->abstractModel->find($criteria);

$criteria->select = 'EXTRACT(YEAR_MONTH FROM date) AS CreditMonth , SUM(t.credit) AS sumCreditMonth';

$criteria->group = 'CreditMonth';

if (count($this->addInCondition)) {
$criteria->addInCondition($this->addInCondition[0], $this->addInCondition[1]);
}
$modelRefillSumm2 = $this->abstractModel->findAll($criteria);

$pkCount = is_array($attributes) || is_object($attributes) ? $attributes : [];
for ($i = 0; $i < count($pkCount); $i++) {
Expand Down
2 changes: 0 additions & 2 deletions protected/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class UserController extends Controller
'credit',
'id_user',
'id_group_agent',
'typepaid',
'creditlimit',
'calllimit',
'restriction',
'restriction_use',
Expand Down

0 comments on commit d98ca62

Please sign in to comment.