Commit 816e328e9fe894cd7a1e99178afd169eb6b6b4b4

Authored by Yarik
1 parent 1fbd7ee8

test

common/models/Team.php
@@ -34,11 +34,6 @@ @@ -34,11 +34,6 @@
34 return 'team'; 34 return 'team';
35 } 35 }
36 36
37 -  
38 -  
39 -  
40 -  
41 -  
42 /** 37 /**
43 * @inheritdoc 38 * @inheritdoc
44 */ 39 */
common/models/TeamSearch.php
@@ -170,7 +170,7 @@ @@ -170,7 +170,7 @@
170 0, 170 0,
171 ]); 171 ]);
172 } 172 }
173 - 173 +
174 $query->andFilterWhere([ 174 $query->andFilterWhere([
175 'like', 175 'like',
176 'firstname', 176 'firstname',
@@ -188,8 +188,8 @@ @@ -188,8 +188,8 @@
188 ]) 188 ])
189 ->andFilterWhere([ 189 ->andFilterWhere([
190 'like', 190 'like',
191 - 'position',  
192 - $this->position, 191 + 'LOWER(position)',
  192 + mb_strtolower($this->position),
193 ]) 193 ])
194 ->andFilterWhere([ 194 ->andFilterWhere([
195 'like', 195 'like',
common/widgets/ImageUploader.php
@@ -21,6 +21,7 @@ class ImageUploader extends Widget @@ -21,6 +21,7 @@ class ImageUploader extends Widget
21 public $gallery; 21 public $gallery;
22 public $size; 22 public $size;
23 public $name = 'Add file...'; 23 public $name = 'Add file...';
  24 + public $remover = false;
24 25
25 public function init(){ 26 public function init(){
26 27
@@ -40,7 +41,8 @@ class ImageUploader extends Widget @@ -40,7 +41,8 @@ class ImageUploader extends Widget
40 'height' => $this->height, 41 'height' => $this->height,
41 'width' => $this->width, 42 'width' => $this->width,
42 'multi' => $this->multi, 43 'multi' => $this->multi,
43 - 'name' => $this->name 44 + 'name' => $this->name,
  45 + 'remover' => $this->remover
44 ]); 46 ]);
45 47
46 } 48 }
common/widgets/views/image_sizer.php
@@ -21,6 +21,13 @@ $id = $model::tableName().'_id'; @@ -21,6 +21,13 @@ $id = $model::tableName().'_id';
21 <div class="tst"> 21 <div class="tst">
22 <div id="<?= $field?>_img_block" class="admin-avatar-pattern-wr"> 22 <div id="<?= $field?>_img_block" class="admin-avatar-pattern-wr">
23 <div class="admin-avatar-pattern"> 23 <div class="admin-avatar-pattern">
  24 + <?php
  25 + if($remover && $model->$field) {
  26 + ?>
  27 + <span id="<?=$field?>_remove_img" class="remover_image" style="left:<?=$size[0]['width']?>px"><img src="/images/delete-ico.png" alt=""></span>
  28 + <?php
  29 + }
  30 + ?>
24 <?= $model->$field ? Html::img($model->$field): '' ?> 31 <?= $model->$field ? Html::img($model->$field): '' ?>
25 </div> 32 </div>
26 </div> 33 </div>
@@ -34,67 +41,93 @@ $id = $model::tableName().&#39;_id&#39;; @@ -34,67 +41,93 @@ $id = $model::tableName().&#39;_id&#39;;
34 </span> 41 </span>
35 42
36 <script> 43 <script>
37 - $(function(){  
38 -  
39 - $("#<?= $field?>").fileupload({  
40 - dataType: 'json',  
41 - formData: {size:'<?= json_encode($size)?>'},  
42 - done: function (e, data) {  
43 - if($("#<?=$field?>_buttons_block").length){  
44 - $("#<?=$field?>_buttons_block").remove() 44 + $(function()
  45 + {
  46 +
  47 + $("#<?= $field?>").fileupload(
  48 + {
  49 + dataType : 'json', formData : {size : '<?= json_encode($size)?>'},
  50 + done : function(e, data)
  51 + {
  52 + if($("#<?=$field?>_buttons_block").length)
  53 + {
  54 + $("#<?=$field?>_buttons_block").remove()
  55 + }
  56 +
  57 + $("#<?= $field?>").parent().prev().find('.admin-ava-wr').remove()
  58 +
  59 + var host = window.location.host.toString();
  60 + var img = '<div class="admin-ava-wr">' +
  61 + <?php
  62 + if($remover) {
  63 + echo "'<span id=\"" . $field . "_remove_img\" class=\"remover_image\" style=\"left:{$size[0]['width']}px\"><img src=\"/images/delete-ico.png\" alt=\"\"></span>'+";
  64 + }
  65 + ?>
  66 + '<img style="vertical-align: middle; width: <?=$width?>px; height: <?=$height?>px;" src="http://' + host + data.result.link + '"></div>' + '<div id="<?=$field?>_buttons_block">' + '<button type="button" id="<?=$field?>_save_img" class="btn btn-success img-action-buttons" >Сохранить</button>' + '<button type="button" id="<?=$field?>_remove_img" class="btn btn-danger img-action-buttons" >Отмена</button>' + '</div>';
  67 + var block = $("#<?= $field?>_img_block .admin-avatar-pattern");
  68 + block.find('img').remove();
  69 + block.append(img);
  70 + block.parents('.file-uploader-block').parent().addClass('success_download');
  71 + $("#<?=$field?>_picture_link").val(data.result.link);
  72 + $("#<?=$field?>_new_img").val(data.result.link);
45 } 73 }
46 -  
47 - $("#<?= $field?>").parent().prev().find('.admin-ava-wr').remove()  
48 -  
49 - var host = window.location.host.toString();  
50 - var img = '<div class="admin-ava-wr"><img style="vertical-align: middle; width: <?=$width?>px; height: <?=$height?>px;" src="http://'+host+data.result.link+'"></div>'+  
51 - '<div id="<?=$field?>_buttons_block">'+  
52 - '<button type="button" id="<?=$field?>_save_img" class="btn btn-success img-action-buttons" >Сохранить</button>'+  
53 - '<button type="button" id="<?=$field?>_remove_img" class="btn btn-danger img-action-buttons" >Отмена</button>'+  
54 - '</div>';  
55 - var block = $("#<?= $field?>_img_block .admin-avatar-pattern");  
56 - block.find('img').remove();  
57 - block.append(img);  
58 - block.parents('.file-uploader-block').parent().addClass('success_download');  
59 - $("#<?=$field?>_picture_link").val(data.result.link);  
60 - $("#<?=$field?>_new_img").val(data.result.link);  
61 } 74 }
62 - });  
63 -  
64 -  
65 - $('body').on('click', '#<?=$field?>_save_img',function(){  
66 - $("#<?= $field?>_img_block").parent().parent().parent().removeClass('success_download')  
67 -  
68 - $("#<?=$field?>_buttons_block").remove();  
69 - var old_url = $('#<?=$field?>_old_img').val();  
70 - var new_url = $('#<?=$field?>_new_img').val();  
71 - var model = '<?=str_replace('\\', '-',$model::className());?>';  
72 - $.post( "/file/uploader/delete-image",{new_url:new_url,old_img: old_url,model:model,field:"<?= $field?>", id:"<?=$model->$id?>",action:'save'}, function() {  
73 - });  
74 - $("#<?=$field?>_picture_link").val(new_url);  
75 - });  
76 -  
77 - $('body').on('click', '#<?=$field?>_remove_img',function(){  
78 - $("#<?= $field?>_img_block").parent().parent().parent().removeClass('success_download')  
79 - $("#<?= $field?>_img_block").parent().parent().find('.admin-ava-wr').remove()  
80 -  
81 - $("#<?=$field?>_buttons_block").remove();  
82 - var old_url = $('#<?=$field?>_old_img').val();  
83 - var new_url = $('#<?=$field?>_new_img').val();  
84 - $.post( "/file/uploader/delete-image",{old_img: new_url}, function() {  
85 - });  
86 - $("#<?=$field?>_picture_link").val(old_url);  
87 - if(old_url.length<=1){  
88 - $('#<?= $field?>_img_block').find('img').remove() 75 + );
  76 +
  77 + $('body').on(
  78 + 'click', '#<?=$field?>_save_img', function()
  79 + {
  80 + $("#<?= $field?>_img_block").parent().parent().parent()
  81 + .removeClass('success_download')
  82 +
  83 + $("#<?=$field?>_buttons_block").remove();
  84 + var old_url = $('#<?=$field?>_old_img').val();
  85 + var new_url = $('#<?=$field?>_new_img').val();
  86 + var model = '<?=str_replace('\\', '-', $model::className());?>';
  87 + $.post(
  88 + "/file/uploader/delete-image", {
  89 + new_url : new_url, old_img : old_url, model : model, field : "<?= $field?>",
  90 + id : "<?=$model->$id?>", action : 'save'
  91 + }, function()
  92 + {
  93 + }
  94 + );
  95 + $("#<?=$field?>_picture_link").val(new_url);
89 } 96 }
90 - else {  
91 - $('#<?= $field?>_img_block').find('img').attr('src',old_url); 97 + );
  98 +
  99 + $('body').on(
  100 + 'click', '#<?=$field?>_remove_img', function()
  101 + {
  102 + $("#<?= $field?>_img_block").parent().parent().parent()
  103 + .removeClass('success_download');
  104 + $("#<?= $field?>_img_block").parent().parent().find('.admin-ava-wr').remove();
  105 +
  106 + $("#<?=$field?>_buttons_block").remove();
  107 + var old_url = $('#<?=$field?>_old_img').val();
  108 + var new_url = $('#<?=$field?>_new_img').val();
  109 + $.post(
  110 + "/file/uploader/delete-image", {old_img : new_url}, function()
  111 + {
  112 + }
  113 + );
  114 + <?php
  115 + if($remover) {
  116 + echo "$(\"#{$field}_picture_link\").val('');
  117 + $('#{$field}_img_block').find('img').remove();";
  118 + } else {
  119 + echo "$(\"#{$field}_picture_link\").val(old_url);
  120 + if(old_url.length<=1){
  121 + $('#{$field}_img_block').find('img').remove()
  122 + }
  123 + else {
  124 + $('#{$field}_img_block').find('img').attr('src',old_url);
  125 + }";
  126 + };
  127 + ?>
92 } 128 }
93 -  
94 - });  
95 -  
96 -  
97 - }) 129 + );
  130 + });
98 </script> 131 </script>
99 132
100 <?php else:?> 133 <?php else:?>
console/migrations/m160208_101449_team.php
@@ -16,7 +16,7 @@ class m160208_101449_team extends Migration @@ -16,7 +16,7 @@ class m160208_101449_team extends Migration
16 'middlename' => $this->string(255), 16 'middlename' => $this->string(255),
17 'link' => $this->string(255), 17 'link' => $this->string(255),
18 'position' => $this->string(255)->notNull(), 18 'position' => $this->string(255)->notNull(),
19 - 'department_id' => $this->integer()->notNull(), 19 + 'department_id' => $this->integer(),
20 'experience_from' => $this->integer(), 20 'experience_from' => $this->integer(),
21 'date_add' => $this->timestamp()->notNull(), 21 'date_add' => $this->timestamp()->notNull(),
22 'user_add_id' => $this->integer(), 22 'user_add_id' => $this->integer(),
frontend/controllers/AccountsController.php
@@ -952,9 +952,14 @@ @@ -952,9 +952,14 @@
952 ->column(); 952 ->column();
953 $post = \Yii::$app->request->post(); 953 $post = \Yii::$app->request->post();
954 if($team->load($post) && $team->save()) { 954 if($team->load($post) && $team->save()) {
955 - return $this->redirect([  
956 - 'team', 955 + return $this->render('_team_form', [
  956 + 'team' => $team,
  957 + 'department' => $department,
  958 + 'country' => $country,
957 ]); 959 ]);
  960 +// return $this->redirect([
  961 +// 'team',
  962 +// ]);
958 } else { 963 } else {
959 return $this->render('_team_form', [ 964 return $this->render('_team_form', [
960 'team' => $team, 965 'team' => $team,
frontend/views/accounts/_team_form.php
@@ -8,9 +8,7 @@ @@ -8,9 +8,7 @@
8 use common\models\Team; 8 use common\models\Team;
9 use common\widgets\ImageUploader; 9 use common\widgets\ImageUploader;
10 use kartik\select2\Select2; 10 use kartik\select2\Select2;
11 - use mihaildev\ckeditor\CKEditor;  
12 use yii\helpers\Html; 11 use yii\helpers\Html;
13 - use yii\jui\DatePicker;  
14 use yii\web\JsExpression; 12 use yii\web\JsExpression;
15 use yii\widgets\ActiveForm; 13 use yii\widgets\ActiveForm;
16 14
@@ -20,13 +18,9 @@ @@ -20,13 +18,9 @@
20 <div class="login-left-column-title"><?= $this->title ?></div> 18 <div class="login-left-column-title"><?= $this->title ?></div>
21 <div class="login-left-column-title-two style">Редактирование:</div> 19 <div class="login-left-column-title-two style">Редактирование:</div>
22 20
23 -<div class="input-blocks-wrapper">  
24 - <div class="input-blocks">  
25 - <?php  
26 - $form = ActiveForm::begin();  
27 - ?>  
28 - </div>  
29 -</div> 21 +<?php
  22 + $form = ActiveForm::begin();
  23 +?>
30 24
31 <div class="input-blocks-wrapper"> 25 <div class="input-blocks-wrapper">
32 <div class="input-blocks"> 26 <div class="input-blocks">
@@ -60,7 +54,7 @@ @@ -60,7 +54,7 @@
60 <div class="input-blocks-wrapper admn-select-company"> 54 <div class="input-blocks-wrapper admn-select-company">
61 <div class="input-blocks"> 55 <div class="input-blocks">
62 <?= $form->field($team, 'department_id') 56 <?= $form->field($team, 'department_id')
63 - ->dropDownList($department) ?> 57 + ->dropDownList($department, [ 'prompt' => 'Выберите отдел' ]) ?>
64 </div> 58 </div>
65 </div> 59 </div>
66 60
@@ -99,13 +93,14 @@ @@ -99,13 +93,14 @@
99 93
100 <div class="input-blocks-wrapper admin-avatar amin-team-foto"> 94 <div class="input-blocks-wrapper admin-avatar amin-team-foto">
101 <?= ImageUploader::widget([ 95 <?= ImageUploader::widget([
  96 + 'remover' => true,
102 'model' => $team, 97 'model' => $team,
103 'field' => 'photo', 98 'field' => 'photo',
104 - 'size' => [ 99 + 'size' => [
105 [ 100 [
106 - 'width' => 100,  
107 - 'height' => 100,  
108 - ] 101 + 'width' => 100,
  102 + 'height' => 100,
  103 + ],
109 ], 104 ],
110 'multi' => false, 105 'multi' => false,
111 'gallery' => $team->photo, 106 'gallery' => $team->photo,
@@ -115,7 +110,7 @@ @@ -115,7 +110,7 @@
115 110
116 <div class="input-blocks-wrapper"> 111 <div class="input-blocks-wrapper">
117 <div class="admin-save-btn skills-save-btn admin-add-remove-wr style"> 112 <div class="admin-save-btn skills-save-btn admin-add-remove-wr style">
118 - <?= Html::submitButton($team->isNewRecord?'Добавить':'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?> 113 + <?= Html::submitButton($team->isNewRecord ? 'Добавить' : 'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?>
119 <div class="admin-remove-note"> 114 <div class="admin-remove-note">
120 <?php 115 <?php
121 if(!$team->isNewRecord) { 116 if(!$team->isNewRecord) {
@@ -133,7 +128,7 @@ @@ -133,7 +128,7 @@
133 ?> 128 ?>
134 </div> 129 </div>
135 <div class="admin-back-note"> 130 <div class="admin-back-note">
136 - <?= Html::a('вернуться', Request::getIsLocal(\Yii::$app->request->referrer)?\Yii::$app->request->referrer:['accounts/team' ]) ?> 131 + <?= Html::a('вернуться', Request::getIsLocal(\Yii::$app->request->referrer) ? \Yii::$app->request->referrer : [ 'accounts/team' ]) ?>
137 </div> 132 </div>
138 </div> 133 </div>
139 </div> 134 </div>
frontend/web/css/art_box.css
@@ -5,3 +5,7 @@ @@ -5,3 +5,7 @@
5 .form_for_company .company_info { 5 .form_for_company .company_info {
6 display: none; 6 display: none;
7 } 7 }
  8 +.remover_image {
  9 + position: absolute;
  10 + cursor: pointer;
  11 +}
8 \ No newline at end of file 12 \ No newline at end of file
frontend/web/css/style.css
@@ -6595,4 +6595,4 @@ input[disabled], select[disabled] { @@ -6595,4 +6595,4 @@ input[disabled], select[disabled] {
6595 width: 24px; 6595 width: 24px;
6596 height: 24px; 6596 height: 24px;
6597 background: transparent url('/images/loading-plugin-new.gif') center left no-repeat; 6597 background: transparent url('/images/loading-plugin-new.gif') center left no-repeat;
6598 -}  
6599 \ No newline at end of file 6598 \ No newline at end of file
  6599 +}
frontend/web/js/script.js
@@ -559,7 +559,6 @@ $(document).ready(function(){ @@ -559,7 +559,6 @@ $(document).ready(function(){
559 alert('fdg') 559 alert('fdg')
560 } 560 }
561 var txtMulti = $('.MultiFile-title').text() 561 var txtMulti = $('.MultiFile-title').text()
562 - console.log(txtMulti)  
563 $('.tender-file-wr a').click(function(e){ 562 $('.tender-file-wr a').click(function(e){
564 e.preventDefault() 563 e.preventDefault()
565 }) 564 })