Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fsini-informatik/fsfahrttool
  • kleemeis/fsfahrttool
2 results
Show changes
Showing
with 2766 additions and 1930 deletions
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(Kuchen, 2 Geld) wurde erstellt.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:29.09 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(, 0 Geld) wurde gel&ouml;scht.<br>
21:30.04 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:30.10 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(Test, 2 Geld) wurde gel&ouml;scht.<br>
21:30.10 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(terst, 2 Geld) wurde erstellt.<br>
21:31.02 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(terst, 2 Geld) wurde gel&ouml;scht.<br>
21:31.07 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
<?PHP
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$myFile = "./log.html";
$stringData = "---";
if(isset($_POST['logging'])) {
$stringData = $_POST['logging'];
}
$stringData = date('G').":".date('i').".".date('s')." - ".date('d').".".date('m').".".date('Y')." | ".$stringData;
$stringData = htmlentities($stringData)."<br>";
$fh = fopen($myFile, 'a') or die("can't open file");
// echo $stringData;
// echo ("<script type='text/javascript'>alert('".$stringData."');</script>");
fwrite($fh, $stringData."\n");
fclose($fh);
?>
\ No newline at end of file
...@@ -6,16 +6,17 @@ ...@@ -6,16 +6,17 @@
var defaultData = []; var defaultData = [];
defaultData.price = { defaultData.price = {
ALL: { // Stuff all have to pay, no matter when the come or leave ALL: { // Stuff all have to pay, no matter when the come or leave
B_FIX: "4", // Fixkosten (z.B. Kurzreisezuschlag) B_FIX: "9", // Fixkosten (z.B. Kurzreisezuschlag)
C_BW: "4.5", // Bettwäsche RUECK: "2", // Reiserücktrittsversicherung
C_BW: "5.5", // Bettwäsche
E_ESS:"5", // Verpflegung gekauft durch uns E_ESS:"5", // Verpflegung gekauft durch uns
REFRA: "42" // Förderung durch RefRat REFRA: "42" // Förderung durch RefRat
}, },
VAR: { // stuff that has to be paid depending on certain variables VAR: { // stuff that has to be paid depending on certain variables
"F_FR": [ // Frühstück "F_FR": [ // Frühstück
{ "val": "", "ind": false, "an": false, "ab": false }, { "val": "", "ind": false, "an": false, "ab": false },
{ "val": "3", "ind": true, "an": false, "ab": true }, { "val": "3.5", "ind": false, "an": false, "ab": false },
{ "val": "3", "ind": true, "an": true, "ab": true } { "val": "3.5", "ind": false, "an": false, "ab": false }
], ],
"G_MI": [ // Mittag "G_MI": [ // Mittag
{ "val": "", "ind": false, "an": false, "ab": false }, { "val": "", "ind": false, "an": false, "ab": false },
...@@ -23,43 +24,59 @@ defaultData.price = { ...@@ -23,43 +24,59 @@ defaultData.price = {
{ "val": "", "ind": false, "an": false, "ab": false } { "val": "", "ind": false, "an": false, "ab": false }
], ],
"H_AB": [ // Abendbrot "H_AB": [ // Abendbrot
{ "val": "4", "ind": true, "an": true, "ab": false }, { "val": "4.5", "ind": false, "an": false, "ab": false },
{ "val": "4.5", "ind": true, "an": true, "ab": false }, { "val": "", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false } { "val": "", "ind": false, "an": false, "ab": false }
], ],
"D_UE": [ // Übernachtung "D_UE": [ // Übernachtung
{ "val": "12.5", "ind": true, "an": true, "ab": false }, { "val": "16", "ind": false, "an": false, "ab": false },
{ "val": "12.5", "ind": true, "an": true, "ab": false }, { "val": "16", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false } { "val": "", "ind": false, "an": false, "ab": false }
], ],
"A_FAHRT": [ // Fahrtkosten (z.B. Bus, Bahn) "A_FAHRT": [ // Fahrtkosten (z.B. Bus, Bahn)
{ "val": "2.5", "ind": false, "an": true, "ab": false }, { "val": "0", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false }, { "val": "", "ind": false, "an": false, "ab": false },
{ "val": "2.5", "ind": false, "an": false, "ab": true } { "val": "", "ind": false, "an": false, "ab": false }
] ]
} }
}; };
defaultData.shopping= [ defaultData.shopping= [
{ "pos": "Limonade", "cnt": "76", "price": "1.43" }, { "pos": "Mio Mio Mate", "cnt": "0", "price": "1.00" },
{ "pos": "Brause", "cnt": "42", "price": "0.83" }, { "pos": "Knicklichter Industrie", "cnt": "5", "price": "1.70" },
{ "pos": "Lutscher", "cnt": "1", "price": "0.5" } { "pos": "Knicklichter Persoenlich", "cnt": "0", "price": "25" },
{ "pos": "Grillen Freitag 01", "cnt": "0", "price": "25" },
{ "pos": "Grillen Samstag 01", "cnt": "0", "price": "25" },
{ "pos": "Freitag 02", "cnt": "0", "price": "8.50" },
{ "pos": "Freitag 03", "cnt": "0", "price": "1" },
{ "pos": "Freitag 04", "cnt": "0", "price": "1" },
{ "pos": "Samstag 02", "cnt": "0", "price": "1" },
{ "pos": "Samstag 03", "cnt": "0", "price": "1" },
{ "pos": "Samstag 04", "cnt": "0", "price": "1" },
{ "pos": "Tankkosten", "cnt": "0", "price": "1" },
{ "pos": "Pfand Sa.", "cnt": "0", "price": "1" },
{ "pos": "Pfand So.", "cnt": "0", "price": "1" },
{ "pos": "Freiplätze KiEZ-Karte", "cnt": "0", "price": "1" },
{ "pos": "Freiplätze für fälschlicherweise nicht mitgefahrene Person", "cnt": "0", "price": "1" },
{ "pos": "RRKV", "cnt": "50", "price": "2" }
]; ];
defaultData.receipt = [ defaultData.receipt = [
{ "pos": "Bettwäsche", "cnt": "1", "mul": "40", "price": "1.43" }, { "pos": "Übernachtung Fr.-Sa.", "cnt": "0", "mul": "50", "price": "16" },
{ "pos": "Grillnutzung", "cnt": "1", "mul": "40", "price": "0.3" }, { "pos": "Frühstück Sa.", "cnt": "0", "mul": "50", "price": "3.50" },
{ "pos": "Halbpension", "cnt": "2", "mul": "40", "price": "12.30" }, { "pos": "Abendessen Fr.", "cnt": "0", "mul": "50", "price": "4.50" },
{ "pos": "Klodeckel", "cnt": 1, "mul": 1, "price": "33" } { "pos": "Grillen Sa.", "cnt": "0", "mul": "50", "price": "3.50" },
{ "pos": "Übernachtung Sa.-So.", "cnt": "0", "mul": "50", "price": "16" },
{ "pos": "Frühstück So.", "cnt": "0", "mul": "50", "price": "3.50" },
{ "pos": "Bettwäsche", "cnt": "0", "mul": "50", "price": "5.50" },
{ "pos": "Freiplätze (hier nur aufführen, bei Einkaufen abrechnen!)", "cnt": "0", "mul": "1", "price": "-43.50" }
]; ];
defaultData.moneyio = { defaultData.moneyio = {
"in": [ "in": [
{ "pos": "Förderung", "val": "1200" }, { "pos": "Pfand", "val": "0" },
{ "pos": "Pfand", "val": "31" } { "pos": "Übertrag WS 17/18", "val": "132.63" }
], ],
"out": [ "out": [
{ "pos": "Einkaufen", "val": "354" }, { "pos": "Ausgleich", "val": "0" },
{ "pos": "Busfahrt Hin", "val": "35" }, { "pos": "Übertrag WS 18/19", "val":"132.63" }
{ "pos": "Busfahrt Rück", "val": "40" },
{ "pos": "Kaution", "val": "100" }
] ]
}; };
defaultData.other = { defaultData.other = {
...@@ -70,7 +87,8 @@ defaultData.other = { ...@@ -70,7 +87,8 @@ defaultData.other = {
"remain" : [],// list of people, who haven't received money yet (structure: von, bis, antyp, abtyp) "remain" : [],// list of people, who haven't received money yet (structure: von, bis, antyp, abtyp)
"fahrt" : [],// dates of the trip (structure: von, bis) "fahrt" : [],// dates of the trip (structure: von, bis)
"arten" : [], "arten" : [],
"cnt" : {"all":0, "geman": 0, "gemab":0} "cnt" : {"all":0, "geman": 0, "gemab":0},
"round" : {"up":0, "down": 0}
}; };
...@@ -111,6 +129,7 @@ dataapp.service('priceData', ["$http", "$rootScope", function ($http, $rootScope ...@@ -111,6 +129,7 @@ dataapp.service('priceData', ["$http", "$rootScope", function ($http, $rootScope
FIX: "Fixkosten", FIX: "Fixkosten",
WIR: "Zusatzverpflegung", WIR: "Zusatzverpflegung",
UE: "Übernachtung", UE: "Übernachtung",
RUECK: "Reiserücktrittsversicherung",
REFRA: "(Förderung)" REFRA: "(Förderung)"
}; };
...@@ -247,6 +266,20 @@ dataapp.service('priceData', ["$http", "$rootScope", function ($http, $rootScope ...@@ -247,6 +266,20 @@ dataapp.service('priceData', ["$http", "$rootScope", function ($http, $rootScope
return table.calc.WIR.sum(); return table.calc.WIR.sum();
} }
}, },
RUECK: {
"pos": table.bez.RUECK,
"sum": function(){
if(!table.base.ALL || !table.base.ALL.RUECK)
return 0;
return table.base.ALL.RUECK;
},
"cnt": function(){
return 1;
},
"val": function(){
return table.calc.RUECK.sum();
}
},
X_REFRA: { X_REFRA: {
"pos": table.bez.REFRA, "pos": table.bez.REFRA,
"sum": function(){ "sum": function(){
...@@ -302,7 +335,7 @@ dataapp.service('shoppingData', ["$http", "$rootScope", function ($http, $rootSc ...@@ -302,7 +335,7 @@ dataapp.service('shoppingData', ["$http", "$rootScope", function ($http, $rootSc
table.sum = function(){ table.sum = function(){
var ret = 0; var ret = 0;
for(var run = 0; run < table.entries.length; run++) for(var run = 0; run < Object.keys(table.entries).length; run++)
if(!table.entries[run].isDeleted) if(!table.entries[run].isDeleted)
ret += table.rowSum(table.entries[run]); ret += table.rowSum(table.entries[run]);
return ret; return ret;
...@@ -336,9 +369,12 @@ dataapp.service('receiptData', ["$http", "$rootScope", function ($http, $rootSco ...@@ -336,9 +369,12 @@ dataapp.service('receiptData', ["$http", "$rootScope", function ($http, $rootSco
table.sum = function(){ table.sum = function(){
var ret = 0; var ret = 0;
for(var run = 0; run < table.entries.length; run++) // console.log(table.entries);
if(!table.entries[run].isDeleted) for(var run = 0; run < Object.keys(table.entries).length; run++) {
if(!table.entries[run].isDeleted) {
ret += table.rowSum(table.entries[run]); ret += table.rowSum(table.entries[run]);
}
}
return ret; return ret;
}; };
...@@ -763,7 +799,8 @@ now the individual controllers and modules for each table.... ...@@ -763,7 +799,8 @@ now the individual controllers and modules for each table....
}; };
scope.meaner = function(tab){ scope.meaner = function(tab){
if(scope.cnt<1) scope.cnt = 1; if(scope.cnt<1) scope.cnt = 1;
return scope.summy(tab) / scope.cnt; var proPrs = scope.summy(tab) / scope.cnt;
return proPrs;
} }
} }
}; };
...@@ -832,6 +869,7 @@ now the individual controllers and modules for each table.... ...@@ -832,6 +869,7 @@ now the individual controllers and modules for each table....
}; };
table.saveTable = function(){ table.saveTable = function(){
table.base = jQuery.extend(true, {}, table.edit); table.base = jQuery.extend(true, {}, table.edit);
writeTextFile("KostenpP("+JSON.stringify(table.edit)+") wird gespeichert.");
$http.post('?page=cost&ajax=set-price-json', table.edit).success(function(data, status, headers, config){ $http.post('?page=cost&ajax=set-price-json', table.edit).success(function(data, status, headers, config){
toastr.success('Saved to Database! (price)'); toastr.success('Saved to Database! (price)');
}); });
...@@ -925,21 +963,32 @@ now the individual controllers and modules for each table.... ...@@ -925,21 +963,32 @@ now the individual controllers and modules for each table....
// save copy of table before editing to have something to reset to // save copy of table before editing to have something to reset to
$scope.prepareForm = function(){ $scope.prepareForm = function(){
table.orig = jQuery.extend(true, {}, table.entries); // table.orig = jQuery.extend(true, {}, table.entries);
table.orig = table.entries.slice();
}; };
// cancel all changes // cancel all changes
$scope.cancel = function() { $scope.cancel = function() {
table.entries = jQuery.extend(true, {}, table.orig); table.entries = table.orig.slice();
// table.entries = jQuery.extend(true, {}, table.orig);
table.orig = []; table.orig = [];
}; };
// save edits // save edits
$scope.saveTable = function() { $scope.saveTable = function() {
var results = []; var results = [];
var arr = Array.from(table.entries);
console.log(arr);
console.log(table.entries);
for (var i = table.entries.length; i--;) { for (var i = table.entries.length; i--;) {
var row = table.entries[i]; var row = table.entries[i];
if(row.isDeleted) {
writeTextFile("Einkauf("+row.pos+", "+row.cnt+", "+row.price+" Geld"+") wurde gelöscht.");
}else if(row.isNew) {
writeTextFile("Einkauf("+row.pos+", "+row.cnt+", "+row.price+" Geld"+") wurde erstellt.");
}else{
writeTextFile("Einkauf("+row.pos+", "+row.cnt+", "+row.price+" Geld"+") wurde gespeichert.");
}
// actually delete row // actually delete row
if (row.isDeleted) { if (row.isDeleted) {
table.entries.splice(i, 1); table.entries.splice(i, 1);
...@@ -982,11 +1031,11 @@ now the individual controllers and modules for each table.... ...@@ -982,11 +1031,11 @@ now the individual controllers and modules for each table....
// === Data Binding stuff == // === Data Binding stuff ==
$scope.dataService = receiptData; $scope.dataService = receiptData;
table.entries = $scope.dataService.entries; table.entries = $scope.dataService.entries;
$scope.$on('data::receiptUpdated', function(event, newTab) { $scope.$on('data::receiptUpdated', function(event, newTab) {
table.entries = newTab; table.entries = newTab;
// console.log(newTab);
console.log("data in receipt controller received"); console.log("data in receipt controller received");
}); });
...@@ -997,8 +1046,6 @@ now the individual controllers and modules for each table.... ...@@ -997,8 +1046,6 @@ now the individual controllers and modules for each table....
}); });
// === edit table functions === // === edit table functions ===
// filter rows to show // filter rows to show
...@@ -1008,6 +1055,7 @@ now the individual controllers and modules for each table.... ...@@ -1008,6 +1055,7 @@ now the individual controllers and modules for each table....
// mark row as deleted // mark row as deleted
$scope.deleteRow = function(index) { $scope.deleteRow = function(index) {
console.log(index);
table.entries[index].isDeleted = true; table.entries[index].isDeleted = true;
}; };
...@@ -1028,21 +1076,31 @@ now the individual controllers and modules for each table.... ...@@ -1028,21 +1076,31 @@ now the individual controllers and modules for each table....
// save copy of table before editing to have something to reset to // save copy of table before editing to have something to reset to
$scope.prepareForm = function(){ $scope.prepareForm = function(){
table.orig = jQuery.extend(true, {}, table.entries); table.orig = table.entries.slice();
// table.orig = jQuery.extend(true, {}, table.entries);
}; };
// cancel all changes // cancel all changes
$scope.cancel = function() { $scope.cancel = function() {
table.entries = jQuery.extend(true, {}, table.orig); table.entries = table.orig.slice();
// table.entries = jQuery.extend(true, {}, table.orig);
table.orig = []; table.orig = [];
}; };
// save edits // save edits
$scope.saveTable = function() { $scope.saveTable = function() {
var results = []; var results = [];
for (var i = table.entries.length; i--;) { for (var i = Object.keys(table.entries).length; i--;) {
var row = table.entries[i]; var row = table.entries[i];
if(row.isDeleted) {
writeTextFile("Herberge("+row.pos+", "+row.cnt+", "+row.mul+", "+row.price+" Geld"+") wurde gelöscht.");
}else if(row.isNew) {
writeTextFile("Herberge("+row.pos+", "+row.cnt+", "+row.mul+", "+row.price+" Geld"+") wurde erstellt.");
}else{
writeTextFile("Herberge("+row.pos+", "+row.cnt+", "+row.mul+", "+row.price+" Geld"+") wurde gespeichert.");
}
// actually delete row // actually delete row
if (row.isDeleted) { if (row.isDeleted) {
table.entries.splice(i, 1); table.entries.splice(i, 1);
...@@ -1111,8 +1169,8 @@ now the individual controllers and modules for each table.... ...@@ -1111,8 +1169,8 @@ now the individual controllers and modules for each table....
}]); }]);
app.controller('TableMoneyioController', app.controller('TableMoneyioController',
["$scope", "$filter", "$q", "$http", "moneyioData", "otherData", "receiptData", ["$scope", "$filter", "$q", "$http", "moneyioData", "otherData", "receiptData", "shoppingData",
function($scope, $filter, $q, $http, moneyioData, otherData, receiptData){ function($scope, $filter, $q, $http, moneyioData, otherData, receiptData, shoppingData) {
var table = this; var table = this;
// === Data Binding stuff == // === Data Binding stuff ==
...@@ -1120,6 +1178,7 @@ now the individual controllers and modules for each table.... ...@@ -1120,6 +1178,7 @@ now the individual controllers and modules for each table....
$scope.moneyioDataService = moneyioData; $scope.moneyioDataService = moneyioData;
$scope.otherDataService = otherData; $scope.otherDataService = otherData;
$scope.receiptDataService = receiptData; $scope.receiptDataService = receiptData;
$scope.shoppingDataService = shoppingData;
table.entries = $scope.moneyioDataService.entries; table.entries = $scope.moneyioDataService.entries;
table.orig = []; table.orig = [];
...@@ -1131,6 +1190,7 @@ now the individual controllers and modules for each table.... ...@@ -1131,6 +1190,7 @@ now the individual controllers and modules for each table....
}, },
"out":{ "out":{
REC: {"pos": "Herberge", "val": 0}, REC: {"pos": "Herberge", "val": 0},
KAUF: {"pos": "Einkauf", "val": 0},
OUT: {"pos": "Rückzahlungen (getätigt)", "val": 0}, OUT: {"pos": "Rückzahlungen (getätigt)", "val": 0},
POUT: {"pos": "Rückzahlungen (ausstehend)", "val": 0} POUT: {"pos": "Rückzahlungen (ausstehend)", "val": 0}
} }
...@@ -1149,6 +1209,7 @@ now the individual controllers and modules for each table.... ...@@ -1149,6 +1209,7 @@ now the individual controllers and modules for each table....
}); });
$scope.$on('data::receiptUpdated', function(event, newTab) { $scope.$on('data::receiptUpdated', function(event, newTab) {
table.extra.out.REC.val = $scope.receiptDataService.sum(); table.extra.out.REC.val = $scope.receiptDataService.sum();
table.extra.out.KAUF.val = $scope.shoppingDataService.sum();
table.extra.in.VOR.val = $scope.otherDataService.intakeSum(); table.extra.in.VOR.val = $scope.otherDataService.intakeSum();
table.extra.in.PVOR.val = $scope.otherDataService.toIntakeSum(); table.extra.in.PVOR.val = $scope.otherDataService.toIntakeSum();
table.extra.out.OUT.val = $scope.otherDataService.repaidSum(); table.extra.out.OUT.val = $scope.otherDataService.repaidSum();
...@@ -1183,11 +1244,13 @@ now the individual controllers and modules for each table.... ...@@ -1183,11 +1244,13 @@ now the individual controllers and modules for each table....
// save copy of table before editing to have something to reset to // save copy of table before editing to have something to reset to
$scope.prepareForm = function(){ $scope.prepareForm = function(){
// table.orig = table.entries.slice();
table.orig = jQuery.extend(true, {}, table.entries); table.orig = jQuery.extend(true, {}, table.entries);
}; };
// cancel all changes // cancel all changes
$scope.cancel = function() { $scope.cancel = function() {
// table.entries = table.orig.slice();
table.entries = jQuery.extend(true, {}, table.orig); table.entries = jQuery.extend(true, {}, table.orig);
table.orig = []; table.orig = [];
}; };
...@@ -1199,6 +1262,14 @@ now the individual controllers and modules for each table.... ...@@ -1199,6 +1262,14 @@ now the individual controllers and modules for each table....
var salbei = function(col){ var salbei = function(col){
for (var i = col.length; i--;) { for (var i = col.length; i--;) {
var row = col[i]; var row = col[i];
console.log(row.pos+", "+row.val+" Geld");
if(row.isDeleted) {
writeTextFile("IO("+row.pos+", "+row.val+" Geld"+") wurde gelöscht.");
}else if(row.isNew) {
writeTextFile("IO("+row.pos+", "+row.val+" Geld"+") wurde erstellt.");
}else{
writeTextFile("IO("+row.pos+", "+row.val+" Geld"+") wurde gespeichert.");
}
// actually delete row // actually delete row
if (row.isDeleted) { if (row.isDeleted) {
...@@ -1225,12 +1296,19 @@ now the individual controllers and modules for each table.... ...@@ -1225,12 +1296,19 @@ now the individual controllers and modules for each table....
})(); })();
/* ======================================================
Logfile
*/
function writeTextFile(output) {
$.ajax({
type:"POST",
data:"logging="+output,
url: "pages_cost/logger.php",
success: function(data){
// alert('Written in Log File');
}
});
}
/* ====================================================================================================== /* ======================================================================================================
Mülltonne Mülltonne
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</span> </span>
</td> </td>
<td class="cost-table-numeric"> <td class="cost-table-numeric">
<span editable-text="row.val" e-form="tableform" e-style="width: 35pt" e-ng-change="chang(row, 'val', $data)"> <span editable-text="row.val" e-form="tableform" e-style="width: 35pt" e-ng-change="chang(row, 'val', $data)">
{{row.val || 0 | currency}} {{row.val || 0 | currency}}
</span> </span>
</td> </td>
......
...@@ -26,4 +26,6 @@ Einschränken auf:<br /> ...@@ -26,4 +26,6 @@ Einschränken auf:<br />
Gewählte Summe: {{summy(table.io) || 0 | currency}}<br /> Gewählte Summe: {{summy(table.io) || 0 | currency}}<br />
Anzahl Personen: {{cnt}} <br /> Anzahl Personen: {{cnt}} <br />
Betrag pro Person: {{meaner(table.io) || 0 | currency}} Betrag pro Person: {{meaner(table.io) || 0 | currency}}<br />
\ No newline at end of file <!--<label><input type="radio" ng-model="round" value="{{table.round.up}}"> Aufrunden</label>
<label><input type="radio" ng-model="round" value="{{table.round.dwn}}" ng-selected="{{table.round.dwn}}"> Abrunden</label>-->
\ No newline at end of file
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 8/26/14
* Time: 10:05 PM
*/
global $config_studitypen, $config_reisearten, $config_essen, $admin_db, $config_current_fahrt_id, $config_admin_verbose_level, $config_verbose_level, $text, $headers, $ajax, $header, $footer;
$text .= '
<ul>
<li><a href="?page=export&ex=refra" target="_blank">RefRat-Liste</a> (<a href="http://www.refrat.hu-berlin.de/finanzen/TeilnehmerInnenlisteMitEinverstaendniserklaerung.pdf">orig</a>)</li>
<li><a href="?page=export&ex=treff" target="_blank">Treffpunktanwesenheitsliste</a></li>
<li><a href="?page=export&ex=konto" target="_blank">Kontodatenliste</a></li>
<li><a href="?page=export&ex=mord" target="_blank">Mörderspiel</a></li>
<li><a href="?page=export&ex=room" target="_blank">Zimmerliste</a></li>
<li><a href="?page=export&ex=unter" target="_blank">Anwesenheitsunterschriftsliste für Unterkunft</a></li>
<li><a href="http://www.refrat.de/docs/finanzen/FormularFSErstattung_sepa_form_2.pdf">Erstattungsformular</a></li>
</ul>
NOTE: No Chrome support! Webkit/Blink haven\'t implemented support for @media print... This feature is developed to support Firefox.
';
if(isset($_REQUEST['ex'])){
global $template;
$text = "";
$noheader = "";
switch($_REQUEST['ex']){
case "refra": genRefRa(); break;
case "treff": genTreff(); break;
case "konto": genKonto(); break;
case "mord": genMord(); $noheader = '_noheaders'; break;
case "room": genRoom(); break;
case "unter": genUnter(); break;
default:
break;
}
$template = file_get_contents("../view/print_template$noheader.html"); class AdminExportPage extends AdminPage {
}
function genRefRa(){ private $text = '';
global $header, $footer, $admin_db, $config_current_fahrt_id; private $headers = '';
private $header = '';
private $footer = '';
$people = $admin_db->select('bachelor',["forname", "sirname"], ["AND" => ["fahrt_id"=>$config_current_fahrt_id, "backstepped" => NULL], "ORDER" => "forname ASC"]); private static $ALLOWED_PAGES = ['refra', 'treff', 'konto', 'mord', 'room', 'unter'];
$tabdata = [];
foreach($people as $p){
array_push($tabdata, [$p['forname']." ".$p['sirname'],"",""]);
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;"]);
}
$tabconf = ["colwidth" => ["20%", "55%", "25%"], public function __construct($base) {
"cellheight" => "35pt"]; parent::__construct($base);
printTable(["Name", "Anschrift", "Unterschrift"], $tabdata, $tabconf); try {
if (!isset($_REQUEST['ex']) or array_search($_REQUEST['ex'], AdminExportPage::$ALLOWED_PAGES) === false)
$data = getFahrtInfo(); throw new Exception('Invalide Seite!');
$exportFunction = 'export' . ucfirst($_REQUEST['ex']);
$header = " $this->$exportFunction();
<h1>TeilnehmerInnenliste und Einverständniserklärung</h1> $this->template = AdminPage::TEMPLATE_PRINT_FULL;
<h2>Fachschaftsfahrt</h2> } catch (Exception $e) {
Fachschaft: <u>Informatik</u><br /> $this->exportDefault();
Ziel: <u>".$data['ziel']."</u><br /> }
Datum der Fahrt: <u>".comm_from_mysqlDate($data['von'])." - ".comm_from_mysqlDate($data['bis'])."</u><br />
Hiermit erklären wir uns mit unserer Unterschrift damit einverstanden, dass das von uns
ausgelegten Geld für die Fachschaftsfahrt auf das Konto des/der Finanzverantwortlichen/r,
<u>".$data['leiter']."</u>, überwiesen wird.";
$footer = "Einverstädniserklärung - ".$data['titel'];
}
function genTreff(){
global $header, $footer, $admin_db, $config_current_fahrt_id, $config_reisearten_o;
$people = $admin_db->select('bachelor',["forname", "sirname"], ["AND" => ["fahrt_id"=>$config_current_fahrt_id, "backstepped" => NULL, "antyp" => $config_reisearten_o['BUSBAHN']], "ORDER" => "forname ASC"]);
$ttabdata = [];
foreach($people as $p){
array_push($ttabdata, $p['forname']." ".$p['sirname']);
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($ttabdata, "&nbsp;");
} }
$tabdata = []; public function getHeaders() {
// transpose long list to have multiple columns return $this->headers;
for($run = 0; $run < count($ttabdata); $run++){
$c1 = (isset($ttabdata[$run]) ? $ttabdata[$run] : "&nbsp;");
$run++;
$c2 = (isset($ttabdata[$run]) ? $ttabdata[$run] : "&nbsp;");
$run++;
$c3 = (isset($ttabdata[$run]) ? $ttabdata[$run] : "&nbsp;");
array_push($tabdata, [$c1, "&nbsp;", "", $c2, "&nbsp;", "", $c3, "&nbsp;"]);
} }
$tabconf = ["colwidth" => ["20%", "10pt", "1px; margin:0; padding:0; font-size:1pt", "20%", "10pt", "1px; margin:0; padding:0; font-size:1pt", "20%", "10pt"], public function getHeader() {
"cellheight" => "25pt"]; return $this->header;
printTable(["Name", "X", "", "Name", "X", "", "Name", "X"], $tabdata, $tabconf);
$data = getFahrtInfo();
$header = "
<h1>Anwesenheitsliste Treffpunkt</h1>
Liste aller Teilnehmer, die angegeben haben, gemeinsam mit Bus/Bahn anzureisen";
$footer = "Anwesenheitsliste - ".$data['titel'];
}
function genKonto(){
global $header, $footer, $admin_db, $config_current_fahrt_id;
$people = $admin_db->select('bachelor',["forname", "sirname"], ["AND" => ["fahrt_id"=>$config_current_fahrt_id, "backstepped" => NULL], "ORDER" => "forname ASC"]);
$tabdata = [];
foreach($people as $p){
array_push($tabdata, [$p['forname']." ".$p['sirname'],"&nbsp;","&nbsp;","&nbsp;","&nbsp;"]);
} }
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"]);
}
$tabconf = ["colwidth" => ["25%", "30%", "25%", "15%", "5%"],
"cellheight" => "35pt",
"class" => [3=>"graycell", 4=>"graycell"]];
printTable(["Name", "Kontonummer/IBAN", "Bankleitzahl/BIC", "Betrag*", "Erl*"], $tabdata, $tabconf);
$data = getFahrtInfo(); public function getFooter() {
return $this->footer;
$header = "
<h1>Kontodaten für Rücküberweisung</h1>
Diese Liste verbleibt bei dem/der Fahrtverantwortlichen <u>".$data['leiter']."</u> und wird benötigt um die Förderung und den Differenzbetrag nach der Fahrt zurück zu überweisen.<br />
<b>Graue/mit Sternchen gekennzeichnete Fehler freilassen</b> (Trolle bekommen kein Geld!!)";
$footer = "Kontodaten (Rücküberweisung) - ".$data['titel'];
}
function genMord(){
global $header, $footer, $admin_db, $config_current_fahrt_id, $text;
$people = $admin_db->select('bachelor',["forname", "sirname"], ["AND" => ["fahrt_id"=>$config_current_fahrt_id, "backstepped" => NULL], "ORDER" => "forname ASC"]);
$tabdata = [];
foreach($people as $p){
array_push($tabdata, [$p['forname']." ".$p['sirname'],"&nbsp;","&nbsp;","&nbsp;"]);
} }
$tabconf = ["colwidth" => ["25%", "20%", "20%", "35%"], public function getText() {
"cellheight" => "35pt"]; return $this->text;
}
printTable(["Opfer", "Zeitpunkt", "Mörder", "Tathergang"], $tabdata, $tabconf);
$text .= '<div class="page-break"></div>'; public function getAjax() {
return '';
}
$people = array_map(function($piece) { return $piece[0]; }, $tabdata); private function exportDefault() {
shuffle($people); $k = [];
$text .= '<div style="page-break-inside: avoid;"><h1>Cheatsheet</h1><p>'; $k = array_keys($this->environment->oconfig['studitypen']);
$text .= implode('&nbsp;->&nbsp;', $people); array_unshift($k,'ALLE');
$text .= '</p></div>'; $this->text = '
<ul>
<li><a href="?page=export&ex=refra" target="_blank">RefRat-Liste</a> (<a href="http://www.refrat.hu-berlin.de/finanzen/TeilnehmerInnenlisteMitEinverstaendniserklaerung.pdf">orig</a>)</li>
<li><a href="?page=export&ex=treff" target="_blank">Treffpunktanwesenheitsliste</a></li>
<li><a href="?page=export&ex=konto" target="_blank">Kontodatenliste</a></li>
<li><a href="#" onClick="openMord()">Mörderspiel</a>
Erstis <input type="checkbox" checked id="e" value="Erstis"/>
Hörstis <input type="checkbox" checked id="h" value="Hoers"/>
Mentoren <input type="checkbox" checked id="m" value="Mento"/>
</li>
<li><a href="?page=export&ex=room" target="_blank">Zimmerliste</a></li>
<li><a href="?page=export&ex=unter" target="_blank">Anwesenheitsunterschriftsliste für Unterkunft</a></li>
<li><a href="http://www.refrat.de/docs/finanzen/FormularFSErstattung_sepa_form_2.pdf">Erstattungsformular</a></li>
</ul>
NOTE: No Chrome support! Webkit/Blink haven\'t implemented support for @media print... This feature is developed to support Firefox.
<script>
function openMord() {
var x = (document.querySelector("#e").checked)? "e":"-";
var y = (document.querySelector("#h").checked)? "h":"-";
var z = (document.querySelector("#m").checked)? "m":"-";
window.open("?page=export&ex=mord&studitypen="+x+y+z);
}
</script>
';
}
$instructions = ['Gib deinem Opfer in einem Moment des Verlusts der Aufmerksamkeit einen Gegenstand private function exportRefra() {
um es umzubringen und melde es dem Spielleiter. Das darf nicht erzwungen werden; keine Zeugen.', $people = $this->fahrt->getBachelors(['backstepped' => false, 'waiting' => false], ['forname'=> 'ASC']);
'Sammle die Wimper deines Opfers ein und händige sie über mit der Bitte sich etwas zu wünschen um dein Opfer zu ermorden. $data = $this->fahrt->getFahrtDetails();
Wimper darf nicht ausgerissen werden. Andere pustbare Dinge auch erlaubt. Das darf nicht erzwungen werden; keine Zeugen.',
'Hilf deinem Opfer bei einer Übungsaufgabe und gib den Stift zurück um es umzubringen. Das darf nicht erzwungen werden; keine Zeugen.']; $tabdata = [];
foreach ($people as $p) {
array_push($tabdata, [$p['forname'] . ' ' . $p['sirname'], '', '']);
}
// leerfelder (just in case)
for ($run = 0; $run < 8; $run++) {
array_push($tabdata, ['&nbsp;', '&nbsp;', '&nbsp;']);
}
$tabconf = ['colwidth' => ['20%', '55%', '25%'],
'cellheight' => '35pt'];
$this->text = $this->tableGenerator(['Name', 'Anschrift', 'Unterschrift'], $tabdata, $tabconf);
$this->header = '
<h1>TeilnehmerInnenliste und Einverständniserklärung</h1>
<h2>Fachschaftsfahrt</h2>
Fachschaft: <u>Informatik</u><br />
Ziel: <u>' . $data['ziel'] . '</u><br />
Datum der Fahrt: <u>' . $this->mysql2german($data['von']) . ' - ' . $this->mysql2german($data['bis']) . '</u><br />
Hiermit erklären wir uns mit unserer Unterschrift damit einverstanden, dass das von uns
ausgelegten Geld für die Fachschaftsfahrt auf das Konto des/der Finanzverantwortlichen/r,
<u>' . $data['leiter'] . '</u>, überwiesen wird.';
$this->footer = 'Einverstädniserklärung - ' . $data['titel'];
}
for($i = 1; $i < count($people); $i++) { private function exportTreff() {
$text .= '<div class="killbox"> $data = $this->fahrt->getFahrtDetails();
<span role="killer">'.$people[$i-1].'</span> $people = $this->fahrt->getBachelors(['antyp' => 'BUSBAHN', 'waiting' => false, 'backstepped' => false], ['forname'=> 'ASC']);
<span role="victim">'.$people[$i].'</span> $ttabdata = [];
<p role="instruction">'.$instructions[array_rand($instructions)].'</p> foreach ($people as $p) {
</div>'; array_push($ttabdata, $p['forname'] . ' ' . $p['sirname']);
}
// leerfelder (just in case)
for ($run = 0; $run < 8; $run++) {
array_push($ttabdata, '&nbsp;');
}
$tabdata = [];
// transpose long list to have multiple columns
for ($run = 0; $run < count($ttabdata); $run++) {
$c1 = (isset($ttabdata[$run]) ? $ttabdata[$run] : '&nbsp;');
$run++;
$c2 = (isset($ttabdata[$run]) ? $ttabdata[$run] : '&nbsp;');
$run++;
$c3 = (isset($ttabdata[$run]) ? $ttabdata[$run] : '&nbsp;');
array_push($tabdata, [$c1, '&nbsp;', '', $c2, '&nbsp;', '', $c3, '&nbsp;']);
}
$tabconf = ['colwidth' => ['20%', '10pt', '1px; margin:0; padding:0; font-size:1pt', '20%', '10pt', '1px; margin:0; padding:0; font-size:1pt', '20%', '10pt'],
'cellheight' => '30pt'];
$this->text = $this->tableGenerator(['Name', 'X', '', 'Name', 'X', '', 'Name', 'X'], $tabdata, $tabconf);
$this->header = '
<h1>Anwesenheitsliste Treffpunkt</h1>
Liste aller Teilnehmer, die angegeben haben, gemeinsam mit Bus/Bahn anzureisen';
$this->footer = 'Anwesenheitsliste - ' . $data['titel'];
} }
private function exportKonto() {
$data = $this->fahrt->getFahrtDetails();
$people = $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false], ['forname'=> 'ASC']);
$tabdata = [];
foreach ($people as $p) {
array_push($tabdata, [$p['forname'] . ' ' . $p['sirname'],
'<img src="iban.png" align="middle">',
'<img src="kontonr.png" align="middle">',
'&nbsp;', '&nbsp;']);
}
// leerfelder (just in case)
for ($run = 0; $run < 8; $run++) {
array_push($tabdata, ['&nbsp;', '&nbsp;', '&nbsp;', '&nbsp;', '&nbsp;']);
}
$tabconf = ['colwidth' => ['25%', '30%', '25%', '15%', '5%'],
'cellheight' => '30pt',
'class' => [3 => 'graycell', 4 => 'graycell']];
$this->text = $this->tableGenerator(['Name', 'Kontonummer/IBAN', 'Bankleitzahl/BIC', 'Betrag*', 'Erl*'], $tabdata, $tabconf);
$this->header = '
<h1>Kontodaten für Rücküberweisung</h1>
Diese Liste verbleibt bei dem/der Fahrtverantwortlichen <u>' . $data['leiter'] . '</u> und wird benötigt um die Förderung und den Differenzbetrag nach der Fahrt zurück zu überweisen.<br />
<b>Graue/mit Sternchen gekennzeichnete Fehler freilassen</b> (Trolle bekommen kein Geld!!)';
$this->footer = 'Kontodaten (Rücküberweisung) - ' . $data['titel'];
}
$data = getFahrtInfo(); function cmp($a, $b) {
if(strcmp($a->forname,$b->forname)==0) {
if(strcmp($a->sirname==$b->sirname)==0) {
return 0;
}else{
return (strcmp($a->forname,$b->forname)<0) ? -1 : 1;
}
}
return (strcmp($a->forname,$b->forname)<0) ? -1 : 1;
}
$header = " private function exportMord() {
<h1>Mordaufträge und Übersicht</h1> $preInstruction = '<u>Mordvorschlag:</u> ';
Fröhliches Morden! Bitte keine tödlichen Gegenstände benutzen."; $instructions = ['Gib deinem Opfer in einem Moment des Verlusts der Aufmerksamkeit einen Gegenstand um es umzubringen und melde es dem Spielleiter.',
$footer = "Mörderspiel - ".$data['titel']; 'Verrühre 2 Eier, 80g Mehl, 20g Zucker, 120ml Milch, 2 TL Backpulver; backe Waffeln daraus und gib eine davon deinem Opfer.',
} '"Hast du schon ein Knicklicht..?"',
'Borge dir einen Stift von deinem Opfer und gib ihn zurück.',
'Kannst du mir Mal bitte kurz die Taschenlampe halten?',
'Verwechslungsgefahr: Deinem Opfer ein Rad geben zählt, einen Rat geben allerdings nicht.',
'Leih dir das Telefon deines Opfers um "mamamameine Mutter anzurufen" und gib es zurück.',
'Sammle die Wimper deines Opfers ein und händige sie über mit der Bitte sich etwas zu wünschen um dein Opfer zu ermorden. Wimper darf nicht ausgerissen werden. Andere pustbare Dinge auch erlaubt. ',
'Hilf deinem Opfer bei einer Übungsaufgabe und gib den Stift zurück um es umzubringen.',
'Das ist ein Testeintrag. Der dient nicht als echter Mordauftrag.'];
$postInstruction = ' <i>Das darf nicht erzwungen werden; keine Zeugen.</i>';
$data = $this->fahrt->getFahrtDetails();
if (false/*isset($_REQUEST['studitypen'])*/) {
$builder = '';
$people = [];
$people = $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false, 'mGame' => true], ['forname'=> 'ASC']);
/* if(strpos($_REQUEST['studitypen'], "e")!==false) {
$people = array_merge($people, $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false, 'mGame' => true, 'studityp' => 'ERSTI'], ['forname'=> 'ASC']));
}
if(strpos($_REQUEST['studitypen'], "h")!==false) {
$people = array_merge($people, $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false, 'mGame' => true, 'studityp' => 'HOERS'], ['forname'=> 'ASC']));
}
if(strpos($_REQUEST['studitypen'], "m")!==false) {
$people = array_merge($people, $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false, 'mGame' => true, 'studityp' => 'MENTO'], ['forname'=> 'ASC']));
}*/
// print_r($people);
usort($people, function ($a, $b) {
if(strcasecmp($a['forname'],$b['forname'])==0) {
if(strcasecmp($a['sirname'],$b['sirname'])==0) {
return 0;
}else{
return (strcasecmp($a['forname'],$b['forname'])<0) ? -1 : 1;
}
}
return (strcasecmp($a['forname'],$b['forname'])<0) ? -1 : 1;
});
}else{
$people = $this->fahrt->getBachelors(['waiting' => false, 'backstepped' => false, 'mGame' => true], ['forname'=> 'ASC']);
}
$tabdata = [];
foreach ($people as $p) {
array_push($tabdata, [$p['forname'] . " " . $p['sirname'], '&nbsp;', '&nbsp;', '&nbsp;']);
}
$tabconf = ['colwidth' => ['25%', '20%', '20%', '35%'], 'cellheight' => '30pt'];
$people = array_map(function ($piece) {
return $piece[0];
}, $tabdata);
shuffle($people);
$this->text = $this->tableGenerator(['Opfer', 'Zeitpunkt', 'Mörder', 'Tathergang'], $tabdata, $tabconf) .
'<div class="page-break"></div>
<div style="page-break-inside: avoid;"><h1>Cheatsheet</h1><p>' . implode('&nbsp;->&nbsp;', $people) .
'</p></div>';
for ($i = 1; $i <= count($people); $i++) {
$this->text .= '<div class="killbox">
<span role="killer">' . $people[$i - 1] . '</span>
<span role="victim">' . $people[$i % count($people)] . '</span>
<p role="instruction">'.
$preInstruction . $instructions[array_rand($instructions)] .
$postInstruction.
'</p></div>';
}
$this->header = '
<h1>Mordaufträge und Übersicht</h1>
Fröhliches Morden! Bitte keine tödlichen Gegenstände benutzen.';
$this->footer = 'Mörderspiel - ' . $data['titel'];
}
function genRoom(){ private function exportRoom() {
global $header,$text, $footer; $this->text = '
<script type="text/javascript">
$text .= ' function updateRoomCnt(val) {
<script type="text/javascript"> var table = document.getElementById("roomtab").getElementsByTagName("tbody")[0];
function updateRoomCnt(val) { table.innerHTML = "";
var table = document.getElementById("roomtab").getElementsByTagName("tbody")[0]; for(var i = 0; i < val; i++) {
table.innerHTML = ""; var row = table.insertRow(table.rows.length);
for(var i = 0; i < val; i++) { row.insertCell(0).style.height="30pt";
var row = table.insertRow(table.rows.length); row.insertCell(1);
row.insertCell(0).style.height="30pt"; row.insertCell(2);
row.insertCell(1); row.insertCell(3);
row.insertCell(2); row.insertCell(4);
row.insertCell(3); row.insertCell(5);
row.insertCell(4); }
row.insertCell(5);
} }
} </script>
</script> <p class="hide-print">Anzahl Zimmer: <input type="number" id="roomcnt" value="10" onchange="updateRoomCnt(this.value)" /><br>
<p class="hide-print">Anzahl Zimmer: <input type="number" id="roomcnt" value="10" onchange="updateRoomCnt(this.value)" /><br> Hint: Es kann sinnvoll sein ein paar mehr Spalten zu generieren als nötig.</p>';
Hint: Es kann sinnvoll sein ein paar mehr Spalten zu generieren als nötig.</p>';
$tabconf = [
"colwidth" => ["16%", "10%", "10%", "30%", "12%", "12%"],
"cellheight" => "35pt",
"id" => "roomtab"
];
printTable(["Haus/ Etage/ Raum", "# Betten", "# Schlüssel", "Verantwortlich", "Erhalten", "Zurück"],
[], $tabconf);
$data = getFahrtInfo();
$header = "
<h1>Übersicht der Schlüssel</h1>
Mit der Unterschrift in der Spalte 'Erhalten' bestätigt die Person, angegeben in der Spalte 'Verantwortlich', den/die
Schlüssel zum entsprechenden Raum erhalten zu haben. Bei Verlust des Schlüssels oder Schäden im Zimmer wird diese
Person Rechenschaft tragen.
In der Spalte 'Zurück' bestätigt der/die Organisator/in der Fahrt (".$data['leiter'].") den Schlüssel wieder in Empfang genommen zu haben.<br>
Diese Liste ist gültig für die Fahrt '".$data['titel']."' nach '".$data['ziel']. "' von " . $data['von'] . " bis " . $data['bis'] . ".";
$footer = "Schlüsselliste - ".$data['titel'];
}
function genUnter(){ $tabconf = [
global $header, $footer, $admin_db, $config_current_fahrt_id; 'colwidth' => ['16%', '10%', '10%', '30%', '12%', '12%'],
'cellheight' => '30pt',
'id' => 'roomtab'
];
$people = $admin_db->select('bachelor',["forname", "sirname"], ["AND" => ["fahrt_id"=>$config_current_fahrt_id, "backstepped" => NULL], "ORDER" => "forname ASC"]); $this->text .= $this->tableGenerator(['Haus/ Etage/ Raum', '# Betten', '# Schlüssel', 'Verantwortlich', 'Erhalten', 'Zurück'], [], $tabconf);
$tabdata = [];
foreach($people as $p){
array_push($tabdata, [$p['forname']." ".$p['sirname'],"&nbsp;","&nbsp;"]);
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;"]);
}
$tabconf = ["colwidth" => ["20%", "25%", "55%"], $data = $this->fahrt->getFahrtDetails();
"cellheight" => "25pt"];
printTable(["Name", "Unterschrift", "&nbsp;"], $tabdata, $tabconf); $this->header = '
<h1>Übersicht der Schlüssel</h1>
Mit der Unterschrift in der Spalte "Erhalten" bestätigt die Person, angegeben in der Spalte "Verantwortlich", den/die
Schlüssel zum entsprechenden Raum erhalten zu haben. Bei Verlust des Schlüssels oder Schäden im Zimmer wird diese
Person Rechenschaft tragen.
In der Spalte "Zurück" bestätigt der/die Organisator/in der Fahrt (' . $data['leiter'] . ') den Schlüssel wieder in Empfang genommen zu haben.<br>
Diese Liste ist gültig für die Fahrt "' . $data['titel'] . '" nach "' . $data['ziel'] . '" von ' . $data['von'] . ' bis ' . $data['bis'] . '.';
$data = getFahrtInfo(); $this->footer = 'Schlüsselliste - ' . $data['titel'];
}
$header = " private function exportUnter() {
<h1>TeilnehmerInnenliste</h1> $data = $this->fahrt->getFahrtDetails();
<h2>Fachschaftsfahrt</h2> $people = $this->fahrt->getBachelors(['backstepped' => false, 'waiting' => false], ['forname'=> 'ASC']);
Fachschaft: <u>Informatik</u><br /> $tabdata = [];
Datum der Fahrt: <u>".comm_from_mysqlDate($data['von'])." - ".comm_from_mysqlDate($data['bis'])."</u><br /> foreach ($people as $p) {
Verantwortlicher: <u>".$data['leiter']."</u><br /> array_push($tabdata, [$p['forname'] . ' ' . $p['sirname'], '&nbsp;', '&nbsp;']);
Liste aller Teilnehmer der Fachschaftsfahrt in der Einrichtung <u>".$data['ziel']."</u>"; }
$footer = "TeilnehmerInnenliste - ".$data['titel']; // leerfelder (just in case)
} for ($run = 0; $run < 8; $run++) {
array_push($tabdata, ['&nbsp;', '&nbsp;', '&nbsp;']);
}
$tabconf = ['colwidth' => ['20%', '25%', '55%'],
'cellheight' => '20pt'];
$this->text = $this->tableGenerator(['Name', 'Unterschrift', '&nbsp;'], $tabdata, $tabconf);
$this->header = '
<h1>TeilnehmerInnenliste</h1>
<h2>Fachschaftsfahrt</h2>
Fachschaft: <u>Informatik</u><br />
Datum der Fahrt: <u>' . $this->mysql2german($data['von']) . ' - ' . $this->mysql2german($data['bis']) . '</u><br />
Verantwortlicher: <u>' . $data['leiter'] . '</u><br />
Liste aller Teilnehmer der Fachschaftsfahrt in der Einrichtung <u>' . $data['ziel'] . '</u>';
$this->footer = 'TeilnehmerInnenliste - ' . $data['titel'];
}
function printTable($headers, $data, $tabconf = []){ private function tableGenerator($headers, $data, $tabconf = []) {
global $text; $thead = '';
foreach ($headers as $cell => $h) {
$text.=" $thead .= '<th ' . $this->tableGeneratorCellStyle($tabconf, $cell) . '>' . $h . '</th>';
<table class='dattable' id='".$tabconf['id']."'> }
<thead>
<tr>"; $tbody = '';
$cell = 0; foreach ($data as $row) {
foreach($headers as $h){ $tbody .= '<tr>';
$text.="<th".cellStyle($tabconf, $cell).">".$h."</th>"; foreach ($row as $cell => $dc) {
$cell++; $tbody .= '<td' . $this->tableGeneratorCellStyle($tabconf, $cell) . '>' . $dc . '</td>';
}
$text.="
</tr>
</thead>
<tbody>";
foreach($data as $dr){
$text .= "<tr>";
$cell = 0;
foreach($dr as $dc){
$text .= "<td".cellStyle($tabconf,$cell).">".$dc."</td>";
$cell++;
}
$text .= "</tr>";
} }
$text .=" $tbody .= '</tr>';
</tbody> }
</table>";
} return '
<table class="dattable" '. (isset($tabconf['id']) ? 'id="'.$tabconf['id'].'"' : '') . '">
<thead>
<tr>' . $thead . '</tr>
</thead>
<tbody>' . $tbody . '</tbody>
</table>';
}
function cellStyle($tabconf, $cell){ private function tableGeneratorCellStyle($tabconf, $cell) {
$ret = ""; $ret = '';
if(isset($tabconf['cellheight']) || isset($tabconf['colwidth']) || isset($tabconf['class'])){ if (isset($tabconf['cellheight']) || isset($tabconf['colwidth']) || isset($tabconf['class'])) {
$ret .= " style='"; $ret .= ' style="';
if(isset($tabconf['cellheight'])) if (isset($tabconf['cellheight']))
$ret .= "height:".$tabconf['cellheight'].";"; $ret .= 'height:' . $tabconf['cellheight'] . ';';
if(isset($tabconf['colwidth']) && isset($tabconf['colwidth'][$cell])) if (isset($tabconf['colwidth']) && isset($tabconf['colwidth'][$cell]))
$ret .= "width:".$tabconf['colwidth'][$cell].";"; $ret .= 'width:' . $tabconf['colwidth'][$cell] . ';';
$ret .= "'"; $ret .= '""';
if(isset($tabconf['class']) && isset($tabconf['class'][$cell])) if (isset($tabconf['class']) && isset($tabconf['class'][$cell]))
$ret .= " class='".$tabconf['class'][$cell]."'"; $ret .= ' class="' . $tabconf['class'][$cell] . '"';
}
return $ret;
} }
return $ret;
} }
function getFahrtInfo(){
global $config_current_fahrt_id, $admin_db;
return $admin_db->get("fahrten", ["beschreibung", "titel", "von", "bis", "ziel", "map_pin", "leiter", "kontakt", "regopen", "max_bachelor"], array("fahrt_id"=>$config_current_fahrt_id));
}
\ No newline at end of file
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 9/23/14
* Time: 11:14 AM
*/
global $text, $headers, $admin_db, $config_current_fahrt_id, $ajax, $config_reisearten, $config_reisearten_0, $config_studitypen_o, $config_admin_verbose_level, $config_verbose_level, $config_essen;
$config_admin_verbose_level = 0;
$config_verbose_level = 0;
$text .= "<h1>Informationen</h1>";
if(isset($_POST['note-content'])){
comm_admin_verbose(2,"received submit");
$admin_db->update("fahrten",["beschreibung" => $_REQUEST['note-content'],
"titel" => $_REQUEST['titel'],
"von" => $_REQUEST['von'],
"bis" => $_REQUEST['bis'],
"ziel" => $_REQUEST['ziel'],
"map_pin" => $_REQUEST['us2-lat']." ".$_REQUEST['us2-lon'],
"leiter" => $_REQUEST['leiter'],
"kontakt" => $_REQUEST['kontakt'],
"max_bachelor" => $_REQUEST['max_bachelor'],
"regopen" => isset($_REQUEST['regopen']) ? 1 : 0,
"wikilink" => $_REQUEST['wikilink'],
"paydeadline" => $_REQUEST['paydeadline'],
"payinfo" => $_REQUEST['payinfo'],
"opentime" => $_REQUEST['opentime']],
array("fahrt_id"=>$config_current_fahrt_id));
}
$data = $admin_db->get("fahrten", ["beschreibung", "titel", "von", "bis", "ziel", "map_pin", "leiter", "kontakt", "regopen", "max_bachelor", "wikilink", "paydeadline", "payinfo", "opentime"], array("fahrt_id"=>$config_current_fahrt_id)); class AdminInfosPage extends AdminPage {
if(!preg_match('/\d{2}\.\d+ \d{2}\.\d+/', $data['map_pin'])){ public function __construct($base) {
$data['map_pin'] = '52.4263218 13.5223815'; parent::__construct($base);
}
if($data['opentime'] == 0) $data['opentime'] = time();
$headers .="<!-- wysihtml5 parser rules -->
<script src=\"../view/js/wysihtml5-0.3.0_rc2.min.js\"></script>
<!-- Library -->
<script src=\"../view/js/wysihtml5-advanced.js\"></script>
<script src=\"../view/js/jquery-1.11.1.min.js\"></script>
<script src=\"../view/js/jquery-ui.min.js\"></script>
<script src=\"../view/js/jquery.datetimepicker.js\"></script>
<script type=\"text/javascript\" src='https://maps.google.com/maps/api/js?sensor=false&libraries=places'></script>
<script src=\"../view/js/locationpicker.jquery.js\"></script>
<link type='text/css' rel='stylesheet' href='../view/jquery-ui/jquery-ui.min.css' />
<link type='text/css' rel='stylesheet' href='../view/css/jquery.datetimepicker.css' />
<!--link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/editor.css' /-->
<link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/stylesheet.css' />
<style type='text/css'>
body {
/*width: 810px;*/
min-height: 100%;
/*margin: 0 auto;*/
padding-top: 40px !important;
padding-left: 10px !important;
}
section{
position: relative;
top: inherit;
bottom: inherit;
width: inherit;
}
.formlist li{
margin: 8px 10px;
clear: both;
height: 30px;
}
.formlist input, .formlist textarea {
float: right;
width: 300px;
}
.formlist label{ if (isset($_POST['note-content'])) {
float:left;
} try {
</style> "; $this->fahrt->set(['beschreibung' => $_REQUEST['note-content'],
'titel' => $_REQUEST['titel'],
$text .= ' 'von' => $_REQUEST['von'],
<section> 'bis' => $_REQUEST['bis'],
<form method="POST" style="height:300px;"> 'ziel' => $_REQUEST['ziel'],
<div style="float:left"> 'map_pin' => $_REQUEST['us2-lat'] . ' ' . $_REQUEST['us2-lon'],
<input type="submit" name="submit" value="submit" class="submit-button" /> 'leiter' => $_REQUEST['leiter'],
<p></p> 'kontakt' => $_REQUEST['kontakt'],
<ul class="formlist"> 'max_bachelor' => $_REQUEST['max_bachelor'],
<li><label>Titel</label> 'regopen' => isset($_REQUEST['regopen']) ? 1 : 0,
<input type="text" name="titel" id="titel" value="'.$data["titel"].'" /></li> 'wikilink' => $_REQUEST['wikilink'],
<li><label>Ziel</label> 'paydeadline' => $_REQUEST['paydeadline'],
<input type="text" name="ziel" id="ziel" value="'.$data["ziel"].'" /></li> 'payinfo' => $_REQUEST['payinfo'],
<li><label>Von</label> 'opentime' => $_REQUEST['opentime'],
<input type="text" name="von" id="von" value="'.$data["von"].'" /></li> 'disclaimlink' => $_REQUEST['disclaimlink'],
<li><label>Bis</label> 'isSummer' => isset($_REQUEST['isSummer']) ? 1 : 0
<input type="text" name="bis" id="bis" value="'.$data["bis"].'" /></li> ]);
<li><label>Anmeldung ab</label> $saveResult = $this->fahrt->save();
<input type="text" name="opentime" id="opentime" value="'.$data["opentime"].'" /></li> if (empty($saveResult)) {
<li><label>Anm. offen</label> $this->message_err = 'Speichern fehlgeschlagen...';
<input type="checkbox" name="regopen" id="regopen" value="penis" '.(($data["regopen"]==1) ? "checked" : "").' /></li> } else {
<li><label>Max TN</label> $this->message_succ = 'Gespeichert.';
<input type="number" name="max_bachelor" id="max_bachelor" value="'.$data["max_bachelor"].'" /></li> }
<li><label>Leiter</label> } catch (Exception $e) {
<input type="text" name="leiter" id="leiter" value="'.$data["leiter"].'" /></li> $this->message_err = 'Fehler aufgetreten: ' . $e->getMessage();
<li><label>E-Mail</label> }
<input type="text" name="kontakt" id="kontakt" value="'.$data["kontakt"].'" /></li>
<li><label>Wiki-Link</label>
<input type="text" name="wikilink" id="wikilink" value="'.$data["wikilink"].'" /></li>
<li><label>Zahlung bis</label>
<input type="text" name="paydeadline" id="paydeadline" value="'.$data["paydeadline"].'" /></li>
<li><label>Zahlungsdetails</label>
<textarea style="border:1px dotted grey;height: 6em; padding: 0 0 0 0.4em" rows="4" name="payinfo" id="payinfo">'.$data["payinfo"].'</textarea></li>
</ul>
</div>
<div style="float:left">
<label>Map Pin</label>
Location: <input type="text" id="us2-address" style="width: 200px"/>
<div id="us2" style="width: 500px; height: 353px;"></div>
<input type="hidden" id="us2-lat" name="us2-lat" value="'.explode(" ",$data["map_pin"])[0].'" />
<input type="hidden" id="us2-lon" name="us2-lon" value="'.explode(" ",$data["map_pin"])[1].'" />
<script>
$(\'#us2\').locationpicker({
location: {latitude: '.explode(" ",$data["map_pin"])[0].', longitude: '.explode(" ",$data["map_pin"])[1].'},
radius:0,
inputBinding: {
latitudeInput: $(\'#us2-lat\'),
longitudeInput: $(\'#us2-lon\'),
locationNameInput: $(\'#us2-address\')
}
});
$(function() {
$( "#von" ).datepicker( { dateFormat: "yy-mm-dd"} );
$( "#bis" ).datepicker( { dateFormat: "yy-mm-dd"} );
$( "#opentime" ).datetimepicker( { format: "unixtime" } );
$( "#paydeadline" ).datepicker( { dateFormat: "yy-mm-dd"} );
});
</script>
</div>
<div style="clear:both"></div>
<br />
<div id="wysihtml5-editor-toolbar">
<header>
<ul class="commands">
<li data-wysihtml5-command="bold" title="Make text bold (CTRL + B)" class="command"></li>
<li data-wysihtml5-command="italic" title="Make text italic (CTRL + I)" class="command"></li>
<li data-wysihtml5-command="insertUnorderedList" title="Insert an unordered list" class="command"></li>
<li data-wysihtml5-command="insertOrderedList" title="Insert an ordered list" class="command"></li>
<li data-wysihtml5-command="createLink" title="Insert a link" class="command"></li>
<li data-wysihtml5-command="insertImage" title="Insert an image" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1" title="Insert headline 1" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" title="Insert headline 2" class="command"></li>
<li data-wysihtml5-command-group="foreColor" class="fore-color" title="Color the selected text" class="command">
<ul>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue"></li>
</ul>
</li>
<li data-wysihtml5-command="insertSpeech" title="Insert speech" class="command"></li>
<li data-wysihtml5-action="change_view" title="Show HTML" class="action"></li>
</ul>
</header>
<div data-wysihtml5-dialog="createLink" style="display: none;">
<label>
Link:
<input data-wysihtml5-dialog-field="href" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
<div data-wysihtml5-dialog="insertImage" style="display: none;">
<label>
Image:
<input data-wysihtml5-dialog-field="src" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
</div>
<textarea name="note-content" id="wysihtml5-editor" spellcheck="false" wrap="off" placeholder="Enter your text ...">'.$data["beschreibung"].'</textarea>
</form>
</section>
<script>
var editor = new wysihtml5.Editor("wysihtml5-editor", {
toolbar: "wysihtml5-editor-toolbar",
stylesheets: ["../view/css/wysihtml5/editor.css"],
parserRules: wysihtml5ParserRules
});
editor.on("load", function() {
var composer = editor.composer,
h1 = editor.composer.element.querySelector("h1");
if (h1) {
composer.selection.selectNode(h1);
} }
}); }
</script>';
\ No newline at end of file public function getHeaders() {
global $config_use_openstreetmap;
return '<!-- wysihtml5 parser rules -->
<script src="../view/js/wysihtml5-0.3.0_rc2.min.js"></script>
<!-- Library -->
<script src="../view/js/wysihtml5-advanced.js"></script>
<script src="../view/js/jquery-1.11.1.min.js"></script>
<script src="../view/js/jquery-ui.min.js"></script>
<script src="../view/js/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="'.(
$config_use_openstreetmap
? 'https://openlayers.org/api/OpenLayers.js'
: 'https://maps.google.com/maps/api/js?sensor=false&libraries=places'
).'"></script>
<script src="../view/js/locationpicker.jquery.js"></script>
<link type="text/css" rel="stylesheet" href="../view/jquery-ui/jquery-ui.min.css" />
<link type="text/css" rel="stylesheet" href="../view/css/jquery.datetimepicker.css" />
<link type="text/css" rel="stylesheet" href="../view/css/wysihtml5/stylesheet.css" />
<style type="text/css">
body {
min-height: 100%;
padding-top: 40px !important;
padding-left: 10px !important;
}
section{
position: relative;
top: inherit;
bottom: inherit;
width: inherit;
}
.formlist li{
margin: 8px 10px;
clear: both;
height: 30px;
}
.formlist input, .formlist textarea {
float: right;
width: 300px;
}
.formlist label{
float:left;
}
</style> ';
}
public function getHeader() {
return '';
}
public function getFooter() {
return '';
}
public function getText() {
global $config_use_openstreetmap;
$data = $this->fahrt->getFahrtDetails();
if ($data['opentime'] == 0) $data['opentime'] = time();
$pin = explode(" ", $data["map_pin"]);
$summer = ($data["isSummer"] == 1) ? "checked" : "";
$regopen = ($data["regopen"] == 1) ? "checked" : "";
return $this->getMessage().<<<EOF
<h2>Informationen</h2>
<section>
<form method="POST" style="height:300px;">
<div style="float:left">
<input type="submit" name="submit" value="submit" class="submit-button" />
<p></p>
<ul class="formlist">
<li><label>Titel</label>
<input type="text" name="titel" id="titel" value="${data["titel"]}" /></li>
<li><label>Ziel</label>
<input type="text" name="ziel" id="ziel" value="${data["ziel"]}" /></li>
<li><label>Von</label>
<input type="text" name="von" id="von" value="${data["von"]}" /></li>
<li><label>Bis</label>
<input type="text" name="bis" id="bis" value="${data["bis"]}" /></li>
<li><label>Anmeldung ab</label>
<input type="text" name="opentime" id="opentime" value="${data["opentime"]}" /></li>
<li><label>Anm. offen</label>
<input type="checkbox" name="regopen" id="regopen" value="penis" $regopen /></li>
<li><label>Max TN</label>
<input type="number" name="max_bachelor" id="max_bachelor" value="${data["max_bachelor"]}" /></li>
<li><label>Leiter</label>
<input type="text" name="leiter" id="leiter" value="${data["leiter"]}" /></li>
<li><label>E-Mail</label>
<input type="text" name="kontakt" id="kontakt" value="${data["kontakt"]}" /></li>
<li><label>Wiki-Link</label>
<input type="text" name="wikilink" id="wikilink" value="${data["wikilink"]}" /></li>
<li><label>Disclaimer-Link</label>
<input type="text" name="disclaimlink" id="disclaimlink" value="${data["disclaimlink"]}" /></li>
<li><label>Zahlung bis</label>
<input type="text" name="paydeadline" id="paydeadline" value="${data["paydeadline"]}" /></li>
<li><label>Zahlungsdetails</label>
<textarea style="border:1px dotted grey;height: 6em; padding: 0 0 0 0.4em" rows="4" name="payinfo" id="payinfo">${data["payinfo"]}</textarea></li>
<li><br><label>Ist eine Sommerfahrt</label>
<input type="checkbox" name="isSummer" id="isSummer" value="penis" $summer /></li>
</ul>
</div>
<div style="float:left">
GPS Coords: <input type="text" id="us2-address" value="${pin[0]} ${pin[1]}" style="width: 350px"/>
<div id="us2" style="width: 500px; height: 353px;"></div>
<input type="hidden" id="us2-lat" name="us2-lat" value="${pin[0]}" />
<input type="hidden" id="us2-lon" name="us2-lon" value="${pin[1]}" />
<script>
EOF
.($config_use_openstreetmap
?<<<EOF
var map = new OpenLayers.Map("us2");
var maplayer = new OpenLayers.Layer.OSM();
map.addLayer(maplayer);
var zoom=10;
var target = new OpenLayers.LonLat(parseFloat(${pin[1]}), parseFloat(${pin[0]}))
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);
var marker = new OpenLayers.Marker(target);
markers.addMarker(marker);
map.setCenter(target, zoom);
map.events.register("click", map, function(e) {
// WORKAROUND: map.getLonLatFromPixel returns the wrong coordinates unless a zoom occurred
map.setCenter(void 0, map.zoom-1);
map.setCenter(void 0, map.zoom+1);
var position = map.getLonLatFromPixel(e.xy).transform(
map.getProjectionObject(), // to Spherical Mercator Projection,
new OpenLayers.Projection("EPSG:4326") // transform from WGS 1984
);
// WORKAROUND: moveTo fails if there is no map object assigned to the marker
marker.map = map;
marker.moveTo(e.xy);
$('#us2-address').val(position.lat+' '+position.lon);
$('#us2-lat').val(position.lat);
$('#us2-lon').val(position.lon);
});
EOF
:<<<EOF
$('#us2').locationpicker({
location: {latitude: ${pin[0]}, longitude: ${pin[1]}},
radius:0,
inputBinding: {
latitudeInput: $('#us2-lat'),
longitudeInput: $('#us2-lon'),
locationNameInput: $('#us2-address')
}
});
$(function() {
$( "#von" ).datepicker( { dateFormat: "yy-mm-dd"} );
$( "#bis" ).datepicker( { dateFormat: "yy-mm-dd"} );
$( "#opentime" ).datetimepicker( { format: "unixtime" } );
$( "#paydeadline" ).datepicker( { dateFormat: "yy-mm-dd"} );
});
EOF
).<<<EOF
</script>
</div>
<div style="clear:both"></div>
<br />
<div id="wysihtml5-editor-toolbar">
<header>
<ul class="commands">
<li data-wysihtml5-command="bold" title="Make text bold (CTRL + B)" class="command"></li>
<li data-wysihtml5-command="italic" title="Make text italic (CTRL + I)" class="command"></li>
<li data-wysihtml5-command="insertUnorderedList" title="Insert an unordered list" class="command"></li>
<li data-wysihtml5-command="insertOrderedList" title="Insert an ordered list" class="command"></li>
<li data-wysihtml5-command="createLink" title="Insert a link" class="command"></li>
<li data-wysihtml5-command="insertImage" title="Insert an image" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1" title="Insert headline 1" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" title="Insert headline 2" class="command"></li>
<li data-wysihtml5-command-group="foreColor" class="fore-color command" title="Color the selected text">
<ul>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue"></li>
</ul>
</li>
<li data-wysihtml5-command="insertSpeech" title="Insert speech" class="command"></li>
<li data-wysihtml5-action="change_view" title="Show HTML" class="action"></li>
</ul>
</header>
<div data-wysihtml5-dialog="createLink" style="display: none;">
<label>
Link:
<input data-wysihtml5-dialog-field="href" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
<div data-wysihtml5-dialog="insertImage" style="display: none;">
<label>
Image:
<input data-wysihtml5-dialog-field="src" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
</div>
<textarea name="note-content" id="wysihtml5-editor" spellcheck="false" wrap="off" placeholder="Enter your text ...">${data["beschreibung"]}</textarea>
</form>
</section>
<script>
var editor = new wysihtml5.Editor("wysihtml5-editor", {
toolbar: "wysihtml5-editor-toolbar",
stylesheets: ["../view/css/wysihtml5/editor.css"],
parserRules: wysihtml5ParserRules
});
editor.on("load", function() {
var composer = editor.composer,
h1 = editor.composer.element.querySelector("h1");
if (h1) {
composer.selection.selectNode(h1);
}
});
</script>
EOF;
}
public function getAjax() {
return '';
}
}
<?php
class AdminJumpOfPage extends AdminPage {
public function __construct($base) {
parent::__construct($base);
if (isset($_REQUEST['change'])) {
try {
$bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$bNew->set(['bachelor_id' => $_REQUEST['change']]);
// print_r($bNew->getData());
$bOld = Bachelor::makeFromDB($this->fahrt, $_REQUEST['change']);
// print_r($bOld->getData());
$bOld->updateBachelor($bNew);
$saveResult = $bOld->save();
if ($saveResult !== Bachelor::SAVE_SUCCESS)
throw new Exception('Fehler beim Speichern mit code ' . $saveResult.'<br />'.implode('<br />', $b->getValidationErrors()));
else
$this->message_succ = 'Bachelor mit ID '.$_REQUEST['change'].' Erfolgreich gespeichert';
} catch (Exception $e) {
$this->message_err = $e->getMessage();
}
}
if (isset($_REQUEST['delete'])) {
$this->environment->database->delete('bachelor', ['AND' => ['bachelor_id' => $_REQUEST['delete'], 'fahrt_id'=>$_REQUEST['fahrt_id']]]);
}
}
public function getHeaders() {
return '<link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery.dataTables.1.10.12.min.js"></script>
<style type="text/css">
div.btn{
width: 18px;
height: 18px;
padding: 3px 5px;
background-image: url("../view/graphics/MyEbaySprite.png");
background-repeat: no-repeat;
float: left;
cursor: pointer;
}
.btn-paid-0{
background-position: -23px -90px;
}
.btn-paid-1{
background-position: -70px -90px;
}
.btn-repaid-0{
background-position: -148px -89px;
}
.btn-repaid-1{
background-position:-194px -89px;
}
.btn-backstepped-0{
background-position: -51px -169px;
}
.btn-backstepped-1{
background-position: -23px -169px;
}
#editForm{
display: none;
position: fixed;
top:100px;
left: 200px;
width: 700px;
height: 80%;
border: 1px solid #000000;
background-color: beige;
padding: 20px 10px 10px 10px;
}
#editForm>p{
display: block;
position:absolute;
height:auto;
bottom:0;
top:0;
left:0;
right:0;
overflow: auto;
padding: 10px;
margin: 20px 0 0 0;
}
#editFormTopbar{
background-color: #b0bed9;
height: 20px;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 0;
}
#editFormTopbar p{
position: absolute;
float: right;
top: 0;
padding: 0;
margin: 0;
right: 5px;
cursor: none;
height: 20px;
display: block;
}
</style>';
}
public function getHeader() {
return '';
}
public function getFooter() {
return '';
}
public function getText() {
$cols = ['Anmelde-ID','Anmeldung','Name','Anreisetyp','Abreisetyp', 'Anreisetag','Abreisetag', 'Studityp', 'PaidReBack', 'BackAt'];
$buttoncol = count($cols)-2;
$thead = '';
$toggle = 'Toggle Column:';
foreach ($cols as $tcnt => $col) {
$thead .= '<th>'.$col.'</th>';
$toggle .= '<a class="toggle-vis" data-column="' . $tcnt . '">' . $col . '</a> - ';
}
$people = $this->fahrt->getBachelors(['waiting'=>false]);
$tbody = '';
foreach ($people as $b) {
if(!$b['backstepped']) {
continue;
}
$tbody .= '
<tr>
<td><a href="#" style="color:black !important;" class="edit_bachelor">'.$b['bachelor_id'].'</a></td>
<td>'.$this->mysql2german($b['anm_time']).'</td>
<td><a href="mailto:'.$b['mehl'].'?subject=FS-Fahrt">' . $b['forname'] . ' ' . $b['sirname'] . ' (' . $b['pseudo'] . ')</a></td>
<td>'.$b['antyp'].'</td>
<td>'.$b['abtyp'].'</td>
<td>'.$this->mysql2german($b['anday']).'</td>
<td>'.$this->mysql2german($b['abday']).'</td>
<td>'.$b['studityp'].'</td>
<td>'.($b['paid'] ? $b['paid'] : '0') . ',' . ($b['repaid'] ? $b['repaid'] : '0') . ',' . ($b['backstepped'] ? $b['backstepped'] : '0').'</td>
<td>'.date('d.m.Y - G:i.s', $b['backstepped']).'</td>
<td>'.($b['backstepped'] ? 1 : '0').'</td>
</tr>';
}
return '<h1>Abspringer Liste</h1>' .
$this->getMessage().'<br />' .
$toggle.'<br />
<br />
<table id="mlist" class="compact hover">
<thead>
<tr>'.$thead.'<th></th></tr>
</thead>
<tbody>'.$tbody.'</tbody>
</table>
<div id="editForm">
<div id="editFormTopbar"><p>X</p></div>
<p></p>
</div>
<script type="text/javascript">
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"link-pre": function ( a ) {
return a.match(/<a [^>]+>([^<]+)<\/a>/)[1];
},
"prb-pre": function ( a ) {
var tmp = a.split(",");
return ((tmp[0]==0) ? "0" : "1") + ((tmp[1]==0) ? "0" : "1") + ((tmp[2]==0) ? "0" : "1");
},
"dedate-pre": function( a ) {
var tmp = a.split(".");
if(tmp.length>2)
return (tmp[2]+tmp[1]+tmp[0]);
return a;
}
});
var ltab;
$(document).ready(function(){
ltab = $("#mlist").DataTable({
"rowCallback": function (row, data, index) {
var spl = data['.$buttoncol.'].split(",");
if (spl[2] != 0) {
$("td", row).addClass("list-backstepped");
} else if (spl[0] != 0 && spl[1] != 0) {
$("td", row).addClass("list-repaid");
} else if (spl[0] != 0) {
$("td", row).addClass("list-paid");
} else if (spl[0] == 0) {
$("td", row).addClass("list-unpaid");
}
},
"columnDefs": [
{
"targets": ['.$buttoncol.'],
"render": function(data, type, row, meta) {
if (type === "display"){
var bid = row[0].match(/<a [^>]+>([^<]+)<\/a>/)[1];
var classes = ["paid", "repaid", "backstepped"];
var btns = "";
var parts = data.split(",");
for (var i = 0; i < parts.length; i++) {
var tmp = (parts[i] ==0) ? 0 : 1;
btns +="<div onclick=\\"btnclick(this, \'"+classes[i]+"\',\'"+bid+"\',"+tmp+");\\" class=\\"btn btn-"+classes[i]+"-"+tmp+"\\">&nbsp;</div>";
}
return btns;
}
return data;
}
},
{ type: "dedate", targets: [1,5,6]},
{ type: "link", targets: [0, 2] },
{ type: "prb", targets: ' . $buttoncol . ' },
{ targets: 10, visible: false, searchable: false }
],
"order": [[ 2, "asc" ]],
"paging": false,
"orderFixed": [ 8, "asc" ]
});
$("a.toggle-vis").click( function (e) {
e.preventDefault();
// Get the column API object
var column = ltab.column( $(this).attr("data-column") );
// Toggle the visibility
column.visible( ! column.visible() );
});
$(".moveToWaitlist").click( function(){
var bid = $(this).closest("tr").find("td:eq(0)").text();
$.get( "?page=jumpOf&ajax=ajax&toWaitlist=toWaitlist&hash="+bid, function( data ) {});
});
$(".edit_bachelor").click( function(){
var bid = $(this).text();
$.get( "?page=jumpOf&ajax=ajax&form=form&hash="+bid, function( data ) {
$("#editForm > p").html(data);
});
$("#editForm").show();
});
$("#editFormTopbar > p").click( function(){
$(this).parent().parent().hide();
});
});
function btnclick(that, type, hash, state){
var newstate = (((state-1)<0) ? 1 : 0);
$.get("index.php?page=jumpOf&ajax=ajax&update="+type+"&hash="+hash+"&nstate="+newstate ,"",
function(){
that.className="btn btn-"+type+"-"+newstate;
that.setAttribute("onclick", "btnclick(this, \'"+type+"\', \'"+hash+"\', "+newstate+")");
var p = $("div", $(that).parent())[0].className;
var r = $("div", $(that).parent())[1].className;
var b = $("div", $(that).parent())[2].className;
if (b == "btn btn-backstepped-1") {
updateClass(that, "list-backstepped");
} else if (p == "btn btn-paid-1" && r == "btn btn-repaid-1") {
updateClass(that, "list-repaid");
} else if (p == "btn btn-paid-1") {
updateClass(that, "list-paid");
} else if (p == "btn btn-paid-0") {
updateClass(that, "list-unpaid");
} else {
updateClass(that);
}
});
}
function updateClass(that, nClass = null) {
$("td", $(that).parent().parent()).removeClass("list-backstepped")
.removeClass("list-repaid")
.removeClass("list-paid")
.removeClass("list-unpaid");
if(nClass != null)
$("td", $(that).parent().parent()).addClass(nClass);
}
</script>';
}
public function getAjax() {
if (isset($_REQUEST['update']) && isset($_REQUEST['hash']) && isset($_REQUEST['nstate'])) {
$b = Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']);
$b->set([$_REQUEST['update'] => ($_REQUEST['nstate'] == 1) ? time() : null]);
return $b->save();
} elseif (isset($_REQUEST['form'])) {
return $this->getEditForm(Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']));
} elseif(isset($_REQUEST['toWaitlist'])) {
try {
$bachelor = Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']);
if (empty($bachelor))
throw new Exception('Person nicht vorhanden.');
$transferResult = $bachelor->registrationToWaitlist();
if ($transferResult == Bachelor::SAVE_SUCCESS) {
$this->message_succ = 'Person erfolgreich von Warteliste auf Anmeldeliste übertragen.';
return true;
} else {
throw new Exception('Hat nicht geklappt. Fehlercode '.$transferResult);
}
} catch (Exception $e) {
$this->message_err = $e->getMessage();
}
}
}
private function nulltime2german($time) {
if (empty($time)) return 'Nein';
return $this->mysql2german($time);
}
/**
* @param $bachelor Bachelor
* @return string
*/
private function getEditForm($bachelor) {
$data = $bachelor->getData();
$bid = $data['bachelor_id'];
$fid = $data['fahrt_id'];
$possibleDates = $this->fahrt->getPossibleDates();
return '
<b>Hash:</b> <a href="../status.php?fid='.$fid.'&hash='.$bid.'" target="_blank">' . $bid . '</a><br/>
<b>Fahrt:</b> ID ' . $fid . '<br/>
<b>Anmeldung:</b> ' . $this->mysql2german($data['anm_time']) . '<br/>
<b>Bezahlt:</b> ' . $this->nulltime2german($data['paid']) . '<br/>
<b>Rückgezahlt:</b> ' . $this->nulltime2german($data['repaid']) . '<br/>
<b>Zurückgetreten:</b> ' . $this->nulltime2german($data['backstepped']) . '<br/>
<br /><hr /> <br/>
<form method="POST" >
Note: Keine Nachfrage, löscht direkt und unwiederruflich!!<br />
<input type="submit" name="submit_del" value="DELETE" />
<input type="hidden" name="delete" value="' . $bid . '" />
<input type="hidden" name="bachelor_id" value="' . $bid . '" />
<input type="hidden" name="fahrt_id" value="' . $fid . '" />
</form>';
}
}
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 9/3/14
* Time: 7:09 PM
*/
class AdminListPage extends AdminPage {
public function __construct($base) {
parent::__construct($base);
$this->isWaitlist = isset($_GET['waitlist']) && $_GET['waitlist'] == 'true';
$this->isAlumniPage = isset($_GET['alumni']) && $_GET['alumni'] == 'true';
// moves entry to final list
if(isset($_REQUEST['move'])){
try {
$bachelor = Bachelor::makeFromDB($this->fahrt, $_REQUEST['move']);
if (empty($bachelor))
throw new Exception('Person nicht vorhanden.');
if ($this->isWaitlist) {
$transferResult = $bachelor->waitlistToRegistration();
} else {
$transferResult = $bachelor->registrationToWaitlist();
}
if ($transferResult == Bachelor::SAVE_SUCCESS) {
$this->message_succ = 'Person erfolgreich von '.($this->isWaitlist?"Warteliste":"Anmeldeliste").' auf '.($this->isWaitlist?"Anmeldeliste":"Warteliste").' übertragen.';
} else {
throw new Exception('Hat nicht geklappt. Fehlercode '.$transferResult);
}
} catch (Exception $e) {
$this->message_err = $e->getMessage();
}
}
global $text, $headers, $admin_db, $config_current_fahrt_id, $ajax, $config_studitypen, $config_essen, $config_reisearten, $config_essen_o, $config_reisearten_o; if (isset($_REQUEST['change'])) {
try {
$ecols = [ $bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
"forname" => function($d){ return $d; }, $bNew->set(['bachelor_id' => $_REQUEST['change']]);
"sirname" => function($d){ return $d; }, $bOld = Bachelor::makeFromDB($this->fahrt, $_REQUEST['change']);
"mehl" => function($d){ return $d; }, $bOld->updateBachelor($bNew);
"pseudo" => function($d){ return $d; }, $saveResult = $bOld->save();
"antyp" => function($d){ return $d; }, if ($saveResult !== Bachelor::SAVE_SUCCESS)
"abtyp" => function($d){ return $d; }, throw new Exception('Fehler beim Speichern mit code ' . $saveResult.'<br />'.implode('<br />', $b->getValidationErrors()));
"anday" => function($d){ return date('Y-m-d', DateTime::createFromFormat('d.m.Y',$d)->getTimestamp()); }, else
"abday" => function($d){ return date('Y-m-d', DateTime::createFromFormat('d.m.Y',$d)->getTimestamp()); }, $this->message_succ = 'Bachelor mit ID '.$_REQUEST['change'].' Erfolgreich gespeichert';
"comment" => function($d){ return htmlspecialchars($d, ENT_QUOTES); }, } catch (Exception $e) {
"studityp"=> function($d){ return $d; }, $this->message_err = $e->getMessage();
"virgin" => function($d){ return (($d=="Nein") ? 1 : 0); }, // nein zu 18+ heißt ja zu virgin => 1 }
"public" => function($d){ return $d; }, }
"essen" => function($d){ return $d; }
];
if(isset($_REQUEST['change'])){ if (isset($_REQUEST['delete'])) {
$update = []; $this->environment->database->delete('bachelor', ['AND' => ['bachelor_id' => $_REQUEST['delete'], 'fahrt_id'=>$_REQUEST['fahrt_id']]]);
foreach($ecols as $k=>$e){ }
if($k == "public")
$update[$k] = isset($_REQUEST[$k]) ? 0 : 1;
else
$update[$k] = $e($_REQUEST[$k]);
} }
$admin_db->update("bachelor", $update, ["bachelor_id"=> $_REQUEST['change']]);
}
if(isset($_REQUEST['delete'])){ public function getHeaders() {
$admin_db->delete("bachelor", ["bachelor_id"=> $_REQUEST['delete']]); return '<link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" />
} <script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery.dataTables.1.10.12.min.js"></script>
<style type="text/css">
div.btn{
width: 18px;
height: 18px;
padding: 3px 5px;
background-image: url("../view/graphics/MyEbaySprite.png");
background-repeat: no-repeat;
float: left;
cursor: pointer;
}
.btn-paid-0{
background-position: -23px -90px;
}
.btn-paid-1{
background-position: -70px -90px;
}
.btn-repaid-0{
background-position: -148px -89px;
}
.btn-repaid-1{
background-position:-194px -89px;
}
.btn-backstepped-0{
background-position: -51px -169px;
}
.btn-backstepped-1{
background-position: -23px -169px;
}
if(isset($_REQUEST['ajax'])){ #editForm{
display: none;
position: fixed;
top:100px;
left: 200px;
width: 700px;
height: 80%;
border: 1px solid #000000;
background-color: beige;
padding: 20px 10px 10px 10px;
}
if(isset($_REQUEST['update']) && isset($_REQUEST['hash']) && isset($_REQUEST['nstate'])){ #editForm>p{
$col = $_REQUEST['update']; display: block;
$id = $_REQUEST['hash']; position:absolute;
$val = ($_REQUEST['nstate'] == 1) ? time() : NULL; height:auto;
$admin_db->update("bachelor", array($col=>$val), array("bachelor_id"=> $id)); bottom:0;
top:0;
left:0;
right:0;
overflow: auto;
padding: 10px;
margin: 20px 0 0 0;
}
#editFormTopbar{
background-color: #b0bed9;
height: 20px;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 0;
}
#editFormTopbar p{
position: absolute;
float: right;
top: 0;
padding: 0;
margin: 0;
right: 5px;
cursor: none;
height: 20px;
display: block;
}
</style>';
} }
public function getHeader() {
elseif(isset($_REQUEST['form'])){ return '';
$bid = $_REQUEST['hash'];
$rcols = [
"bachelor_id" => ["Hash", function( $b ){ return $b; }],
"fahrt_id" => ["Fahrt", function( $b ){ return "ID ".$b; }],
"anm_time" => ["Anmeldung", function( $b ){ return date("d.m.Y",$b); }],
"paid" => ["Bezahlt", function( $b ){ return ($b==0) ? "Nein" : date("d.m.Y", $b); }],
"repaid" => ["Rückgezahlt", function($b){ return ($b==0) ? "Nein" : date("d.m.Y", $b); }],
"backstepped" => ["Zurückgetreten", function( $b ){ return ($b==0) ? "Nein" : date("d.m.Y", $b); }]
];
$bachelor = $admin_db->get('bachelor', array_merge(array_keys($ecols), array_keys($rcols)), array('bachelor_id'=>$bid));
$possible_dates = comm_get_possible_dates($admin_db, $bachelor['fahrt_id']);
foreach($rcols as $k=>$r){
$ajax .= "<b>".$r[0].":</b> ".$r[1]($bachelor[$k])."<br />";
}
$ajax .= '<br />
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="?page=list">';
$ajax .= '<input type="hidden" value="'.$bid.'" name="change" id="change" />';
$ajax .= admin_show_formular_helper_input("Vorname", "forname", $bachelor["forname"], "");
$ajax .= admin_show_formular_helper_input("Nachname","sirname",$bachelor["sirname"],"");
$ajax .= admin_show_formular_helper_input("Anzeigename","pseudo",$bachelor["pseudo"],"");
$ajax .= admin_show_formular_helper_input("E-Mail-Adresse","mehl",$bachelor["mehl"],"regelmäßig lesen!");
$ajax .= admin_show_formular_helper_sel("Er/Sie/Es ist","studityp",$config_studitypen, $bachelor["studityp"],"");
$ajax .= admin_show_formular_helper_sel("Alter 18+?","virgin",array("Nein", "Ja"), (($bachelor["virgin"]==1) ? "Nein" : "Ja"), "Älter als 18?");
$ajax .= admin_show_formular_helper_sel("Essenswunsch","essen",$config_essen, $bachelor["essen"],"Info für den Koch.");
$ajax .= "<div style='clear: both;'></div>";
$ajax .= admin_show_formular_helper_sel2("Anreise","anday", array_slice($possible_dates,0, -1), comm_from_mysqlDate($bachelor["anday"])
,"antyp",$config_reisearten, $bachelor["antyp"],"");
$ajax .= admin_show_formular_helper_sel2("Abreise","abday", array_slice($possible_dates,1), comm_from_mysqlDate($bachelor["abday"])
,"abtyp",$config_reisearten,$bachelor["abtyp"],"");
$ajax .= '
<label>Anmerkung</label>
<textarea id="comment" name="comment" rows="3" cols="40">'.$bachelor["comment"].'</textarea>
<input type="checkbox" name="public" value="public" style="width:40px" '.(($bachelor['public']==0 ? " checked" : "")).'><span style="float:left">Anmeldung verstecken</span><br/>
<div style="clear:both"></div>
Note: No check for validity of data here!
<button type="submit" name="submit" id="submit" value="submit">Ändern!</button>
<div class="spacer"></div>';
$ajax .= '</form>
</div>
';
$ajax .= '<br /><hr /> <br/>
<form method="POST" >
Note: Keine Nachfrage, löscht direkt und unwiederruflich!!<br />
<input type="submit" name="submit_del" value="DELETE" />
<input type="hidden" name="delete" value="'.$bid.'" />
</form>
';
} }
public function getFooter() {
} else { return '';
$headers =<<<END
<link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery.dataTables.1.10.9.min.js"></script>
END;
$headers .= "
<style type='text/css'>
div.btn{
width: 18px;
height: 18px;
padding: 3px 5px;
background-image: url('../view/graphics/MyEbaySprite.png');
background-repeat: no-repeat;
float: left;
cursor: pointer;
}
.btn-paid-0{
background-position: -23px -90px;
}
.btn-paid-1{
background-position: -70px -90px;
}
.btn-repaid-0{
background-position: -148px -89px;
}
.btn-repaid-1{
background-position:-194px -89px;
}
.btn-backstepped-0{
background-position: -51px -169px;
}
.btn-backstepped-1{
background-position: -23px -169px;
}
#editForm{
display: none;
position: fixed;
top:100px;
left: 200px;
width: 700px;
height: 80%;
border: 1px solid #000000;
background-color: beige;
padding: 20px 10px 10px 10px;
}
#editForm>p{
display: block;
position:absolute;
height:auto;
bottom:0;
top:0;
left:0;
right:0;
overflow: auto;
padding: 10px;
margin: 20px 0 0 0;
}
#editFormTopbar{
background-color: #b0bed9;
height: 20px;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 0;
}
#editFormTopbar p{
position: absolute;
float: right;
top: 0;
padding: 0;
margin: 0;
right: 5px;
cursor: none;
height: 20px;
display: block;
}
</style>";
$text .= "<h1>Meldeliste</h1>";
$columns = array(
"bachelor_id",
"fahrt_id",
"anm_time",
"forname",
"sirname",
"mehl",
"pseudo",
"antyp",
"abtyp",
"anday",
"abday",
"comment",
"studityp",
"paid",
"repaid",
"backstepped",
"virgin",
"essen"
);
$columnFunctions = array(
"Anmelde-ID" => function($person) { return "<a href='#' class='edit_bachelor'>".$person["bachelor_id"]."</a>"; }
//,"FahrtID" => function($person) { return $person["fahrt_id"]; }
,"Anmeldung" => function($person) { return date("d.m.Y", $person['anm_time']); },
"Name" => function($person) { return "<a href='mailto:".$person["mehl"]."?subject=FS-Fahrt'>".$person["forname"]." ".$person["sirname"]." (".$person["pseudo"].")</a>"; },
"Anreisetyp" => function($person) { global $config_reisearten_o; return array_search($person["antyp"], $config_reisearten_o); },
"Abreisetyp" => function($person) { global $config_reisearten_o; return array_search($person["abtyp"], $config_reisearten_o); },
"Anreisetag" => function($person) { return comm_from_mysqlDate( $person["anday"]); },
"Abreisetag" => function($person) { return comm_from_mysqlDate( $person["abday"]); },
"Kommentar" => function($person) { return $person["comment"]; },
"StudiTyp" => function($person) { return $person["studityp"]; },
"Essen" => function($person) { global $config_essen_o; return array_search($person["essen"], $config_essen_o); },
"18+" => function($person) { return (($person["virgin"]==0) ? "Ja" : "Nein"); },
"PaidReBack" => function($person) { return ($person["paid"] ? $person["paid"] : "0") .",". ($person["repaid"] ? $person["repaid"] : "0") .",". ($person["backstepped"] ? $person["backstepped"] : "0"); }
);
$text .= "Toggle Column: ";
$tcnt = 0;
foreach($columnFunctions as $key => $value){
$text .= '<a class="toggle-vis" data-column="'.$tcnt.'">'.$key.'</a> - ';
$tcnt++;
}
$text .= "<br />";
$text .= '
<table id="mlist" class="compact hover">
<thead>
<tr>';
foreach($columnFunctions as $key => $value) {
$text .= "<th>".$key."</th>";
}
$text .="<th></th></tr>
</thead>
<tbody>";
$people = $admin_db->select('bachelor',$columns, array("fahrt_id"=>$config_current_fahrt_id));
foreach($people as $person) {
$text .= "<tr>\n"; //".((explode(',',$columnFunctions['PaidReBack']($person))[2]==0) ? "" : "class='list-backstepped'")."
foreach($columnFunctions as $key => $value) {
$text .= "<td class='".$key."'>".$value($person)."</td>\n";
} }
$text .= "<td>".((explode(',',$columnFunctions['PaidReBack']($person))[2]==0) ? '0' : '1')."</td>";
$text .= "</tr>";
}
$buttoncol = 11;
$text .=<<<END
</tbody>
</table>
<div id="editForm">
<div id="editFormTopbar"><p>X</p></div>
<p></p>
</div>
<script type='text/javascript'>
jQuery.extend( jQuery.fn.dataTableExt.oSort, { public function getText() {
"link-pre": function ( a ) { $extra_filters = ['fahrt_id' => $this->fahrt->getID()];
return a.match(/<a [^>]+>([^<]+)<\/a>/)[1]; $cols = ['Anmelde-ID','Anmeldung', 'Name', 'Pseudo', 'Anreisetyp', 'Abreisetyp', 'Anreisetag','Abreisetag',
} 'Kommentar','Studityp','Essen', '18+', 'Orga', 'M.spiel', 'PaidReBack'];
, $buttoncol = count($cols)-1;
"prb-pre": function ( a ){
var tmp = a.split(","); $thead = '';
return ((tmp[0]==0) ? '0' : '1') + ((tmp[1]==0) ? '0' : '1') + ((tmp[2]==0) ? '0' : '1'); $toggle = 'Toggle Column:';
foreach ($cols as $tcnt => $col) {
$thead .= '<th>'.$col.'</th>';
$toggle .= '<a class="toggle-vis" data-column="' . $tcnt . '">' . $col . '</a> - ';
}
if ($this->isWaitlist) {
$thead .= '<th>Übertragen</th>';
$toggle .= '<a class="toggle-vis" data-column=\''.sizeof($cols).'\'>toWaitlist</a> - ';
$extra_filters['on_waitlist'] = 1;
$extra_filters['studityp'.($this->isAlumniPage ? '' : '[!]')] = 'ALUMN';
} else {
$extra_filters['AND'] = [
'on_waitlist' => 0
];
$includeResigned = false;
if (isset($_REQUEST['includeResigned'])) {
$includeResigned = true;
} }
, if (!$includeResigned) {
"dedate-pre": function(a){ $extra_filters['AND']['backstepped'] = null;
var tmp = a.split(".");
if(tmp.length>2)
return (tmp[2]+tmp[1]+tmp[0]);
return a;
} }
} ); $thead .= '<th>toWaitlist</th>';
var ltab; $toggle .= '<a class="toggle-vis" data-column=\''.sizeof($cols).'\'>toWaitlist</a> - ';
$(document).ready(function(){ }
ltab = $('#mlist').DataTable({
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var tmp = aData[$buttoncol].split(',');
if (tmp[2] > 0) {
$('td',nRow).addClass('list-backstepped');
}
return nRow;
},
"aoColumnDefs": [
{
"aTargets": [ $buttoncol ],
"mDataProp": function ( data, type, row ) {
if (type === 'set') {
data[$buttoncol] = row;
var btns = "";
var classes = ["paid", "repaid", "backstepped"];
var txt = data[$buttoncol].split(",");
for(var i = 0; i < txt.length; i++){
var tmp = (txt[i]==0) ? 0 : 1;
btns += "<div onclick=\"btnclick(this, '"+classes[i]+"','"+data[0].match(/<a [^>]+>([^<]+)<\/a>/)[1]+"',"+tmp+");\" class='btn btn-"+classes[i]+"-"+tmp+"'>&nbsp;</div>";
}
// Store the computed display for speed $tbody = '';
data.date_rendered = btns; $people = $this->environment->database->select('bachelor', Bachelor::$ALLOWED_FIELDS,
return; ['AND' => $extra_filters], ['anm_time' => 'ASC']);
} foreach ($people as $b) {
else if (type === 'display' || type === 'filter') { $zurueckgetreten = $b['backstepped'] ? 1 : 0;
return data.date_rendered; $anfahrtDatum = $this->mysql2german($b['anday']);
} $abfahrtDatum = $this->mysql2german($b['abday']);
// 'sort' and 'type' both just use the raw data $antyp = strtolower($b['antyp']);
return data[$buttoncol]; $abtyp = strtolower($b['abtyp']);
$studityp = strtolower($b['studityp']);
$essen = strtolower($b['essen']);
$anmelde_zeit = date('d.m.Y - G:i.s', $b['anm_time']);
$ueber18JaNein = $b['virgin'] == 1 ? 'Nein' : 'Ja';
$orgaJaNein = $b['isOrga'] == 1 ? 'Ja' : 'Nein';
$moerderSpielJaNein = $b['mGame'] == 1 ? 'Ja' : 'Nein';
$bezahltJaNein = $b['paid'] ? 1 : 0;
$zurueckgezahltJaNein = $b['repaid'] ? 1 : 0;
$kommentar = htmlspecialchars($b['comment'], ENT_QUOTES);
$waitlist_tf = $this->isWaitlist ? "true" : "false";
$alumni_tf = $this->isAlumniPage ? "true" : "false";
$transfer_text = $this->isWaitlist ? "Anmeldeliste" : "Warteliste";
$tbody .= <<<EOF
<tr>
<td><a href="#" class="edit_bachelor">${b['bachelor_id']}</a></td>
<td>$anmelde_zeit</td>
<td><a href="mailto:${b['mehl']}?subject=FS-Fahrt">${b['forname']} ${b['sirname']}</a></td>
<td>${b['pseudo']}</td>
<td>${antyp}</td>
<td>${abtyp}</td>
<td>$anfahrtDatum</td>
<td>$abfahrtDatum</td>
<td>$kommentar</td>
<td>${studityp}</td>
<td>${essen}</td>
<td>$ueber18JaNein</td>
<td>$orgaJaNein</td>
<td>$moerderSpielJaNein</td>
<td>$bezahltJaNein,$zurueckgezahltJaNein,$zurueckgetreten</td>
<td><a href="?page=list&waitlist=${waitlist_tf}&alumni=${alumni_tf}&move=${b['bachelor_id']}">&#8614; ${transfer_text}</a></td>
<td>$zurueckgetreten</td>
</tr>
EOF;
}
$resignCheckbox = '';
if (!$this->isWaitlist) {
$includeResignedChecked = isset($_REQUEST['includeResigned']) && $_REQUEST['includeResigned'] == 1 ? 'checked ' : '';
$resignCheckbox .= <<<EOF
<form method="GET">
<input type="hidden" name="page" value="list" />
<label><input type="checkbox" name="includeResigned" value="1" $includeResignedChecked /> Abspringer anzeigen</label>
<input type="submit" value="aktualisieren" />
</form><br/>
EOF;
}
return '<h1>' . ($this->isWaitlist ? 'Warteliste' : 'Meldeliste') . ($this->isAlumniPage ? ' für Alumnis' : '') . '</h1>' .
$this->getMessage().'<br />' .
$resignCheckbox.
$toggle.'<br />
<br />
<table id="mlist" class="compact hover">
<thead>
<tr>'.$thead.'<th></th></tr>
</thead>
<tbody>'.$tbody.'</tbody>
</table>
<div id="editForm">
<div id="editFormTopbar"><p>X</p></div>
<p></p>
</div>
<script type="text/javascript">
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"link-pre": function ( a ) {
return a.match(/<a [^>]+>([^<]+)<\/a>/)[1];
},
"prb-pre": function ( a ) {
var tmp = a.split(",");
return ((tmp[0]==0) ? "0" : "1") + ((tmp[1]==0) ? "0" : "1") + ((tmp[2]==0) ? "0" : "1");
},
"dedate-pre": function( a ) {
var tmp = a.split(".");
if(tmp.length>2)
return (tmp[2]+tmp[1]+tmp[0]);
return a;
}
});
var ltab;
$(document).ready(function() {
ltab = $("#mlist").DataTable({
"rowCallback": function (row, data, index) {
var spl = data['.$buttoncol.'].split(",");
if (spl[2] != 0) {
$("td", row).addClass("list-backstepped");
} else if (spl[0] != 0 && spl[1] != 0) {
$("td", row).addClass("list-repaid");
} else if (spl[0] != 0) {
$("td", row).addClass("list-paid");
} else if (spl[0] == 0) {
$("td", row).addClass("list-unpaid");
} }
}, },
{ type: 'dedate', targets: [1,5,6]}, "columnDefs": [
{ type: 'link', targets: [0, 2] }, {
{ type: 'prb', targets: $buttoncol }, "targets": ['.$buttoncol.'],
{ targets: 12, visible: false, searchable: false }, "render": function(data, type, row, meta) {
], if (type === "display"){
"order": [[ 2, "asc" ]], var bid = row[0].match(/<a [^>]+>([^<]+)<\/a>/)[1];
"orderFixed": [ 12, 'asc' ], var classes = ["paid", "repaid", "backstepped"];
"paging": false var btns = "";
}); var parts = data.split(",");
for (var i = 0; i < parts.length; i++) {
$('a.toggle-vis').click( function (e) { var tmp = (parts[i] ==0) ? 0 : 1;
e.preventDefault(); btns +="<div onclick=\\"btnclick(this, \'"+classes[i]+"\',\'"+bid+"\',"+tmp+");\\" class=\\"btn btn-"+classes[i]+"-"+tmp+"\\">&nbsp;</div>";
}
return btns;
}
return data;
}
},
{ type: "dedate", targets: [1,5,6]},
{ type: "link", targets: [0, 2] },
{ type: "prb", targets: ' . $buttoncol . ' },
{ targets: 16, visible: false, searchable: false }
],
"order": [[ 2, "asc" ]],
"paging": false,
"orderFixed": [ 16, "asc" ]
});
$("a.toggle-vis").click( function (e) {
e.preventDefault();
// Get the column API object if($(this).attr("data-column")>=0) {
var column = ltab.column( $(this).attr('data-column') ); // Get the column API object
var column = ltab.column( $(this).attr("data-column") );
// Toggle the visibility // Toggle the visibility
column.visible( ! column.visible() ); column.visible( ! column.visible() );
} ); }
$(".edit_bachelor").click( function(){ });
var bid = $(this).text(); $(".moveToWaitlist").click( function(){
$.get( "?page=list&ajax=ajax&form=form&hash="+bid, function( data ) { var bid = $(this).closest("tr").find("td:eq(0)").text();
$("#editForm > p").html(data); $.get( "?page=list&ajax=ajax&toWaitlist=toWaitlist&hash="+bid, function( data ) {});
}); });
$(".edit_bachelor").click( function(){
var bid = $(this).text();
$.get( "?page=list&ajax=ajax&form=form&hash="+bid, function( data ) {
$("#editForm > p").html(data);
});
$("#editForm").show(); $("#editForm").show();
}); });
$("#editFormTopbar > p").click( function(){ $("#editFormTopbar > p").click( function(){
$(this).parent().parent().hide(); $(this).parent().parent().hide();
});
var column = ltab.column(3);
column.visible(false);
var column = ltab.column(8);
column.visible(false);
}); });
function btnclick(that, type, hash, state){
var newstate = (((state-1)<0) ? 1 : 0);
$.get("index.php?page=list&ajax=ajax&update="+type+"&hash="+hash+"&nstate="+newstate ,"",
function(){
that.className="btn btn-"+type+"-"+newstate;
that.setAttribute("onclick", "btnclick(this, \'"+type+"\', \'"+hash+"\', "+newstate+")");
var p = $("div", $(that).parent())[0].className;
var r = $("div", $(that).parent())[1].className;
var b = $("div", $(that).parent())[2].className;
if (b == "btn btn-backstepped-1") {
updateClass(that, "list-backstepped");
} else if (p == "btn btn-paid-1" && r == "btn btn-repaid-1") {
updateClass(that, "list-repaid");
} else if (p == "btn btn-paid-1") {
updateClass(that, "list-paid");
} else if (p == "btn btn-paid-0") {
updateClass(that, "list-unpaid");
} else {
updateClass(that);
}
});
}
}); function updateClass(that, nClass = null) {
$("td", $(that).parent().parent()).removeClass("list-backstepped")
.removeClass("list-repaid")
.removeClass("list-paid")
.removeClass("list-unpaid");
if(nClass != null)
$("td", $(that).parent().parent()).addClass(nClass);
}
</script>';
}
function btnclick(that, type, hash, state){ public function getAjax() {
var newstate = (((state-1)<0) ? 1 : 0); if (isset($_REQUEST['update']) && isset($_REQUEST['hash']) && isset($_REQUEST['nstate'])) {
$.get("index.php?page=list&ajax=ajax&update="+type+"&hash="+hash+"&nstate="+newstate ,"", $b = Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']);
function(){ $b->set([$_REQUEST['update'] => ($_REQUEST['nstate'] == 1) ? time() : null]);
if(newstate === 1 && type === "backstepped") { return $b->save();
$('td',$(that).parent().parent()).addClass('list-backstepped'); } elseif (isset($_REQUEST['form'])) {
} else { return $this->getEditForm(Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']));
$('td',$(that).parent().parent()).removeClass('list-backstepped'); } elseif(isset($_REQUEST['toWaitlist'])) {
} try {
that.className="btn btn-"+type+"-"+newstate; $bachelor = Bachelor::makeFromDB($this->fahrt, $_REQUEST['hash']);
that.setAttribute("onclick", "btnclick(this, '"+type+"', '"+hash+"', "+newstate+")"); if (empty($bachelor))
}); throw new Exception('Person nicht vorhanden.');
$transferResult = $bachelor->registrationToWaitlist();
if ($transferResult == Bachelor::SAVE_SUCCESS) {
$this->message_succ = 'Person erfolgreich von Warteliste auf Anmeldeliste übertragen.';
return true;
} else {
throw new Exception('Hat nicht geklappt. Fehlercode '.$transferResult);
}
} catch (Exception $e) {
$this->message_err = $e->getMessage();
}
} }
</script> }
END;
private function nulltime2german($time) {
if (empty($time)) return 'Nein';
return $this->mysql2german($time);
}
/**
* @param $bachelor Bachelor
* @return string
*/
private function getEditForm($bachelor) {
$data = $bachelor->getData();
$bid = $data['bachelor_id'];
$fid = $data['fahrt_id'];
$possibleDates = $this->fahrt->getPossibleDates();
return '
<b>Hash:</b> <a href="../status.php?fid='.$fid.'&hash='.$bid.'" target="_blank">' . $bid . '</a><br/>
<b>Fahrt:</b> ID ' . $fid . '<br/>
<b>Anmeldung:</b> ' . $this->mysql2german($data['anm_time']) . '<br/>
<b>Bezahlt:</b> ' . $this->nulltime2german($data['paid']) . '<br/>
<b>Rückgezahlt:</b> ' . $this->nulltime2german($data['repaid']) . '<br/>
<b>Zurückgetreten:</b> ' . $this->nulltime2german($data['backstepped']) . '<br/>
<br />
<div id="stylized" class="myform">
<form id="form" name="form" method="post">
<input type="hidden" value="' . $bid . '" name="change" id="change" />
<input type="hidden" value="' . $fid . '" name="fahrt_id" id="fahrt_id" />' .
$this->getFormInput('Vorname', 'forname', $data['forname'], '') .
$this->getFormInput('Nachname', 'sirname', $data['sirname'], '') .
$this->getFormInput('Anzeigename', 'pseudo', $data['pseudo'], '') .
$this->getFormInput('E-Mail', 'mehl', $data['mehl'], 'regelmäßig lesen!') .
$this->getFormSel('Er/Sie/Es ist', 'studityp', array_keys($this->environment->oconfig['studitypen']), $data['studityp'], '') .
$this->getFormSel('Alter 18+?', 'virgin', ['Ja', 'Nein'], ($data['virgin'] == 1) ? 'Nein' : 'Ja', 'Älter als 18?') .
$this->getFormSel('Ist in der Orga', 'isOrga', ['Ja', 'Nein'], ($data['isOrga'] == 1) ? 'Ja' : 'Nein', '') .
$this->getFormSel('Spielt Mörderspiel', 'mGame', ['Ja', 'Nein'], ($data['mGame'] == 1) ? 'Ja' : 'Nein', '') .
$this->getFormSel('Essenswunsch', 'essen', array_keys($this->environment->oconfig['essen']), $data['essen'], 'Info für den Koch') .
'<div style="clear:both;"></div>' .
$this->getFormSel2('Anreise', 'anday', array_slice($possibleDates, 0, -1), $this->mysql2german($data['anday']),
'antyp', array_keys($this->environment->oconfig['reisearten']), $data['antyp'], '') .
$this->getFormSel2('Abreise', 'abday', array_slice($possibleDates, 1), $this->mysql2german($data['abday']),
'abtyp', array_keys($this->environment->oconfig['reisearten']), $data['abtyp'], '') .
'<label>Anmerkung</label>
<textarea id="comment" name="comment" rows="3" cols="40">' . $data['comment'] . '</textarea>
<input type="checkbox" name="public" value="public" style="width:40px" ' . (($data['public'] == 0 ? " checked" : "")) . '>
<span style="float:left">Anmeldung verstecken</span><br/>
<div style="clear:both"></div>
Note: No check for validity of data here!
<button type="submit" name="submit" id="submit" value="submit">Ändern!</button>
<div class="spacer"></div>
</form>
</div>
<br /><hr /> <br/>
<form method="POST" >
Note: Keine Nachfrage, löscht direkt und unwiederruflich!!<br />
<input type="submit" name="submit_del" value="DELETE" />
<input type="hidden" name="delete" value="' . $bid . '" />
<input type="hidden" name="bachelor_id" value="' . $bid . '" />
<input type="hidden" name="fahrt_id" value="' . $fid . '" />
</form>';
}
} }
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 8/17/14
* Time: 11:05 PM
*/
// ENHANCEMENT: simplified presets (Alle, gezahlt, nicht gezahlt, Anreise individuell) class AdminMailPage extends AdminPage {
global $config_studitypen, $config_reisearten, $config_essen, $admin_db, $config_current_fahrt_id, $config_admin_verbose_level, $config_verbose_level, $text, $headers, $ajax; private $mails;
$config_verbose_level = 0;
$config_admin_verbose_level = 0;
$headers .= '<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script> public function __construct($base) {
<script type="text/javascript" src="../view/js/jquery-ui.min.js"></script>'; parent::__construct($base);
$text .= ' $this->mails = $this->environment->database->select('bachelor',
<script type="text/javascript"> ['mehl', 'forname', 'sirname'],
$(function(){ $this->buildQueryWhere());
}
$("#mform").submit(function(event){ public function getHeaders() {
event.preventDefault(); return '<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
var str = $("#mform").serialize(); <script type="text/javascript" src="../view/js/jquery-ui.min.js"></script>';
str += "&submit=submit&ajax=ajax"; }
$.post(document.url, str, function(data){
$("#mails").html(data);
}, "text");
$("#mails").fadeOut().delay(50).fadeIn(); public function getHeader() {
return '';
}
}); public function getFooter() {
}); return '';
</script> }
<form method="POST" id="mform">
<table>
<tr>
<td>Studityp</td>
<td>Anreise</td>
<td>Abreise</td>
<td>Nächte</td>
<td>Essen</td>
<td>Gezahlt</td>
<td>Rückgezahlt</td>
<td>18+</td>
<td>Zurückgetreten</td>
</tr>
<tr>
<td><input type="checkbox" name="check_studityp" /></td>
<td><input type="checkbox" name="check_antyp" /></td>
<td><input type="checkbox" name="check_abtyp" /></td>
<td><input type="checkbox" name="check_nights" /></td>
<td><input type="checkbox" name="check_essen" /></td>
<td><input type="checkbox" name="check_paid" /></td>
<td><input type="checkbox" name="check_repaid" /></td>
<td><input type="checkbox" name="check_virgin" /></td>
<td><input type="checkbox" name="check_backstepped" /></td>
</tr>
<tr>
<td>
<select multiple name="val_studityp[]">';
foreach($config_studitypen as $typ)
$text .= '<option value="'.$typ.'">'.$typ.'</option>';
$text .= '
</select>
</td>
<td>
<select multiple name="val_antyp[]">';
foreach($config_reisearten as $typ)
$text .= '<option value="'.$typ.'">'.$typ.'</option>';
$text .= '
</select>
</td>
<td>
<select multiple name="val_abtyp[]">';
foreach($config_reisearten as $typ)
$text .= '<option value="'.$typ.'">'.$typ.'</option>';
$text .= '
</select>
</td>
<td>
<select multiple name="val_nights[]">';
$tage = $admin_db->query("SELECT DATEDIFF(bis, von) AS diff FROM fahrten WHERE fahrt_id=".$config_current_fahrt_id)->fetch(0);
for($cnt = $tage['diff']; $cnt>=0; $cnt--)
$text .= '<option value="'.$cnt.'">'.$cnt.'</option>';
$text .= '
</select>
</td>
<td>
<select multiple name="val_essen[]">';
foreach($config_essen as $typ)
$text .= '<option value="'.$typ.'">'.$typ.'</option>';
$text .= '
</select>
</td>
<td>
<select name="val_paid">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_repaid">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_virgin">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_backstepped">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
</tr>
</table>
<input type="submit" name="submit">
</form>';
$query = "SELECT mehl, forname, sirname FROM bachelor"; public function getText() {
$where = array("fahrt_id = ".$config_current_fahrt_id); $studitypen = '';
$dsa = ""; foreach ($this->environment->oconfig['studitypen'] as $key => $typ) {
if(!isset($_REQUEST['submit'])){ $studitypen .= '<option value="' . $key . '">' . $typ . '</option>';
// not submitted
//$dsa = "nosubmit";
} else {
//$dsa = "submit";
if(isset($_REQUEST['check_studityp'])){
$tmp = "";
foreach($_REQUEST['val_studityp'] as $st){
$tmp.= "studityp = '".$st."' OR ";
} }
array_push($where,substr($tmp,0,-3)); $reisearten = '';
} foreach ($this->environment->oconfig['reisearten'] as $key => $typ) {
if(isset($_REQUEST['check_antyp'])){ $reisearten .= '<option value="' . $key . '">' . $typ . '</option>';
$tmp = "";
foreach($_REQUEST['val_antyp'] AS $st){
$tmp.= "antyp = '".$st."' OR ";
} }
array_push($where,substr($tmp,0,-3)); $essen = '';
} foreach ($this->environment->oconfig['essen'] as $key => $typ) {
if(isset($_REQUEST['check_abtyp'])){ $essen .= '<option value="' . $key . '">' . $typ . '</option>';
$tmp = "";
foreach($_REQUEST['val_abtyp'] AS $st){
$tmp.= "abtyp = '".$st."' OR ";
} }
array_push($where,substr($tmp,0,-3)); $maxtage = $this->fahrt->getLenTage();
$tage = '';
for ($cnt = $maxtage; $cnt >= 0; $cnt--)
$tage .= '<option value="' . $cnt . '">' . $cnt . '</option>';
return '
<script type="text/javascript">
$(function(){
$("#mform").submit(function(event){
event.preventDefault();
var str = $("#mform").serialize();
str += "&submit=submit&ajax=ajax";
$.post(document.url, str, function(data){
$("#mails").html(data);
}, "text");
$("#mails").fadeOut().delay(50).fadeIn();
});
});
</script>
<form method="POST" id="mform">
<label>
Trennzeichen
<select name="trenner">
<option>"; "</option>
<option value="br">Zeilenumbruch</option>
</select>
</label>
<table>
<tr>
<td>Studityp</td>
<td>Anreise</td>
<td>Abreise</td>
<!--<td>Nächte</td>-->
<td>Essen</td>
<td>Gezahlt</td>
<td>Rückgezahlt</td>
<td>18+</td>
<td>Zurückgetreten</td>
<td>Orga?</td>
<td>Liste</td>
</tr>
<tr>
<td><input type="checkbox" name="check_studityp" /></td>
<td><input type="checkbox" name="check_antyp" /></td>
<td><input type="checkbox" name="check_abtyp" /></td>
<!--<td><input type="checkbox" name="check_nights" /></td>-->
<td><input type="checkbox" name="check_essen" /></td>
<td><input type="checkbox" name="check_paid" /></td>
<td><input type="checkbox" name="check_repaid" /></td>
<td><input type="checkbox" name="check_virgin" /></td>
<td><input type="checkbox" name="check_backstepped" /></td>
<td><input type="checkbox" name="check_isOrga" /></td>
<td><input type="checkbox" name="check_list" /></td>
</tr>
<tr>
<td>
<select multiple name="val_studityp[]">' . $studitypen . '</select>
</td>
<td>
<select multiple name="val_antyp[]">' . $reisearten . '</select>
</td>
<td>
<select multiple name="val_abtyp[]">' . $reisearten . '</select>
</td>
<!--<td>
<select multiple name="val_nights[]">' . $tage . '</select>
</td>-->
<td>
<select multiple name="val_essen[]">' . $essen . '</select>
</td>
<td>
<select name="val_paid">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_repaid">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_virgin">
<option value="0">Ja</option>
<option value="1">Nein</option>
</select>
</td>
<td>
<select name="val_backstepped">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_isOrga">
<option value="1">Ja</option>
<option value="0">Nein</option>
</select>
</td>
<td>
<select name="val_list">
<option value="0">Anmeldeliste</option>
<option value="1">Warteliste</option>
<option value="2">War auf Warteliste</option>
</select>
</td>
</tr>
</table>
<input type="submit" name="submit">
</form>
<textarea style="height:300px; width:800px" id="mails">'.$this->transformContacts().'</textarea>';
} }
if(isset($_REQUEST['check_nights'])){
// TODO public function getAjax() {
return $this->transformContacts();
} }
if(isset($_REQUEST['check_essen'])){
$tmp = ""; private function transformContacts() {
foreach($_REQUEST['val_essen'] AS $st){ $trenner = "; ";
$tmp.= "essen = '".$st."' OR "; if (isset($_REQUEST['trenner'])) {
$trenner = $_REQUEST['trenner'];
if ($trenner == 'br') $trenner = "\n";
} }
array_push($where,substr($tmp,0,-3)); $accounts = array_map(function($mehl) {
} return $mehl['forname'] . " " . $mehl['sirname'] . " <" . $mehl['mehl'] . ">";
if(isset($_REQUEST['check_paid'])){ }, $this->mails);
if($_REQUEST['val_paid'] == 1) sort($accounts);
array_push($where,"paid IS NOT NULL"); return join($trenner, $accounts);
else
array_push($where,"paid IS NULL");
}
if(isset($_REQUEST['check_repaid'])){
if($_REQUEST['val_repaid'] == 1)
array_push($where,"repaid IS NOT NULL");
else
array_push($where,"repaid IS NULL");
}
if(isset($_REQUEST['check_virgin'])){
array_push($where,"virgin = ".$_REQUEST['val_virgin']);
}
if(isset($_REQUEST['check_backstepped'])){
if($_REQUEST['val_backstepped'] == 1)
array_push($where,"backstepped IS NOT NULL");
else
array_push($where,"backstepped IS NULL");
} }
private function buildQueryWhere() {
$where = ['fahrt_id' => $this->fahrt->getID()];
if (isset($_REQUEST['submit'])) {
if (isset($_REQUEST['check_'])) {
$where['wasOnWaitlist' . ($_REQUEST['val_wasOnWaitlist'] == 1 ? '[!]' : '')] = null;
}
if (isset($_REQUEST['check_studityp'])) {
$where['studityp'] = $_REQUEST['val_studityp'];
}
if (isset($_REQUEST['check_antyp'])) {
$where['antyp'] = $_REQUEST['val_antyp'];
}
if (isset($_REQUEST['check_abtyp'])) {
$where['abtyp'] = $_REQUEST['val_abtyp'];
}
if (isset($_REQUEST['check_nights'])) {
// TODO
}
if (isset($_REQUEST['check_essen'])) {
$where['essen'] = $_REQUEST['val_essen'];
}
if (isset($_REQUEST['check_paid'])) {
$where['paid' . ($_REQUEST['val_paid'] == 1 ? '[!]' : '')] = null;
}
if (isset($_REQUEST['check_repaid'])) {
$where['repaid' . ($_REQUEST['val_repaid'] == 1 ? '[!]' : '')] = null;
}
if (isset($_REQUEST['check_virgin'])) {
$where['virgin'] = $_REQUEST['val_virgin'];
}
if (isset($_REQUEST['check_backstepped'])) {
$where['backstepped' . ($_REQUEST['val_backstepped'] == 1 ? '[!]' : '')] = null;
}
if (isset($_REQUEST['check_isOrga'])) {
$where['isOrga'] = $_REQUEST['val_isOrga'];
}
if (isset($_REQUEST['check_list'])) {
if($_REQUEST['val_list'] == 0) { // anmeldeliste
$where['OR'] = ['on_waitlist' => 0];
}else if($_REQUEST['val_list'] == 1){ // waitlist
$where['OR'] = ['on_waitlist' => 1];
}else if($_REQUEST['val_list'] == 2){ // was on waitlist
$where['AND'] = [
'on_waitlist' => 0,
'transferred[!]' => null
];
}
}
}else{
$where['OR'] = ['on_waitlist' => 0,
'AND' => [
'transferred[!]' => null,
'on_waitlist' => 1
]];
}
return ['AND' => $where];
}
} }
if(count($where)>0){
$query .= " WHERE ";
foreach($where AS $w)
$query .= "(".$w.") AND ";
$query = substr($query,0,-4); // cut last AND
}
//$config_verbose_level = 4;
$tmp = $admin_db->query($query.";");
if($tmp)
$mails = $tmp->fetchAll(PDO::FETCH_ASSOC);
else{
comm_admin_verbose(3,$admin_db->error());
$mails = array();
}
$text .= '<textarea style="height:300px; width:800px" id="mails">'.$dsa;
foreach($mails as $mehl){
$text .= $mehl['forname']." ".$mehl['sirname']." <".$mehl['mehl'].">; ";
$ajax .= $mehl['forname']." ".$mehl['sirname']." <".$mehl['mehl'].">; ";
}
$text .= '</textarea>';
comm_admin_verbose(3,$_REQUEST);
?>
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 8/9/14
* Time: 4:07 PM
*/
global $headers, $text, $admin_db, $config_current_fahrt_id, $config_admin_verbose_level, $config_verbose_level;
$config_admin_verbose_level = 0;
$config_verbose_level = 0;
if(isset($_POST['note-content'])){ class AdminNotesPage extends AdminPage {
comm_admin_verbose(2,"received submit");
$cont = $_REQUEST['note-content'];
if($admin_db->has("notes", array("fahrt_id"=>$config_current_fahrt_id)))
$admin_db->update("notes",array("note"=>$cont),array("fahrt_id"=>$config_current_fahrt_id));
else
$admin_db->insert("notes",array("note"=>$cont, "fahrt_id"=>$config_current_fahrt_id));
}
$content = $admin_db->get("notes", "note", array("fahrt_id"=>$config_current_fahrt_id)); public function __construct($base) {
parent::__construct($base);
$headers .="<!-- wysihtml5 parser rules --> if (isset($_POST['note-content'])) {
<script src=\"../view/js/wysihtml5-0.3.0_rc2.min.js\"></script> $cont = $_REQUEST['note-content'];
<!-- Library --> if ($this->environment->database->has('notes', ['fahrt_id' => $this->fahrt->getID()]))
<script src=\"../view/js/wysihtml5-advanced.js\"></script> $this->environment->database->update('notes', ['note' => $cont], ['fahrt_id' => $this->fahrt->getID()]);
else
$this->environment->database->insert('notes', ['note' => $cont, 'fahrt_id' => $this->fahrt->getID()]);
}
<link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/editor.css' /> $this->content = $this->environment->database->get('notes', 'note', ['fahrt_id' => $this->fahrt->getID()]);
<link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/stylesheet.css' /> }
<style type='text/css'>
body {
/*width: 810px;*/
min-height: 100%;
/*margin: 0 auto;*/
padding-top: 40px !important;
padding-left: 10px !important;
}
#admin-content{
height: 100% !important;
}
</style>";
$text .= ' public function getHeaders() {
<div id="wysihtml5-editor-toolbar"> return "<!-- wysihtml5 parser rules -->
<header> <script src=\"../view/js/wysihtml5-0.3.0_rc2.min.js\"></script>
<ul class="commands"> <!-- Library -->
<li data-wysihtml5-command="bold" title="Make text bold (CTRL + B)" class="command"></li> <script src=\"../view/js/wysihtml5-advanced.js\"></script>
<li data-wysihtml5-command="italic" title="Make text italic (CTRL + I)" class="command"></li>
<li data-wysihtml5-command="insertUnorderedList" title="Insert an unordered list" class="command"></li>
<li data-wysihtml5-command="insertOrderedList" title="Insert an ordered list" class="command"></li>
<li data-wysihtml5-command="createLink" title="Insert a link" class="command"></li>
<li data-wysihtml5-command="insertImage" title="Insert an image" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1" title="Insert headline 1" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" title="Insert headline 2" class="command"></li>
<li data-wysihtml5-command-group="foreColor" class="fore-color" title="Color the selected text" class="command">
<ul>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue"></li>
</ul>
</li>
<li data-wysihtml5-command="insertSpeech" title="Insert speech" class="command"></li>
<li data-wysihtml5-action="change_view" title="Show HTML" class="action"></li>
</ul>
</header>
<div data-wysihtml5-dialog="createLink" style="display: none;">
<label>
Link:
<input data-wysihtml5-dialog-field="href" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
<div data-wysihtml5-dialog="insertImage" style="display: none;"> <link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/editor.css' />
<label> <link type='text/css' rel='stylesheet' href='../view/css/wysihtml5/stylesheet.css' />
Image: <style type='text/css'>
<input data-wysihtml5-dialog-field="src" value="http://"> body {
</label> /*width: 810px;*/
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a> min-height: 100%;
</div> /*margin: 0 auto;*/
</div> padding-top: 40px !important;
padding-left: 10px !important;
}
#admin-content{
height: 100% !important;
}
</style>";
}
<section><form method="POST" style="height:100%"> <input type="submit" name="submit" value="submit" class="submit-button" /><textarea name="note-content" id="wysihtml5-editor" spellcheck="false" wrap="off" placeholder="Enter your text ...">'.$content.'</textarea></form></section> public function getHeader() {
return '';
}
<script> public function getFooter() {
var editor = new wysihtml5.Editor("wysihtml5-editor", { return '';
toolbar: "wysihtml5-editor-toolbar", }
stylesheets: ["../view/css/wysihtml5/editor.css"],
parserRules: wysihtml5ParserRules
});
editor.on("load", function() { public function getText() {
var composer = editor.composer, return '
h1 = editor.composer.element.querySelector("h1"); <div id="wysihtml5-editor-toolbar">
if (h1) { <header>
composer.selection.selectNode(h1); <ul class="commands">
} <li data-wysihtml5-command="bold" title="Make text bold (CTRL + B)" class="command"></li>
}); <li data-wysihtml5-command="italic" title="Make text italic (CTRL + I)" class="command"></li>
</script>'; <li data-wysihtml5-command="insertUnorderedList" title="Insert an unordered list" class="command"></li>
<li data-wysihtml5-command="insertOrderedList" title="Insert an ordered list" class="command"></li>
<li data-wysihtml5-command="createLink" title="Insert a link" class="command"></li>
<li data-wysihtml5-command="insertImage" title="Insert an image" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1" title="Insert headline 1" class="command"></li>
<li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" title="Insert headline 2" class="command"></li>
<li data-wysihtml5-command-group="foreColor" class="fore-color command" title="Color the selected text">
<ul>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy"></li>
<li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue"></li>
</ul>
</li>
<li data-wysihtml5-command="insertSpeech" title="Insert speech" class="command"></li>
<li data-wysihtml5-action="change_view" title="Show HTML" class="action"></li>
</ul>
</header>
<div data-wysihtml5-dialog="createLink" style="display: none;">
<label>
Link:
<input data-wysihtml5-dialog-field="href" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
<div data-wysihtml5-dialog="insertImage" style="display: none;">
<label>
Image:
<input data-wysihtml5-dialog-field="src" value="http://">
</label>
<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>
</div>
</div>
<section><form method="POST" style="height:100%">
<input type="submit" name="submit" value="submit" class="submit-button" />
<textarea name="note-content" id="wysihtml5-editor" spellcheck="false" wrap="off" placeholder="Enter your text ...">' .
$this->content .
'</textarea></form></section>
<script>
var editor = new wysihtml5.Editor("wysihtml5-editor", {
toolbar: "wysihtml5-editor-toolbar",
stylesheets: ["../view/css/wysihtml5/editor.css"],
parserRules: wysihtml5ParserRules
});
editor.on("load", function() {
var composer = editor.composer,
h1 = editor.composer.element.querySelector("h1");
if (h1) {
composer.selection.selectNode(h1);
}
});
</script>';
}
public function getAjax() {
return '';
}
}
\ No newline at end of file
<?php <?php
/**
* Created by PhpStorm.
* User: tim
* Date: 9/17/14
* Time: 8:04 PM
*/
global $text, $headers, $admin_db, $config_current_fahrt_id, $ajax, $config_reisearten, $config_reisearten_o, $config_studitypen_o, $config_admin_verbose_level, $config_verbose_level, $config_essen;
$config_admin_verbose_level = 0;
$config_verbose_level = 0;
$text .= "<h1>Übersichtsseite</h1>";
$mitfahrer['gesam'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id]]);
$mitfahrer['gesaa'] = $admin_db->count("bachelor", ["fahrt_id" => $config_current_fahrt_id]);
$mitfahrer['erste'] = $admin_db->query("SELECT date_format(anday, '%j') as anday, COUNT(anday) as anday_cnt FROM bachelor WHERE backstepped is null and fahrt_id=".$config_current_fahrt_id." GROUP BY anday ORDER BY anday ASC LIMIT 1")->fetchAll();
$mitfahrer['zweit'] = $admin_db->query("SELECT date_format(abday, '%j') as abday, COUNT(abday) as abday_cnt FROM bachelor WHERE backstepped is null and fahrt_id=".$config_current_fahrt_id." GROUP BY abday ORDER BY abday DESC LIMIT 1")->fetchAll();
$mitfahrer['erste'] = isset($mitfahrer['erste'][0]) ? $mitfahrer['erste'][0]['anday_cnt'] : 0;
$mitfahrer['zweit'] = isset($mitfahrer['zweit'][0]) ? $mitfahrer['zweit'][0]['abday_cnt'] : 0;;
$mitfahrer['veget'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"essen[!]" => $config_essen[0]]]);
$mitfahrer['backs'] = $admin_db->count("bachelor", ["AND"=>
["backstepped[!]" => NULL,
"fahrt_id" => $config_current_fahrt_id]]);
$mitfahrer['treff'] = $admin_db->count("bachelor", ["AND" =>
["antyp" => $config_reisearten_o["BUSBAHN"],
"backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id]]);
$mitfahrer['ersti'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"studityp" => $config_studitypen_o["ERSTI"]]]);
$mitfahrer['tutti'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"studityp" => $config_studitypen_o["TUTTI"]]]);
$mitfahrer['hoers'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id],
"LIKE"=>["studityp" => $config_studitypen_o["HOERS"]]]);
$mitfahrer['virgi'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"virgin" => 1]]);
$warte['ntran'] = $admin_db->count("waitlist", ["AND"=>
["transferred" => NULL,
"fahrt_id" => $config_current_fahrt_id]]);
$warte['gesam'] = $admin_db->count("waitlist", ["fahrt_id" => $config_current_fahrt_id]);
$money['erhalten'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"paid[!]" => NULL]]);
$money['aus'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"paid" => NULL]]);
$money['gezahlt'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"repaid[!]" => NULL]]);
$money['ausstehend'] = $admin_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $config_current_fahrt_id,
"repaid" => NULL]]);
$text .= "<div style='float:left; margin-left: 15px'><h2>Mitfahrer</h2>
<ul class='list-nodeco'>
<li>Gesamt: ".$mitfahrer['gesam']." (".$mitfahrer['gesaa'].")</li>
<ul>
<li>Erste Nacht: ".$mitfahrer['erste']."</li>
<li>Letzte Nacht: ".$mitfahrer['zweit']."</li>
<li>Nicht-Allesesser: ".$mitfahrer['veget']."</li>
<li>Zurückgetreten: ".$mitfahrer['backs']."</li>
<li>Personen am Treffpunkt: ".$mitfahrer['treff']."</li>
</ul>
<li>Warteliste:</li>
<ul>
<li>Noch wartend: ".$warte['ntran']."</li>
<li>Übertragen: ".($warte['gesam']-$warte['ntran'])."</li>
<li>Gesamt: ".$warte['gesam']."</li>
</ul>
<li>Verteilung</li>
<ul>
<li>Jungfrauen: ".$mitfahrer['virgi']."</li>
<li>Erstis: ".$mitfahrer['ersti']."</li>
<li>Hörstis: ".$mitfahrer['hoers']."</li>
<li>Tutti: ".$mitfahrer['tutti']."</li>
<li>= Anteil Erstis: ".round(($mitfahrer['ersti']/((($mitfahrer['ersti']+$mitfahrer['hoers']+$mitfahrer['tutti']) <=0) ? (($mitfahrer['ersti'] <= 0) ? 1 : $mitfahrer['ersti']) : ($mitfahrer['ersti']+$mitfahrer['hoers']+$mitfahrer['tutti'])))*100,2)."%</li>
</ul>
</ul></div>";
$text .= "<div style='float:left; margin-left: 15px'><h2>Zahlungen</h2>
<ul>
<li>Zahlungen</li>
<ul>
<li>Erhalten: ".$money['erhalten']."</li>
<li>Ausstehende Zahlungen: ".$money['aus']."</li>
<li>Ausgezahlt: ".$money['gezahlt']."</li>
<li>Ausstehende Rückzahlungen: ".$money['ausstehend']."</li>
</ul>
<!--li>Einnahmen</li>
<ul>
<li>Soll:</li>
<li>Ist:</li>
<li>Differenz:</li>
</ul-->
</ul></div>";
$text .= "<p style='clear:both'></p>";
class AdminOverviewPage extends AdminPage {
private $data;
public function __construct($base) {
parent::__construct($base);
$fid = $this->fahrt->getID();
$db = $this->environment->database;
// to use in OR
$notwaiting = ['on_waitlist' => 0,
'AND' => [
'transferred[!]' => null,
'on_waitlist' => 1
]];
$notwaitingQ = '(on_waitlist = 0 OR (transferred IS NOT NULL AND on_waitlist = 1))';
$baseW = ['fahrt_id' => $fid, 'OR'=>$notwaiting, 'backstepped'=>null];
$naechte = [
'erste' => $db->query("SELECT date_format(anday, '%j') as anday, COUNT(anday) as anday_cnt FROM bachelor WHERE fahrt_id = ".$fid." AND ".$notwaitingQ." AND backstepped IS NULL GROUP BY anday ORDER BY anday ASC LIMIT 1")->fetchAll(),
'zweite' => $db->query("SELECT date_format(abday, '%j') as abday, COUNT(anday) as abday_cnt FROM bachelor WHERE fahrt_id = ".$fid." AND ".$notwaitingQ." AND backstepped IS NULL GROUP BY abday ORDER BY anday ASC LIMIT 1")->fetchAll()
];
$this->data = [
'mitfahrer' => [
'gesamt' => $this->fahrt->getNumTakenSpots(),
'gesamt_all' => $db->count('bachelor', [
'AND' => ['fahrt_id' => $fid, 'OR' => $notwaiting]]),
'erste' => isset($naechte['erste'][0]) ? $naechte['erste'][0]['anday_cnt'] : 0,
'zweite' => isset($naechte['zweite'][0]) ? $naechte['zweite'][0]['abday_cnt'] : 0,
'vege' => $db->count('bachelor', ['AND' =>
['essen' => 'VEGE', 'fahrt_id'=>$fid, 'backstepped'=>null, 'OR' => $notwaiting]]),
'vega' => $db->count('bachelor', ['AND' =>
['essen' => 'VEGA', 'fahrt_id'=>$fid, 'backstepped'=>null, 'OR' => $notwaiting]]),
'backstepped' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'backstepped[!]' => null]]),
'treffpunkt' => $db->count('bachelor', ['AND' => array_merge($baseW, ['antyp' => 'BUSBAHN'])]),
'berstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'ERSTI_B'])]),
'merstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'ERSTI_M'])]),
'erstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'ERSTI'])]),
'orgas' => $db->count('bachelor', ['AND' => array_merge($baseW, ['isOrga' => 1])]),
'alumni' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'ALUMN'])]),
'mentor' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'MENTO'])]),
'hoerstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'HOERS'])]), # deprecated
'bhoerstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'HOERS_B'])]),
'mhoerstis' => $db->count('bachelor', ['AND' => array_merge($baseW, ['studityp' => 'HOERS_M'])]),
'virgins' => $db->count('bachelor', ['AND' => array_merge($baseW, ['virgin' => 1])])
],
'warte' => [
'transferred' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'transferred[!]' => null, 'on_waitlist' => 1]]),
'waiting' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'transferred' => null, 'on_waitlist' => 1]]),
'wl_al' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'transferred' => null, 'on_waitlist' => 1, 'studityp' => 'ALUMN']]),
'wl' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'transferred' => null, 'on_waitlist' => 1, 'studityp[!]' => 'ALUMN']]),
'on_waitlist' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'on_waitlist' => 1]])
],
'money' => [
'in_erhalten' => $db->count('bachelor', ['AND' => ['fahrt_id' => $fid, 'paid[!]' => null]]),
'in_ausstehend' => $db->count('bachelor', ['AND' => array_merge($baseW, ['paid' => null])]),
'out_erhalten' => $db->count('bachelor', ['AND' => array_merge($baseW, ['repaid[!]' => null])]),
'out_ausstehend' => $db->count('bachelor', ['AND' => array_merge($baseW, ['repaid' => null])]),
]
];
$this->data['mitfahrer']['erstis'] = $this->data['mitfahrer']['merstis']+$this->data['mitfahrer']['berstis']+$this->data['mitfahrer']['erstis'];
$this->data['ratio'] = ['sum' => ($this->data['mitfahrer']['mentor']+$this->data['mitfahrer']['alumni']+$this->data['mitfahrer']['erstis']+$this->data['mitfahrer']['hoerstis'])];
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioErsti'] = round($this->data['mitfahrer']['erstis']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioErsti'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioBErsti'] = round($this->data['mitfahrer']['berstis']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioBErsti'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioMErsti'] = round($this->data['mitfahrer']['merstis']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioMErsti'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioHoerst'] = round($this->data['mitfahrer']['hoerstis']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioHoerst'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioHoerstMentoren'] = round(($this->data['mitfahrer']['hoerstis']+$this->data['mitfahrer']['mentor'])/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioHoerstMentoren'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioMento'] = round($this->data['mitfahrer']['mentor']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioMento'] = round(100, 2);
if ($this->data['ratio']['sum'] > 0)
$this->data['ratio']['ratioAlumn'] = round($this->data['mitfahrer']['alumni']/$this->data['ratio']['sum']*100, 2);
else
$this->data['ratio']['ratioAlumn'] = round(100, 2);
}
public function getHeaders() {
return '';
}
public function getHeader() {
return '';
}
public function getFooter() {
return '';
}
public function getText() {
return '<h1>Übersichtsseite</h1>
<div style="float:left; margin-left: 15px">
<h2>Mitfahrende</h2>
<ul class="list-nodeco">
<li>Gesamt: '.$this->data['mitfahrer']['gesamt'].' ('.$this->data['mitfahrer']['gesamt_all'].')</li>
<ul>
<li>Erste Nacht: '.$this->data['mitfahrer']['erste'].'</li>
<li>Letzte Nacht: '.$this->data['mitfahrer']['zweite'].'</li>
<li>Nicht-Allesesser: '.$this->data['mitfahrer']['vege'].' (vegetarisch), '.$this->data['mitfahrer']['vega'].' (vegan)</li>
<li>Zurückgetreten: '.$this->data['mitfahrer']['backstepped'].'</li>
<li>Personen am Treffpunkt: '.$this->data['mitfahrer']['treffpunkt'].'</li>
</ul>
<li>Warteliste:</li>
<ul>
<li>Noch wartend: '.$this->data['warte']['waiting'].'</li>
<li>= Anteil Alumnis: '.$this->data['warte']['wl_al'].'</li>
<li>= Anteil Rest: '.$this->data['warte']['wl'].'</li>
<li>Übertragen: '.$this->data['warte']['transferred'].'</li>
<li>Gesamt: '.$this->data['warte']['on_waitlist'].'</li>
</ul>
<li>Verteilung:</li>
<ul>
<li>Jungfrauen: '.$this->data['mitfahrer']['virgins'].'</li>
<li>Erstis: '.$this->data['mitfahrer']['erstis'].'</li>
<li>Alumnis: '.$this->data['mitfahrer']['alumni'].'</li>
<li>Hörstis: '.$this->data['mitfahrer']['hoerstis'].'</li>
<li>MentorIn: '.$this->data['mitfahrer']['mentor'].'</li>
<li>= Anteil Hörstis: '.$this->data['ratio']['ratioHoerst'].'%</li>
<li>= Anteil Mentoren: '.$this->data['ratio']['ratioMento'].'%</li>
<li>= Anteil Alumnis: '.$this->data['ratio']['ratioAlumn'].'%</li>
<li>= Anteil Hörstis + Mentoren: '.$this->data['ratio']['ratioHoerstMentoren'].'%</li>
<li>= Anteil Erstis: '.$this->data['ratio']['ratioErsti'].'%</li>
<li>=> Anteil Bachelor Erstis: '.$this->data['ratio']['ratioBErsti'].'%</li>
<li>=> Anteil Master Erstis: '.$this->data['ratio']['ratioMErsti'].'%</li>
</ul>
<li>Orgas: '.$this->data['mitfahrer']['orgas'].'</li>
</ul>
</div>
<div style="float:left; margin-left: 15px"><h2>Zahlungen</h2>
<ul>
<li>Zahlungen</li>
<ul>
<li>Erhalten: '.$this->data['money']['in_erhalten'].'</li>
<li>Ausstehende Zahlungen: '.$this->data['money']['in_ausstehend'].'</li>
<li>Ausgezahlt: '.$this->data['money']['out_erhalten'].'</li>
<li>Ausstehende Rückzahlungen: '.$this->data['money']['out_ausstehend'].'</li>
</ul>
</ul>
</div>
<p style="clear:both"></p>';
}
public function getAjax() {
return '';
}
}
/* Vorlage: /* Vorlage:
* *
......
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 9/25/14
* Time: 9:24 PM
*/
global $text, $headers, $admin_db, $config_userfile, $config_current_fahrt_file, $config_current_fahrt_id, $ajax, $config_reisearten, $config_reisearten_0, $config_studitypen_o, $config_admin_verbose_level, $config_verbose_level, $config_essen;
//$config_admin_verbose_level = 4;
//$config_verbose_level = 4;
$text .= "<h1>SuperAdmin Panel</h1>";
// FORM submit stuff
if(isset($_REQUEST['us_submit'])){
if(!isset($_REQUEST['users'])) $text.= "something wrong... wanted to submit users";
else {
$tmp = file_put_contents($config_userfile, $_REQUEST['users']);
$text .= "updated userfile!<br />
written to file '".$config_userfile."' with exit code: ". $tmp ."<br />
if no code shown, then false -> check if file has chmod rw-rw-rw-!";
}
}
if(isset($_REQUEST['nf_submit'])){
if(isset($_REQUEST['resubmit'])){}
else{
$admin_db->insert("fahrten", ["titel"=>"neu", "map_pin" => "52.42951196033782 13.530490995971718", "von"=>date('Y-m-d'), "bis" => date('Y-m-d')]);
$tmp = $admin_db->max("fahrten", "fahrt_id");
$text .= "neue Fahrt angelegt mit ID: ".$tmp. "<br/>
Zum Bearbeiten ID ändern!";
}
}
if(isset($_REQUEST['id_submit'])){
$tmp = file_put_contents($config_current_fahrt_file, $_REQUEST['fid']);
$text .= "changed \$config_current_fahrt_id to ".$_REQUEST['fid'] . "<br />
written to file '".$config_current_fahrt_file."' with exit code: ". $tmp ."<br />
if no code shown, then false -> check if file has chmod rw-rw-rw-!";
}
// VIEW stuff:
if(file_exists($config_userfile))
$usas = file_get_contents($config_userfile);
$text .= '<h2>Nutzer bearbeiten</h2>
ACHTUNG: Tippfehler können Systemfunktionalität beeinträchtigen! <i>Format: {N|S}⎵USERNAME⎵PASSWORD⎵RANDOMSTUFF</i><br />
<i>N = Organisator der Fahrt; S = Superadmin (sieht auch diese Seite)</i><br />
Captain Obvious: "Nutzername darf kein Leerzeichen enthalten!"<br />
<a href="../passwd/index.html">Passwort-gen tool</a> (an Organisator weiterleiten, der schickt dann Passwort hash zurück)<br />
<form method="POST">
<textarea rows="8" cols="130" name="users" id="users">'.$usas.'</textarea><br />
<input type="submit" name="us_submit" id="us_submit" value="us_submit" />
</form> ';
$text .= '<h2>Neue Fahrt anlegen</h2>
<form method="POST" target="?resubmit=not">
<input type="submit" name="nf_submit" value="nf_submit" id="nf_submit" />
</form> ';
$text .= '<!--h2>Fahrt löschen</h2>
ACHTUNG: löscht ohne Nachfrage ALLE mit dieser Fahrt verbunden Daten!<br /-->';
$fids = $admin_db->select("fahrten","fahrt_id");
$config_current_fahrt_id = getCFID();
$text .= '<h2>Aktuelle Fahrt ID</h2>
Wählt die Fahrt, die über das Adminpanel bearbeitet/verwaltet werden kann.<br />
<form method="POST" >
<label>Neue ID wählen (aktiv: '.$config_current_fahrt_id.'):</label>
<select name="fid" id="fid">';
foreach($fids as $fid)
$text .= '<option value="'.$fid.'">'.$fid.'</option>';
$text .= '
</select>
<input type="submit" name="id_submit" value="id_submit" id="id_submit" />
</form>';
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 10/2/14
* Time: 7:53 PM
*/
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors",1);
global $text, $headers, $admin_db, $config_current_fahrt_id, $ajax, $config_studitypen, $config_essen, $config_reisearten, $config_essen_o, $config_reisearten_o, $config_baseurl;
require_once("../frameworks/commons.php");
// deletes the entry completely
if(isset($_REQUEST['delete'])){
$admin_db->delete("bachelor", ["bachelor_id"=> $_REQUEST['delete']]);
}
// moves entry to final list
if(isset($_REQUEST['move'])){
$transdata = $admin_db->get("waitlist", [
"fahrt_id",
"anm_time",
"forname",
"sirname",
"mehl",
"pseudo",
"antyp",
"abtyp",
"anday",
"abday",
"comment",
"studityp",
"virgin",
"public",
"essen"],
["AND" => [
"waitlist_id" => $_REQUEST['move'],
"fahrt_id" => $config_current_fahrt_id
]]
);
$tinsert = $tupdate = NULL;
if($transdata){
$transdata['bachelor_id'] = $_REQUEST['move'];
$duplicate = FALSE;
if($admin_db->has("bachelor", ["AND" =>[
"bachelor_id" => $_REQUEST['move'],
"fahrt_id" => $config_current_fahrt_id]]))
$duplicate = TRUE;
else{
$tinsert = $admin_db->insert("bachelor", $transdata);
$tupdate = $admin_db->update("waitlist", ["transferred" => time()], ["AND" => [
"waitlist_id" => $_REQUEST['move'],
"fahrt_id" => $config_current_fahrt_id
]]);
}
}
if(!$transdata || is_null($tinsert) || is_null($tupdate) || $duplicate)
$text .= '<div style="color:red;">Some error at transfer...</div>';
else{
$text .= '<div style="color:green;">Transfer seems successfull, sending automatic mail now to '.$transdata['mehl'].'</div>';
// === notify success ===
$from = $admin_db->get("fahrten", ["kontakt","leiter", "paydeadline", "payinfo", "wikilink"],
["fahrt_id"=>$transdata['fahrt_id']]);
foreach ([ "lang_waittoregmail", "lang_payinfomail"] as $mail_lang) {
$mail = comm_get_lang($mail_lang, [
"{{url}}" => $config_baseurl . "status.php?hash=" . $_REQUEST['move'],
"{{organisator}}" => $from['leiter'],
"{{paydeadline}}" => $from['paydeadline'],
"{{payinfo}}" => $from['payinfo'],
"{{wikilink}}" => $from['wikilink']]);
$bcc = $mail_lang === "lang_payinfomail" ? $from['kontakt'] : NULL;
comm_send_mail($admin_db, $transdata['mehl'], $mail, $from['kontakt'], $bcc);
}
}
}
$headers =<<<END
<link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery.dataTables.1.10.9.min.js"></script>
END;
$text .= "<h1>Warteliste</h1>";
$columns = array(
"waitlist_id",
"fahrt_id",
"anm_time",
"forname",
"sirname",
"mehl",
"pseudo",
"antyp",
"abtyp",
"anday",
"abday",
"comment",
"studityp",
"virgin",
"essen",
"transferred"
);
$columnFunctions = array(
"Anmelde-ID" => function($person) { return $person["waitlist_id"]; }
//,"FahrtID" => function($person) { return $person["fahrt_id"]; }
,"Anmeldung" => function($person) { return date("d.m.Y", $person['anm_time']); },
"Name" => function($person) { return "<a href='mailto:".$person["mehl"]."?subject=FS-Fahrt'>".$person["forname"]." ".$person["sirname"]." (".$person["pseudo"].")</a>"; },
"Anreisetyp" => function($person) { global $config_reisearten_o; return array_search($person["antyp"], $config_reisearten_o); },
"Abreisetyp" => function($person) { global $config_reisearten_o; return array_search($person["abtyp"], $config_reisearten_o); },
"Anreisetag" => function($person) { return comm_from_mysqlDate( $person["anday"]); },
"Abreisetag" => function($person) { return comm_from_mysqlDate( $person["abday"]); },
"Kommentar" => function($person) { return $person["comment"]; },
"StudiTyp" => function($person) { return $person["studityp"]; },
"Essen" => function($person) { global $config_essen_o; return array_search($person["essen"], $config_essen_o); },
"18+" => function($person) { return (($person["virgin"]==0) ? "Ja" : "Nein"); },
"Uebertragen" => function($person) {
if(!is_numeric($person["transferred"]))
return "<a href='?page=wl&move=".$person["waitlist_id"]."'>&#8614; übertragen</a>";
else
return date("d.m.Y", $person['transferred']);
}
);
$text .= "Toggle Column: ";
$tcnt = 0;
foreach($columnFunctions as $key => $value){
$text .= '<a class="toggle-vis" data-column="'.$tcnt.'">'.$key.'</a> - ';
$tcnt++;
}
$text .= "<br />";
$text .= '
<table id="mlist" class="compact hover">
<thead>
<tr>';
foreach($columnFunctions as $key => $value)
{
$text .= "<th>".$key."</th>";
}
$text .= '
</tr>
</thead>
<tbody>';
$people = $admin_db->select('waitlist',$columns, array("fahrt_id"=>$config_current_fahrt_id));
foreach($people as $person) {
$text .= "<tr>";
foreach($columnFunctions as $key => $value){
$text .= "<td class='".$key.((strpos($columnFunctions['Uebertragen']($person), "href")>0) ? '' : ' list-backstepped')."'>".$value($person)."</td>";
}
$text .= "</tr>";
}
$buttoncol = 11;
$text .=<<<END
</tbody>
</table>
<script type='text/javascript'>
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"link-pre": function ( a ) {
var tmp = a.match(/<a [^>]+>([^<]+)<\/a>/);
if(tmp)
return a.match(/<a [^>]+>([^<]+)<\/a>/)[1];
else
return a;
}
,
"dedate-pre": function(a){
var tmp = a.split(".");
console.log(tmp[2]+tmp[1]+tmp[0]);
if(tmp.length>2)
return (tmp[2]+tmp[1]+tmp[0]);
return a;
}
} );
var ltab;
$(document).ready(function(){
ltab = $('#mlist').DataTable({
"columnDefs": [
{ type: 'dedate', targets: [1,5,6]},
{ type: 'link', targets: [2, 11] }
],
"order": [[ 11, "desc" ], [1,"asc" ]],
"paging": false
});
$('a.toggle-vis').click( function (e) {
e.preventDefault();
// Get the column API object
var column = ltab.column( $(this).attr('data-column') );
// Toggle the visibility
column.visible( ! column.visible() );
} );
});
</script>
END;
...@@ -14,17 +14,18 @@ date_default_timezone_set("Europe/Berlin"); ...@@ -14,17 +14,18 @@ date_default_timezone_set("Europe/Berlin");
require("config.local.php"); require("config.local.php");
// ========= DONT TOUCH ANYTHING DOWN HERE!!! ========================================================================== // ========= DONT TOUCH ANYTHING DOWN HERE!!! ==========================================================================
$config_invalidCharsRegEx = "/^[^0-9<>!?.::,#*@^_$\\\"'%;()&+]{2,50}$/"; // d©_©b
$config_studitypen_o = array( $config_studitypen_o = array(
"ERSTI" => "Ersti", // 0 "ERSTI_B" => "Bachelor Ersti",
//"Wechsli", // 1 - woanders/was anderes studiert, jetzt hier "ERSTI_M" => "Master Ersti",
//"MasterErsti", // 2 "HOERS" => "Hörsti",
"HOERS" => "Hoersti", // 3 - länger an der HU "HOERS_B" => "Bachelor Hörsti",
"TUTTI" => "Tutor" // 4 - Tutor "HOERS_M" => "Master Hörsti",
//"Fachi" // 5 - FS Ini "MENTO" => "MentorIn",
"ALUMN" => "Alumni"
); );
$config_studitypen = array_values($config_studitypen_o); $config_studitypen = array_values($config_studitypen_o);
...@@ -32,19 +33,18 @@ $config_essen_o = array( ...@@ -32,19 +33,18 @@ $config_essen_o = array(
"ALLES" => "Alles", "ALLES" => "Alles",
"VEGE" => "Vegetarisch", "VEGE" => "Vegetarisch",
"VEGA" => "Vegan" "VEGA" => "Vegan"
//,"Frutarisch",
//"Grießbrei",
//"Carnivore",
//"Extrawurst"
); );
$config_essen = array_values($config_essen_o); $config_essen = array_values($config_essen_o);
$config_reisearten_o_short = array(
"BUSBAHN" => "Bus/Bahn",
"RAD" => "Fahrrad",
"INDIVIDUELL" => "Kamel/Individuell"
);
$config_reisearten_o = array( $config_reisearten_o = array(
"BUSBAHN"=>"gemeinsam mit Bus/Bahn", "BUSBAHN" => "gemeinsam mit Bus/Bahn",
"RAD"=>"gemeinsam mit Rad", "RAD" => "gemeinsam mit Rad",
"AUTO"=>"selbst mit Auto", "INDIVIDUELL" => "Kamel/Individuell"
"INDIVIDUELL"=>"Kamel/Individuell"
//,"mit Kamel"
); );
$config_reisearten = array_values($config_reisearten_o); $config_reisearten = array_values($config_reisearten_o);
...@@ -54,31 +54,8 @@ $config_reisearten_destroyed = array( ...@@ -54,31 +54,8 @@ $config_reisearten_destroyed = array(
"mit Schlauchboot" "mit Schlauchboot"
); );
$config_userfile = $config_basepath . "/passwd/users.txt"; // relative to configfile
/* // deprecated: $config_current_fahrt_file = $config_basepath . "/config_current_fahrt_id";
$config_admins = array(
// username => password
"tim" => '{SHA-256}8013a101f26fd8dcc8c40d0eb1dcb513$c3a97d44e67564ed79a60fa0de6ea4193bb18932a8d08b5e8d664bd14b32a4f5', // broetchen
"manu" => '{SHA-256}12c9b021c42741545f9f01e2afd67aa2$7112be28c0c11f987de4401798a2ba041e518bb3f22bcb8cf4f3bf3f590b65b9' // mepmepmep
,"nosa" => "{SHA-256}10be99b14c2627e8691134db9bacf456$0a7ce2973159cb2f3c971a62944fb865e5110780503513da6f6f1e16326f18a1" // murmeltier
);
$config_superadmins = array(
"tim", "manu"
);
*/
$config_userfile = $config_basepath."/passwd/users.txt"; // relative to configfile
$config_current_fahrt_file = $config_basepath."/config_current_fahrt_id";
$config_mailtag = "[FS-Fahrt] - "; $config_mailtag = "[FS-Fahrt] - ";
$config_current_fahrt_id = getCFID();
function getCFID(){
global $config_current_fahrt_file;
if(file_exists( $config_current_fahrt_file ))
$tmp = file_get_contents($config_current_fahrt_file);
if(is_numeric($tmp))
return $tmp;
return 1;
}
<?php <?php
$config_verbose_level = 0; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose, 4 = with sql if (true) {
$config_admin_verbose_level = 0; ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
$config_databse_debug = false;
// URL where site is hosted with trailing slash // URL where site is hosted with trailing slash
$config_baseurl = "http://localhost/fsfahrt"; $config_baseurl = "http://localhost/fsfahrt/registration-system/";
// absolute path to doc root withOUT trailing slash // absolute path to doc root withOUT trailing slash
$config_basepath = __DIR__; $config_basepath = __DIR__;
$config_impressum = 'https://fachschaft.informatik.hu-berlin.de/index.php/Fachschaft_Informatik:Impressum';
// database config // database config
$config_db = [ $config_db = [
"name" => "fsfahrt", // name of DB "name" => "fsfahrt", // name of DB
...@@ -17,3 +23,5 @@ $config_db = [ ...@@ -17,3 +23,5 @@ $config_db = [
"host" => "localhost", // host "host" => "localhost", // host
"type" => "mysql" // type of DB - only tested with mysql (so better not change)!! "type" => "mysql" // type of DB - only tested with mysql (so better not change)!!
]; ];
$config_use_openstreetmap = true;
<?php <?php
require_once 'environment.php'; require_once __DIR__ . '/Environment.php';
require_once 'commons.php';
class Bachelor { class Bachelor {
const SAVE_SUCCESS = 0; const SAVE_SUCCESS = 0;
...@@ -8,6 +7,8 @@ class Bachelor { ...@@ -8,6 +7,8 @@ class Bachelor {
const SAVE_ERROR_DUPLICATE = 2; const SAVE_ERROR_DUPLICATE = 2;
const SAVE_ERROR_CLOSED = 3; const SAVE_ERROR_CLOSED = 3;
const SAVE_ERROR_EXCEPTION = 4; const SAVE_ERROR_EXCEPTION = 4;
const SAVE_ERROR_MISSING_RIGHTS = 5;
const SAVE_ERROR_INVALID = 6;
/** @var Environment */ /** @var Environment */
protected $environment; protected $environment;
...@@ -18,10 +19,12 @@ class Bachelor { ...@@ -18,10 +19,12 @@ class Bachelor {
/** @var Fahrt the fahrt object this bachelor belongs to */ /** @var Fahrt the fahrt object this bachelor belongs to */
protected $fahrt; protected $fahrt;
const ALLOWED_FIELDS = ['bachelor_id', 'fahrt_id', 'anm_time', 'forname', 'sirname', 'mehl', protected $validationErrors = null;
public static $ALLOWED_FIELDS = ['bachelor_id', 'fahrt_id', 'anm_time', 'forname', 'sirname', 'mehl',
'pseudo', 'antyp', 'abtyp', 'anday', 'abday', 'comment', 'studityp', 'paid', 'repaid', 'backstepped', 'pseudo', 'antyp', 'abtyp', 'anday', 'abday', 'comment', 'studityp', 'paid', 'repaid', 'backstepped',
'virgin', 'essen', 'on_waitlist', 'transferred', 'public', 'version']; 'virgin', 'essen', 'on_waitlist', 'transferred', 'public', 'version', 'signupstats','isOrga','mGame'];
const NULLFIELDS = ['paid', 'repaid', 'backstepped', 'transferred', 'on_waitlist']; public static $NULLFIELDS = ['paid', 'repaid', 'backstepped', 'transferred', 'on_waitlist', 'signupstats'];
/** /**
* Bachelor constructor. * Bachelor constructor.
...@@ -39,11 +42,11 @@ class Bachelor { ...@@ -39,11 +42,11 @@ class Bachelor {
* @return Bachelor * @return Bachelor
* @throws Exception * @throws Exception
*/ */
public static function makeNewBachelor($fahrt) { public static function makeEmptyBachelor($fahrt) {
$newBachelor = new Bachelor($fahrt); $newBachelor = new Bachelor($fahrt);
$data = []; $data = [];
foreach (Bachelor::ALLOWED_FIELDS as $field) { foreach (Bachelor::$ALLOWED_FIELDS as $field) {
if (!in_array($field, Bachelor::NULLFIELDS)) if (!in_array($field, Bachelor::$NULLFIELDS))
$data[$field] = ''; $data[$field] = '';
} }
$possible_dates = $fahrt->getPossibleDates(); $possible_dates = $fahrt->getPossibleDates();
...@@ -64,15 +67,38 @@ class Bachelor { ...@@ -64,15 +67,38 @@ class Bachelor {
* @throws Exception * @throws Exception
*/ */
public static function makeFromDB($fahrt, $bid) { public static function makeFromDB($fahrt, $bid) {
$newBachelor = new Bachelor($fahrt); try {
$data = $newBachelor->environment->database->get('bachelor', $newBachelor = new Bachelor($fahrt);
Bachelor::ALLOWED_FIELDS, $data = $newBachelor->environment->database->get('bachelor',
['AND' => [ Bachelor::$ALLOWED_FIELDS,
'fahrt_id' => $fahrt->getID(), ['AND' => [
'bachelor_id' => $bid 'fahrt_id' => $fahrt->getID(),
]]); 'bachelor_id' => $bid
$newBachelor->set($data); ]]);
return $newBachelor;
$newBachelor->set($data);
return $newBachelor;
} catch (Exception $e) {
return null;
}
}
public static function makeFromForm($isNew = true, $fahrt = null, $ignoreClosed = false, $admincheck = false) {
$tmpEnv = Environment::getEnv();
if (empty($fahrt))
$fahrt = $tmpEnv->getTrip();
$errorBachelor = new Bachelor(null);
if (is_null($fahrt))
$errorBachelor->validationErrors = ['Ungültige Fahrt!'];
elseif ($fahrt->getRegistrationState() == Fahrt::STATUS_IS_CLOSED and !$ignoreClosed)
$errorBachelor->validationErrors = ['Anmeldung zur Fahrt bereits geschlossen!'];
else {
$newBachelor = new Bachelor($fahrt, $isNew);
$newBachelor->populateAndValidate($admincheck);
return $newBachelor;
}
return $errorBachelor;
} }
/** /**
...@@ -89,8 +115,10 @@ class Bachelor { ...@@ -89,8 +115,10 @@ class Bachelor {
} }
public function set($data) { public function set($data) {
if (is_null($data) or !isset($data) or empty($data))
throw new Exception('No data to set!');
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
if (in_array($key, Bachelor::ALLOWED_FIELDS)) { if (in_array($key, Bachelor::$ALLOWED_FIELDS)) {
$this->data[$key] = $val; $this->data[$key] = $val;
} else { } else {
throw new Exception('Bachelor hat kein Feld: ' . $key); throw new Exception('Bachelor hat kein Feld: ' . $key);
...@@ -98,25 +126,52 @@ class Bachelor { ...@@ -98,25 +126,52 @@ class Bachelor {
} }
} }
public function get() { public function getSignupStats() {
if (isset($this->data['signupstats']) and !is_null(json_decode($this->data['signupstats'], true))) {
return json_decode($this->data['signupstats'], true);
}
return null;
}
public function getData() {
return $this->data; return $this->data;
} }
public function isOnWaitlist() {
return $this->data['on_waitlist'] == 1;
}
public function isTransferred() {
return $this->data['transferred'] == null;
}
public function isWaiting() {
return $this->isOnWaitlist();
}
public function isBackstepped() {
if (isset($this->data['backstepped']) and !is_null($this->data['backstepped']))
return true;
return false;
}
/** /**
* Move Bachelor from Waitlist to full registration * Move Bachelor from Waitlist to full registration
* *
* @return int see SAVE_* constants * @return int see SAVE_* constants
*/ */
public function waitlistToRegistration() { public function waitlistToRegistration() {
if ($this->data['on_waitlist'] == 1 and if ($this->data['on_waitlist'] == 1) {
(!isset($this->data['transferred']) or is_null($this->data['transferred'])) $this->data['on_waitlist'] = 0;
) {
$this->data['transferred'] = time(); $this->data['transferred'] = time();
$code = $this->save(); $code = $this->save();
if ($code == Bachelor::SAVE_SUCCESS) { if ($code == Bachelor::SAVE_SUCCESS) {
$this->feedbackHelper(['lang_waittoregmail', 'lang_payinfomail']); $lang_payinfomail_selector = 'lang_payinfomail_winter';
if ($this->fahrt->get('isSummer') == 1)
$lang_payinfomail_selector = 'lang_payinfomail_summer';
$this->feedbackHelper(['lang_waittoregmail', $lang_payinfomail_selector]);
} }
return $code; return $code;
} else { } else {
...@@ -148,6 +203,9 @@ class Bachelor { ...@@ -148,6 +203,9 @@ class Bachelor {
// lock database tables to prevent funny things // lock database tables to prevent funny things
$this->environment->database->exec("LOCK TABLES fahrten, bachelor WRITE"); $this->environment->database->exec("LOCK TABLES fahrten, bachelor WRITE");
if (!$this->isDataValid())
return Bachelor::SAVE_ERROR_INVALID;
// get status // get status
$state = $this->fahrt->getRegistrationState(); $state = $this->fahrt->getRegistrationState();
$wlmode = $this->environment->isInWaitlistMode(); $wlmode = $this->environment->isInWaitlistMode();
...@@ -180,10 +238,16 @@ class Bachelor { ...@@ -180,10 +238,16 @@ class Bachelor {
if (is_null($code)) if (is_null($code))
return Bachelor::SAVE_ERROR_EXCEPTION; return Bachelor::SAVE_ERROR_EXCEPTION;
if ($wlmode) if ($wlmode) {
$this->feedbackHelper('lang_waitmail'); $this->feedbackHelper('lang_waitmail');
else } else if ($this->data['studityp'] == 'ALUMN') {
$this->feedbackHelper(['lang_regmail', 'lang_payinfomail']); $this->feedbackHelper('lang_waitalumnimail');
} else {
$lang_payinfomail_selector = 'lang_payinfomail_winter';
if ($this->fahrt->get('isSummer') == 1)
$lang_payinfomail_selector = 'lang_payinfomail_summer';
$this->feedbackHelper(['lang_regmail', $lang_payinfomail_selector]);
}
return Bachelor::SAVE_SUCCESS; return Bachelor::SAVE_SUCCESS;
...@@ -193,9 +257,21 @@ class Bachelor { ...@@ -193,9 +257,21 @@ class Bachelor {
$this->environment->database->exec("UNLOCK TABLES"); $this->environment->database->exec("UNLOCK TABLES");
} }
} else { } else {
if (!$this->environment->isAdmin())
return Bachelor::SAVE_ERROR_MISSING_RIGHTS;
if (!$this->isDataValid())
return Bachelor::SAVE_ERROR_INVALID;
$this->data['version']++; $this->data['version']++;
$code = $this->environment->database->update('bachelor', $this->data, ['AND' => [
'fahrt_id' => $this->fahrt->getID(), 'bachelor_id' => $this->data['bachelor_id']]]); if (preg_match('/\d{1,2}\.\d{1,2}\.\d{4}/', $this->data['anday']))
$this->data['anday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y', $this->data['anday'])->getTimestamp());
if (preg_match('/\d{1,2}\.\d{1,2}\.\d{4}/', $this->data['abday']))
$this->data['abday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y', $this->data['abday'])->getTimestamp());
$code = $this->environment->database->update('bachelor', $this->data,
['AND' => ['fahrt_id' => $this->fahrt->getID(), 'bachelor_id' => $this->data['bachelor_id']]]);
if (is_null($code)) if (is_null($code))
return Bachelor::SAVE_ERROR_EXCEPTION; return Bachelor::SAVE_ERROR_EXCEPTION;
...@@ -221,12 +297,10 @@ class Bachelor { ...@@ -221,12 +297,10 @@ class Bachelor {
for ($run = 0; $run < 10; $run++) { for ($run = 0; $run < 10; $run++) {
$bytes = openssl_random_pseudo_bytes(8); $bytes = openssl_random_pseudo_bytes(8);
$hex = bin2hex($bytes); $hex = bin2hex($bytes);
comm_verbose(3, "generated hex for test: " . $hex);
if ($this->environment->database->has('fahrten', ['AND' => ['fahrt_id' => $fid]]) and if ($this->environment->database->has('fahrten', ['AND' => ['fahrt_id' => $fid]]) and
!$this->environment->database->has('bachelor', ['AND' => ['fahrt_id' => $fid, 'bachelor_id' => $hex]]) !$this->environment->database->has('bachelor', ['AND' => ['fahrt_id' => $fid, 'bachelor_id' => $hex]])
) { ) {
comm_verbose(2, "generated hex: " . $hex);
return $hex; return $hex;
} }
} }
...@@ -243,14 +317,200 @@ class Bachelor { ...@@ -243,14 +317,200 @@ class Bachelor {
$hash = $this->data['bachelor_id']; $hash = $this->data['bachelor_id'];
foreach ($mail_langs as $mail_lang) { foreach ($mail_langs as $mail_lang) {
$mail = comm_get_lang($mail_lang, [ $mail = $this->environment->getLanguageString($mail_lang, [
"{{url}}" => $config_baseurl . "status.php?hash=" . $hash, '{{url}}' => $config_baseurl . 'status.php?fid=' . $this->fahrt->getID() . '&hash=' . $hash,
"{{organisator}}" => $fahrt_details['leiter'], '{{organisator}}' => $fahrt_details['leiter'],
"{{paydeadline}}" => $fahrt_details['paydeadline'], '{{paydeadline}}' => $fahrt_details['paydeadline'],
"{{payinfo}}" => $fahrt_details['payinfo'], '{{payinfo}}' => $fahrt_details['payinfo'],
"{{wikilink}}" => $fahrt_details['wikilink']]); '{{wikilink}}' => $fahrt_details['wikilink']]);
$bcc = $mail_lang === "lang_payinfomail" ? $fahrt_details['kontakt'] : NULL; $bcc = (($mail_lang === 'lang_payinfomail_summer') OR ($mail_lang === 'lang_payinfomail_winter')) ? $fahrt_details['kontakt'] : NULL;
comm_send_mail($to, $mail, $fahrt_details['kontakt'], $bcc); $this->environment->sendMail($to, $mail, $fahrt_details['kontakt'], $bcc);
}
}
public function isDataValid() {
return empty($this->validationErrors);
}
public function getValidationErrors() {
return $this->validationErrors;
}
/**
* This function takes submitted form data from $_REQUEST and validates the input.
*
* returns assoc array looking like this:
* [
* "valid" => true|false,
* "message" => 'a message',
* "errors" => ['array of', 'errors'],
* "data" => [<validated data as assoc array>]
* ]
*
* @return array (see above)
*/
private function populateAndValidate($admincheck = false) {
$possibleDates = $this->fahrt->getPossibleDates();
$invalidChars = $this->environment->config['invalidChars'];
$oconf = $this->environment->oconfig;
$this->set(['fahrt_id' => $this->fahrt->getID(), 'version' => 1]);
$this->validationErrors = [];
$this->validateField('forname', $invalidChars, 'Fehlerhafter oder fehlender Vorname!');
$this->validateField('sirname', $invalidChars, 'Fehlerhafter oder fehlender Nachname!');
$this->validateField('pseudo', $invalidChars, 'Fehlerhafter oder fehlender Anzeigename!');
$this->validateField('mehl', 'mail', 'Fehlerhafte oder fehlende E-Mail-Adresse!');
$this->validateField('anday', array_slice($possibleDates, 0, -1), 'Hilfe beim Ausfüllen: <a href="https://www.hu-berlin.de/studium/bewerbung/imma/exma">hier klicken!</a>');
$this->validateField('abday', array_slice($possibleDates, 1), 'Ruth hat mitgedacht: <a href="https://www.hu-berlin.de/studium/bewerbung/imma/exma">hier klicken!</a>');
$this->validateField('antyp', $oconf['reisearten'], 'Trolle hier lang: <a href="https://www.hu-berlin.de/studium/bewerbung/imma/exma">hier klicken!</a>');
$this->validateField('abtyp', $oconf['reisearten'], 'Entwicklern Bier geben und: <a href="https://www.hu-berlin.de/studium/bewerbung/imma/exma">hier klicken!</a>');
$this->validateField('essen', $oconf['essen'], 'Hat das wirklich nicht gereicht??');
$this->validateField('studityp', $oconf['studitypen'], 'Das bist du ganz bestimmt nicht!');
$this->validateField('public', 'checkbox', 'Trollololol');
$this->validateField('virgin', 'virgin', 'Bitte Altersbereich wählen!');
$this->validateField('comment', 'comment', 'Trollololol');
$this->validateField('isOrga', 'isOrga', 'OrgaCode ist falsch!');
$this->validateField('mGame', 'mGame', '!');
$tmp = trim($_REQUEST['studityp']);
if($tmp == 'ALUMN') {
$this->data['on_waitlist'] = 1;
}
if (!$admincheck) {
$this->validateField('captcha', 'captcha', 'Captcha falsch eingegeben.');
if (!isset($_REQUEST['disclaimer']))
array_push($this->validationErrors, 'Disclaimer *muss* akzeptiert werden!');
}
if ($this->data['anday'] == $this->data['abday'])
array_push($this->validationErrors, 'Anreisetag = Abreisetag -> Bitte prüfen!');
// try parsing stats
if (isset($_REQUEST['signupstats']) and !is_null(json_decode($_REQUEST['signupstats'], true)))
$this->data['signupstats'] = $_REQUEST['signupstats']; // TODO make checks for signupmethods?
else
$this->data['signupstats'] = null;
unset($_SESSION['captcha']);
}
/**
* checks for correctness of a given field ($index) by trying $check.
* pushes $errmess into $errarr, if $check fails
* pushes empty data on fail or correct data on success into $data
*
* check can be regex or array or special (public, mail, comment).
* if array, than check only succeeds if sent data is inside that array
*
* @param $index
* @param $check
* @param $errmess
*/
private function validateField($index, $check, $errmess) {
try {
// check that first because if unchecked it doesnt exist
if ($check == 'checkbox') {
$this->set([$index => (isset($_REQUEST[$index])) ? 0 : 1]);
} // if index is missing -> error!
elseif (!isset($_REQUEST[$index])) {
array_push($this->validationErrors, $errmess);
// set it in every case so corrections are possible
$this->set([$index => '']);
} // index is there -> check if value is allowed
else {
$tmp = trim($_REQUEST[$index]);
// do specific check if a set of variables is allowed
if (is_array($check)) {
$vals = array_values($check);
$keys = array_keys($check);
if (in_array($tmp, $vals))
$val = array_search($tmp, $check);
elseif (in_array($tmp, $keys))
$val = $tmp;
else {
array_push($this->validationErrors, $errmess);
$val = $keys[0];
}
if ($index == 'studityp') {
if($tmp == 'ALUMN' && ($this->fahrt->get('isSummer') == 0)) {
array_push($this->validationErrors, "Zur Winterfahrt sind keine Alumnis erlaubt.");
}
}
if ($index == 'anday' or $index == 'abday')
$val = $tmp;
$this->set([$index => $val]);
} // check captcha
elseif ($check == "captcha") {
if (!(isset($_SESSION['captcha']) && strtolower($tmp) == strtolower($_SESSION['captcha']))) {
array_push($this->validationErrors, $errmess);
}
} // check mail address
elseif ($check == "mail") {
if (!filter_var($tmp, FILTER_VALIDATE_EMAIL))
array_push($this->validationErrors, $errmess);
// set it in every case so corrections are possible
$this->set([$index => $tmp]);
} // check comment field
elseif ($check == "comment") {
if(strlen($index)<=100) {
$this->set([$index => htmlspecialchars($tmp, ENT_QUOTES)]);
}else{
array_push($this->validationErrors, $errmess);
}
} // check if orgacode ist correct
elseif($check == "isOrga") {
if (empty($tmp) or $tmp == '')
$this->set([$index => 0]);
else
if (isset($_REQUEST['captcha']))
$this->set([$index => ($tmp == 'sommerfahrt2018') ? 1 : 0]);
else
$this->set([$index => (strtoupper($tmp) == 'JA') ? 1 : 0]);
}
elseif($check == "mGame") {
if (empty($tmp) or $tmp == 'UNSET')
array_push($this->validationErrors, $errmess);
else {
$this->set([$index => (strtoupper($tmp)=="JA") ? 1 : 0]);
}
}
// check virgin field
elseif ($check == "virgin") {
// NOTE: for consistency: virgin = 0 means > 18
if (empty($tmp) or $tmp == 'UNSET')
array_push($this->validationErrors, $errmess);
else
$this->set([$index => (strtoupper($tmp) == 'JA') ? 0 : 1]);
} //everything else
else {
// check with regex
if (!(preg_match($check, $tmp) == 1))
array_push($this->validationErrors, $errmess);
// set it in every case so corrections are possible
$this->set([$index => $tmp]);
}
}
} catch (Exception $e) {
array_push($this->validationErrors, 'Neeee du, voll daneben!');
}
}
/**
* @param $newBachelor Bachelor
*/
public function updateBachelor($newBachelor) {
$nBdata = $newBachelor->getData();
foreach ($this->data as $key => $val) {
// echo "->".$key."\n";
if (isset($nBdata[$key])/* and !empty($nBdata[$key])*/) {
$this->data[$key] = $nBdata[$key];
// echo "->".$key." - ".$this->data[$key]." - ".$nBdata[$key]."\n";
}
} }
} }
} }
\ No newline at end of file
<?php <?php
require_once __DIR__.'/../config.inc.php'; require_once __DIR__ . '/../config.inc.php';
require_once __DIR__.'/../lang.php'; require_once __DIR__ . '/../lang.php';
require_once 'medoo.php'; require_once __DIR__ . '/medoo.php';
require_once 'commons.php'; require_once __DIR__ . '/soft_protect.php';
require_once 'soft_protect.php'; require_once __DIR__ . '/Fahrt.php';
require_once __DIR__ . '/Bachelor.php';
use medoo\Medoo;
class Environment { class Environment {
const LOGIN_RIGHTS_NONE = 0;
const LOGIN_RIGHTS_ADMIN = 1;
const LOGIN_RIGHTS_SUDO = 2;
private static $__instance; private static $__instance;
public $database; public $database;
public $config; public $config;
private $dangling_form_data; public $sysconf;
private $permission_level = Environment::LOGIN_RIGHTS_NONE;
private $adminEnv;
public static function getEnv() { // if the context provides a specific trip or bachelor, these are set
if(self::$__instance == NULL) self::$__instance = new Environment(); /** @var Fahrt */
private $fahrt;
/** @var Bachelor */
private $bachelor;
public static function getEnv($admin = false) {
if (self::$__instance == NULL) self::$__instance = new Environment($admin);
if (!self::$__instance->adminEnv and $admin) self::$__instance = new Environment($admin);
return self::$__instance; return self::$__instance;
} }
protected function __construct() { protected function __construct($admin = false) {
global $config_db, $config_studitypen, $config_essen, $config_reisearten, $invalidCharsRegEx, global $config_db, $config_studitypen, $config_essen, $config_reisearten, $config_invalidCharsRegEx,
$config_reisearten_o, $config_essen_o, $config_studitypen_o; $config_reisearten_o, $config_essen_o, $config_studitypen_o, $config_baseurl, $config_basepath,
$config_mailtag, $config_impressum, $config_reisearten_destroyed, $config_databse_debug,
$config_userfile, $config_current_fahrt_file, $config_reisearten_o_short;
$this->adminEnv = $admin;
$this->database = new medoo(array( $this->database = new medoo(array(
'database_type' => $config_db["type"], 'database_type' => $config_db["type"],
'database_name' => $config_db["name"], 'database_name' => $config_db["name"],
'server' => $config_db["host"], 'server' => $config_db["host"],
'username' => $config_db["user"], 'username' => $config_db["user"],
'password' => $config_db["pass"] 'password' => $config_db["pass"]
)); ));
$this->config = [ $this->config = [
'studitypen' => $config_studitypen, 'studitypen' => $config_studitypen,
'essen' => $config_essen, 'essen' => $config_essen,
'reisearten' => $config_reisearten, 'reisearten' => $config_reisearten,
'invalidChars' => $invalidCharsRegEx 'invalidChars' => $config_invalidCharsRegEx,
'reiseartenDestroyed' => $config_reisearten_destroyed
]; ];
$this->oconfig = [ $this->oconfig = [
'studitypen' => $config_studitypen_o, 'studitypen' => $config_studitypen_o,
'essen' => $config_essen_o, 'essen' => $config_essen_o,
'reisearten' => $config_reisearten_o 'reisearten' => $config_reisearten_o,
'reiseartenShort' => $config_reisearten_o_short
];
$this->sysconf = [
'currentTripId' => $this->readCurrentTripId(),
'baseURL' => $config_baseurl,
'basePath' => $config_basepath,
'mailTag' => $config_mailtag,
'impressum' => $config_impressum,
'databaseDebug' => $config_databse_debug,
'adminUsersFile' => $config_userfile,
'currentFahrtFile' => $config_current_fahrt_file,
'gitSummary' => $this->getGitSummary()
]; ];
$this->bachelor = null;
$this->fahrt = null;
if ($admin) {
self::adminCheckIfLogin();
if (self::adminIsLoggedIn())
$this->permission_level = self::adminGetLevel();
}
} }
// signup method public function __destruct() {
if ($this->sysconf['databaseDebug']) {
echo '<pre>';
var_dump($this->database->log());
echo '</pre>';
}
}
// ========================================================================================================
// ADMIN STUFF
private static function adminCheckIfLogin() {
if (isset($_GET['logout'])) {
Environment::adminLogOut();
} else if (isset($_POST['user']) and isset($_POST['password'])) {
$user = $_POST['user'];
$password = $_POST['password'];
if (Environment::adminIsValidUser($user, $password)) {
$_SESSION['loggedIn'] = $user;
$_SESSION['userStyle'] = Environment::getStylePreference($user);
}
}
}
private static function getStylePreference($user) {
$config_admins = Environment::adminReadUsersFile();
foreach ($config_admins as $cfg_user => $cfg_password) {
if ($cfg_user != $user)
continue;
return $cfg_password["style"];
}
return 0;
}
// only waitlist private static function adminIsValidUser($user, $password) {
$config_admins = Environment::adminReadUsersFile();
foreach ($config_admins as $cfg_user => $cfg_password) {
if ($cfg_user != $user)
continue;
$cfg_password = $cfg_password["pw"];
if ($cfg_password[0] == '{') {
if (strpos($cfg_password, "{SHA256}") >= 0) {
$beginOfSalt = strpos($cfg_password, "$");
$salt = substr($cfg_password, 9, strpos($cfg_password, "$") - 9);
$hash = substr($cfg_password, $beginOfSalt + 1);
if (hash('sha256', $password . $salt) == $hash) {
return true;
}
}
} else {
// ONLY sha256 yet, others not implemented
}
}
return false;
}
/** private static function adminReadUsersFile() {
* @returns TRUE iff regular registration is allowed global $config_userfile;
*/ $ret = [];
public function isRegistrationOpen($fid) { $handle = fopen($config_userfile, "r");
$ret = $this->getRegistrationState($fid); if ($handle) {
return $ret === 0; while (($line = fgets($handle)) !== false) {
$tmp = explode(" ", $line);
if (count($tmp) >= 3) {
$ret[$tmp[1]] = ["pw" => $tmp[2], "sa" => $tmp[0], "style" => $tmp[3]];
}
}
}
fclose($handle);
return $ret;
} }
/** private static function adminIsLoggedIn() {
* @returns TRUE iff regular registration is allowed return isset($_SESSION['loggedIn']) and $_SESSION['loggedIn'] != '';
* @param $fid - fahrt id to check
* @param $mail - email address to check
* @param $list - list to check (bachelor or waitlist)
*/
public function isRegistered($fid, $mail, $list = 'bachelor') {
return $this->database->has($list, ['AND' => ['fahrt_id'=>$fid, 'mehl' => $mail]]);
} }
/** private static function adminGetLevel() {
* returns value depending on registration status $config_admins = Environment::adminReadUsersFile();
* 0 = registration open (slots available) if (isset($_SESSION['loggedIn']) && isset($config_admins[$_SESSION['loggedIn']])) {
* 1 = all slots taken -> waitlist open if ($config_admins[$_SESSION['loggedIn']]['sa'] === 'S')
* 2 = registration closed! return Environment::LOGIN_RIGHTS_SUDO;
* elseif ($config_admins[$_SESSION['loggedIn']]['sa'] === 'N')
* @param $fid (optional) to pass this parameter return Environment::LOGIN_RIGHTS_ADMIN;
* @returns int the state of the trip (see above) }
*/ return Environment::LOGIN_RIGHTS_NONE;
public function getRegistrationState($fid = NULL) { }
if(is_null($fid)) $fid = $this->getSelectedTripId();
public function isAdmin() {
return $this->permission_level == Environment::LOGIN_RIGHTS_ADMIN or
$this->permission_level == Environment::LOGIN_RIGHTS_SUDO;
}
public function isSuperAdmin() {
return $this->permission_level == Environment::LOGIN_RIGHTS_SUDO;
}
comm_verbose(3,"checking if fid ". $fid . " is open"); public static function adminLogOut() {
$open = $this->database->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]); session_destroy();
if(!$open) header("location: ..");
return 2; }
$cnt = $this->database->count("bachelor", ["AND"=> private function getGitSummary() {
["backstepped" => NULL, if (isset($this->sysconf['gitSummary']) and !empty($this->sysconf['gitSummary']))
"fahrt_id" => $fid]]); return $this->sysconf['gitSummary'];
$max = $this->database->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]);
$wl = $this->database->count('waitlist', ['AND' =>
["transferred" => NULL,
"fahrt_id" => $fid]]);
comm_verbose(3,"cnt: ".$cnt.", max: ".$max.", open: ".($open ? "yes" : "no")); exec('git show --quiet HEAD', $output);
return $output;
}
if ( $cnt < $max && $wl == 0 ) // ===========================================================================================================
return 0; // Some context based trip getters
return 1; private function readCurrentTripId() {
global $config_current_fahrt_file;
if (file_exists($config_current_fahrt_file)) {
$tmp = file_get_contents($config_current_fahrt_file);
if (is_numeric($tmp))
return $tmp;
}
return null;
}
private function isTripIdValid($fid) {
if (empty($fid) and $fid != 0) return false;
return $this->database->has('fahrten', ['fahrt_id' => $fid]);
}
public function getCurrentTripId() {
return $this->sysconf['currentTripId'];
} }
/**
* @return trip selected via $_REQUEST (or null)
*/
public function getSelectedTripId() { public function getSelectedTripId() {
if(isset($_REQUEST['fid'])) if (isset($_REQUEST['fid']))
return (int) $_REQUEST['fid']; return (int)$_REQUEST['fid'];
else else
return null; return null;
} }
/**
* @return bool true iff selected trip id is in the DB
*/
public function isSelectedTripIdValid() { public function isSelectedTripIdValid() {
$fid = $this->getSelectedTripId(); return $this->isTripIdValid($this->getSelectedTripId());
if ($fid == null) return false; }
$valid = $this->database->has('fahrten',
['fahrt_id'=> $fid]); public function getTrip($fallbackCurrent = false) {
if(!$valid) comm_verbose(1,"FID nicht vorhanden!"); $tripID = $this->getSelectedTripId();
if (is_null($tripID) and !$fallbackCurrent)
return null;
if (!is_null($this->fahrt))
return $this->fahrt;
return $valid; if (is_null($tripID) and $fallbackCurrent)
$tripID = $this->getCurrentTripId();
if (!$this->isTripIdValid($tripID))
return null;
$this->fahrt = new Fahrt($tripID);
return $this->fahrt;
} }
/**
* @return bool true iff user confirmed to enter waitlist // ===========================================================================================================
*/ // Some context based bachelor getters
public function isInWaitlistMode() { public function isInWaitlistMode() {
return isset($_REQUEST['waitlist']); return isset($_REQUEST['waitlist']);
} }
/**
* Stash form data in this class (i.e. for edit)
* @param $data
*/
public function setDanglingFormData($data) {
$this->dangling_form_data = $data;
}
/** /**
* @return bool true iff formdata is received * @return bool true iff formdata is received
...@@ -146,115 +265,61 @@ class Environment { ...@@ -146,115 +265,61 @@ class Environment {
return isset($_REQUEST['submit']) || isset($_REQUEST['storySubmit']); return isset($_REQUEST['submit']) || isset($_REQUEST['storySubmit']);
} }
public function getBachelor($bid = NULL) { public function getSelectedBachelorId() {
if(!is_null($this->dangling_form_data)) if (isset($_REQUEST['bid']))
return $this->dangling_form_data; return $_REQUEST['bid'];
if(is_null($bid)) if (isset($_REQUEST['hash']))
return $this->getEmptyBachelor(); return $_REQUEST['hash'];
else
return $this->getBachelorFromDB($bid);
}
/** return null;
* Given a registration id, return all parameters from the db
*
* @param $bid
* @return null or registration details
*/
public function getBachelorFromDB($bid) {
if(!is_null($bid) &&
$this->database->has('bachelor', ['bachelor_id' => $bid])){
$bachelor = $this->database->select('bachelor',
['forname','sirname','anday','abday','antyp','abtyp','pseudo',
'mehl','essen','public','virgin','studityp','comment'],
['bachelor_id'=>$bid]);
$bachelor['id'] = $bid;
return $bachelor[0];
}
return $this->getEmptyBachelor();
} }
/** public function getBachelor($allowTripIdFallback = false, $fallbackNew = false, $declareNew = false) {
* Will return an empty registration field if ($this->formDataReceived())
* return Bachelor::makeFromForm($declareNew);
* @return array $bid = $this->getSelectedBachelorId();
*/ $trip = $this->getTrip($allowTripIdFallback);
public function getEmptyBachelor() { if (!is_null($bid) and !is_null($trip))
$possible_dates = comm_get_possible_dates($this->database, $this->getSelectedTripId()); return Bachelor::makeFromDB($trip, $bid);
if ($fallbackNew)
return [ return Bachelor::makeEmptyBachelor($trip);
'forname' => "", 'sirname' => "", return null;
'anday' => $possible_dates[0], 'abday' => $possible_dates[count($possible_dates)-1],
'antyp' => "", 'abtyp' => "",
'pseudo' => "", 'mehl' => "", 'essen' => "", 'public' => "",
'studityp' => "", 'comment'=>""
];
} }
/**
* @param $data
* @return bool
*/
public function sendBachelorToDB($data) {
// === prepare data to insert ===
$data['anm_time'] = time();
$data['anday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y',$data['anday'])->getTimestamp());
$data['abday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y',$data['abday'])->getTimestamp());
if($this->isInWaitlistMode()){
if($this->getRegistrationState($data['fahrt_id'])==1){
$this->database->exec("LOCK TABLES fahrten, waitlist WRITE"); // count should not be calculated in two scripts at once
// === prepare data to insert ===
$data['waitlist_id'] = comm_generate_key($this->database,
["bachelor" => "bachelor_id", "waitlist" => "waitlist_id"],
['fahrt_id'=>$data['fahrt_id']]);
// === insert data ===
$insertOk = !$this->isRegistered($data['fahrt_id'], $data['mehl'], 'waitlist');
if($insertOk) $this->database->insert("waitlist", $data);
$this->database->exec("UNLOCK TABLES"); // insert is done now, count may be recalculated in other threads
if(!$insertOk) return false;
// === notify success === // ==========================================================================================================
$this->feedbackHelper("lang_waitmail", $data['mehl'], $data['waitlist_id'], $data['fahrt_id']); // SOME OTHER STUFF
}
else return false;
} else {
$this->database->exec("LOCK TABLES fahrten, bachelor WRITE"); // count should not be calculated in two scripts at once
// === prepare data to insert ===
$data['version'] = 1;
$data['bachelor_id'] = comm_generate_key($this->database,
["bachelor" => "bachelor_id"],
['fahrt_id'=>$data['fahrt_id']]);
// === check regstration full ===
$res = $this->database->get("fahrten",
["regopen", "max_bachelor"],
["fahrt_id" => $data['fahrt_id']]);
if (!$res || $res['regopen'] != "1") {
$this->database->exec("UNLOCK TABLES");
return false;
}
$insertOk = $this->isRegistrationOpen($data['fahrt_id']) && !$this->isRegistered($data['fahrt_id'], $data['mehl']);
if ($insertOk) /**
$this->database->insert("bachelor", $data); * sends mail
$this->database->exec("UNLOCK TABLES"); // insert is done now, count may be recalculated in other threads *
if (!$insertOk) * first line of $cont is used as subject iff terminated by double backslash (\\)
return false; // full * note that there should be no "\\" anywhere else in the string!!!
*
// === notify success === * returns true/false depending on success
$this->feedbackHelper(["lang_regmail", "lang_payinfomail"], $data['mehl'], $data['bachelor_id'], $data['fahrt_id']); */
public function sendMail($addr, $cont, $from = null, $bcc = null) {
$subj = "Wichtige Information";
$mess = $cont;
$tmp = explode("\\\\", $cont);
if (count($tmp) > 1) {
$subj = $tmp[0];
$mess = $tmp[1];
} }
$subj = $this->sysconf['mailTag'] . $subj;
return true; $headers = 'MIME-Version: 1.0' . "\r\n" .
} 'Content-type: text/plain; charset=UTF-8' . "\r\n" .
'From: ' . $from . "\r\n" .
'Reply-To: ' . $from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (!is_null($bcc)) $headers .= "\r\nBcc: " . $bcc;
return mail($addr, $subj, $mess, $headers);
}
public function getLanguageString($lang, $replace) {
global $$lang;
return str_replace(array_keys($replace), array_values($replace), $$lang);
}
} }
<?php <?php
require_once 'Bachelor.php'; require_once __DIR__ . '/Bachelor.php';
require_once __DIR__ . '/Environment.php';
class Fahrt { class Fahrt {
const STATUS_IS_OPEN_NOT_FULL = 0; const STATUS_IS_OPEN_NOT_FULL = 0;
const STATUS_IS_OPEN_FULL = 1; const STATUS_IS_OPEN_FULL = 1;
const STATUS_IS_CLOSED = 2; const STATUS_IS_CLOSED = 2;
const STATUS_IS_COUNTDOWN = 3;
const ALLOWED_FIELDS = ['fahrt_id', 'titel', 'ziel', 'vom', 'bis', 'regopen', 'beschreibung', 'leiter', 'kontakt', public static $ALLOWED_FIELDS = ['fahrt_id', 'titel', 'ziel', 'von', 'bis', 'regopen', 'beschreibung', 'leiter', 'kontakt',
'map_pin', 'max_bachelor', 'wikilink', 'paydeadline', 'payinfo', 'opentime']; 'map_pin', 'max_bachelor', 'wikilink', 'paydeadline', 'payinfo', 'opentime', 'disclaimlink', 'isSummer'];
/** @var Environment */
private $environment; private $environment;
private $fid; private $fid;
private $data; private $data;
private $newFahrt = false;
function __construct($fid) { function __construct($fid) {
$this->environment = Environment::getEnv(); $this->environment = Environment::getEnv();
...@@ -21,16 +25,91 @@ class Fahrt { ...@@ -21,16 +25,91 @@ class Fahrt {
$this->data = null; $this->data = null;
} }
public static function getEmptyFahrt() {
$newFahrt = new Fahrt(null);
foreach (Fahrt::$ALLOWED_FIELDS as $field) {
$newFahrt->data[$field] = '';
}
unset($newFahrt->data['fahrt_id']);
$newFahrt->set([
'titel' => 'Neue Fahrt',
'map_pin' => '52.42951196033782 13.530490995971718',
'von' => date('Y-m-d'),
'bis' => date('Y-m-d')
]);
$newFahrt->newFahrt = true;
return $newFahrt;
}
public static function getFahrtFromData($data) {
$newFahrt = new Fahrt($data['fahrt_id']);
try {
$newFahrt->set($data);
return $newFahrt;
} catch (Exception $e) {
return null;
}
}
public static function getAlleFahrten() {
$tmpEnvironment = Environment::getEnv();
// $fahrtenData = $tmpEnvironment->database->select('fahrten', Fahrt::$ALLOWED_FIELDS, 'ORDER BY fahrt_id DESC');
$fahrtenData = $tmpEnvironment->database->select('fahrten', Fahrt::$ALLOWED_FIELDS, ["ORDER" => ["fahrt_id" => "DESC"]]);
if (empty($fahrtenData))
return null;
$fahrten = array_map(function ($fahrtData) {
return Fahrt::getFahrtFromData($fahrtData);
}, $fahrtenData);
return $fahrten;
}
public function set($data) {
if (is_null($data) or !isset($data) or empty($data))
throw new Exception('No data to set!');
foreach ($data as $key => $val) {
if (in_array($key, Fahrt::$ALLOWED_FIELDS)) {
$this->data[$key] = $val;
} else {
throw new Exception('Fahrt hat kein Feld: ' . $key);
}
}
}
public function save() {
if ($this->environment->isSuperAdmin() and $this->newFahrt) {
return $this->environment->database->insert('fahrten', $this->data)->rowCount() > 0;
} elseif ($this->environment->isAdmin() and !$this->newFahrt) {
return $this->environment->database->update('fahrten', $this->data, ['fahrt_id' => $this->fid])->rowCount() > 0;
} else {
throw new Exception('Nicht erlaubt!');
}
}
private function getBachelorsSelector($params) { private function getBachelorsSelector($params) {
$conditions = [ $conditions = [
'fahrt_id' => $this->fid 'fahrt_id' => $this->fid
]; ];
if (isset($params['waiting'])) { if (isset($params['waiting'])) {
$conditions['transferred' . (($params['waiting']) ? '' : '[!]')] = null; if ($params['waiting']) {
$conditions['on_waitlist'] = ($params['waiting']) ? 1 : 0; $conditions['transferred'] = null;
$conditions['on_waitlist'] = 1;
} else {
$conditions['OR'] = [
'on_waitlist' => 0,
'AND' => [
'transferred[!]' => null,
'on_waitlist' => 1
]
];
}
} }
if (isset($params['essen'])) if (isset($params['essen']))
$conditions['essen'] = $params['essen']; $conditions['essen'] = $params['essen'];
if (isset($params['antyp']))
$conditions['antyp'] = $params['antyp'];
if (isset($params['studityp'])) if (isset($params['studityp']))
$conditions['studityp'] = $params['studityp']; $conditions['studityp'] = $params['studityp'];
if (isset($params['virgin'])) if (isset($params['virgin']))
...@@ -43,10 +122,12 @@ class Fahrt { ...@@ -43,10 +122,12 @@ class Fahrt {
$conditions['repaid' . (($params['backstepped']) ? '[!]' : '')] = null; $conditions['repaid' . (($params['backstepped']) ? '[!]' : '')] = null;
if (isset($params['public'])) if (isset($params['public']))
$conditions['public'] = ($params['public']) ? 1 : 0; $conditions['public'] = ($params['public']) ? 1 : 0;
if (isset($params['mGame']))
$conditions['mGame'] = ($params['mGame']) ? 1 : 0;
$selector = [ $selector = [
'table' => 'bachelor', 'table' => 'bachelor',
'fields' => !isset($params['fields']) ? Bachelor::ALLOWED_FIELDS : $params['fields'], 'fields' => !isset($params['fields']) ? Bachelor::$ALLOWED_FIELDS : $params['fields'],
'where' => ['AND' => $conditions] 'where' => ['AND' => $conditions]
]; ];
...@@ -72,9 +153,10 @@ class Fahrt { ...@@ -72,9 +153,10 @@ class Fahrt {
* *
* @return medoo result * @return medoo result
*/ */
public function getBachelors($params) { public function getBachelors($params, $order = null) {
$selector = $this->getBachelorsSelector($params); $selector = $this->getBachelorsSelector($params);
if (!empty($order))
$selector['where']['ORDER'] = $order;
return $this->environment->database->select($selector['table'], $selector['fields'], $selector['where']); return $this->environment->database->select($selector['table'], $selector['fields'], $selector['where']);
} }
...@@ -83,42 +165,78 @@ class Fahrt { ...@@ -83,42 +165,78 @@ class Fahrt {
} }
public function getFahrtDetails() { public function getFahrtDetails() {
if (!is_null($this->data)) if (!is_null($this->data) and !empty($this->data))
return $this->data; return $this->data;
$this->data = $this->environment->database->get('fahrten', Fahrt::ALLOWED_FIELDS, ['fahrt_id' => $this->fid]); $this->data = $this->environment->database->get('fahrten', Fahrt::$ALLOWED_FIELDS, ['fahrt_id' => $this->fid]);
return $this->data; return $this->data;
} }
public function get($field) {
if (in_array($field, Fahrt::$ALLOWED_FIELDS))
return $this->getFahrtDetails()[$field];
else
throw new Exception('Dieses Feld ist nicht vorhanden!');
}
public function getID() { public function getID() {
return $this->fid; return $this->fid;
} }
public function getPossibleDates(){ public function getPossibleDates() {
$details = $this->getFahrtDetails(); $details = $this->getFahrtDetails();
$end = new DateTime($details['bis']); $end = new DateTime($details['bis']);
$period = new DatePeriod( $period = new DatePeriod(
new DateTime($details['von']), new DateTime($details['von']),
new DateInterval('P1D'), new DateInterval('P1D'),
$end->modify( '+1 day' ) $end->modify('+1 day')
); );
$ret = []; $ret = [];
foreach($period as $d){ foreach ($period as $d) {
array_push($ret, $d->format("d.m.Y")); array_push($ret, $d->format("d.m.Y"));
} }
return $ret; return $ret;
} }
public function getRegistrationState() { public function getGPS() {
comm_verbose(3, 'checking if fid ' . $this->fid . ' is open'); $pin = $this->getFahrtDetails()['map_pin'];
if (!preg_match("/\\d+\\.\\d+ \\d+\\.\\d+/m", $pin))
return '52.4263218 13.5223815';//'71.555267 99.690962';
return $pin;
}
public function getLenTage() {
return $this->environment->database->query("SELECT DATEDIFF(bis, von) AS diff FROM fahrten WHERE fahrt_id=" . $this->fid)->fetch(0)['diff'];
}
public function getNumMaxSpots() {
return $this->getFahrtDetails()['max_bachelor'];
}
public function getNumTakenSpots() {
$selector = $this->getBachelorsSelector(['backstepped' => false, 'waiting' => false]);
return $this->environment->database->count('bachelor', $selector['where']);
}
public function getTimeToOpen() {
$opentime = $this->getFahrtDetails()['opentime'];
return $opentime - time();
}
public function getOpenTime() {
return $this->getFahrtDetails()['opentime'];
}
public function getRegistrationState() {
if (!$this->environment->database->has('fahrten', ['AND' => ['fahrt_id' => $this->fid, 'regopen' => 1]])) if (!$this->environment->database->has('fahrten', ['AND' => ['fahrt_id' => $this->fid, 'regopen' => 1]]))
return Fahrt::STATUS_IS_CLOSED; return Fahrt::STATUS_IS_CLOSED;
$selector = $this->getBachelorsSelector(['backstepped' => false, 'waiting' => false]); $timeToOpen = $this->getTimeToOpen();
if ($timeToOpen > 0)
return Fahrt::STATUS_IS_COUNTDOWN;
$cnt = $this->environment->database->count('bachelor', $selector['where']); $cnt = $this->getNumTakenSpots();
$max = $this->getFahrtDetails()['max_bachelor']; $max = $this->getNumMaxSpots();
if ($cnt < $max) if ($cnt < $max)
return Fahrt::STATUS_IS_OPEN_NOT_FULL; return Fahrt::STATUS_IS_OPEN_NOT_FULL;
...@@ -130,4 +248,4 @@ class Fahrt { ...@@ -130,4 +248,4 @@ class Fahrt {
$state = $this->getRegistrationState(); $state = $this->getRegistrationState();
return $state == Fahrt::STATUS_IS_OPEN_FULL or $state == Fahrt::STATUS_IS_OPEN_NOT_FULL; return $state == Fahrt::STATUS_IS_OPEN_FULL or $state == Fahrt::STATUS_IS_OPEN_NOT_FULL;
} }
} }
\ No newline at end of file
<?php
$invalidCharsRegEx = "/^[^0-9<>!?.::,#*@^_$\\\"'%;()&+]{2,50}$/"; // d©_©b
/**
* converts mail into safe for web format
* @param $mail - mail to convert
* @return mixed - converted mail
*/
function comm_convert_mail($mail){
return str_replace(array("@","."),array("&Oslash;", "&middot;"), $mail);
}
function comm_verbose($level, $text){
global $config_verbose_level;
if($config_verbose_level >= $level) {
if(is_array($text)){
echo "<pre>"; print_r($text); echo "</pre>";
} else
echo $text.'<br />';
}
}
function comm_from_mysqlDate($date){
return date('d.m.Y', strtotime($date));
}
/*
* sends mail
*
* first line of $cont is used as subject iff terminated by double backslash (\\)
* note that there should be no "\\" anywhere else in the string!!!
*
* returns true/false depending on success
*/
function comm_send_mail($addr, $cont, $from = NULL, $bcc = NULL){
global $config_mailtag;
$subj = "Wichtige Information";
$mess = $cont;
$tmp = explode("\\\\", $cont);
if(count($tmp)>1){
$subj = $tmp[0];
$mess = $tmp[1];
}
$subj = $config_mailtag.$subj;
$headers = 'From: ' . $from . "\r\n" .
'Reply-To: ' . $from. "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (!is_null($bcc)) $headers .= "\r\nBcc: " . $bcc;
comm_verbose(3, "sending mail... from: ".$from."<br/>to:".$addr."<br />subject: ".$subj."<br/>content:".$mess);
return mail($addr, $subj, $mess, $headers);
}
function comm_get_lang($lang, $replace){
global $config_basepath;
//require_once($config_basepath."/lang.php");
//echo $config_basepath."/lang.php";
global $$lang;
comm_verbose(3,"found lang variable: <br />".$$lang);
return str_replace(array_keys($replace), array_values($replace), $$lang);
}