Blame view

frontend/views/accounts/employment.php 4.28 KB
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
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
                  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']);
eacb83cc   Yarik   test
76
      echo Html::submitButton('Обновить');
e9013fc3   Yarik   test
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
      $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>