Auftrags-Controller: cv_id in customer_id umbenannt.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 10 Aug 2015 11:41:55 +0000 (13:41 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:56 +0000 (16:15 +0100)
SL/Controller/Order.pm
templates/webpages/order/tabs/basic_data.html

index 546d58a..9aaa1f1 100644 (file)
@@ -123,7 +123,7 @@ sub action_customer_vendor_changed {
     ->replaceWith('#order_cp_id',     $self->build_contact_select)
     ->replaceWith('#order_shipto_id', $self->build_shipto_select)
     ->val('#order_taxzone_id', $self->order->{$self->cv}->taxzone_id)
-    ->focus('#order_cv_id')
+    ->focus('#order_' . $self->cv . ' _id')
     ->render($self);
 }
 
@@ -151,7 +151,7 @@ sub action_set_item_values {
   my $item    = SL::DB::Manager::OrderItem->find_by_or_create(id => $item_id);
 
   my $cv_class    = "SL::DB::" . ucfirst($self->cv);
-  my $cv_discount = $::form->{cv_id}? $cv_class->new(id => $::form->{cv_id})->load->discount :0.0;
+  my $cv_discount = $::form->{cv_id}? $cv_class->new(id => $::form->{$self->cv . '_id'})->load->discount :0.0;
 
   $item->assign_attributes(
     parts_id  => $part->id,
@@ -255,7 +255,6 @@ sub _load_or_new_order {
 sub _setup {
   my ($self) = @_;
 
-  $::form->{order}->{ $self->cv . '_id' } = delete $::form->{order}->{cv_id} if $::form->{order}->{cv_id};
   $self->order->assign_attributes(%{$::form->{order}});
 
   # bb: todo: currency later
index f3cd724..93f954a 100644 (file)
@@ -11,7 +11,7 @@
           <tr>
             <th align="right">[% SELF.cv | $T8 %]</th>
             [% SET cv_id = SELF.cv _ '_id' %]
-            <td>[% L.customer_vendor_picker('order.cv_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %]</td>
+            <td>[% L.customer_vendor_picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %]</td>
           </tr>
 
           <tr id='cp_row' [%- IF !SELF.order.${SELF.cv}.contacts.size %]style='display:none;'[%- END %]>
 <script type='text/javascript'>
 function reload_cv_dependend_selections() {
   $.post("controller.pl", { 'action': 'Order/customer_vendor_changed',
-                            'cv_id':  function(){ return $('#order_cv_id').val() },
+                            'cv_id':  function(){ return $('#order_[%- cv_id%]').val() },
                             'type':   function(){ return $('#type').val() },
                           }, kivi.eval_json_result);
 }
@@ -195,7 +195,7 @@ function delete_order_item_row(clicked) {
 }
 
 function set_item_values(event) {
-  var cv_id = $('#order_cv_id').val();
+  var cv_id = $('#order_[%- cv_id %]').val();
   var parts_id = $(event.target).val();
   var row = $(event.target).parents("tr").first();
 
@@ -226,7 +226,7 @@ function recalc_linetotal(item_id, amount) {
 
 
 $(function(){
-  $('#order_cv_id').change(reload_cv_dependend_selections);
+  $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
   $('[id^="order_orderitems"][id$="parts_id"]').change(set_item_values);
 });
 </script>