Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 078bb016

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

  • ID 078bb016bca38979f722bf94b8a4d006f5b57077
  • Vorgänger 3c22e5f4
  • Nachfolger fdb3de69

Zeiterfassung: Auftrag auswählen können, Kunden und ggf. Projekt daraus setzen

Auftrag hat Vorrang und setzt Kunde und Projekt. Diese Felder sind dann
gesperrt.
Wenn kein Auftrag gewählt ist (oder einer wieder abgtewählt wird,
dann ist Kunde und Projekt wieder frei.

Unterschiede anzeigen:

SL/Controller/TimeRecording.pm
11 11
use SL::Controller::Helper::ReportGenerator;
12 12
use SL::DB::Customer;
13 13
use SL::DB::Employee;
14
use SL::DB::Order;
14 15
use SL::DB::Part;
15 16
use SL::DB::TimeRecording;
16 17
use SL::DB::TimeRecordingArticle;
......
22 23
use Rose::Object::MakeMethods::Generic
23 24
(
24 25
# scalar                  => [ qw() ],
25
 'scalar --get_set_init' => [ qw(time_recording models all_employees all_time_recording_articles can_view_all can_edit_all use_duration) ],
26
 'scalar --get_set_init' => [ qw(time_recording models all_employees all_time_recording_articles all_orders can_view_all can_edit_all use_duration) ],
26 27
);
27 28

  
28 29

  
......
119 120
  $self->redirect_to(safe_callback());
120 121
}
121 122

  
123
sub action_ajaj_get_order_info {
124

  
125
  my $order = SL::DB::Order->new(id => $::form->{id})->load;
126
  my $data  = { customer => { id    => $order->customer_id,
127
                              value => $order->customer->displayable_name,
128
                              type  => 'customer'
129
                },
130
                project => { id     =>  $order->globalproject_id,
131
                             value  => ($order->globalproject_id ? $order->globalproject->displayable_name : undef),
132
                },
133
  };
134

  
135
  $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
136
}
137

  
122 138
sub init_time_recording {
123 139
  my ($self) = @_;
124 140

  
......
196 212
  return $res;
197 213
}
198 214

  
215
sub init_all_orders {
216
  SL::DB::Manager::Order->get_all_sorted(query => [or             => [ closed => 0, closed => undef ],
217
                                                   '!customer_id' => undef]);
218
}
219

  
199 220
sub init_use_duration {
200 221
  return SL::Helper::UserPreferences::TimeRecording->new()->get_use_duration();
201 222
}
js/kivi.TimeRecording.js
19 19
    $time.val(kivi.format_time(date));
20 20
  };
21 21

  
22
  ns.order_changed = function(value) {
23
    if (!value) {
24
      $('#time_recording_customer_id').data('customer_vendor_picker').set_item({});
25
      $('#time_recording_customer_id_name').prop('disabled', false);
26
      $('#time_recording_project_id').data('project_picker').set_item({});
27
      $('#time_recording_project_id_name').prop('disabled', false);
28
        return;
29
    }
30

  
31
    var url = 'controller.pl?action=TimeRecording/ajaj_get_order_info&id='+ value;
32
    $.getJSON(url, function(data) {
33
      $('#time_recording_customer_id').data('customer_vendor_picker').set_item(data.customer);
34
      $('#time_recording_customer_id_name').prop('disabled', true);
35
      $('#time_recording_project_id').data('project_picker').set_item(data.project);
36
      $('#time_recording_project_id_name').prop('disabled', true);
37
    });
38
  };
39

  
22 40
});
templates/webpages/time_recording/form.html
22 22
        <th>[% 'Start' | $T8 %]</th>
23 23
        <th>[% 'End'   | $T8 %]</th>
24 24
       [%- END %]
25
        <th>[% 'Sales Order' | $T8 %]</th>
25 26
        <th>[% 'Customer' | $T8 %]</th>
26 27
        <th>[% 'Article' | $T8 %]</th>
27 28
        <th>[% 'Project' | $T8 %]</th>
......
50 51
          [% P.button_tag('kivi.TimeRecording.set_current_date_time("end")', LxERP.t8('now')) %]
51 52
        </td>
52 53
       [%- END %]
54
        <td>[% P.select_tag('time_recording.order_id', SELF.all_orders, default=SELF.time_recording.order_id, title_key='digest', with_empty=1, onchange='kivi.TimeRecording.order_changed(this.value)') %]</td>
53 55
        <td>[% P.customer_vendor.picker('time_recording.customer_id', SELF.time_recording.customer_id, type='customer', style='width: 300px', "data-validate"="required", "data-title"=LxERP.t8('Customer')) %]</td>
54 56
        <td>[% P.select_tag('time_recording.part_id', SELF.all_time_recording_articles, default=SELF.time_recording.part_id, with_empty=1, value_key='id', title_key='description') %]</td>
55 57
        <td>[% P.project.picker('time_recording.project_id', SELF.time_recording.project_id, style='width: 300px') %]</td>

Auch abrufbar als: Unified diff