small fix redmine fix

parent 119ec16e
......@@ -5,6 +5,7 @@ namespace common\modules\support\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\Controller;
use yii\web\Response;
use yii\web\NotFoundHttpException;
......@@ -127,19 +128,26 @@ class SupportController extends Controller
{
if($_FILES['files'])
{
$client = $this->getClient();
$html = '';
foreach ($_FILES['files']['name'] as $i => $name)
{
$client = $this->getClient();
$response = json_decode($client->attachment->upload(@file_get_contents($_FILES['files']['tmp_name'][$i])));
$html .= $this->renderPartial('_file', [
'name' => $name,
'size' => RedmineHelper::formatSize($_FILES['files']['size'][$i]),
'token' => $response->upload->token,
'type' => $_FILES['files']['type'][$i]
]);
if($_FILES['files']['size'][$i] <= RedmineHelper::MAX_FILE_SIZE)
{
$response = json_decode($client->attachment->upload(@file_get_contents($_FILES['files']['tmp_name'][$i])));
$html .= $this->renderPartial('_file', [
'name' => $name,
'size' => RedmineHelper::formatSize($_FILES['files']['size'][$i]),
'token' => $response->upload->token,
'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 [
......
......@@ -29,7 +29,12 @@ class Issue extends yii\base\Model
public function rules()
{
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'],
[['description'], 'string'],
[['files'], 'safe'],
......
......@@ -6,6 +6,8 @@ use common\models\Settings;
class RedmineHelper
{
const MAX_FILE_SIZE = 5242880; //5mb
public static function sortIsuues($issues = null)
{
if($issues)
......
......@@ -28,15 +28,15 @@ use common\modules\support\models\redmine\RedmineHelper;
<div class="row">
<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']) ?>
<?=$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 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'>
{input}
<p class='important_button_text_1'>Важная</p>
......@@ -190,6 +190,14 @@ use common\modules\support\models\redmine\RedmineHelper;
font-size: 9px;
line-height: 16px;
}
.help-block {
font-size: 12px;
line-height: 10px;
margin: -10px 0 25px;
}
.container_white .form-control {
float: none;
}
</style>
<?=$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