Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision be0f02ee

Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt

  • ID be0f02ee8008482ceece366f2327203850756ad4
  • Vorgänger 51e60701
  • Nachfolger 6e445d41

Wiedervorlage für mehrere Benutzer: Erstellen und Bearbeiten

Unterschiede anzeigen:

SL/FU.pm
35 35
  if (!$params{id}) {
36 36
    ($params{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('follow_up_id')|);
37 37

  
38
    $query = qq|INSERT INTO follow_ups (created_by, done, note_id, follow_up_date, created_for_user, id)
39
                VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|;
38
    $query = qq|INSERT INTO follow_ups (created_by, done, note_id, follow_up_date, id)
39
                VALUES ((SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?)|;
40 40

  
41 41
    push @values, $::myconfig{login};
42 42

  
43 43
  } else {
44
    $query = qq|UPDATE follow_ups SET done = ?, note_id = ?, follow_up_date = ?, created_for_user = ? WHERE id = ?|;
44
    $query = qq|UPDATE follow_ups SET done = ?, note_id = ?, follow_up_date = ? WHERE id = ?|;
45 45
  }
46 46

  
47 47
  $params{note_id} = Notes->save('id'           => $params{note_id},
......
53 53

  
54 54
  $params{done} = 1 if (!defined $params{done});
55 55

  
56
  do_query($form, $dbh, $query, @values, $params{done} ? 't' : 'f', conv_i($params{note_id}), $params{follow_up_date}, conv_i($params{created_for_user}), conv_i($params{id}));
56
  do_query($form, $dbh, $query, @values, $params{done} ? 't' : 'f', conv_i($params{note_id}), $params{follow_up_date}, conv_i($params{id}));
57 57

  
58 58
  do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id = ?|, conv_i($params{id}));
59 59

  
......
66 66

  
67 67
  $sth->finish();
68 68

  
69
  do_query($form, $dbh, qq|DELETE FROM follow_up_created_for_employees WHERE follow_up_id = ?|, conv_i($params{id}));
70

  
71
  $query = qq|INSERT INTO follow_up_created_for_employees (follow_up_id, employee_id) VALUES (?, ?)|;
72
  $sth   = prepare_query($form, $dbh, $query);
73

  
74
  foreach my $employee_id (@{ $params{created_for_employees} }) {
75
    do_statement($form, $sth, $query, conv_i($params{id}), $employee_id);
76
  }
77

  
69 78
  return 1;
70 79
}
71 80

  
......
131 140
  $query            = qq|SELECT fu.*, n.subject, n.body, n.created_by
132 141
                         FROM follow_ups fu
133 142
                         LEFT JOIN notes n ON (fu.note_id = n.id)
143
                         LEFT JOIN follow_up_created_for_employees ON (follow_up_created_for_employees.follow_up_id = fu.id)
134 144
                         WHERE (fu.id = ?)
135
                           AND (   (fu.created_by = ?) OR (fu.created_for_user = ?)
145
                           AND (   (fu.created_by = ?) OR (follow_up_created_for_employees.employee_id = ?)
136 146
                                OR (fu.created_by IN (SELECT DISTINCT what FROM follow_up_access WHERE who = ?)))|;
137 147
  my $ref           = selectfirst_hashref_query($form, $dbh, $query, conv_i($params{id}), $employee_id, $employee_id, $employee_id);
138 148

  
bin/mozilla/fu.pl
83 83
    $form->{title} = $locale->text('Edit Follow-Up');
84 84
  }
85 85

  
86
  $form->{created_for_employees} = SL::DB::FollowUp->new(id => $form->{id})->load->created_for_employees;
87

  
86 88
  display_form();
87 89

  
88 90
  $main::lxdebug->leave_sub();
......
95 97

  
96 98
  my $form     = $main::form;
97 99

  
98
  $form->get_lists("employees" => "EMPLOYEES");
100
  $form->{all_employees} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
99 101

  
100 102
  my %params;
101 103
  $params{not_id}     = $form->{id} if ($form->{id});
......
107 109

  
108 110
  setup_fu_display_form_action_bar() unless $::form->{POPUP_MODE};
109 111

  
110
  $form->header(no_layout => $::form->{POPUP_MODE});
112
  $form->header(no_layout       => $::form->{POPUP_MODE},
113
                use_javascripts => [ qw(jquery.selectboxes jquery.multiselect2side) ],
114
  );
111 115
  print $form->parse_html_template('fu/add_edit');
112 116

  
113 117
  $main::lxdebug->leave_sub();
......
121 125
  my $form     = $main::form;
122 126
  my $locale   = $main::locale;
123 127

  
124
  $form->isblank('created_for_user', $locale->text('You must chose a user.'));
128
  $form->error(                      $locale->text('You must chose a user.'))          if !$form->{created_for_employees};
125 129
  $form->isblank('follow_up_date',   $locale->text('The follow-up date is missing.'));
126 130
  $form->isblank('subject',          $locale->text('The subject is missing.'));
127 131

  
128
  my %params = (map({ $_ => $form->{$_} } qw(id subject body note_id created_for_user follow_up_date)), 'done' => 0);
132
  my %params = (map({ $_ => $form->{$_} } qw(id subject body note_id created_for_employees follow_up_date)), 'done' => 0);
129 133

  
130 134
  _collect_links(\%params);
131 135

  
......
143 147
    $form->redirect();
144 148
  }
145 149

  
146
  delete @{$form}{qw(id subject body created_for_user follow_up_date)};
150
  delete @{$form}{qw(id subject body created_for_employees follow_up_date)};
147 151

  
148 152
  map { $form->{$_} = 1 } qw(due_only all_users not_done);
149 153

  
templates/webpages/fu/add_edit.html
1 1
[%- USE T8 %]
2 2
[%- USE L %]
3 3
[%- USE HTML %]
4
[%- USE LxERP %]
4 5
<h1>[% title %]</h1>
5 6

  
6 7
 <script type="text/javascript">
......
21 22
  <table>
22 23
    <tr>
23 24
     <td valign="top">[% 'Follow-Up for user' | $T8 %]</td>
24
     <td valign="top">
25
      <select name="created_for_user">
26
       [%- FOREACH row = EMPLOYEES %]
27
       <option value="[% HTML.escape(row.id) %]"[% IF created_for_user == row.id %] selected[% END %]>
28
        [%- IF row.name %][% HTML.escape(row.name) %] ([% HTML.escape(row.login) %])[% ELSE %][% HTML.escape(row.login) %][% END %]
29
       </option>
30
       [%- END %]
31
      </select>
25
     <td align="top">
26
      [% L.select_tag(
27
        'created_for_employees[]',
28
        all_employees,
29
        id                => 'created_for_employees',
30
        value_key         => 'id',
31
        title_key         => 'safe_name',
32
        default           => created_for_employees,
33
        default_value_key => 'id',
34
        multiple          => 1)
35
      %]
36
      [% L.multiselect2side(
37
      'created_for_employees',
38
       labelsx => LxERP.t8('All users'),
39
       labeldx => LxERP.t8('Wiedervorlage für Benutzer'))
40
      -%]
32 41
     </td>
33 42
    </tr>
34 43

  

Auch abrufbar als: Unified diff