small fix redmine fix

parent 119ec16e
...@@ -5,6 +5,7 @@ namespace common\modules\support\controllers; ...@@ -5,6 +5,7 @@ namespace common\modules\support\controllers;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\Controller; use yii\web\Controller;
use yii\web\Response; use yii\web\Response;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
...@@ -127,11 +128,13 @@ class SupportController extends Controller ...@@ -127,11 +128,13 @@ class SupportController extends Controller
{ {
if($_FILES['files']) if($_FILES['files'])
{ {
$client = $this->getClient();
$html = ''; $html = '';
foreach ($_FILES['files']['name'] as $i => $name) foreach ($_FILES['files']['name'] as $i => $name)
{ {
$client = $this->getClient(); if($_FILES['files']['size'][$i] <= RedmineHelper::MAX_FILE_SIZE)
{
$response = json_decode($client->attachment->upload(@file_get_contents($_FILES['files']['tmp_name'][$i]))); $response = json_decode($client->attachment->upload(@file_get_contents($_FILES['files']['tmp_name'][$i])));
$html .= $this->renderPartial('_file', [ $html .= $this->renderPartial('_file', [
...@@ -141,6 +144,11 @@ class SupportController extends Controller ...@@ -141,6 +144,11 @@ class SupportController extends Controller
'type' => $_FILES['files']['type'][$i] 'type' => $_FILES['files']['type'][$i]
]); ]);
} }
else
{
$html .= Html::tag('div', 'Превышен максимально допустимый размер файла&nbsp;&nbsp;<a class="delete-file" href="#"><span class="glyphicon glyphicon-remove color_gray"></span></a>', ['class'=>'file_box_wr']);
}
}
return [ return [
'html' => $html, 'html' => $html,
......
...@@ -29,7 +29,12 @@ class Issue extends yii\base\Model ...@@ -29,7 +29,12 @@ class Issue extends yii\base\Model
public function rules() public function rules()
{ {
return [ return [
[['tracker_id', 'project_id', 'status_id', 'priority_id', 'description'], 'required'], [['tracker_id', 'status_id', 'priority_id'], 'required'],
[['project_id'], 'required', 'message' => 'Выберите проект, к которому относится новая задача'],
[['subject'], 'required', 'message' => 'Введите наименование задачи'],
[['description'], 'required', 'message' => 'Укажите описание задачи'],
[['tracker_id', 'project_id', 'status_id', 'priority_id'], 'integer'], [['tracker_id', 'project_id', 'status_id', 'priority_id'], 'integer'],
[['description'], 'string'], [['description'], 'string'],
[['files'], 'safe'], [['files'], 'safe'],
......
...@@ -6,6 +6,8 @@ use common\models\Settings; ...@@ -6,6 +6,8 @@ use common\models\Settings;
class RedmineHelper class RedmineHelper
{ {
const MAX_FILE_SIZE = 5242880; //5mb
public static function sortIsuues($issues = null) public static function sortIsuues($issues = null)
{ {
if($issues) if($issues)
......
...@@ -28,15 +28,15 @@ use common\modules\support\models\redmine\RedmineHelper; ...@@ -28,15 +28,15 @@ use common\modules\support\models\redmine\RedmineHelper;
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<?=$form->field($model, 'subject', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}\n{hint}\n{error}"])->textInput(['maxlength' => 255, 'placeholder' => 'Дизайн оформления витринных окон для ресторана Subway'])?>
</div>
<div class="col-md-3 col-xs-6 col-sm-12">
<?php $projects = RedmineHelper::sortMemberships($user['user']['memberships']) ?> <?php $projects = RedmineHelper::sortMemberships($user['user']['memberships']) ?>
<?=$form->field($model, 'project_id', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}\n{hint}\n{error}"])->dropDownList($projects, (count($projects)>1?['prompt' => 'Выберите проект']:[]))?> <?=$form->field($model, 'project_id', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}\n{hint}\n{error}"])->dropDownList($projects, (count($projects)>1?['prompt' => 'Выберите проект']:[]))?>
</div> </div>
<div class="col-md-3 col-xs-6 col-sm-12"> <div class="col-sm-12">
<?=$form->field($model, 'subject', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}\n{hint}\n{error}"])->textInput(['maxlength' => 255, 'placeholder' => 'Дизайн оформления витринных окон для ресторана Subway'])?>
</div>
<div class="col-sm-12">
<?=$form->field($model, 'priority_id', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n<div class='important_box important_button_text'> <?=$form->field($model, 'priority_id', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n<div class='important_box important_button_text'>
{input} {input}
<p class='important_button_text_1'>Важная</p> <p class='important_button_text_1'>Важная</p>
...@@ -190,6 +190,14 @@ use common\modules\support\models\redmine\RedmineHelper; ...@@ -190,6 +190,14 @@ use common\modules\support\models\redmine\RedmineHelper;
font-size: 9px; font-size: 9px;
line-height: 16px; line-height: 16px;
} }
.help-block {
font-size: 12px;
line-height: 10px;
margin: -10px 0 25px;
}
.container_white .form-control {
float: none;
}
</style> </style>
<?=$this->render('@app/views/layouts/footer');?> <?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
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