51e0a262
Yarik
test
|
1
|
<?php
|
e9013fc3
Yarik
test
|
2
3
4
5
6
7
8
|
/**
* @var Job[] $job
*/
use common\models\Job;
use yii\helpers\Html;
use yii\jui\DatePicker;
use yii\widgets\ActiveForm;
|
51e0a262
Yarik
test
|
9
|
|
e9013fc3
Yarik
test
|
10
|
$this->title = 'Трудовой стаж';
|
51e0a262
Yarik
test
|
11
12
|
$this->params['breadcrumbs'][] = $this->title;
?>
|
e9013fc3
Yarik
test
|
13
|
<h1><?= $this->title ?></h1>
|
51e0a262
Yarik
test
|
14
|
<?php
|
e9013fc3
Yarik
test
|
15
16
|
$form = ActiveForm::begin ();
$current = array_shift ($job);
|
51e0a262
Yarik
test
|
17
|
?>
|
e9013fc3
Yarik
test
|
18
19
20
21
|
<div class="current_job_container">
<p>Текущее место работы:</p>
<div class="current_job_inputs">
<?php
|
e9013fc3
Yarik
test
|
22
23
24
25
26
27
|
echo $form->field ($current, '[0]name')
->label ('Название')
->textInput ();
echo $form->field ($current, '[0]link')
->label ('Ссылка на компанию на сайте МФП')
->textInput ();
|
588209fc
Yarik
test
|
28
|
echo $form->field ($current, '[0]date_start', ['options' => ['class' => 'test2class']])
|
e9013fc3
Yarik
test
|
29
|
->label ('Дата начала работы')
|
588209fc
Yarik
test
|
30
|
->widget (DatePicker::className (), ['options' => ['class' => 'testclass'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]);
|
e9013fc3
Yarik
test
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
echo $form->field ($current, '[0]position')
->label ('Должность')
->textInput ();
echo $form->field ($current, '[0]total_count')
->label ('Количество проектов, в которых принимали участие')
->input ('number');
echo $form->field ($current, '[0]complete_count')
->label ('из них реализовано')
->input ('number');
?>
</div>
</div>
<div class="prev_job_container">
<p>Предыдущие места работы</p>
<?php
foreach ($job as $index => $job_model)
{
echo "<div class='prev_job_inputs'>";
echo $form->field ($job_model, '['. ($index + 1) .']name')
->label ('Название')
->textInput ();
echo $form->field ($job_model, '['. ($index + 1) .']link')
->label ('Ссылка на компанию на сайте МФП')
->textInput ();
echo $form->field ($job_model, '['. ($index + 1) .']date_start')
->label ('Дата начала работы')
->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']);
echo $form->field ($job_model, '['. ($index + 1) .']date_end')
->label ('Дата окончания работы')
->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']);
echo $form->field ($job_model, '['. ($index + 1) .']position')
->label ('Должность')
->textInput ();
echo $form->field ($job_model, '['. ($index + 1) .']total_count')
->label ('Количество проектов, в которых принимали участие')
->input ('number');
echo $form->field ($job_model, '['. ($index + 1) .']complete_count')
->label ('из них реализовано')
->input ('number');
|
588209fc
Yarik
test
|
70
|
echo Html::button('Удалить', ['class' => 'remove_job_button']);
|
e9013fc3
Yarik
test
|
71
72
73
74
75
76
|
echo "</div>";
}
?>
</div>
<?php
echo Html::button('Добавить место работы', ['id' => 'add_job_button']);
|
eacb83cc
Yarik
test
|
77
|
echo Html::submitButton('Обновить');
|
e9013fc3
Yarik
test
|
78
79
80
81
82
83
84
85
|
$form->end ();
?>
<script>
$(function() {
var regexp = /^[\w]+\[(\d+)\].*$/;
$(document).on('click', '#add_job_button', function() {
var inputs = $('.prev_job_inputs').last();
var name = $(inputs).find('input, textarea').first().attr('name');
|
588209fc
Yarik
test
|
86
87
88
89
90
91
92
|
var result = regexp.exec(name);
var lastindex;
if(result != null) {
lastindex = result[1];
} else {
lastindex = 1;
}
|
e9013fc3
Yarik
test
|
93
94
95
96
97
|
$.get('/accounts/get-form', { lastindex: lastindex }, function(data) {
$('.prev_job_container').append($(data).find('.ajax-loaded').first().html());
$(data).filter('script').appendTo('body');
});
});
|
588209fc
Yarik
test
|
98
99
100
|
$(document).on('click', '.remove_job_button', function() {
$(this).parents('.prev_job_inputs').remove();
});
|
e9013fc3
Yarik
test
|
101
102
|
});
</script>
|