use SL::DB::Employee;
use SL::DB::Order;
use SL::DB::Part;
+use SL::DB::Project;
use SL::DB::TimeRecording;
use SL::DB::TimeRecordingArticle;
use SL::Helper::Flash qw(flash);
$_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
}
+sub action_ajaj_get_project_info {
+
+ my $project = SL::DB::Project->new(id => $::form->{id})->load;
+
+ my $data;
+ if ($project->customer_id) {
+ $data = { customer => { id => $project->customer_id,
+ value => $project->customer->displayable_name,
+ type => 'customer'
+ },
+ };
+ }
+
+ $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
+}
+
sub init_time_recording {
my ($self) = @_;
$('#time_recording_customer_id_name').prop('disabled', false);
$('#time_recording_project_id').data('project_picker').set_item({});
$('#time_recording_project_id_name').prop('disabled', false);
- return;
+ return;
}
var url = 'controller.pl?action=TimeRecording/ajaj_get_order_info&id='+ value;
});
};
+ ns.project_changed = function() {
+ var project_id = $('#time_recording_project_id').val();
+
+ if (!project_id) {
+ $('#time_recording_customer_id_name').prop('disabled', false);
+ return;
+ }
+
+ var url = 'controller.pl?action=TimeRecording/ajaj_get_project_info&id='+ project_id;
+ $.getJSON(url, function(data) {
+ if (data) {
+ $('#time_recording_customer_id').data('customer_vendor_picker').set_item(data.customer);
+ $('#time_recording_customer_id_name').prop('disabled', true);
+ } else {
+ $('#time_recording_customer_id_name').prop('disabled', false);
+ }
+ });
+ };
+
});
</tr>
<tr>
<th align="right">[% 'Project' | $T8 %]</th>
- <td>[% P.project.picker('time_recording.project_id', SELF.time_recording.project_id, style='width: 300px') %]</td>
+ <td>[% P.project.picker('time_recording.project_id', SELF.time_recording.project_id, fat_set_item=1, style='width: 300px', onchange='kivi.TimeRecording.project_changed()') %]</td>
</tr>
<tr></tr><tr></tr>
<tr>