Revision 2ff2f6c9
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
bin/mozilla/am.pl | ||
---|---|---|
620 | 620 |
$main::lxdebug->leave_sub(); |
621 | 621 |
} |
622 | 622 |
|
623 |
sub add_department { |
|
624 |
$main::lxdebug->enter_sub(); |
|
625 |
|
|
626 |
my $form = $main::form; |
|
627 |
|
|
628 |
$main::auth->assert('config'); |
|
629 |
|
|
630 |
$form->{title} = "Add"; |
|
631 |
$form->{role} = "P"; |
|
632 |
|
|
633 |
$form->{callback} = "am.pl?action=add_department" unless $form->{callback}; |
|
634 |
|
|
635 |
&department_header; |
|
636 |
&form_footer; |
|
637 |
|
|
638 |
$main::lxdebug->leave_sub(); |
|
639 |
} |
|
640 |
|
|
641 |
sub edit_department { |
|
642 |
$main::lxdebug->enter_sub(); |
|
643 |
|
|
644 |
my $form = $main::form; |
|
645 |
my %myconfig = %main::myconfig; |
|
646 |
|
|
647 |
$main::auth->assert('config'); |
|
648 |
|
|
649 |
$form->{title} = "Edit"; |
|
650 |
|
|
651 |
AM->get_department(\%myconfig, \%$form); |
|
652 |
|
|
653 |
&department_header; |
|
654 |
&form_footer; |
|
655 |
|
|
656 |
$main::lxdebug->leave_sub(); |
|
657 |
} |
|
658 |
|
|
659 |
sub list_department { |
|
660 |
$main::lxdebug->enter_sub(); |
|
661 |
|
|
662 |
my $form = $main::form; |
|
663 |
my %myconfig = %main::myconfig; |
|
664 |
my $locale = $main::locale; |
|
665 |
|
|
666 |
$main::auth->assert('config'); |
|
667 |
|
|
668 |
AM->departments(\%myconfig, \%$form); |
|
669 |
|
|
670 |
$form->{callback} = "am.pl?action=list_department"; |
|
671 |
|
|
672 |
my $callback = $form->escape($form->{callback}); |
|
673 |
|
|
674 |
$form->{title} = $locale->text('Departments'); |
|
675 |
|
|
676 |
my @column_index = qw(description cost profit); |
|
677 |
my %column_header; |
|
678 |
$column_header{description} = |
|
679 |
qq|<th class=listheading width=90%>| |
|
680 |
. $locale->text('Description') |
|
681 |
. qq|</th>|; |
|
682 |
$column_header{cost} = |
|
683 |
qq|<th class=listheading nowrap>| |
|
684 |
. $locale->text('Cost Center') |
|
685 |
. qq|</th>|; |
|
686 |
$column_header{profit} = |
|
687 |
qq|<th class=listheading nowrap>| |
|
688 |
. $locale->text('Profit Center') |
|
689 |
. qq|</th>|; |
|
690 |
|
|
691 |
$form->header; |
|
692 |
|
|
693 |
print qq| |
|
694 |
<body> |
|
695 |
|
|
696 |
<table width=100%> |
|
697 |
<tr> |
|
698 |
<th class=listtop>$form->{title}</th> |
|
699 |
</tr> |
|
700 |
<tr height="5"></tr> |
|
701 |
<tr> |
|
702 |
<td> |
|
703 |
<table width=100%> |
|
704 |
<tr class=listheading> |
|
705 |
|; |
|
706 |
|
|
707 |
map { print "$column_header{$_}\n" } @column_index; |
|
708 |
|
|
709 |
print qq| |
|
710 |
</tr> |
|
711 |
|; |
|
712 |
|
|
713 |
my ($i, %column_data); |
|
714 |
foreach my $ref (@{ $form->{ALL} }) { |
|
715 |
|
|
716 |
$i++; |
|
717 |
$i %= 2; |
|
718 |
|
|
719 |
print qq| |
|
720 |
<tr valign=top class=listrow$i> |
|
721 |
|; |
|
722 |
|
|
723 |
my $costcenter = ($ref->{role} eq "C") ? "X" : ""; |
|
724 |
my $profitcenter = ($ref->{role} eq "P") ? "X" : ""; |
|
725 |
|
|
726 |
$column_data{description} = |
|
727 |
qq|<td><a href="am.pl?action=edit_department&id=$ref->{id}&callback=$callback">$ref->{description}</td>|; |
|
728 |
$column_data{cost} = qq|<td align=center>$costcenter</td>|; |
|
729 |
$column_data{profit} = qq|<td align=center>$profitcenter</td>|; |
|
730 |
|
|
731 |
map { print "$column_data{$_}\n" } @column_index; |
|
732 |
|
|
733 |
print qq| |
|
734 |
</tr> |
|
735 |
|; |
|
736 |
} |
|
737 |
|
|
738 |
print qq| |
|
739 |
</table> |
|
740 |
</td> |
|
741 |
</tr> |
|
742 |
<tr> |
|
743 |
<td><hr size=3 noshade></td> |
|
744 |
</tr> |
|
745 |
</table> |
|
746 |
|
|
747 |
<br> |
|
748 |
<form method=post action=am.pl> |
|
749 |
|
|
750 |
<input name=callback type=hidden value="$form->{callback}"> |
|
751 |
|
|
752 |
<input type=hidden name=type value=department> |
|
753 |
|
|
754 |
<input class=submit type=submit name=action value="| |
|
755 |
. $locale->text('Add') . qq|"> |
|
756 |
|
|
757 |
</form> |
|
758 |
|
|
759 |
</body> |
|
760 |
</html> |
|
761 |
|; |
|
762 |
|
|
763 |
$main::lxdebug->leave_sub(); |
|
764 |
} |
|
765 |
|
|
766 |
sub department_header { |
|
767 |
$main::lxdebug->enter_sub(); |
|
768 |
|
|
769 |
my $form = $main::form; |
|
770 |
my $locale = $main::locale; |
|
771 |
|
|
772 |
$main::auth->assert('config'); |
|
773 |
|
|
774 |
$form->{title} = $locale->text("$form->{title} Department"); |
|
775 |
|
|
776 |
# $locale->text('Add Department') |
|
777 |
# $locale->text('Edit Department') |
|
778 |
|
|
779 |
$form->{description} =~ s/\"/"/g; |
|
780 |
|
|
781 |
my ($rows, $description); |
|
782 |
if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { |
|
783 |
$description = |
|
784 |
qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|; |
|
785 |
} else { |
|
786 |
$description = |
|
787 |
qq|<input name=description size=60 value="$form->{description}">|; |
|
788 |
} |
|
789 |
|
|
790 |
my $costcenter = "checked" if $form->{role} eq "C"; |
|
791 |
my $profitcenter = "checked" if $form->{role} eq "P"; |
|
792 |
|
|
793 |
$form->header; |
|
794 |
|
|
795 |
print qq| |
|
796 |
<body> |
|
797 |
|
|
798 |
<form method=post action=am.pl> |
|
799 |
|
|
800 |
<input type=hidden name=id value=$form->{id}> |
|
801 |
<input type=hidden name=type value=department> |
|
802 |
|
|
803 |
<table width=100%> |
|
804 |
<tr> |
|
805 |
<th class=listtop colspan=2>$form->{title}</th> |
|
806 |
</tr> |
|
807 |
<tr height="5"></tr> |
|
808 |
<tr> |
|
809 |
<th align=right>| . $locale->text('Description') . qq|</th> |
|
810 |
<td>$description</td> |
|
811 |
</tr> |
|
812 |
<tr> |
|
813 |
<td></td> |
|
814 |
<td><input type=radio style=radio name=role value="C" $costcenter> | |
|
815 |
. $locale->text('Cost Center') . qq| |
|
816 |
<input type=radio style=radio name=role value="P" $profitcenter> | |
|
817 |
. $locale->text('Profit Center') . qq| |
|
818 |
</td> |
|
819 |
<tr> |
|
820 |
<td colspan=2><hr size=3 noshade></td> |
|
821 |
</tr> |
|
822 |
</table> |
|
823 |
|; |
|
824 |
|
|
825 |
$main::lxdebug->leave_sub(); |
|
826 |
} |
|
827 |
|
|
828 |
sub save_department { |
|
829 |
$main::lxdebug->enter_sub(); |
|
830 |
|
|
831 |
my $form = $main::form; |
|
832 |
my %myconfig = %main::myconfig; |
|
833 |
my $locale = $main::locale; |
|
834 |
|
|
835 |
$main::auth->assert('config'); |
|
836 |
|
|
837 |
$form->isblank("description", $locale->text('Description missing!')); |
|
838 |
AM->save_department(\%myconfig, \%$form); |
|
839 |
$form->redirect($locale->text('Department saved!')); |
|
840 |
|
|
841 |
$main::lxdebug->leave_sub(); |
|
842 |
} |
|
843 |
|
|
844 |
sub delete_department { |
|
845 |
$main::lxdebug->enter_sub(); |
|
846 |
|
|
847 |
my $form = $main::form; |
|
848 |
my %myconfig = %main::myconfig; |
|
849 |
my $locale = $main::locale; |
|
850 |
|
|
851 |
$main::auth->assert('config'); |
|
852 |
|
|
853 |
AM->delete_department(\%myconfig, \%$form); |
|
854 |
$form->redirect($locale->text('Department deleted!')); |
|
855 |
|
|
856 |
$main::lxdebug->leave_sub(); |
|
857 |
} |
|
858 |
|
|
859 | 623 |
sub add_lead { |
860 | 624 |
$main::lxdebug->enter_sub(); |
861 | 625 |
|
Auch abrufbar als: Unified diff
Verwaltung von Abteilungen auf Controller umgestellt