employment.php
4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* @var Job[] $job
*/
use common\models\Job;
use yii\helpers\Html;
use yii\jui\DatePicker;
use yii\widgets\ActiveForm;
$this->title = 'Трудовой стаж';
$this->params['breadcrumbs'][] = $this->title;
?>
<h1><?= $this->title ?></h1>
<?php
$form = ActiveForm::begin ();
$current = array_shift ($job);
?>
<div class="current_job_container">
<p>Текущее место работы:</p>
<div class="current_job_inputs">
<?php
echo $form->field ($current, '[0]name')
->label ('Название')
->textInput ();
echo $form->field ($current, '[0]link')
->label ('Ссылка на компанию на сайте МФП')
->textInput ();
echo $form->field ($current, '[0]date_start')
->label ('Дата начала работы')
->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']);
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');
echo "</div>";
}
?>
</div>
<?php
echo Html::button('Добавить место работы', ['id' => 'add_job_button']);
echo Html::submitButton('Обновить');
$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');
var lastindex = regexp.exec(name)[1];
$.get('/accounts/get-form', { lastindex: lastindex }, function(data) {
$('.prev_job_container').append($(data).find('.ajax-loaded').first().html());
$(data).filter('script').appendTo('body');
});
});
});
</script>