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,78 +5,74 @@ 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">
<div class="panel panel-default">
<div class="panel-heading table-responsive">
<table class="w100pr table_header">
<tbody>
<tr>
<td>
<p class="panel-title2 pull-left">
<!-- <a href=""><span class="glyphicon glyphicon-align-justify"></span></a>&nbsp;&nbsp; -->
<strong><?=$title?></strong>&nbsp;&nbsp;
</p>
</td>
<td class="box_td">
<p><strong>Дата <br> поступления</strong></p>
</td>
<td class="box_td">
<p><strong>Срок <br> исполнения</strong></p>
</td>
<td class="box_td">
<p><strong>Стоимость <br> руб.</strong></p>
</td>
</tr>
</tbody>
</table>
<table class="w100pr table_header">
<tbody>
<tr>
<td>
<p class="panel-title2 pull-left">
<!-- <a href=""><span class="glyphicon glyphicon-align-justify"></span></a>&nbsp;&nbsp; -->
<strong><?=$title?></strong>&nbsp;&nbsp;
</p>
</td>
<td class="box_td">
<p><strong>Дата <br> поступления</strong></p>
</td>
<td class="box_td">
<p><strong>Срок <br> исполнения</strong></p>
</td>
<td class="box_td">
<p><strong>Стоимость <br> руб.</strong></p>
</td>
</tr>
</tbody>
</table>
</div>
<div id="collapse_1" class="panel-collapse collapse in">
<?php foreach ($output['models'] as $model) : ?>
<div class="panel-body panel-body-ex-1 color_on_cursor gray_box_2">
<table class="w100pr">
<tbody>
<tr>
<td class="box_td_fir">
<!-- <div class="arrov_poz pull-left">
<a href=""><span class="caret caret_top"></span></a>
<a href=""><span class="caret"></span></a>
</div> -->
<span><?=$model['id']?></span>
</td>
<td class="box_td_cont">
<p><strong><?=Html::a($model['subject'], ['/support/view/'.$model['id']])?></strong></p>
</td>
<td class="box_td">
<span><?=date('d.m.Y', strtotime($model['created_on']))?></span>
</td>
<td class="box_td">
<span><?=($model->due_date?date('d.m.Y', strtotime($model['due_date'])):'Не установлено')?></span>
</td>
<td class="box_td">
</div>
<div id="collapse_1" class="panel-collapse collapse in">
<?php foreach ($output['models'] as $model) : ?>
<div class="panel-body panel-body-ex-1 color_on_cursor gray_box_2">
<table class="w100pr">
<tbody>
<tr>
<td class="box_td_fir">
<!-- <div class="arrov_poz pull-left">
<a href=""><span class="caret caret_top"></span></a>
<a href=""><span class="caret"></span></a>
</div> -->
<span><?=$model['id']?></span>
</td>
<td class="box_td_cont">
<p><strong><?=Html::a($model['subject'], ['/support/view/'.$model['id']])?></strong></p>
</td>
<td class="box_td">
<span><?=date('d.m.Y', strtotime($model['created_on']))?></span>
</td>
<td class="box_td">
<span><?=($model->due_date?date('d.m.Y', strtotime($model['due_date'])):'Не установлено')?></span>
</td>
<td class="box_td">
<?php if(!$output['rating'] && $model['price_for_customer'] == 0) : ?>
<p class="green_text align_right"><strong>Гарантия</strong></p>
<?php else : ?>
<p class="pull-left"><strong><?=($model['price_for_customer']!=0 ? Yii::$app->formatter->asCurrency($model['price_for_customer'], 'RUR', [], [\NumberFormatter::CURRENCY_SYMBOL => '₽']) : 'Не установлено')?></strong></p>
<?php endif; ?>
<!-- <div class="tooltip_wr pull-right">
<div class="tooltip_box">Счет был выставлен</div>
<span class="tooltip_cont"><img src="/images/score_icon.jpg" height="24" width="19" alt=""></span>
</div> -->
</td>
</tr>
</tbody>
</table>
</div>
<?php endforeach; ?>
<?php if(!$output['rating'] && $model['price_for_customer'] == 0) : ?>
<p class="green_text align_right"><strong>Гарантия</strong></p>
<?php else : ?>
<p class="pull-left"><strong><?=($model['price_for_customer']!=0 ? Yii::$app->formatter->asCurrency($model['price_for_customer'], 'RUR', [], [\NumberFormatter::CURRENCY_SYMBOL => '₽']) : 'Не установлено')?></strong></p>
<?php endif; ?>
<!-- <div class="tooltip_wr pull-right">
<div class="tooltip_box">Счет был выставлен</div>
<span class="tooltip_cont"><img src="/images/score_icon.jpg" height="24" width="19" alt=""></span>
</div> -->
</td>
</tr>
</tbody>
</table>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
\ No newline at end of file
......@@ -63,23 +63,27 @@ use common\modules\support\models\redmine\RedmineHelper;
<tr>
<td class="no_pad">
<?php
if($issues = RedmineHelper::sortIsuues($models['issues']))
{
foreach ($issues as $issue)
<div class="panel-group panel-group-2" id="accordion_2">
<?php
if($issues = RedmineHelper::sortIsuues($models['issues']))
{
if(!isset($issue['close']))
{
echo $this->render('_loop', ['output' => $issue, 'title' => $issue['title']]);
}
else
foreach ($issues as $issue)
{
$accepteds = $issue['models'];
if(!isset($issue['close']))
{
echo $this->render('_loop', ['output' => $issue, 'title' => $issue['title']]);
}
else
{
$accepteds = $issue['models'];
}
}
}
}
?>
?>
</div>
</td>
</tr>
</table>
......
......@@ -26,7 +26,11 @@ $parser = new \Netcarver\Textile\Parser();
</div>
<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