fix redmine module

parent 1c5848e3
......@@ -29,11 +29,11 @@ class SupportController extends Controller
'access' => [
'class' => AccessControl::className(),
'user' => 'support',
'only' => ['index', 'create', 'view', 'file'],
'only' => ['index', 'create', 'view', 'file', 'close'],
'rules' => [
[
'allow' => true,
'actions' => ['index', 'create', 'view', 'file'],
'actions' => ['index', 'create', 'view', 'file', 'close'],
'roles' => ['@'],
],
],
......@@ -87,9 +87,34 @@ class SupportController extends Controller
'priority_id' => $model->priority_id,
'status_id' => $model->status_id,
'tracker_id' => $model->tracker_id,
'author_id' => $user['user']['id']
'author_id' => $user['user']['id'],
'assigned_to_manager_id' => null
];
$membership = $client->membership->all($model->project_id);
if(isset($membership))
{
foreach ($membership as $member)
{
if(isset($member['roles']))
{
foreach ($member['roles'] as $role)
{
if($role['id'] == RedmineHelper::MANAGER)
{
$params['assigned_to_manager_id'] = $member['user']['id'];
}
}
}
if($params['assigned_to_manager_id'])
{
break;
}
}
}
if($model->files)
{
$uploads = [];
......@@ -125,6 +150,7 @@ class SupportController extends Controller
$client = $this->getClient();
$user = $client->user->getCurrentUser();
$model = $client->issue->show($id, [
......@@ -177,6 +203,29 @@ class SupportController extends Controller
]);
}
public function actionClose($id)
{
$client = $this->getClient();
$user = $client->user->getCurrentUser();
$model = $client->issue->show($id);
if(empty($model['issue']) || $model['issue']['author']['id'] != $user['user']['id'])
{
throw new NotFoundHttpException('Доступ запрещен!');
}
if($model['issue']['status']['id'] == Issue::STATUS_APPROVE)
{
$client->issue->update($id, [
'status_id' => Issue::STATUS_ACCEPTED
]);
}
return $this->redirect(['/support/view/'.$id]);
}
public function actionFile()
{
if(Yii::$app->request->isAjax)
......
......@@ -23,6 +23,8 @@ class Issue extends yii\base\Model
const TRACKER_NONE = 14; // Не определено
const STATUS_NEW = 7;
const STATUS_APPROVE = 16;
const STATUS_ACCEPTED = 14;
const SCENARIO_CREATE = 'create';
const SCENARIO_UPDATE = 'update';
......
......@@ -8,6 +8,10 @@ class RedmineHelper
{
const MAX_FILE_SIZE = 5242880; //5mb
const OTHER_PROJECT = 75;
const MANAGER = 3;
public static $markupSet = [
[
'name' => 'Жирный',
......@@ -152,6 +156,15 @@ class RedmineHelper
}
}
$other[self::OTHER_PROJECT] = $output[self::OTHER_PROJECT];
unset($output[self::OTHER_PROJECT]);
$output = [
'Доступные проекты' => $output,
$other[self::OTHER_PROJECT] => $other
];
return $output;
}
......
......@@ -5,8 +5,6 @@ use yii\helpers\Html;
?>
<?php if($output['models']) : ?>
<div class="panel-group panel-group-2" id="accordion_2">
<div class="panel panel-default">
<div class="panel-heading table-responsive">
......@@ -77,6 +75,4 @@ use yii\helpers\Html;
</div>
</div>
</div>
<?php endif; ?>
\ No newline at end of file
......@@ -63,6 +63,8 @@ use common\modules\support\models\redmine\RedmineHelper;
<tr>
<td class="no_pad">
<div class="panel-group panel-group-2" id="accordion_2">
<?php
if($issues = RedmineHelper::sortIsuues($models['issues']))
{
......@@ -80,6 +82,8 @@ use common\modules\support\models\redmine\RedmineHelper;
}
?>
</div>
</td>
</tr>
</table>
......
......@@ -27,6 +27,10 @@ $parser = new \Netcarver\Textile\Parser();
<div class="row">
<?php if($model['status']['id'] == Issue::STATUS_APPROVE) : ?>
<div class="col-md-2 col-md-offset-10"><?=Html::a('Закрыть', ['/support/close/'.$model['id']], ['class' => 'btn btn-primary pull-right']);?></div>
<?php endif; ?>
<div class="col-md-12">
<div class="panel-body panel-body-ex-1 panel-body-ex-3 notifications_box color_on_cursor" <?=($model['priority']['id']==Issue::PRIORITY_SIMPLE?'style="border:0;"':'')?>>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment