]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/RequirementSpecOrder.pm
ic/parts_language_selection.html: Nicht mehr benötigte Vorlage entfernt
[mfinanz.git] / SL / Controller / RequirementSpecOrder.pm
index f0f20d49675b28377274127fa46b09fc65c61eb5..2bfb1cffd328a88ec18094064c004be05b093d03 100644 (file)
@@ -63,13 +63,20 @@ sub action_create {
 
   # 2. Create actual quotation/order.
   my $order = $self->create_order(sections => $sections);
-  $order->save;
+  $order->db->with_transaction(sub {
+    $order->save;
+
+    $self->requirement_spec->orders(
+      @{ $self->requirement_spec->orders },
+      SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version)
+    );
+    $self->requirement_spec->save;
+
+    $self->requirement_spec->link_to_record($order);
+  }) or do {
+    $::lxdebug->message(LXDebug::WARN(), "Error creating the order object: $@");
+  };
 
-  $self->requirement_spec->orders(
-    @{ $self->requirement_spec->orders },
-    SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version)
-  );
-  $self->requirement_spec->save;
   $self->init_requirement_spec;
 
   # 3. Notify the user and return to list.
@@ -135,7 +142,13 @@ sub action_do_update {
   $order->orderitems([ @{ $order->orderitems }, @new_orderitems ]) if @new_orderitems;
 
   $order->calculate_prices_and_taxes;
-  $order->save;
+
+  $order->db->with_transaction(sub {
+    $order->save;
+    $self->requirement_spec->link_to_record($order);
+  }) or do {
+    $::lxdebug->message(LXDebug::WARN(), "Error updating the order object: $@");
+  };
 
   $self->init_requirement_spec;
 
@@ -242,10 +255,14 @@ sub create_order_item {
   my $longdescription = $translation->{longdescription} || $part->notes;
 
   if (!$section->{keep_description}) {
-    foreach my $field (\$description, \$longdescription) {
-      $$field =  '<%fb_number%> <%title%>' unless $$field =~ m{<%};
-      $$field =~ s{<% (.+?) %>}{ $section->can($1) ? $section->$1 : '<' . t8('Invalid variable #1', $1) . '>' }egx;
-    }
+    $description     = '<%fb_number%> <%title%>' unless $description =~ m{<%};
+    $longdescription = '&lt;%description%&gt;'   unless $longdescription =~ m{&lt;%};
+
+    $description     =~ s{<% (.+?) %>}{ $section->can($1) ? $section->$1 : '<' . t8('Invalid variable #1', $1) . '>' }egx;
+    $longdescription =~ s{\&lt;\% description \%\&gt;}{!!!!DESCRIPTION!!!!}gx;
+    $longdescription =~ s{<[pP]> !!!!DESCRIPTION!!!! </[pP]>}{!!!!DESCRIPTION!!!!}gx;
+    $longdescription =~ s{\&lt;\% (.+?) \%\&gt;}{ $section->can($1) ? $::locale->quote_special_chars('HTML', $section->$1 // '') : '<' . t8('Invalid variable #1', $1) . '>' }egx;
+    $longdescription =~ s{!!!!DESCRIPTION!!!!}{ $section->description // '' }egx;
   }
 
   $item->assign_attributes(