Blame view

src/app/frontend/views/series_of_letters/addEdit.php 3.93 KB
3b975a80   Administrator   change request to...
1
2
3
4
5
6
7
  <div id="addEdit">
      <div class="inner"><?= $this->flash->output(); ?></div>
      <div class="inner">
          <div class="clearfix">
              <form enctype="multipart/form-data" method="post" action="" id="email_event_add_edit">
                  <div class="version_1 clearfix">
  
3b975a80   Administrator   change request to...
8
9
  
                      <div class="input-group">
4081157a   Administrator   change request to...
10
11
                          <input type="checkbox" name="status" class="unique" value="value='<?=  (isset( $page->status ) && !empty( $page->status ) ? $page->status : '') ?>'">
                          <label for="status">Статус рассылки</label>
3b975a80   Administrator   change request to...
12
13
14
15
16
                      </div>
  
  
  
                      <div class="input-group">
4081157a   Administrator   change request to...
17
18
                          <span class="input-group-addon title-block-sizing">Название рассылки</span>
                          <input type="text" name="title" class="form-control" value='<?=  (isset( $page->name ) && !empty( $page->name ) ? $page->name : '') ?>'>
3b975a80   Administrator   change request to...
19
20
21
22
                      </div>
  
  
                      <div class="input-group">
4081157a   Administrator   change request to...
23
24
25
26
27
28
29
30
31
32
33
34
  
                              <table id="templates-list" class="table table-hover">
                              </table>
                              <div class="input-group">
                                  <span class="input-group-addon title-block-sizing">Введите email пользователя</span>
                                  <input type="text" value="" class="form-control" name="autocomplete_user_email" id="autocomplete_templates"  autocomplete="off">
                              </div>
  
                              <table class="table table-hover">
                                  <thead>
                                  <tr>
                                      <th id="name">Имя</th>
4081157a   Administrator   change request to...
35
36
37
38
39
40
41
42
                                      <th class="table-buttons"></th>
                                  </tr>
                                  </thead>
                                  <tbody id="result">
  
                                  </tbody>
                              </table>
                          </div>
3b975a80   Administrator   change request to...
43
44
45
46
  
                  </div>
  
                  <div class="input-group">
43d8495a   Administrator   change request to...
47
                      <a href="<?= $this->url->get( 'series_of_letters/index') ?>" class="news_cancel float">Отмена</a>
3b975a80   Administrator   change request to...
48
49
50
51
52
53
54
                      <input type="submit" class="news_submit float" name="save" value="Сохранить">
                  </div>
  
              </form>
          </div>
      </div>
  </div>
4081157a   Administrator   change request to...
55
56
  <script>
      jQuery(document).ready( function() {
09aa724a   Administrator   change request to...
57
58
  
          $('#autocomplete_templates').on('keyup', function () {
a78c80af   Administrator   change request to...
59
              console.log('here is a lot off information');
4081157a   Administrator   change request to...
60
61
62
              var like = $(this).val();
  
              if (like.length > 3) {
8faffe86   Administrator   change request to...
63
                  $.post('/series_of_letters/gettemplate', {like: like}, function (data) {
4081157a   Administrator   change request to...
64
65
66
67
68
                      var ajax = $.parseJSON(data);
                      var count = ajax.length;
                      var block = $('#result');
                      block.html('');
                      for (var i = 0; i < count; i++) {
b7d96b61   Administrator   change request to...
69
                          var row = "<tr><td id='name'>" + ajax[i]['name'] + "</td><td><p data-id='" + ajax[i]['id'] + "' class = 'btn btn-primary select-template'>Добавить в список</p></td></tr>";
4081157a   Administrator   change request to...
70
71
72
73
74
75
76
                          block.append(row);
                      }
                  });
              }
          });
  
  
b7d96b61   Administrator   change request to...
77
          $('#result').on('click', '.select-template', function () {
83d5cde0   Administrator   change request to...
78
              var event = $(this).data('id');
4081157a   Administrator   change request to...
79
80
              var row = $(this).closest('tr');
              var block = $('#templates-list');
4081157a   Administrator   change request to...
81
              var name = row.find('#name').html();
83d5cde0   Administrator   change request to...
82
83
              var new_row = "<tr><td id='name'>" + name + "</td><td><p class = 'btn btn-primary delete-row'>Убрать из списка</p>" +
                  "<input type='hidden' value='" + event + "' name='event[]'></td></tr>";
4081157a   Administrator   change request to...
84
85
86
87
88
89
90
91
92
93
              block.append(new_row);
              row.remove();
          });
  
          $('#templates-list').on('click', '.delete-row', function () {
              var row = $(this).closest('tr');
              row.remove();
          });
      });
  </script>