Revision 508801bb
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
bin/mozilla/am.pl | ||
---|---|---|
822 | 822 |
$main::lxdebug->leave_sub(); |
823 | 823 |
} |
824 | 824 |
|
825 |
sub add_business { |
|
826 |
$main::lxdebug->enter_sub(); |
|
827 |
|
|
828 |
my $form = $main::form; |
|
829 |
|
|
830 |
$main::auth->assert('config'); |
|
831 |
|
|
832 |
$form->{title} = "Add"; |
|
833 |
|
|
834 |
$form->{callback} = "am.pl?action=add_business" unless $form->{callback}; |
|
835 |
|
|
836 |
&business_header; |
|
837 |
&form_footer; |
|
838 |
|
|
839 |
$main::lxdebug->leave_sub(); |
|
840 |
} |
|
841 |
|
|
842 |
sub edit_business { |
|
843 |
$main::lxdebug->enter_sub(); |
|
844 |
|
|
845 |
my $form = $main::form; |
|
846 |
my %myconfig = %main::myconfig; |
|
847 |
|
|
848 |
$form->{title} = "Edit"; |
|
849 |
|
|
850 |
AM->get_business(\%myconfig, \%$form); |
|
851 |
|
|
852 |
&business_header; |
|
853 |
|
|
854 |
$form->{orphaned} = 1; |
|
855 |
&form_footer; |
|
856 |
|
|
857 |
$main::lxdebug->leave_sub(); |
|
858 |
} |
|
859 |
|
|
860 |
sub list_business { |
|
861 |
$main::lxdebug->enter_sub(); |
|
862 |
|
|
863 |
my $form = $main::form; |
|
864 |
my %myconfig = %main::myconfig; |
|
865 |
my $locale = $main::locale; |
|
866 |
|
|
867 |
$main::auth->assert('config'); |
|
868 |
|
|
869 |
AM->business(\%myconfig, \%$form); |
|
870 |
|
|
871 |
$form->{callback} = "am.pl?action=list_business"; |
|
872 |
|
|
873 |
my $callback = $form->escape($form->{callback}); |
|
874 |
|
|
875 |
$form->{title} = $locale->text('Type of Business'); |
|
876 |
|
|
877 |
my @column_index = qw(description discount customernumberinit); |
|
878 |
push @column_index, 'salesman' if $::lx_office_conf{features}->{vertreter}; |
|
879 |
my %column_header; |
|
880 |
$column_header{description} = |
|
881 |
qq|<th class=listheading width=60%>| |
|
882 |
. $locale->text('Description') |
|
883 |
. qq|</th>|; |
|
884 |
$column_header{discount} = |
|
885 |
qq|<th class=listheading width=10%>| |
|
886 |
. $locale->text('Discount') |
|
887 |
. qq| %</th>|; |
|
888 |
$column_header{customernumberinit} = |
|
889 |
qq|<th class=listheading>| |
|
890 |
. $locale->text('Customernumberinit') |
|
891 |
. qq|</th>|; |
|
892 |
$column_header{salesman} = |
|
893 |
qq|<th class=listheading>| |
|
894 |
. $locale->text('Representative') |
|
895 |
. qq|</th>|; |
|
896 |
|
|
897 |
$form->header; |
|
898 |
|
|
899 |
print qq| |
|
900 |
<body> |
|
901 |
|
|
902 |
<table width=100%> |
|
903 |
<tr> |
|
904 |
<th class=listtop>$form->{title}</th> |
|
905 |
</tr> |
|
906 |
<tr height="5"></tr> |
|
907 |
<tr> |
|
908 |
<td> |
|
909 |
<table width=100%> |
|
910 |
<tr class=listheading> |
|
911 |
|; |
|
912 |
|
|
913 |
map { print "$column_header{$_}\n" } @column_index; |
|
914 |
|
|
915 |
print qq| |
|
916 |
</tr> |
|
917 |
|; |
|
918 |
|
|
919 |
my ($i, %column_data); |
|
920 |
foreach my $ref (@{ $form->{ALL} }) { |
|
921 |
|
|
922 |
$i++; |
|
923 |
$i %= 2; |
|
924 |
|
|
925 |
print qq| |
|
926 |
<tr valign=top class=listrow$i> |
|
927 |
|; |
|
928 |
|
|
929 |
my $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100); |
|
930 |
my $description = $ref->{description}; |
|
931 |
$column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|; |
|
932 |
$column_data{discount} = qq|<td align=right>$discount</td>|; |
|
933 |
$column_data{customernumberinit} = |
|
934 |
qq|<td align=right>$ref->{customernumberinit}</td>|; |
|
935 |
$column_data{salesman} = '<td>' . ($ref->{salesman} ? $::locale->text('Yes') : $::locale->text('No')) . '</td>'; |
|
936 |
|
|
937 |
map { print "$column_data{$_}\n" } @column_index; |
|
938 |
|
|
939 |
print qq| |
|
940 |
</tr> |
|
941 |
|; |
|
942 |
} |
|
943 |
|
|
944 |
print qq| |
|
945 |
</table> |
|
946 |
</td> |
|
947 |
</tr> |
|
948 |
<tr> |
|
949 |
<td><hr size=3 noshade></td> |
|
950 |
</tr> |
|
951 |
</table> |
|
952 |
|
|
953 |
<br> |
|
954 |
<form method=post action=am.pl> |
|
955 |
|
|
956 |
<input name=callback type=hidden value="$form->{callback}"> |
|
957 |
|
|
958 |
<input type=hidden name=type value=business> |
|
959 |
|
|
960 |
<input class=submit type=submit name=action value="| |
|
961 |
. $locale->text('Add') . qq|"> |
|
962 |
|
|
963 |
</form> |
|
964 |
|
|
965 |
</body> |
|
966 |
</html> |
|
967 |
|; |
|
968 |
|
|
969 |
$main::lxdebug->leave_sub(); |
|
970 |
} |
|
971 |
|
|
972 |
sub business_header { |
|
973 |
$main::lxdebug->enter_sub(); |
|
974 |
|
|
975 |
my $form = $main::form; |
|
976 |
my %myconfig = %main::myconfig; |
|
977 |
my $locale = $main::locale; |
|
978 |
|
|
979 |
$main::auth->assert('config'); |
|
980 |
|
|
981 |
$form->{title} = $locale->text("$form->{title} Business"); |
|
982 |
|
|
983 |
# $locale->text('Add Business') |
|
984 |
# $locale->text('Edit Business') |
|
985 |
|
|
986 |
$form->{description} =~ s/\"/"/g; |
|
987 |
$form->{discount} = |
|
988 |
$form->format_amount(\%myconfig, $form->{discount} * 100); |
|
989 |
|
|
990 |
my $salesman_code; |
|
991 |
if ($::lx_office_conf{features}->{vertreter}) { |
|
992 |
$salesman_code = qq| |
|
993 |
<tr> |
|
994 |
<th align="right">| . $locale->text('Representative') . qq|</th> |
|
995 |
<td>| . $::cgi->checkbox(-name => "salesman", -value => 1, -label => '', 'checked' => $form->{salesman} ? 1 : 0) . qq|</td> |
|
996 |
</tr> |
|
997 |
|; |
|
998 |
} else { |
|
999 |
$salesman_code = $::cgi->hidden(-name => 'salesman', -value => $form->{salesman} ? 1 : 0); |
|
1000 |
} |
|
1001 |
|
|
1002 |
$form->header; |
|
1003 |
|
|
1004 |
print qq| |
|
1005 |
<body> |
|
1006 |
|
|
1007 |
<form method=post action=am.pl> |
|
1008 |
|
|
1009 |
<input type=hidden name=id value=$form->{id}> |
|
1010 |
<input type=hidden name=type value=business> |
|
1011 |
|
|
1012 |
<table width=100%> |
|
1013 |
<tr> |
|
1014 |
<th class=listtop colspan=2>$form->{title}</th> |
|
1015 |
</tr> |
|
1016 |
<tr height="5"></tr> |
|
1017 |
<tr> |
|
1018 |
<th align=right>| . $locale->text('Type of Business') . qq|</th> |
|
1019 |
<td><input name=description size=30 value="$form->{description}"></td> |
|
1020 |
<tr> |
|
1021 |
<tr> |
|
1022 |
<th align=right>| . $locale->text('Discount') . qq| %</th> |
|
1023 |
<td><input name=discount size=5 value=$form->{discount}></td> |
|
1024 |
</tr> |
|
1025 |
<tr> |
|
1026 |
<th align=right>| . $locale->text('Customernumberinit') . qq|</th> |
|
1027 |
<td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td> |
|
1028 |
</tr> |
|
1029 |
$salesman_code |
|
1030 |
<td colspan=2><hr size=3 noshade></td> |
|
1031 |
</tr> |
|
1032 |
</table> |
|
1033 |
|; |
|
1034 |
|
|
1035 |
$main::lxdebug->leave_sub(); |
|
1036 |
} |
|
1037 |
|
|
1038 |
sub save_business { |
|
1039 |
$main::lxdebug->enter_sub(); |
|
1040 |
|
|
1041 |
my $form = $main::form; |
|
1042 |
my %myconfig = %main::myconfig; |
|
1043 |
my $locale = $main::locale; |
|
1044 |
|
|
1045 |
$main::auth->assert('config'); |
|
1046 |
|
|
1047 |
$form->isblank("description", $locale->text('Description missing!')); |
|
1048 |
$form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100; |
|
1049 |
AM->save_business(\%myconfig, \%$form); |
|
1050 |
$form->redirect($locale->text('Business saved!')); |
|
1051 |
|
|
1052 |
$main::lxdebug->leave_sub(); |
|
1053 |
} |
|
1054 |
|
|
1055 |
sub delete_business { |
|
1056 |
$main::lxdebug->enter_sub(); |
|
1057 |
|
|
1058 |
my $form = $main::form; |
|
1059 |
my %myconfig = %main::myconfig; |
|
1060 |
my $locale = $main::locale; |
|
1061 |
|
|
1062 |
$main::auth->assert('config'); |
|
1063 |
|
|
1064 |
AM->delete_business(\%myconfig, \%$form); |
|
1065 |
$form->redirect($locale->text('Business deleted!')); |
|
1066 |
|
|
1067 |
$main::lxdebug->leave_sub(); |
|
1068 |
} |
|
1069 |
|
|
1070 | 825 |
sub add_language { |
1071 | 826 |
$main::lxdebug->enter_sub(); |
1072 | 827 |
|
Auch abrufbar als: Unified diff
Verwaltung von Kunden-/Lieferantentypen auf Controller umgestellt