Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

expense-request.pl 6.0KB

7 months ago
7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #!/usr/bin/perl
  2. #
  3. # Script for handling expense requests
  4. # Copyright (C) Free Software Foundation Europe e.V.
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>
  18. use CGI;
  19. use POSIX qw(strftime);
  20. # -----------------------------------------------------------------------------
  21. # List of full names
  22. # -----------------------------------------------------------------------------
  23. my %names = (
  24. "eal" => "Erik Albers",
  25. "mk" => "Matthias Kirschner",
  26. "repentinus" => "Heiki Lohmus",
  27. "galia" => "Galina Mancheva",
  28. "max.mehl" => "Max Mehl",
  29. "reinhard" => "Reinhard Müller",
  30. "alex.sander" => "Alexander Sander",
  31. "usli" => "Ulrike Sliwinski",
  32. "gabriel.ku" => "Gabriel Ku Wei Bin",
  33. );
  34. # -----------------------------------------------------------------------------
  35. # List of people responsible for the projects
  36. # -----------------------------------------------------------------------------
  37. my %responsible = (
  38. "PA-EVENTS" => "council",
  39. "PA-MATERIAL" => "council",
  40. "PA-CAMPAIGNS" => "council",
  41. "LEGAL-EVENTS" => "council",
  42. "LEGAL-ORG" => "council",
  43. "POLICY-EVENTS" => "council",
  44. "POLICY-CAMPAIGNS" => "council",
  45. "POLICY-OTHER" => "council",
  46. "FOSS4SME-EVENTS" => "council",
  47. "FOSS4SME-OTHER" => "council",
  48. "REUSE-EVENTS" => "council",
  49. "REUSE-MATERIAL" => "council",
  50. "REUSE-OTHER" => "council",
  51. "NGI0-DISCOVERY" => "council",
  52. "NGI0-PET" => "council",
  53. "NGI0-COMMON" => "council",
  54. "MERCHANDISE-PURCHASE" => "usli",
  55. "MERCHANDISE-OTHER" => "usli",
  56. "INTERNAL-COORD" => "council",
  57. "INTERNAL-GA" => "council",
  58. "INTERNAL-TECH" => "council",
  59. "INTERNAL-FUNDRAISING" => "council",
  60. "PERSONELL-INTERN" => "council",
  61. "PERSONELL-KIRSCHNER" => "council",
  62. "PERSONELL-ALBERS" => "council",
  63. "PERSONELL-SLIWINSKI" => "council",
  64. "PERSONELL-MEHL" => "council",
  65. "PERSONELL-SANDER" => "council",
  66. "PERSONELL-KU" => "council",
  67. "PERSONELL-MANCHEVA" => "council",
  68. "OFFICE-BERLIN" => "usli",
  69. );
  70. my %account = (
  71. "PA-EVENTS" => "2513",
  72. "PA-MATERIAL" => "2514",
  73. "PA-CAMPAIGNS" => "2515",
  74. "LEGAL-EVENTS" => "2533",
  75. "LEGAL-ORG" => "2535",
  76. "POLICY-EVENTS" => "2543",
  77. "POLICY-CAMPAIGNS" => "2545",
  78. "POLICY-OTHER" => "2540",
  79. "FOSS4SME-EVENTS" => "2553",
  80. "FOSS4SME-OTHER" => "2550",
  81. "NGI0-DISCOVERY" => "2560",
  82. "NGI0-PET" => "2570",
  83. "NGI0-COMMON" => "2580",
  84. "REUSE-EVENTS" => "6113",
  85. "REUSE-MATERIAL" => "6114",
  86. "REUSE-OTHER" => "6110",
  87. "MERCHANDISE-PURCHASE" => "8154",
  88. "MERCHANDISE-OTHER" => "8159",
  89. "INTERNAL-COORD" => "2504",
  90. "INTERNAL-GA" => "2505",
  91. "INTERNAL-TECH" => "2506",
  92. "INTERNAL-FUNDRAISING" => "2509",
  93. "PERSONELL-INTERN" => "81000",
  94. "PERSONELL-KIRSCHNER" => "81012",
  95. "PERSONELL-ALBERS" => "81021",
  96. "PERSONELL-SLIWINSKI" => "81036",
  97. "PERSONELL-MALAJA" => "81040",
  98. "PERSONELL-MEHL" => "81052",
  99. "PERSONELL-SANDER" => "81057",
  100. "PERSONELL-KU" => "81058",
  101. "PERSONELL-MANCHEVA" => "81059",
  102. "OFFICE-BERLIN" => "82001",
  103. );
  104. # -----------------------------------------------------------------------------
  105. # Get parameters
  106. # -----------------------------------------------------------------------------
  107. my $query = new CGI;
  108. my $catch_phrase = $query->param("catch_phrase");
  109. my $who = $query->param("who");
  110. my $what = $query->param("what");
  111. my $when = $query->param("when");
  112. my $why = $query->param("why");
  113. my $estimate = $query->param("estimate");
  114. my $budget = $query->param("budget");
  115. my $refund = $query->param("refund");
  116. my $date = strftime("%Y-%m-%d", localtime);
  117. my $time = strftime("%s", localtime);
  118. my $account = $account{$budget};
  119. my $reference = "er.$date." . substr($time, -3) . ".$account";
  120. my $to = $responsible{$budget};
  121. my $subject = "Expense Request $reference $catch_phrase ($budget)";
  122. # -----------------------------------------------------------------------------
  123. # Generate mail to responsible person
  124. # -----------------------------------------------------------------------------
  125. my $boundary = "NextPart$reference";
  126. my $replyto = "finance\@fsfe.org, $to\@fsfe.org, $who\@fsfe.org";
  127. open(MAIL, "|/usr/lib/sendmail -t -f $who\@fsfe.org");
  128. print MAIL "From: $who\@fsfe.org\n";
  129. print MAIL "Reply-To: $replyto\n";
  130. print MAIL "Mail-Followup-To: $replyto\n";
  131. print MAIL "To: $to\@fsfe.org\n";
  132. print MAIL "CC: $who\@fsfe.org\n";
  133. print MAIL "BCC: auto-er\@fsfeurope.org\n";
  134. print MAIL "Subject: $subject\n";
  135. print MAIL "Mime-Version: 1.0\n";
  136. print MAIL "Content-Type: multipart/mixed; boundary=$boundary\n";
  137. print MAIL "Content-Transfer-Encoding: 8bit\n\n\n";
  138. print MAIL "--$boundary\n";
  139. print MAIL "Content-Type: text/plain; charset=utf-8\n";
  140. print MAIL "Content-Transfer-Encoding: 8bit\n\n";
  141. print MAIL "WHO: $names{$who}\n\n";
  142. print MAIL "WHAT: $what\n\n";
  143. print MAIL "WHEN: $when\n\n";
  144. print MAIL "WHY: $why\n\n";
  145. print MAIL "ESTIMATE: $estimate\n\n";
  146. print MAIL "BUDGET: $budget ($account)\n\n";
  147. print MAIL "REFUND CONTACT: $refund\n\n";
  148. print MAIL "AUTHORISED:\n\n";
  149. print MAIL "BY:\n\n";
  150. print MAIL "--$boundary--\n";
  151. close MAIL;
  152. # -----------------------------------------------------------------------------
  153. # Inform user that everything was ok
  154. # -----------------------------------------------------------------------------
  155. print "Content-type: text/html; charset=utf-8\n\n";
  156. print "Your request $reference was sent. Thank you.<br /><br />";
  157. print "WHO: $names{$who}<br />\n\n";
  158. print "WHAT: $what<br />\n\n";
  159. print "WHEN: $when<br />\n\n";
  160. print "WHY: $why<br />\n\n";
  161. print "ESTIMATE: $estimate<br />\n\n";
  162. print "BUDGET: $budget<br />\n\n";
  163. print "REFUND CONTACT: $refund<br />\n\n";