]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Controller/Order.pm
OrderController: Kosmetik
[kivitendo-erp.git] / SL / Controller / Order.pm
index 656883c077226971abcf4ef02e96e77b098834db..86ccb72970955807b9700b342da36cbb12640345 100644 (file)
@@ -11,6 +11,7 @@ use SL::PriceSource;
 use SL::Webdav;
 use SL::File;
 use SL::Util qw(trim);
+use SL::YAML;
 use SL::DB::Order;
 use SL::DB::Default;
 use SL::DB::Unit;
@@ -552,7 +553,7 @@ sub action_assign_periodic_invoices_config {
                  email_body                 => $::form->{email_body},
                };
 
-  my $periodic_invoices_config = YAML::Dump($config);
+  my $periodic_invoices_config = SL::YAML::Dump($config);
 
   my $status = $self->get_periodic_invoices_status($config);
 
@@ -910,9 +911,17 @@ sub action_reorder_items {
   my $method = $sort_keys{$::form->{order_by}};
   my @to_sort = map { { old_pos => $_->position, order_by => $method->($_) } } @{ $self->order->items_sorted };
   if ($::form->{sort_dir}) {
-    @to_sort = sort { Sort::Naturally::ncmp($a->{order_by}, $b->{order_by} ) } @to_sort;
+    if ( $::form->{order_by} =~ m/qty|sellprice|discount/ ){
+      @to_sort = sort { $a->{order_by} <=> $b->{order_by} } @to_sort;
+    } else {
+      @to_sort = sort { $a->{order_by} cmp $b->{order_by} } @to_sort;
+    }
   } else {
-    @to_sort = sort { Sort::Naturally::ncmp($b->{order_by}, $a->{order_by} ) } @to_sort;
+    if ( $::form->{order_by} =~ m/qty|sellprice|discount/ ){
+      @to_sort = sort { $b->{order_by} <=> $a->{order_by} } @to_sort;
+    } else {
+      @to_sort = sort { $b->{order_by} cmp $a->{order_by} } @to_sort;
+    }
   }
   $self->js
     ->run('kivi.Order.redisplay_items', \@to_sort)
@@ -1224,7 +1233,7 @@ sub make_order {
 
   $order->assign_attributes(%{$::form->{order}});
 
-  if (my $periodic_invoices_config_attrs = $form_periodic_invoices_config ? YAML::Load($form_periodic_invoices_config) : undef) {
+  if (my $periodic_invoices_config_attrs = $form_periodic_invoices_config ? SL::YAML::Load($form_periodic_invoices_config) : undef) {
     my $periodic_invoices_config = $order->periodic_invoices_config || $order->periodic_invoices_config(SL::DB::PeriodicInvoicesConfig->new);
     $periodic_invoices_config->assign_attributes(%$periodic_invoices_config_attrs);
   }
@@ -1468,6 +1477,7 @@ sub save {
 
 sub workflow_sales_or_purchase_order {
   my ($self) = @_;
+
   # always save
   my $errors = $self->save();
 
@@ -1476,7 +1486,6 @@ sub workflow_sales_or_purchase_order {
     return $self->js->render();
   }
 
-
   my $destination_type = $::form->{type} eq sales_quotation_type()   ? sales_order_type()
                        : $::form->{type} eq request_quotation_type() ? purchase_order_type()
                        : $::form->{type} eq purchase_order_type()    ? sales_order_type()
@@ -1715,7 +1724,7 @@ sub generate_pdf {
         },
       );
       1;
-    } || push @errors, ref($EVAL_ERROR) eq 'SL::X::FormError' ? $EVAL_ERROR->getMessage : $EVAL_ERROR;
+    } || push @errors, ref($EVAL_ERROR) eq 'SL::X::FormError' ? $EVAL_ERROR->error : $EVAL_ERROR;
   });
 
   return @errors;
@@ -1757,7 +1766,7 @@ sub make_periodic_invoices_config_from_yaml {
   my ($yaml_config) = @_;
 
   return if !$yaml_config;
-  my $attr = YAML::Load($yaml_config);
+  my $attr = SL::YAML::Load($yaml_config);
   return if 'HASH' ne ref $attr;
   return SL::DB::PeriodicInvoicesConfig->new(%$attr);
 }