Revision 2500bc30
Von Bernd Bleßmann vor fast 9 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
1083 | 1083 |
$main::lxdebug->leave_sub(); |
1084 | 1084 |
} |
1085 | 1085 |
|
1086 |
# generate the printing options displayed at the bottom of oe and is forms. |
|
1087 |
# this function will attempt to guess what type of form is displayed, and will generate according options |
|
1088 |
# |
|
1089 |
# about the coding: |
|
1090 |
# this version builds the arrays of options pretty directly. if you have trouble understanding how, |
|
1091 |
# the opthash function builds hashrefs which are then pieced together for the template arrays. |
|
1092 |
# unneeded options are "undef"ed out, and then grepped out. |
|
1093 |
# |
|
1094 |
# the inline options is untested, but intended to be used later in metatemplating |
|
1095 | 1086 |
sub print_options { |
1096 |
$main::lxdebug->enter_sub();
|
|
1087 |
$::lxdebug->enter_sub(); |
|
1097 | 1088 |
|
1098 |
my $form = $main::form; |
|
1099 |
my %myconfig = %main::myconfig; |
|
1100 |
my $locale = $main::locale; |
|
1089 |
my (%options) = @_; |
|
1101 | 1090 |
|
1102 | 1091 |
_check_io_auth(); |
1103 | 1092 |
|
1104 |
my %options = @_; |
|
1105 |
|
|
1106 |
# names 3 parameters and returns a hashref, for use in templates |
|
1107 |
sub opthash { +{ value => shift, selected => shift, oname => shift } } |
|
1108 |
my (@FORMNAME, @LANGUAGE_ID, @FORMAT, @SENDMODE, @MEDIA, @PRINTER_ID, @SELECTS) = (); |
|
1109 |
|
|
1110 |
# note: "||"-selection is only correct for values where "0" is _not_ a correct entry |
|
1111 |
$form->{sendmode} = "attachment"; |
|
1112 |
$form->{format} = $form->{format} || $myconfig{template_format} || "pdf"; |
|
1113 |
$form->{copies} = $form->{copies} || $myconfig{copies} || 3; |
|
1114 |
$form->{media} = $form->{media} || $myconfig{default_media} || "screen"; |
|
1115 |
$form->{printer_id} = defined $form->{printer_id} ? $form->{printer_id} : |
|
1116 |
defined $myconfig{default_printer_id} ? $myconfig{default_printer_id} : ""; |
|
1117 |
|
|
1118 |
$form->{PD}{ $form->{formname} } = "selected"; |
|
1119 |
$form->{DF}{ $form->{format} } = "selected"; |
|
1120 |
$form->{OP}{ $form->{media} } = "selected"; |
|
1121 |
$form->{SM}{ $form->{sendmode} } = "selected"; |
|
1122 |
|
|
1123 |
push @FORMNAME, grep $_, |
|
1124 |
($form->{type} eq 'purchase_order') ? ( |
|
1125 |
opthash("purchase_order", $form->{PD}{purchase_order}, $locale->text('Purchase Order')), |
|
1126 |
opthash("bin_list", $form->{PD}{bin_list}, $locale->text('Bin List')) |
|
1127 |
) : undef, |
|
1128 |
($form->{type} eq 'credit_note') ? |
|
1129 |
opthash("credit_note", $form->{PD}{credit_note}, $locale->text('Credit Note')) : undef, |
|
1130 |
($form->{type} eq 'sales_order') ? ( |
|
1131 |
opthash("sales_order", $form->{PD}{sales_order}, $locale->text('Confirmation')), |
|
1132 |
opthash("proforma", $form->{PD}{proforma}, $locale->text('Proforma Invoice')), |
|
1133 |
) : undef, |
|
1134 |
($form->{type} =~ /sales_quotation$/) ? |
|
1135 |
opthash('sales_quotation', $form->{PD}{sales_quotation}, $locale->text('Quotation')) : undef, |
|
1136 |
($form->{type} =~ /request_quotation$/) ? |
|
1137 |
opthash('request_quotation', $form->{PD}{request_quotation}, $locale->text('Request for Quotation')) : undef, |
|
1138 |
($form->{type} eq 'invoice') ? ( |
|
1139 |
opthash("invoice", $form->{PD}{invoice}, $locale->text('Invoice')), |
|
1140 |
opthash("proforma", $form->{PD}{proforma}, $locale->text('Proforma Invoice')), |
|
1141 |
) : undef, |
|
1142 |
($form->{type} eq 'invoice' && $form->{storno}) ? ( |
|
1143 |
opthash("storno_invoice", $form->{PD}{storno_invoice}, $locale->text('Storno Invoice')), |
|
1144 |
) : undef, |
|
1145 |
($form->{type} =~ /_delivery_order$/) ? ( |
|
1146 |
opthash($form->{type}, $form->{PD}{$form->{type}}, $locale->text('Delivery Order')), |
|
1147 |
opthash('pick_list', $form->{PD}{pick_list}, $locale->text('Pick List')), |
|
1148 |
) : undef; |
|
1149 |
|
|
1150 |
push @SENDMODE, |
|
1151 |
opthash("attachment", $form->{SM}{attachment}, $locale->text('Attachment')), |
|
1152 |
opthash("inline", $form->{SM}{inline}, $locale->text('In-line')) |
|
1153 |
if ($form->{media} eq 'email'); |
|
1154 |
|
|
1155 |
my $printable_templates = any { $::lx_office_conf{print_templates}->{$_} } qw(latex opendocument); |
|
1156 |
push @MEDIA, grep $_, |
|
1157 |
opthash("screen", $form->{OP}{screen}, $locale->text('Screen')), |
|
1158 |
($printable_templates && $form->{printers} && scalar @{ $form->{printers} }) ? |
|
1159 |
opthash("printer", $form->{OP}{printer}, $locale->text('Printer')) : undef, |
|
1160 |
($printable_templates && !$options{no_queue}) ? |
|
1161 |
opthash("queue", $form->{OP}{queue}, $locale->text('Queue')) : undef |
|
1162 |
if ($form->{media} ne 'email'); |
|
1163 |
|
|
1164 |
push @FORMAT, grep $_, |
|
1165 |
($::lx_office_conf{print_templates}->{opendocument} && $::lx_office_conf{applications}->{openofficeorg_writer} && $::lx_office_conf{applications}->{xvfb} |
|
1166 |
&& (-x $::lx_office_conf{applications}->{openofficeorg_writer}) && (-x $::lx_office_conf{applications}->{xvfb}) |
|
1167 |
&& !$options{no_opendocument_pdf}) ? |
|
1168 |
opthash("opendocument_pdf", $form->{DF}{"opendocument_pdf"}, $locale->text("PDF (OpenDocument/OASIS)")) : undef, |
|
1169 |
($::lx_office_conf{print_templates}->{latex}) ? |
|
1170 |
opthash("pdf", $form->{DF}{pdf}, $locale->text('PDF')) : undef, |
|
1171 |
($::lx_office_conf{print_templates}->{latex} && !$options{no_postscript}) ? |
|
1172 |
opthash("postscript", $form->{DF}{postscript}, $locale->text('Postscript')) : undef, |
|
1173 |
(!$options{no_html}) ? |
|
1174 |
opthash("html", $form->{DF}{html}, "HTML") : undef, |
|
1175 |
($::lx_office_conf{print_templates}->{opendocument} && !$options{no_opendocument}) ? |
|
1176 |
opthash("opendocument", $form->{DF}{opendocument}, $locale->text("OpenDocument/OASIS")) : undef, |
|
1177 |
($::lx_office_conf{print_templates}->{excel} && !$options{no_excel}) ? |
|
1178 |
opthash("excel", $form->{DF}{excel}, $locale->text("Excel")) : undef; |
|
1179 |
|
|
1180 |
push @LANGUAGE_ID, |
|
1181 |
map { opthash($_->{id}, ($_->{id} eq $form->{language_id} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{languages} } |
|
1182 |
if (ref $form->{languages} eq 'ARRAY'); |
|
1183 |
|
|
1184 |
push @PRINTER_ID, |
|
1185 |
map { opthash($_->{id}, ($_->{id} eq $form->{printer_id} ? 'selected' : ''), $_->{printer_description}) } +{}, @{ $form->{printers} } |
|
1186 |
if ((ref $form->{printers} eq 'ARRAY') && scalar @{ $form->{printers } }); |
|
1187 |
|
|
1188 |
@SELECTS = map { |
|
1189 |
sname => $_->[1], |
|
1190 |
DATA => $_->[0], |
|
1191 |
show => !$options{"hide_" . $_->[1]} && scalar @{ $_->[0] } |
|
1192 |
}, |
|
1193 |
[ \@FORMNAME, 'formname', ], |
|
1194 |
[ \@LANGUAGE_ID, 'language_id', ], |
|
1195 |
[ \@FORMAT, 'format', ], |
|
1196 |
[ \@SENDMODE, 'sendmode', ], |
|
1197 |
[ \@MEDIA, 'media', ], |
|
1198 |
[ \@PRINTER_ID, 'printer_id', ]; |
|
1199 |
|
|
1200 |
my %dont_display_groupitems = ( |
|
1201 |
'dunning' => 1, |
|
1202 |
'letter' => 1, |
|
1203 |
); |
|
1204 |
|
|
1205 |
my %template_vars = ( |
|
1206 |
display_copies => scalar @{ $form->{printers} || [] } && $::lx_office_conf{print_templates}->{latex} && $form->{media} ne 'email', |
|
1207 |
display_remove_draft => (!$form->{id} && $form->{draft_id}), |
|
1208 |
display_groupitems => !$dont_display_groupitems{$form->{type}}, |
|
1209 |
groupitems_checked => $form->{groupitems} ? "checked" : '', |
|
1210 |
remove_draft_checked => $form->{remove_draft} ? "checked" : '' |
|
1211 |
); |
|
1093 |
my $inline = delete $options{inline}; |
|
1212 | 1094 |
|
1213 |
my $print_options = $form->parse_html_template("generic/print_options", { SELECTS => \@SELECTS, %template_vars } ); |
|
1095 |
require SL::Helper::PrintOptions; |
|
1096 |
my $print_options = SL::Helper::PrintOptions->get_print_options( |
|
1097 |
form => $::form, |
|
1098 |
myconfig => \%::myconfig, |
|
1099 |
locale => $::locale, |
|
1100 |
options => \%options); |
|
1214 | 1101 |
|
1215 |
if ($options{inline}) {
|
|
1216 |
$main::lxdebug->leave_sub();
|
|
1102 |
if ($inline) {
|
|
1103 |
$::lxdebug->leave_sub(); |
|
1217 | 1104 |
return $print_options; |
1218 | 1105 |
} |
1219 | 1106 |
|
1220 | 1107 |
print $print_options; |
1221 |
|
|
1222 |
$main::lxdebug->leave_sub(); |
|
1108 |
$::lxdebug->leave_sub(); |
|
1223 | 1109 |
} |
1224 | 1110 |
|
1111 |
|
|
1225 | 1112 |
sub print { |
1226 | 1113 |
$main::lxdebug->enter_sub(); |
1227 | 1114 |
|
Auch abrufbar als: Unified diff
print_options in Helper ausgelagert.