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 3145 additions and 1495 deletions
<?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 @@
var defaultData = [];
defaultData.price = {
ALL: { // Stuff all have to pay, no matter when the come or leave
B_FIX: "4", // Fixkosten (z.B. Kurzreisezuschlag)
C_BW: "4.5", // Bettwäsche
B_FIX: "9", // Fixkosten (z.B. Kurzreisezuschlag)
RUECK: "2", // Reiserücktrittsversicherung
C_BW: "5.5", // Bettwäsche
E_ESS:"5", // Verpflegung gekauft durch uns
REFRA: "42" // Förderung durch RefRat
},
VAR: { // stuff that has to be paid depending on certain variables
"F_FR": [ // Frühstück
{ "val": "", "ind": false, "an": false, "ab": false },
{ "val": "3", "ind": true, "an": false, "ab": true },
{ "val": "3", "ind": true, "an": true, "ab": true }
{ "val": "3.5", "ind": false, "an": false, "ab": false },
{ "val": "3.5", "ind": false, "an": false, "ab": false }
],
"G_MI": [ // Mittag
{ "val": "", "ind": false, "an": false, "ab": false },
......@@ -23,43 +24,59 @@ defaultData.price = {
{ "val": "", "ind": false, "an": false, "ab": false }
],
"H_AB": [ // Abendbrot
{ "val": "4", "ind": true, "an": true, "ab": false },
{ "val": "4.5", "ind": true, "an": true, "ab": false },
{ "val": "4.5", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false }
],
"D_UE": [ // Übernachtung
{ "val": "12.5", "ind": true, "an": true, "ab": false },
{ "val": "12.5", "ind": true, "an": true, "ab": false },
{ "val": "16", "ind": false, "an": false, "ab": false },
{ "val": "16", "ind": false, "an": false, "ab": false },
{ "val": "", "ind": false, "an": false, "ab": false }
],
"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": "2.5", "ind": false, "an": false, "ab": true }
{ "val": "", "ind": false, "an": false, "ab": false }
]
}
};
defaultData.shopping= [
{ "pos": "Limonade", "cnt": "76", "price": "1.43" },
{ "pos": "Brause", "cnt": "42", "price": "0.83" },
{ "pos": "Lutscher", "cnt": "1", "price": "0.5" }
{ "pos": "Mio Mio Mate", "cnt": "0", "price": "1.00" },
{ "pos": "Knicklichter Industrie", "cnt": "5", "price": "1.70" },
{ "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 = [
{ "pos": "Bettwäsche", "cnt": "1", "mul": "40", "price": "1.43" },
{ "pos": "Grillnutzung", "cnt": "1", "mul": "40", "price": "0.3" },
{ "pos": "Halbpension", "cnt": "2", "mul": "40", "price": "12.30" },
{ "pos": "Klodeckel", "cnt": 1, "mul": 1, "price": "33" }
{ "pos": "Übernachtung Fr.-Sa.", "cnt": "0", "mul": "50", "price": "16" },
{ "pos": "Frühstück Sa.", "cnt": "0", "mul": "50", "price": "3.50" },
{ "pos": "Abendessen Fr.", "cnt": "0", "mul": "50", "price": "4.50" },
{ "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 = {
"in": [
{ "pos": "Förderung", "val": "1200" },
{ "pos": "Pfand", "val": "31" }
{ "pos": "Pfand", "val": "0" },
{ "pos": "Übertrag WS 17/18", "val": "132.63" }
],
"out": [
{ "pos": "Einkaufen", "val": "354" },
{ "pos": "Busfahrt Hin", "val": "35" },
{ "pos": "Busfahrt Rück", "val": "40" },
{ "pos": "Kaution", "val": "100" }
{ "pos": "Ausgleich", "val": "0" },
{ "pos": "Übertrag WS 18/19", "val":"132.63" }
]
};
defaultData.other = {
......@@ -70,7 +87,8 @@ defaultData.other = {
"remain" : [],// list of people, who haven't received money yet (structure: von, bis, antyp, abtyp)
"fahrt" : [],// dates of the trip (structure: von, bis)
"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
FIX: "Fixkosten",
WIR: "Zusatzverpflegung",
UE: "Übernachtung",
RUECK: "Reiserücktrittsversicherung",
REFRA: "(Förderung)"
};
......@@ -247,6 +266,20 @@ dataapp.service('priceData', ["$http", "$rootScope", function ($http, $rootScope
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: {
"pos": table.bez.REFRA,
"sum": function(){
......@@ -302,7 +335,7 @@ dataapp.service('shoppingData', ["$http", "$rootScope", function ($http, $rootSc
table.sum = function(){
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)
ret += table.rowSum(table.entries[run]);
return ret;
......@@ -336,9 +369,12 @@ dataapp.service('receiptData', ["$http", "$rootScope", function ($http, $rootSco
table.sum = function(){
var ret = 0;
for(var run = 0; run < table.entries.length; run++)
if(!table.entries[run].isDeleted)
// console.log(table.entries);
for(var run = 0; run < Object.keys(table.entries).length; run++) {
if(!table.entries[run].isDeleted) {
ret += table.rowSum(table.entries[run]);
}
}
return ret;
};
......@@ -763,7 +799,8 @@ now the individual controllers and modules for each table....
};
scope.meaner = function(tab){
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....
};
table.saveTable = function(){
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){
toastr.success('Saved to Database! (price)');
});
......@@ -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
$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
$scope.cancel = function() {
table.entries = jQuery.extend(true, {}, table.orig);
table.entries = table.orig.slice();
// table.entries = jQuery.extend(true, {}, table.orig);
table.orig = [];
};
// save edits
$scope.saveTable = function() {
var results = [];
var arr = Array.from(table.entries);
console.log(arr);
console.log(table.entries);
for (var i = table.entries.length; 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
if (row.isDeleted) {
table.entries.splice(i, 1);
......@@ -982,11 +1031,11 @@ now the individual controllers and modules for each table....
// === Data Binding stuff ==
$scope.dataService = receiptData;
table.entries = $scope.dataService.entries;
$scope.$on('data::receiptUpdated', function(event, newTab) {
table.entries = newTab;
// console.log(newTab);
console.log("data in receipt controller received");
});
......@@ -997,8 +1046,6 @@ now the individual controllers and modules for each table....
});
// === edit table functions ===
// filter rows to show
......@@ -1008,6 +1055,7 @@ now the individual controllers and modules for each table....
// mark row as deleted
$scope.deleteRow = function(index) {
console.log(index);
table.entries[index].isDeleted = true;
};
......@@ -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
$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
$scope.cancel = function() {
table.entries = jQuery.extend(true, {}, table.orig);
table.entries = table.orig.slice();
// table.entries = jQuery.extend(true, {}, table.orig);
table.orig = [];
};
// save edits
$scope.saveTable = function() {
var results = [];
for (var i = table.entries.length; i--;) {
for (var i = Object.keys(table.entries).length; 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
if (row.isDeleted) {
table.entries.splice(i, 1);
......@@ -1111,8 +1169,8 @@ now the individual controllers and modules for each table....
}]);
app.controller('TableMoneyioController',
["$scope", "$filter", "$q", "$http", "moneyioData", "otherData", "receiptData",
function($scope, $filter, $q, $http, moneyioData, otherData, receiptData){
["$scope", "$filter", "$q", "$http", "moneyioData", "otherData", "receiptData", "shoppingData",
function($scope, $filter, $q, $http, moneyioData, otherData, receiptData, shoppingData) {
var table = this;
// === Data Binding stuff ==
......@@ -1120,6 +1178,7 @@ now the individual controllers and modules for each table....
$scope.moneyioDataService = moneyioData;
$scope.otherDataService = otherData;
$scope.receiptDataService = receiptData;
$scope.shoppingDataService = shoppingData;
table.entries = $scope.moneyioDataService.entries;
table.orig = [];
......@@ -1131,6 +1190,7 @@ now the individual controllers and modules for each table....
},
"out":{
REC: {"pos": "Herberge", "val": 0},
KAUF: {"pos": "Einkauf", "val": 0},
OUT: {"pos": "Rückzahlungen (getätigt)", "val": 0},
POUT: {"pos": "Rückzahlungen (ausstehend)", "val": 0}
}
......@@ -1149,6 +1209,7 @@ now the individual controllers and modules for each table....
});
$scope.$on('data::receiptUpdated', function(event, newTab) {
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.PVOR.val = $scope.otherDataService.toIntakeSum();
table.extra.out.OUT.val = $scope.otherDataService.repaidSum();
......@@ -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
$scope.prepareForm = function(){
// table.orig = table.entries.slice();
table.orig = jQuery.extend(true, {}, table.entries);
};
// cancel all changes
$scope.cancel = function() {
// table.entries = table.orig.slice();
table.entries = jQuery.extend(true, {}, table.orig);
table.orig = [];
};
......@@ -1199,6 +1262,14 @@ now the individual controllers and modules for each table....
var salbei = function(col){
for (var i = col.length; 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
if (row.isDeleted) {
......@@ -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
......
......@@ -21,7 +21,7 @@
</span>
</td>
<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}}
</span>
</td>
......
......@@ -26,4 +26,6 @@ Einschränken auf:<br />
Gewählte Summe: {{summy(table.io) || 0 | currency}}<br />
Anzahl Personen: {{cnt}} <br />
Betrag pro Person: {{meaner(table.io) || 0 | currency}}
\ No newline at end of file
Betrag pro Person: {{meaner(table.io) || 0 | currency}}<br />
<!--<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
/**
* 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=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;
$template = file_get_contents("../view/print_template.html");
$text = "";
switch($_REQUEST['ex']){
case "refra": genRefRa(); break;
case "treff": genTreff(); break;
case "konto": genKonto(); break;
case "unter": genUnter(); break;
default:
break;
}
}
function genRefRa(){
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'],"",""]);
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;"]);
}
class AdminExportPage extends AdminPage {
$tabconf = ["colwidth" => ["20%", "55%", "25%"],
"cellheight" => "35pt"];
private $text = '';
private $headers = '';
private $header = '';
private $footer = '';
printTable(["Name", "Anschrift", "Unterschrift"], $tabdata, $tabconf);
private static $ALLOWED_PAGES = ['refra', 'treff', 'konto', 'mord', 'room', 'unter'];
$data = getFahrtInfo();
public function __construct($base) {
parent::__construct($base);
$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>".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'];
}
try {
if (!isset($_REQUEST['ex']) or array_search($_REQUEST['ex'], AdminExportPage::$ALLOWED_PAGES) === false)
throw new Exception('Invalide Seite!');
$exportFunction = 'export' . ucfirst($_REQUEST['ex']);
$this->$exportFunction();
$this->template = AdminPage::TEMPLATE_PRINT_FULL;
} catch (Exception $e) {
$this->exportDefault();
}
}
function genTreff(){
global $header, $footer, $admin_db, $config_current_fahrt_id, $config_reisearten_o;
public function getHeaders() {
return $this->headers;
}
$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']);
public function getHeader() {
return $this->header;
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($ttabdata, "&nbsp;");
public function getFooter() {
return $this->footer;
}
$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;"]);
public function getText() {
return $this->text;
}
$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" => "25pt"];
public function getAjax() {
return '';
}
printTable(["Name", "X", "", "Name", "X", "", "Name", "X"], $tabdata, $tabconf);
private function exportDefault() {
$k = [];
$k = array_keys($this->environment->oconfig['studitypen']);
array_unshift($k,'ALLE');
$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>
';
}
$data = getFahrtInfo();
private function exportRefra() {
$people = $this->fahrt->getBachelors(['backstepped' => false, 'waiting' => false], ['forname'=> 'ASC']);
$data = $this->fahrt->getFahrtDetails();
$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'];
}
$header = "
<h1>Anwesenheitsliste Treffpunkt</h1>
Liste aller Teilnehmer, die angegeben haben, gemeinsam mit Bus/Bahn anzureisen";
$footer = "Anwesenheitsliste - ".$data['titel'];
}
private function exportTreff() {
$data = $this->fahrt->getFahrtDetails();
$people = $this->fahrt->getBachelors(['antyp' => 'BUSBAHN', 'waiting' => false, 'backstepped' => false], ['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 = [];
// 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'];
}
function genKonto(){
global $header, $footer, $admin_db, $config_current_fahrt_id;
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'];
}
$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;"]);
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;
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"]);
private function exportMord() {
$preInstruction = '<u>Mordvorschlag:</u> ';
$instructions = ['Gib deinem Opfer in einem Moment des Verlusts der Aufmerksamkeit einen Gegenstand um es umzubringen und melde es dem Spielleiter.',
'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'];
}
$tabconf = ["colwidth" => ["25%", "30%", "25%", "15%", "5%"],
"cellheight" => "35pt",
"class" => [3=>"graycell", 4=>"graycell"]];
private function exportRoom() {
$this->text = '
<script type="text/javascript">
function updateRoomCnt(val) {
var table = document.getElementById("roomtab").getElementsByTagName("tbody")[0];
table.innerHTML = "";
for(var i = 0; i < val; i++) {
var row = table.insertRow(table.rows.length);
row.insertCell(0).style.height="30pt";
row.insertCell(1);
row.insertCell(2);
row.insertCell(3);
row.insertCell(4);
row.insertCell(5);
}
}
</script>
<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>';
printTable(["Name", "Kontonummer/IBAN", "Bankleitzahl/BIC", "Betrag*", "Erl*"], $tabdata, $tabconf);
$tabconf = [
'colwidth' => ['16%', '10%', '10%', '30%', '12%', '12%'],
'cellheight' => '30pt',
'id' => 'roomtab'
];
$data = getFahrtInfo();
$this->text .= $this->tableGenerator(['Haus/ Etage/ Raum', '# Betten', '# Schlüssel', 'Verantwortlich', 'Erhalten', 'Zurück'], [], $tabconf);
$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'];
}
$data = $this->fahrt->getFahrtDetails();
function genUnter(){
global $header, $footer, $admin_db, $config_current_fahrt_id;
$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'] . '.';
$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;"]);
}
// leerfelder (just in case)
for($run = 0; $run < 8; $run++){
array_push($tabdata, ["&nbsp;","&nbsp;","&nbsp;"]);
$this->footer = 'Schlüsselliste - ' . $data['titel'];
}
$tabconf = ["colwidth" => ["20%", "25%", "55%"],
"cellheight" => "25pt"];
printTable(["Name", "Unterschrift", "&nbsp;"], $tabdata, $tabconf);
$data = getFahrtInfo();
$header = "
<h1>TeilnehmerInnenliste</h1>
<h2>Fachschaftsfahrt</h2>
Fachschaft: <u>Informatik</u><br />
Datum der Fahrt: <u>".comm_from_mysqlDate($data['von'])." - ".comm_from_mysqlDate($data['bis'])."</u><br />
Verantwortlicher: <u>".$data['leiter']."</u><br />
Liste aller Teilnehmer der Fachschaftsfahrt in der Einrichtung <u>".$data['ziel']."</u>";
$footer = "TeilnehmerInnenliste - ".$data['titel'];
}
private function exportUnter() {
$data = $this->fahrt->getFahrtDetails();
$people = $this->fahrt->getBachelors(['backstepped' => false, 'waiting' => false], ['forname'=> 'ASC']);
$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%'],
'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 = []){
global $text;
$text.="
<table class='dattable'>
<thead>
<tr>";
$cell = 0;
foreach($headers as $h){
$text.="<th".cellStyle($tabconf, $cell).">".$h."</th>";
$cell++;
}
$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>";
private function tableGenerator($headers, $data, $tabconf = []) {
$thead = '';
foreach ($headers as $cell => $h) {
$thead .= '<th ' . $this->tableGeneratorCellStyle($tabconf, $cell) . '>' . $h . '</th>';
}
$tbody = '';
foreach ($data as $row) {
$tbody .= '<tr>';
foreach ($row as $cell => $dc) {
$tbody .= '<td' . $this->tableGeneratorCellStyle($tabconf, $cell) . '>' . $dc . '</td>';
}
$text .="
</tbody>
</table>";
}
function cellStyle($tabconf, $cell){
$ret = "";
if(isset($tabconf['cellheight']) || isset($tabconf['colwidth']) || isset($tabconf['class'])){
$ret .= " style='";
if(isset($tabconf['cellheight']))
$ret .= "height:".$tabconf['cellheight'].";";
if(isset($tabconf['colwidth']) && isset($tabconf['colwidth'][$cell]))
$ret .= "width:".$tabconf['colwidth'][$cell].";";
$ret .= "'";
$tbody .= '</tr>';
}
return '
<table class="dattable" '. (isset($tabconf['id']) ? 'id="'.$tabconf['id'].'"' : '') . '">
<thead>
<tr>' . $thead . '</tr>
</thead>
<tbody>' . $tbody . '</tbody>
</table>';
}
if(isset($tabconf['class']) && isset($tabconf['class'][$cell]))
$ret .= " class='".$tabconf['class'][$cell]."'";
private function tableGeneratorCellStyle($tabconf, $cell) {
$ret = '';
if (isset($tabconf['cellheight']) || isset($tabconf['colwidth']) || isset($tabconf['class'])) {
$ret .= ' style="';
if (isset($tabconf['cellheight']))
$ret .= 'height:' . $tabconf['cellheight'] . ';';
if (isset($tabconf['colwidth']) && isset($tabconf['colwidth'][$cell]))
$ret .= 'width:' . $tabconf['colwidth'][$cell] . ';';
$ret .= '""';
if (isset($tabconf['class']) && isset($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
/**
* 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],
array("fahrt_id"=>$config_current_fahrt_id));
}
$data = $admin_db->get("fahrten", ["beschreibung", "titel", "von", "bis", "ziel", "map_pin", "leiter", "kontakt", "regopen", "max_bachelor"], array("fahrt_id"=>$config_current_fahrt_id));
$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 type=\"text/javascript\" src='http://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/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{
float: right;
width: 300px;
}
.formlist label{
float:left;
}
</style> ";
$text .= '
<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>Anm. offen</label>
<input type="checkbox" name="regopen" id="regopen" value="penis" '.(($data["regopen"]==1) ? "checked" : "").' /></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>
</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"} );
});
</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);
class AdminInfosPage extends AdminPage {
public function __construct($base) {
parent::__construct($base);
if (isset($_POST['note-content'])) {
try {
$this->fahrt->set(['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'],
'disclaimlink' => $_REQUEST['disclaimlink'],
'isSummer' => isset($_REQUEST['isSummer']) ? 1 : 0
]);
$saveResult = $this->fahrt->save();
if (empty($saveResult)) {
$this->message_err = 'Speichern fehlgeschlagen...';
} else {
$this->message_succ = 'Gespeichert.';
}
} catch (Exception $e) {
$this->message_err = 'Fehler aufgetreten: ' . $e->getMessage();
}
}
});
</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
/**
* 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;
$ecols = [
"forname" => function($d){ return $d; },
"sirname" => function($d){ return $d; },
"mehl" => function($d){ return $d; },
"pseudo" => function($d){ return $d; },
"antyp" => function($d){ return $d; },
"abtyp" => function($d){ return $d; },
"anday" => function($d){ return date('Y-m-d', DateTime::createFromFormat('d.m.Y',$d)->getTimestamp()); },
"abday" => function($d){ return date('Y-m-d', DateTime::createFromFormat('d.m.Y',$d)->getTimestamp()); },
"comment" => function($d){ return $d; },
"studityp"=> function($d){ return $d; },
"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'])) {
try {
$bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$bNew->set(['bachelor_id' => $_REQUEST['change']]);
$bOld = Bachelor::makeFromDB($this->fahrt, $_REQUEST['change']);
$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['change'])){
$update = [];
foreach($ecols as $k=>$e){
if($k == "public")
$update[$k] = isset($_REQUEST[$k]) ? 0 : 1;
else
$update[$k] = $e($_REQUEST[$k]);
if (isset($_REQUEST['delete'])) {
$this->environment->database->delete('bachelor', ['AND' => ['bachelor_id' => $_REQUEST['delete'], 'fahrt_id'=>$_REQUEST['fahrt_id']]]);
}
}
$admin_db->update("bachelor", $update, ["bachelor_id"=> $_REQUEST['change']]);
}
if(isset($_REQUEST['delete'])){
$admin_db->delete("bachelor", ["bachelor_id"=> $_REQUEST['delete']]);
}
if(isset($_REQUEST['ajax'])){
if(isset($_REQUEST['update']) && isset($_REQUEST['hash']) && isset($_REQUEST['nstate'])){
$col = $_REQUEST['update'];
$id = $_REQUEST['hash'];
$val = ($_REQUEST['nstate'] == 1) ? time() : NULL;
$admin_db->update("bachelor", array($col=>$val), array("bachelor_id"=> $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>';
}
elseif(isset($_REQUEST['form'])){
$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 getHeader() {
return '';
}
} else {
$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.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 .=<<<END
<table id="mlist" class="compact hover">
<thead>
<tr>
END;
foreach($columnFunctions as $key => $value)
{
$text .= "<th>".$key."</th>";
}
$text .=<<<END
</tr>
</thead>
<tbody>
END;
$people = $admin_db->select('bachelor',$columns, array("fahrt_id"=>$config_current_fahrt_id));
foreach($people as $person) {
$text .= "<tr>"; //".((explode(',',$columnFunctions['PaidReBack']($person))[2]==0) ? "" : "class='list-backstepped'")."
foreach($columnFunctions as $key => $value)
{
$text .= "<td class='".$key.((explode(',',$columnFunctions['PaidReBack']($person))[2]==0) ? '' : ' list-backstepped')."'>".$value($person)."</td>";
public function getFooter() {
return '';
}
$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, {
"link-pre": function ( a ) {
return a.match(/<a [^>]+>([^<]+)<\/a>/)[1];
}
,
"prb-pre": function ( a ){
var tmp = a.split(",");
//alert();
return ((tmp[0]==0) ? '0' : '1') + ((tmp[1]==0) ? '0' : '1') + ((tmp[2]==0) ? '0' : '1');
public function getText() {
$extra_filters = ['fahrt_id' => $this->fahrt->getID()];
$cols = ['Anmelde-ID','Anmeldung', 'Name', 'Pseudo', 'Anreisetyp', 'Abreisetyp', 'Anreisetag','Abreisetag',
'Kommentar','Studityp','Essen', '18+', 'Orga', 'M.spiel', 'PaidReBack'];
$buttoncol = count($cols)-1;
$thead = '';
$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;
}
,
"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;
if (!$includeResigned) {
$extra_filters['AND']['backstepped'] = null;
}
} );
var ltab;
$(document).ready(function(){
ltab = $('#mlist').DataTable({
"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>";
}
$thead .= '<th>toWaitlist</th>';
$toggle .= '<a class="toggle-vis" data-column=\''.sizeof($cols).'\'>toWaitlist</a> - ';
}
// Store the computed display for speed
data.date_rendered = btns;
return;
}
else if (type === 'display' || type === 'filter') {
return data.date_rendered;
}
// 'sort' and 'type' both just use the raw data
return data[$buttoncol];
$tbody = '';
$people = $this->environment->database->select('bachelor', Bachelor::$ALLOWED_FIELDS,
['AND' => $extra_filters], ['anm_time' => 'ASC']);
foreach ($people as $b) {
$zurueckgetreten = $b['backstepped'] ? 1 : 0;
$anfahrtDatum = $this->mysql2german($b['anday']);
$abfahrtDatum = $this->mysql2german($b['abday']);
$antyp = strtolower($b['antyp']);
$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]},
{ type: 'link', targets: [0, 2] },
{ type: 'prb', targets: $buttoncol }
],
"order": [[ 2, "asc" ]],
"paging": false
});
$('a.toggle-vis').click( function (e) {
e.preventDefault();
"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: 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
var column = ltab.column( $(this).attr('data-column') );
if($(this).attr("data-column")>=0) {
// Get the column API object
var column = ltab.column( $(this).attr("data-column") );
// Toggle the visibility
column.visible( ! column.visible() );
} );
$(".edit_bachelor").click( function(){
var bid = $(this).text();
$.get( "?page=list&ajax=ajax&form=form&hash="+bid, function( data ) {
$("#editForm > p").html(data);
// Toggle the visibility
column.visible( ! column.visible() );
}
});
$(".moveToWaitlist").click( function(){
var bid = $(this).closest("tr").find("td:eq(0)").text();
$.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(){
$(this).parent().parent().hide();
$("#editFormTopbar > p").click( function(){
$(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){
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+")");
});
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();
}
}
</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
/**
* 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;
$config_verbose_level = 0;
$config_admin_verbose_level = 0;
private $mails;
$headers .= '<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery-ui.min.js"></script>';
$text .= '
<script type="text/javascript">
$(function(){
public function __construct($base) {
parent::__construct($base);
$this->mails = $this->environment->database->select('bachelor',
['mehl', 'forname', 'sirname'],
$this->buildQueryWhere());
}
$("#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");
public function getHeaders() {
return '<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../view/js/jquery-ui.min.js"></script>';
}
$("#mails").fadeOut().delay(50).fadeIn();
public function getHeader() {
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>';
public function getFooter() {
return '';
}
$query = "SELECT mehl, forname, sirname FROM bachelor";
$where = array("fahrt_id = ".$config_current_fahrt_id);
$dsa = "";
if(!isset($_REQUEST['submit'])){
// not submitted
//$dsa = "nosubmit";
} else {
//$dsa = "submit";
if(isset($_REQUEST['check_studityp'])){
$tmp = "";
foreach($_REQUEST['val_studityp'] as $st){
$tmp.= "studityp = '".$st."' OR ";
public function getText() {
$studitypen = '';
foreach ($this->environment->oconfig['studitypen'] as $key => $typ) {
$studitypen .= '<option value="' . $key . '">' . $typ . '</option>';
}
array_push($where,substr($tmp,0,-3));
}
if(isset($_REQUEST['check_antyp'])){
$tmp = "";
foreach($_REQUEST['val_antyp'] AS $st){
$tmp.= "antyp = '".$st."' OR ";
$reisearten = '';
foreach ($this->environment->oconfig['reisearten'] as $key => $typ) {
$reisearten .= '<option value="' . $key . '">' . $typ . '</option>';
}
array_push($where,substr($tmp,0,-3));
}
if(isset($_REQUEST['check_abtyp'])){
$tmp = "";
foreach($_REQUEST['val_abtyp'] AS $st){
$tmp.= "abtyp = '".$st."' OR ";
$essen = '';
foreach ($this->environment->oconfig['essen'] as $key => $typ) {
$essen .= '<option value="' . $key . '">' . $typ . '</option>';
}
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 = "";
foreach($_REQUEST['val_essen'] AS $st){
$tmp.= "essen = '".$st."' OR ";
private function transformContacts() {
$trenner = "; ";
if (isset($_REQUEST['trenner'])) {
$trenner = $_REQUEST['trenner'];
if ($trenner == 'br') $trenner = "\n";
}
array_push($where,substr($tmp,0,-3));
}
if(isset($_REQUEST['check_paid'])){
if($_REQUEST['val_paid'] == 1)
array_push($where,"paid IS NOT NULL");
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");
$accounts = array_map(function($mehl) {
return $mehl['forname'] . " " . $mehl['sirname'] . " <" . $mehl['mehl'] . ">";
}, $this->mails);
sort($accounts);
return join($trenner, $accounts);
}
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
/**
* 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'])){
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));
}
class AdminNotesPage extends AdminPage {
$content = $admin_db->get("notes", "note", array("fahrt_id"=>$config_current_fahrt_id));
public function __construct($base) {
parent::__construct($base);
$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>
if (isset($_POST['note-content'])) {
$cont = $_REQUEST['note-content'];
if ($this->environment->database->has('notes', ['fahrt_id' => $this->fahrt->getID()]))
$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' />
<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>";
$this->content = $this->environment->database->get('notes', 'note', ['fahrt_id' => $this->fahrt->getID()]);
}
$text .= '
<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>
public function getHeaders() {
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>
<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>
<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;
}
#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>
var editor = new wysihtml5.Editor("wysihtml5-editor", {
toolbar: "wysihtml5-editor-toolbar",
stylesheets: ["../view/css/wysihtml5/editor.css"],
parserRules: wysihtml5ParserRules
});
public function getFooter() {
return '';
}
editor.on("load", function() {
var composer = editor.composer,
h1 = editor.composer.element.querySelector("h1");
if (h1) {
composer.selection.selectNode(h1);
}
});
</script>';
public function getText() {
return '
<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>
<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
/**
* 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 = 4;
//$config_verbose_level = 4;
$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 fahrt_id=".$config_current_fahrt_id." GROUP BY anday ORDER BY anday ASC LIMIT 1")->fetchAll()[0]['anday_cnt'];
$mitfahrer['zweit'] = $admin_db->query("SELECT date_format(abday, '%j') as abday, COUNT(abday) as abday_cnt FROM bachelor WHERE fahrt_id=".$config_current_fahrt_id." GROUP BY abday ORDER BY abday DESC LIMIT 1")->fetchAll()[0]['abday_cnt'];
$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']))*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:
*
......
<?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",
"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", array("kontakt","leiter"), array("fahrt_id"=>$transdata['fahrt_id']));
$mail = comm_get_lang("lang_waittoregmail", array( "{{url}}" => $config_baseurl."status.php?hash=".$_REQUEST['move'],
"{{organisator}}" => $from['leiter']));
comm_send_mail($admin_db, $transdata['mehl'], $mail, $from['kontakt']);
}
}
$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.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;
<?php
// https://repke.eu:8443
// passwort manu:kuzerPenis666!
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
......@@ -16,17 +14,18 @@ date_default_timezone_set("Europe/Berlin");
require("config.local.php");
// ========= DONT TOUCH ANYTHING DOWN HERE!!! ==========================================================================
$config_invalidCharsRegEx = "/^[^0-9<>!?.::,#*@^_$\\\"'%;()&+]{2,50}$/"; // d©_©b
$config_studitypen_o = array(
"ERSTI" => "Ersti", // 0
//"Wechsli", // 1 - woanders/was anderes studiert, jetzt hier
//"MasterErsti", // 2
"HOERS" => "Hoersti", // 3 - länger an der HU
"TUTTI" => "Tutor" // 4 - Tutor
//"Fachi" // 5 - FS Ini
"ERSTI_B" => "Bachelor Ersti",
"ERSTI_M" => "Master Ersti",
"HOERS" => "Hörsti",
"HOERS_B" => "Bachelor Hörsti",
"HOERS_M" => "Master Hörsti",
"MENTO" => "MentorIn",
"ALUMN" => "Alumni"
);
$config_studitypen = array_values($config_studitypen_o);
......@@ -34,19 +33,18 @@ $config_essen_o = array(
"ALLES" => "Alles",
"VEGE" => "Vegetarisch",
"VEGA" => "Vegan"
//,"Frutarisch",
//"Grießbrei",
//"Carnivore",
//"Extrawurst"
);
$config_essen = array_values($config_essen_o);
$config_reisearten_o_short = array(
"BUSBAHN" => "Bus/Bahn",
"RAD" => "Fahrrad",
"INDIVIDUELL" => "Kamel/Individuell"
);
$config_reisearten_o = array(
"BUSBAHN"=>"gemeinsam mit Bus/Bahn",
"RAD"=>"gemeinsam mit Rad",
"AUTO"=>"selbst mit Auto",
"INDIVIDUELL"=>"Kamel/Individuell"
//,"mit Kamel"
"BUSBAHN" => "gemeinsam mit Bus/Bahn",
"RAD" => "gemeinsam mit Rad",
"INDIVIDUELL" => "Kamel/Individuell"
);
$config_reisearten = array_values($config_reisearten_o);
......@@ -56,31 +54,8 @@ $config_reisearten_destroyed = array(
"mit Schlauchboot"
);
/* // deprecated:
$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_userfile = $config_basepath . "/passwd/users.txt"; // relative to configfile
$config_current_fahrt_file = $config_basepath . "/config_current_fahrt_id";
$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
$config_verbose_level = 0; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose, 4 = with sql
$config_admin_verbose_level = 0;
if (true) {
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
$config_baseurl = "localhost/fsfahrt"; //"http://fsfahrt.repke.eu/anmeldung/registration-system/";
$config_baseurl = "http://localhost/fsfahrt/registration-system/";
// absolute path to doc root withOUT trailing slash
$config_basepath = __DIR__; //"/var/www/vhosts/fsfahrt.repke.eu/httpdocs/anmeldung/registration-system";
$config_basepath = __DIR__;
$config_impressum = 'https://fachschaft.informatik.hu-berlin.de/index.php/Fachschaft_Informatik:Impressum';
// database config
$config_db = array(
$config_db = [
"name" => "fsfahrt", // name of DB
"user" => "fsfahrt", // username
"pass" => "9Lug*96q", // password
"host" => "localhost", // host
"type" => "mysql" // type of DB - only tested with mysql (so better not change)!!
);
];
$config_use_openstreetmap = true;
2
\ No newline at end of file
registration-system/favicon.ico

766 B

<?php
require_once __DIR__ . '/Environment.php';
class Bachelor {
const SAVE_SUCCESS = 0;
const SAVE_ERROR_FULL = 1;
const SAVE_ERROR_DUPLICATE = 2;
const SAVE_ERROR_CLOSED = 3;
const SAVE_ERROR_EXCEPTION = 4;
const SAVE_ERROR_MISSING_RIGHTS = 5;
const SAVE_ERROR_INVALID = 6;
/** @var Environment */
protected $environment;
protected $data = [];
/** @var bool true iff this is a new bachelor, not yet in DB */
protected $isNew;
/** @var Fahrt the fahrt object this bachelor belongs to */
protected $fahrt;
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',
'virgin', 'essen', 'on_waitlist', 'transferred', 'public', 'version', 'signupstats','isOrga','mGame'];
public static $NULLFIELDS = ['paid', 'repaid', 'backstepped', 'transferred', 'on_waitlist', 'signupstats'];
/**
* Bachelor constructor.
* @param $fahrt Fahrt
* @param bool|false $isNew
*/
private function __construct($fahrt, $isNew = false) {
$this->environment = Environment::getEnv();
$this->isNew = $isNew;
$this->fahrt = $fahrt;
}
/**
* @param $fahrt Fahrt
* @return Bachelor
* @throws Exception
*/
public static function makeEmptyBachelor($fahrt) {
$newBachelor = new Bachelor($fahrt);
$data = [];
foreach (Bachelor::$ALLOWED_FIELDS as $field) {
if (!in_array($field, Bachelor::$NULLFIELDS))
$data[$field] = '';
}
$possible_dates = $fahrt->getPossibleDates();
$data['anday'] = $possible_dates[0];
$data['abday'] = $possible_dates[count($possible_dates) - 1];
$data['fahrt_id'] = $fahrt->getID();
$newBachelor->set($data);
$newBachelor->isNew = true;
return $newBachelor;
}
/**
* @param $fahrt Fahrt
* @param $bid
* @return Bachelor
* @throws Exception
*/
public static function makeFromDB($fahrt, $bid) {
try {
$newBachelor = new Bachelor($fahrt);
$data = $newBachelor->environment->database->get('bachelor',
Bachelor::$ALLOWED_FIELDS,
['AND' => [
'fahrt_id' => $fahrt->getID(),
'bachelor_id' => $bid
]]);
$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;
}
/**
* @param $fahrt
* @param $barr
* @param bool|false $isNew
* @return Bachelor
* @throws Exception
*/
public static function makeBachelorFromData($fahrt, $barr, $isNew = false) {
$newBachelor = new Bachelor($fahrt, $isNew);
$newBachelor->set($barr);
return $newBachelor;
}
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, Bachelor::$ALLOWED_FIELDS)) {
$this->data[$key] = $val;
} else {
throw new Exception('Bachelor hat kein Feld: ' . $key);
}
}
}
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;
}
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
*
* @return int see SAVE_* constants
*/
public function waitlistToRegistration() {
if ($this->data['on_waitlist'] == 1) {
$this->data['on_waitlist'] = 0;
$this->data['transferred'] = time();
$code = $this->save();
if ($code == Bachelor::SAVE_SUCCESS) {
$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;
} else {
return Bachelor::SAVE_ERROR_EXCEPTION;
}
}
/**
* Move Bachelor from Registration to Waitlist.
* TODO check if paid already?
* TODO send mail?
*
* @return int see SAVE_* constants
*/
public function registrationToWaitlist() {
$this->data['on_waitlist'] = 1;
$this->data['transferred'] = null;
return $this->save();
}
/**
* Save this bachelor to database
*
* @return int see SAVE_* constants
*/
public function save() {
if ($this->isNew) {
try {
// lock database tables to prevent funny things
$this->environment->database->exec("LOCK TABLES fahrten, bachelor WRITE");
if (!$this->isDataValid())
return Bachelor::SAVE_ERROR_INVALID;
// get status
$state = $this->fahrt->getRegistrationState();
$wlmode = $this->environment->isInWaitlistMode();
$duplicate = $this->hasDuplicate();
// registration closed already, return!
if ($state == Fahrt::STATUS_IS_CLOSED)
return Bachelor::SAVE_ERROR_CLOSED;
// duplicate detected, return!
if ($duplicate)
return Bachelor::SAVE_ERROR_DUPLICATE;
// is full, but waitlist not accepted, return!
if (!$wlmode and $state == Fahrt::STATUS_IS_OPEN_FULL)
return Bachelor::SAVE_ERROR_FULL;
$this->data['version'] = 1;
$this->data['anm_time'] = time();
$this->data['anday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y', $this->data['anday'])->getTimestamp());
$this->data['abday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y', $this->data['abday'])->getTimestamp());
$this->data['bachelor_id'] = $this->generateKey();
if ($wlmode) {
$this->data['on_waitlist'] = 1;
}
$code = $this->environment->database->insert('bachelor', $this->data);
if (is_null($code))
return Bachelor::SAVE_ERROR_EXCEPTION;
if ($wlmode) {
$this->feedbackHelper('lang_waitmail');
} else if ($this->data['studityp'] == 'ALUMN') {
$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;
} catch (Exception $e) {
return Bachelor::SAVE_ERROR_EXCEPTION;
} finally {
$this->environment->database->exec("UNLOCK TABLES");
}
} else {
if (!$this->environment->isAdmin())
return Bachelor::SAVE_ERROR_MISSING_RIGHTS;
if (!$this->isDataValid())
return Bachelor::SAVE_ERROR_INVALID;
$this->data['version']++;
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))
return Bachelor::SAVE_ERROR_EXCEPTION;
else
return Bachelor::SAVE_SUCCESS;
}
}
private function hasDuplicate() {
return $this->environment->database->has('bachelor', ['AND' => [
'fahrt_id' => $this->fahrt->getID(),
'mehl' => $this->data['mehl']]]);
}
/**
* Tries to generate a unique id.
*
* @return string
* @throws Exception
*/
private function generateKey() {
$fid = $this->fahrt->getID();
for ($run = 0; $run < 10; $run++) {
$bytes = openssl_random_pseudo_bytes(8);
$hex = bin2hex($bytes);
if ($this->environment->database->has('fahrten', ['AND' => ['fahrt_id' => $fid]]) and
!$this->environment->database->has('bachelor', ['AND' => ['fahrt_id' => $fid, 'bachelor_id' => $hex]])
) {
return $hex;
}
}
throw new Exception('Too many retries finding unique random bachelor_id!');
}
private function feedbackHelper($mail_langs) {
global $config_baseurl;
if (!is_array($mail_langs)) $mail_langs = [$mail_langs];
$fahrt_details = $this->fahrt->getFahrtDetails();
$to = $this->data['mehl'];
$hash = $this->data['bachelor_id'];
foreach ($mail_langs as $mail_lang) {
$mail = $this->environment->getLanguageString($mail_lang, [
'{{url}}' => $config_baseurl . 'status.php?fid=' . $this->fahrt->getID() . '&hash=' . $hash,
'{{organisator}}' => $fahrt_details['leiter'],
'{{paydeadline}}' => $fahrt_details['paydeadline'],
'{{payinfo}}' => $fahrt_details['payinfo'],
'{{wikilink}}' => $fahrt_details['wikilink']]);
$bcc = (($mail_lang === 'lang_payinfomail_summer') OR ($mail_lang === 'lang_payinfomail_winter')) ? $fahrt_details['kontakt'] : NULL;
$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";
}
}
}
}
<?php
require_once __DIR__ . '/../config.inc.php';
require_once __DIR__ . '/../lang.php';
require_once __DIR__ . '/medoo.php';
require_once __DIR__ . '/soft_protect.php';
require_once __DIR__ . '/Fahrt.php';
require_once __DIR__ . '/Bachelor.php';
use medoo\Medoo;
class Environment {
const LOGIN_RIGHTS_NONE = 0;
const LOGIN_RIGHTS_ADMIN = 1;
const LOGIN_RIGHTS_SUDO = 2;
private static $__instance;
public $database;
public $config;
public $sysconf;
private $permission_level = Environment::LOGIN_RIGHTS_NONE;
private $adminEnv;
// if the context provides a specific trip or bachelor, these are set
/** @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;
}
protected function __construct($admin = false) {
global $config_db, $config_studitypen, $config_essen, $config_reisearten, $config_invalidCharsRegEx,
$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(
'database_type' => $config_db["type"],
'database_name' => $config_db["name"],
'server' => $config_db["host"],
'username' => $config_db["user"],
'password' => $config_db["pass"]
));
$this->config = [
'studitypen' => $config_studitypen,
'essen' => $config_essen,
'reisearten' => $config_reisearten,
'invalidChars' => $config_invalidCharsRegEx,
'reiseartenDestroyed' => $config_reisearten_destroyed
];
$this->oconfig = [
'studitypen' => $config_studitypen_o,
'essen' => $config_essen_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();
}
}
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;
}
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() {
global $config_userfile;
$ret = [];
$handle = fopen($config_userfile, "r");
if ($handle) {
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() {
return isset($_SESSION['loggedIn']) and $_SESSION['loggedIn'] != '';
}
private static function adminGetLevel() {
$config_admins = Environment::adminReadUsersFile();
if (isset($_SESSION['loggedIn']) && isset($config_admins[$_SESSION['loggedIn']])) {
if ($config_admins[$_SESSION['loggedIn']]['sa'] === 'S')
return Environment::LOGIN_RIGHTS_SUDO;
elseif ($config_admins[$_SESSION['loggedIn']]['sa'] === 'N')
return Environment::LOGIN_RIGHTS_ADMIN;
}
return Environment::LOGIN_RIGHTS_NONE;
}
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;
}
public static function adminLogOut() {
session_destroy();
header("location: ..");
}
private function getGitSummary() {
if (isset($this->sysconf['gitSummary']) and !empty($this->sysconf['gitSummary']))
return $this->sysconf['gitSummary'];
exec('git show --quiet HEAD', $output);
return $output;
}
// ===========================================================================================================
// Some context based trip getters
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'];
}
public function getSelectedTripId() {
if (isset($_REQUEST['fid']))
return (int)$_REQUEST['fid'];
else
return null;
}
public function isSelectedTripIdValid() {
return $this->isTripIdValid($this->getSelectedTripId());
}
public function getTrip($fallbackCurrent = false) {
$tripID = $this->getSelectedTripId();
if (is_null($tripID) and !$fallbackCurrent)
return null;
if (!is_null($this->fahrt))
return $this->fahrt;
if (is_null($tripID) and $fallbackCurrent)
$tripID = $this->getCurrentTripId();
if (!$this->isTripIdValid($tripID))
return null;
$this->fahrt = new Fahrt($tripID);
return $this->fahrt;
}
// ===========================================================================================================
// Some context based bachelor getters
public function isInWaitlistMode() {
return isset($_REQUEST['waitlist']);
}
/**
* @return bool true iff formdata is received
*/
public function formDataReceived() {
return isset($_REQUEST['submit']) || isset($_REQUEST['storySubmit']);
}
public function getSelectedBachelorId() {
if (isset($_REQUEST['bid']))
return $_REQUEST['bid'];
if (isset($_REQUEST['hash']))
return $_REQUEST['hash'];
return null;
}
public function getBachelor($allowTripIdFallback = false, $fallbackNew = false, $declareNew = false) {
if ($this->formDataReceived())
return Bachelor::makeFromForm($declareNew);
$bid = $this->getSelectedBachelorId();
$trip = $this->getTrip($allowTripIdFallback);
if (!is_null($bid) and !is_null($trip))
return Bachelor::makeFromDB($trip, $bid);
if ($fallbackNew)
return Bachelor::makeEmptyBachelor($trip);
return null;
}
// ==========================================================================================================
// SOME OTHER STUFF
/**
* 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
*/
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;
$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
require_once __DIR__ . '/Bachelor.php';
require_once __DIR__ . '/Environment.php';
class Fahrt {
const STATUS_IS_OPEN_NOT_FULL = 0;
const STATUS_IS_OPEN_FULL = 1;
const STATUS_IS_CLOSED = 2;
const STATUS_IS_COUNTDOWN = 3;
public static $ALLOWED_FIELDS = ['fahrt_id', 'titel', 'ziel', 'von', 'bis', 'regopen', 'beschreibung', 'leiter', 'kontakt',
'map_pin', 'max_bachelor', 'wikilink', 'paydeadline', 'payinfo', 'opentime', 'disclaimlink', 'isSummer'];
/** @var Environment */
private $environment;
private $fid;
private $data;
private $newFahrt = false;
function __construct($fid) {
$this->environment = Environment::getEnv();
$this->fid = $fid;
$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) {
$conditions = [
'fahrt_id' => $this->fid
];
if (isset($params['waiting'])) {
if ($params['waiting']) {
$conditions['transferred'] = null;
$conditions['on_waitlist'] = 1;
} else {
$conditions['OR'] = [
'on_waitlist' => 0,
'AND' => [
'transferred[!]' => null,
'on_waitlist' => 1
]
];
}
}
if (isset($params['essen']))
$conditions['essen'] = $params['essen'];
if (isset($params['antyp']))
$conditions['antyp'] = $params['antyp'];
if (isset($params['studityp']))
$conditions['studityp'] = $params['studityp'];
if (isset($params['virgin']))
$conditions['virgin'] = ($params['virgin']) ? 1 : 0;
if (isset($params['backstepped']))
$conditions['backstepped' . (($params['backstepped']) ? '[!]' : '')] = null;
if (isset($params['paid']))
$conditions['paid' . (($params['paid']) ? '[!]' : '')] = null;
if (isset($params['repaid']))
$conditions['repaid' . (($params['backstepped']) ? '[!]' : '')] = null;
if (isset($params['public']))
$conditions['public'] = ($params['public']) ? 1 : 0;
if (isset($params['mGame']))
$conditions['mGame'] = ($params['mGame']) ? 1 : 0;
$selector = [
'table' => 'bachelor',
'fields' => !isset($params['fields']) ? Bachelor::$ALLOWED_FIELDS : $params['fields'],
'where' => ['AND' => $conditions]
];
return $selector;
}
/**
* This function returns participants of this fahrt.
* Set parameters to filter, keep unset means 'dont care'.
*
* Form the param array as follows:
* - $fields (array[string]) columns you want to select
* - $waiting (bool) is on the waitlist and not transferred
* - $essen (str) has specific food preferences
* - $studityp (int) is of specific studityp
* - $virgin (bool) is <18 or not
* - $backstepped (bool) stepped back or not
* - $paid (bool) paid or not
* - $repaid (bool) got money back or not
* - $public (bool) publically visible
*
* @param array $params params for the selector
*
* @return medoo result
*/
public function getBachelors($params, $order = null) {
$selector = $this->getBachelorsSelector($params);
if (!empty($order))
$selector['where']['ORDER'] = $order;
return $this->environment->database->select($selector['table'], $selector['fields'], $selector['where']);
}
public function getBachelor($bid) {
return Bachelor::makeFromDB($this->fid, $bid);
}
public function getFahrtDetails() {
if (!is_null($this->data) and !empty($this->data))
return $this->data;
$this->data = $this->environment->database->get('fahrten', Fahrt::$ALLOWED_FIELDS, ['fahrt_id' => $this->fid]);
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() {
return $this->fid;
}
public function getPossibleDates() {
$details = $this->getFahrtDetails();
$end = new DateTime($details['bis']);
$period = new DatePeriod(
new DateTime($details['von']),
new DateInterval('P1D'),
$end->modify('+1 day')
);
$ret = [];
foreach ($period as $d) {
array_push($ret, $d->format("d.m.Y"));
}
return $ret;
}
public function getGPS() {
$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]]))
return Fahrt::STATUS_IS_CLOSED;
$timeToOpen = $this->getTimeToOpen();
if ($timeToOpen > 0)
return Fahrt::STATUS_IS_COUNTDOWN;
$cnt = $this->getNumTakenSpots();
$max = $this->getNumMaxSpots();
if ($cnt < $max)
return Fahrt::STATUS_IS_OPEN_NOT_FULL;
return Fahrt::STATUS_IS_OPEN_FULL;
}
public function isRegistrationOpen() {
$state = $this->getRegistrationState();
return $state == Fahrt::STATUS_IS_OPEN_FULL or $state == Fahrt::STATUS_IS_OPEN_NOT_FULL;
}
}