Umstellung der HTML-Vorlagen aus templates/webpages/rp von HTML::Template auf Template.
[kivitendo-erp.git] / bin / mozilla / oe.pl
index 7b7fae9..a89de30 100644 (file)
@@ -300,7 +300,9 @@ sub prepare_order {
 sub form_header {
   $lxdebug->enter_sub();
   my @custom_hiddens;
-  %TMPL_VAR = ();
+
+  # Container for template variables. Unfortunately this has to be visible in form_footer too, so not my.
+  our %TMPL_VAR = ();
 
   $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
   $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
@@ -310,19 +312,19 @@ sub form_header {
   $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
   $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
 
-  map { $form->{$_} =~ s/\"/"/g }
-    qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
+  map { $form->{$_} = H($form->{$_}) }
+    qw(shippingpoint shipvia notes intnotes shiptoname
        shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
        shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
  
   # use JavaScript Calendar or not
   $form->{jsscript} = 1;
   $TMPL_VAR{button1} = qq|
-     <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\">
+     <td nowrap><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\">
       <input type=button name=transdate id="trigger1" value=| . $locale->text('button') . qq|></td>
     |;
   $TMPL_VAR{button2} = qq|
-     <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\">
+     <td nowrap width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\">
       <input type=button name=reqdate name=reqdate id="trigger2" value=| . $locale->text('button') . qq|></td>
    |;
   #write Trigger
@@ -382,7 +384,7 @@ sub form_header {
        ($myconfig{vclimit} <=  scalar(@values)) 
         ? $cgi->textfield(-value => H($form->{"old$form->{vc}"} =~ /^(.*)\-\-.*$/), -name => $form->{vc}) 
         : NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"}, 
-                               '-onChange' => 'document.getElementById(\'update_button\').click();',
+                               '-onChange' => "document.getElementById('update_button').click();",
                                '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px'));
 
   # payments (for footer)
@@ -393,6 +395,10 @@ sub form_header {
 
   # shipto
   @values = ("", map { $_->{shipto_id} } @{ $form->{ALL_SHIPTO} });
+  $TMPL_VAR{ALL_SHIPTO} = $form->{ALL_SHIPTO};
+  for my $item ( @{ $TMPL_VAR{ALL_SHIPTO} }) {
+     $item->{label} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
+  }
   %labels = map { my $item=$_; $_->{shipto_id} => join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city) } @{ $form->{ALL_SHIPTO} };
   $TMPL_VAR{shipto} = NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
                                            '-labels' => \%labels, '-default' => $form->{"shipto_id"})) if scalar @values > 1;
@@ -1081,8 +1087,8 @@ sub orders {
   }
 
   $report->set_options('top_info_text'        => join("\n", @options),
-                       'raw_top_info_text'    => $form->parse_html_template('oe/orders_top'),
-                       'raw_bottom_info_text' => $form->parse_html_template('oe/orders_bottom', { 'SHOW_CONTINUE_BUTTON' => $allow_multiple_orders }),
+                       'raw_top_info_text'    => $form->parse_html_template2('oe/orders_top'),
+                       'raw_bottom_info_text' => $form->parse_html_template2('oe/orders_bottom', { 'SHOW_CONTINUE_BUTTON' => $allow_multiple_orders }),
                        'output_format'        => 'HTML',
                        'title'                => $form->{title},
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
@@ -1834,7 +1840,7 @@ sub check_for_direct_delivery {
   $form->{VARIABLES} = [ map { { "key" => $_, "value" => $form->{$_} } } grep { ref $_ eq "" } keys %{ $form } ];
 
   $form->header();
-  print $form->parse_html_template("oe/check_for_direct_delivery");
+  print $form->parse_html_template2("oe/check_for_direct_delivery");
 
   $lxdebug->leave_sub();
 
@@ -2013,7 +2019,7 @@ sub display_row {
     {  id => 'projectnr',     width => 10,    value => $locale->text('Project'),              display => 0, },
     {  id => 'sellprice',     width => 15,    value => $locale->text('Price'),                display => 1, },
     {  id => 'sellprice_pg',  width => 15,    value => $locale->text('Pricegroup'),           display => $form->{type} =~ /^sales_/,  },
-    {  id => 'discount',      width => undef, value => $locale->text('Discount'),             display => $form->{vc} eq 'customer', },
+    {  id => 'discount',      width => 5,     value => $locale->text('Discount'),             display => $form->{vc} eq 'customer', },
     {  id => 'linetotal',     width => 10,    value => $locale->text('Extended'),             display => 1, },
     {  id => 'bin',           width => 10,    value => $locale->text('Bin'),                  display => 0, },
   ); 
@@ -2193,11 +2199,9 @@ sub display_row {
     push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, };
   }
 
-  print $form->parse_html_template('oe/sales_order', { ROWS   => \@ROWS, 
-                                                       HEADER => \@HEADER,
-                                                       show_details_checked => ($form->{show_details} ? "checked" : ""),
-                                                       show_details_new     => !$form->{show_details},
-                                                     });
+  print $form->parse_html_template2('oe/sales_order', { ROWS   => \@ROWS,
+                                                        HEADER => \@HEADER,
+                                                      });
 
   if (0 != ($form->{sellprice_total} * 1)) {
     $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;