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
Commits on Source (398)
Showing
with 1744 additions and 879 deletions
*.svg -diff
......@@ -2,3 +2,10 @@
*/.idea*
*/view/signups/game1/tiles
*.swp
**/config_current_fahrt_id
*/passwd/users.txt
*/Isues
*/other/backups/*
!*/other/backups/.htaccess
mysql_data
clean.sh
Fork Source: [Registration System](https://github.com/TimRepke/registration-system)
Registration System
===================
[![volkswagen status](https://auchenberg.github.io/volkswagen/volkswargen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen)
[![Bild passt](https://img.shields.io/badge/bild-passt-green.svg)]()
This system was developed for the computer science students union at the Humboldt-Universität zu Berlin to organise our
annual freshers weekend trips. Since the attendance grew over the years we needed a powerful system that can handle
all the registrations, messaging and a powerful admin panel to plan costs, take notes, manage waiting list and registration
and much more.
annual freshers weekend trips. Since the attendance grew over the years, we needed a powerful system that helps managing
the registrations (including a waiting list) and finances.
Props go to
- Manuel Herrmann (mostly frontend, graphics, games)
- Tim Repke (mostly backend and admin stuff)
- [Manuel Herrmann](https://github.com/0x17de/)
- [Tim Repke](https://github.com/TimRepke/)
# Features
- multiple methods for the signup process
- cost planning (for collecting and redistributing leftover money)
- ...
# Basic usage
### Create a new trip
TODO
### Link to send to the freshers
TODO
### Status of a signup
TODO
### Play-only mode
coming soon! (because the stuff is too good to just open it for one signup)
### Add new admin
Send out the link to `passwd/index.html` to the new user. They'll send their encrypted password back. Add that
(in the appropriate structure) to the `passwd/users.txt` file.
# Project structure
There are two files that sort of handle the configuration because we couldn't be bothered to create another
database table:
- `./passwd/users.txt` add users to this file. `S` stands for super admin (can create new trips), `N` users can only manage the current trip
- `./config_current_fahrt_id` (a file that only contains the id of the current trip
Folder structure:
- The `admin` folder contains everything for the admin backend.
- `view` contains all frontend stuff
- `view/signups` contains all possible signup methods (games, add them to `config.inc.php`)
- `view/js` should contain all commonly used js things
- ...
# How to deploy
### Server requirements
- PHP 5.5.x (tested with 5.5.3)<br />
- MySQL (other databases might work, check the medoo framework)
### Database setup
Check out the folger `other/sqlDumps`. There is an SQL file that creates the database. We also tried to make sure
to provide migrations in case updates are needed.
### Configuration
Make adjustments in `config.inc.php`
- multiple innovative methods for the signup process
- powerful management of registrations
- waiting list mode (if trip limit is already reached)
- eastereggs
- countdown till official registration opening
- automatic emails and status tracking for registrations
- backend user management
- export of different helpful lists for use during the trip
- take notes in the backend
- email export selection based on a multitude of parameters
- cost planning
- precisely spreading expenses over individual registrations
- calculation of specific amounts to pay back to everybody
- Database parameters (`$config_db`)
- Set base URL (`$config_baseurl`)
# Demo of the RPG registration mode
### File permissions
- [Game hosted on 0x17.de](https://www.0x17.de/fsfahrt/game1/)
- [Short screencast](https://www.youtube.com/watch?v=6HaQEVPJar0)
Adjust CHMOD for
- config_current_fahrt_id (rw-rw-rw-)
- passwd/users.txt (rw-rw-rw-)
# Usage
# Further notes
Check the guides in the wiki:
You could add the the config file in your local gitignore file to prevent overrides on updates.
In case you do that, remember to check for necessary updates.
\ No newline at end of file
- [for Trip organisers](https://github.com/TimRepke/registration-system/wiki/HowTo-f%C3%BCr-Fahrtorga-(Adminpanel))
- [for web admins](https://github.com/TimRepke/registration-system/wiki/HowTo-f%C3%BCr-Sysadmin)
- [for developers](https://github.com/TimRepke/registration-system/wiki/HowTo:-Deploy-Update)
# Docker Environment Setup
## Setup And Using The Environment
### Step 1
Ensure database dump path inside docker-compose.yml points to the newest dump
### Step 2
Change database connection inside
registration-system/config.local.php
from "localhost" to "db"
You might additionally adjust the base url inside the same config file:
```
$config_baseurl = "http://localhost:8080/";
```
### Step 3
Build and start up the containers
```
docker-compose build
docker-compose up -d
```
### Step 4
Wait for containers to start up.
Run a bash inside the web container (`docker exec -it registrationsystem_web_1 bash`) and
```
cd usr/share/nginx/html/
echo -n 2 > config_current_fahrt_id
chmod 777 config_current_fahrt_id
cp passwd/users.example.txt passwd/users.txt
```
### Step 6
Open http://localhost:8080 in your browser
Admin interface is at http://localhost:8080/admin (login with sudo:password)
For phpMyAdmin find the IP it runs on (`docker inspect registrationsystem_phpmyadmin_1` and find IPAddress) and open
http://<ip>:8090
## Mysql Dump Upgrade
Remove containers as in cleanup, remove mysql_dump folder and start again
## Cleanup
Run:
```
docker-compose stop
docker-compose rm
```
Then remove mysql_data folder
Tim Repke (tim@repke.eu)
Manuel Herrmann (admin@icetruck.de)
Manuel Herrmann (m@manuel-herrmann.de)
web:
image: nginx:latest
links:
- php
volumes:
- ./registration-system:/var/www/html:ro
- ./.git:/var/www/html/.git:ro
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
ports:
- "127.0.0.1:8080:80"
php:
build: docker/php
links:
- db
volumes:
- ./registration-system:/var/www/html
- ./.git:/var/www/html/.git:ro
expose:
- "9000"
pma:
image: phpmyadmin/phpmyadmin
links:
- db
environment:
- PMA_HOST=db
- PMA_PORT=3306
- PMA_USER=fsfahrt
- PMA_PASSWORD=9Lug*96q
ports:
- "127.0.0.1:8090:80"
db:
image: mariadb:10.1
environment:
- MYSQL_DATABASE=fsfahrt
- MYSQL_USER=fsfahrt
- MYSQL_PASSWORD=9Lug*96q
- MYSQL_RANDOM_ROOT_PASSWORD=yes
expose:
- "3306"
volumes:
- ./mysql_data:/var/lib/mysql
- ./registration-system/other/sqlDumps/init_20180118.sql:/docker-entrypoint-initdb.d/dump.sql:ro
server {
listen 80;
server_name default_name;
location / {
root /var/www/html;
index index.php index.html;
}
location ~ \.php$ {
root /var/www/html;
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
}
location /passwd {
deny all;
}
location ~ /\.ht {
deny all;
}
}
\ No newline at end of file
FROM php:7-fpm
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
&& apt-get update -y \
&& apt-get install -y zlib1g-dev libpng-dev libfreetype6-dev \
&& docker-php-ext-configure gd --with-freetype \
&& docker-php-ext-configure pdo_mysql \
&& docker-php-ext-install pdo_mysql gd \
&& docker-php-source delete
-- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Aug 08, 2014 at 07:42 PM
-- Server version: 5.1.73-0ubuntu0.10.04.1
-- PHP Version: 5.4.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `fsfahrt`
--
CREATE DATABASE IF NOT EXISTS `fsfahrt` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `fsfahrt`;
-- --------------------------------------------------------
--
-- Table structure for table `bachelor`
--
DROP TABLE IF EXISTS `bachelor`;
CREATE TABLE IF NOT EXISTS `bachelor` (
`bachelor_id` varchar(15) NOT NULL,
`fahrt_id` int(11) NOT NULL,
`version` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` varchar(10) NOT NULL,
`abday` varchar(10) NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
PRIMARY KEY (`bachelor_id`,`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `bachelor`
--
INSERT INTO `bachelor` (`bachelor_id`, `fahrt_id`, `version`, `forname`, `sirname`, `anday`, `abday`, `antyp`, `abtyp`, `pseudo`, `mehl`, `essen`, `public`, `virgin`, `studityp`, `comment`) VALUES
('5b61b92044983e1', 2, 1, 'asd', 'ad', '12.03.2014', '14.03.2014', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ffas', 'asdasd@asd.de', 'Alles', 1, 0, '0', 'dasd'),
('f35f12ca7c55462', 2, 1, 'fcacs', 'ads', '12.03.2014', '14.03.2014', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'fas', 'asd@asd.de', 'Alles', 0, 0, '0', 'adasdasda'),
('068e4198f255a1e', 2, 1, 'göll', 'asd', '12.03.2014', '14.03.2014', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'adsad', 'adskd@asdl.de', 'Alles', 1, 0, '0', 'adasd'),
('d748d40c0d7e475', 2, 1, 'ad', 'adsd', '12.03.2014', '14.03.2014', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdadl', 'asdas@asd.de', 'Vegan', 1, 0, '0', 'ad'),
('ec2cac23f915bf9', 2, 1, 'gbhg', 'ncvbx', '12.03.2014', '14.03.2014', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'cvxcvxsdfs', 'ads@asdl.de', 'Alles', 1, 0, '0', 'ycyxc'),
('78a322842b66657', 2, 1, 'lkblka', 'kbvnfj', '12.03.2014', '14.03.2014', 'individuell', 'gemeinsam mit Rad', 'kmkm', 'sdkk@ksad.de', 'Vegan', 1, 0, 'MasterErsti', 'asda');
-- --------------------------------------------------------
--
-- Table structure for table `fahrten`
--
DROP TABLE IF EXISTS `fahrten`;
CREATE TABLE IF NOT EXISTS `fahrten` (
`fahrt_id` int(11) NOT NULL AUTO_INCREMENT,
`titel` varchar(200) NOT NULL,
`ziel` varchar(100) NOT NULL,
`von` date NOT NULL,
`bis` date NOT NULL,
`regopen` int(1) NOT NULL,
`beschreibung` text NOT NULL,
`leiter` varchar(100) NOT NULL,
`kontakt` varchar(100) NOT NULL,
PRIMARY KEY (`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `fahrten`
--
INSERT INTO `fahrten` (`fahrt_id`, `titel`, `ziel`, `von`, `bis`, `regopen`, `beschreibung`, `leiter`, `kontakt`) VALUES
(1, 'Porno laut im Flur Fahrt', 'Irgendwo', '2012-10-17', '2012-10-19', 0, 'irgendein Text', 'Willi', 'hans@wurst.de'),
(2, 'Vodka in Hand Fahrt', 'Halbinsel', '2013-10-18', '2013-10-20', 1, 'Mehr Text passt nicht!', 'Tim', 'wahr@gi.na');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
var dataapp = angular.module("dataapp", []);
dataapp.service('tab1Data', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.tab1 = [];
$http.get("?page=archive&ajax=get-tab1-json&id="+cc).success(function(data) {
table.tab1 = data;
$rootScope.$broadcast('data::receiptUpdated1', table.tab1);
});
}]);
dataapp.service('tab2Data', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.tab2 = [];
$http.get("?page=archive&ajax=get-tab2-json&id="+cc).success(function(data) {
table.tab2 = data;
$rootScope.$broadcast('data::receiptUpdated2', table.tab2);
});
}]);
dataapp.service('moniTab1Data', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.moniTab1 = [];
$http.get("?page=archive&ajax=get-moniTab1-json&id="+cc).success(function(data) {
table.moniTab1 = data;
$rootScope.$broadcast('data::receiptUpdated3', table.moniTab1);
});
table.bez = {
A_FAHRT: "Fahrt",
B_FIX: "Fix",
C_BW: "Bettwäsche",
D_UE: "Übernachtung",
E_ESS: "Essen (wir)",
F_FR: "Frühstück",
G_MI: "Mittag",
H_AB: "Abend"
,
FAHRT: "Fahrtkosten",
ESSEN: "Verpflegung",
FIX: "Fixkosten",
WIR: "Zusatzverpflegung",
UE: "Übernachtung",
RUECK: "Reiserücktrittsversicherung",
REFRA: "(Förderung)"
};
table.calc = {
FAHRT: {
"pos": table.bez.FAHRT,
"sum": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.A_FAHRT)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.A_FAHRT.length; len--;)
tmp += (table.moniTab1.VAR.A_FAHRT[len].val * 1);
return tmp;
},
"cnt": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.A_FAHRT)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.A_FAHRT.length; len--;)
if(table.moniTab1.VAR.A_FAHRT[len].val > 0)
tmp++;
return tmp;
},
"val": function(){
var tmp = table.calc.FAHRT.cnt();
if(tmp > 0)
return table.calc.FAHRT.sum() / tmp;
return table.calc.FAHRT.sum();
}
},
ESSEN: {
"pos": table.bez.ESSEN,
"sum": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.H_AB || !table.moniTab1.VAR.F_FR || !table.moniTab1.VAR.G_MI)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.H_AB.length; len--;)
tmp += (table.moniTab1.VAR.H_AB[len].val * 1);
for(var len = table.moniTab1.VAR.F_FR.length; len--;)
tmp += (table.moniTab1.VAR.F_FR[len].val * 1);
for(var len = table.moniTab1.VAR.G_MI.length; len--;)
tmp += (table.moniTab1.VAR.G_MI[len].val * 1);
return tmp;
},
"cnt": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.H_AB || !table.moniTab1.VAR.F_FR || !table.moniTab1.VAR.G_MI)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.F_FR.length; len--;)
if(table.moniTab1.VAR.F_FR[len].val > 0)
tmp++;
for(var len = table.moniTab1.VAR.G_MI.length; len--;)
if(table.moniTab1.VAR.G_MI[len].val > 0)
tmp++;
for(var len = table.moniTab1.VAR.H_AB.length; len--;)
if(table.moniTab1.VAR.H_AB[len].val > 0)
tmp++;
return tmp;
},
"val": function(){
var tmp = table.calc.ESSEN.cnt();
if(tmp > 0)
return table.calc.ESSEN.sum() / tmp;
return table.calc.ESSEN.sum();
}
},
FIX: {
"pos": table.bez.FIX,
"sum": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.B_FIX || !table.moniTab1.ALL.C_BW)
return 0;
return (table.moniTab1.ALL.B_FIX * 1) + (table.moniTab1.ALL.C_BW * 1);
},
"cnt": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.B_FIX || !table.moniTab1.ALL.C_BW)
return 0;
return (table.moniTab1.ALL.B_FIX > 0 ? 1 : 0) + (table.moniTab1.ALL.C_BW > 0 ? 1 : 0);
},
"val": function(){
var tmp = table.calc.FIX.cnt();
if(tmp > 0)
return table.calc.FIX.sum() / tmp;
return table.calc.FIX.sum();
}
},
UE: {
"pos": table.bez.UE,
"sum": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.D_UE)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.D_UE.length; len--;)
tmp += (table.moniTab1.VAR.D_UE[len].val * 1);
return tmp;
},
"cnt": function(){
if(!table.moniTab1.VAR || !table.moniTab1.VAR.D_UE)
return 0;
var tmp = 0;
for(var len = table.moniTab1.VAR.D_UE.length; len--;)
if(table.moniTab1.VAR.D_UE[len].val > 0)
tmp++;
return tmp;
},
"val": function(){
var tmp = table.calc.UE.cnt();
if(tmp > 0)
return table.calc.UE.sum() / tmp;
return table.calc.UE.sum();
}
},
WIR: {
"pos": table.bez.WIR,
"sum": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.E_ESS)
return 0;
return table.moniTab1.ALL.E_ESS * 1;
},
"cnt": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.E_ESS)
return 0;
return table.moniTab1.ALL.E_ESS > 0 ? 1 : 0;
},
"val": function(){
var tmp = table.calc.WIR.cnt();
if(tmp>0)
return table.calc.WIR.sum() / tmp;
return table.calc.WIR.sum();
}
},
RUECK: {
"pos": table.bez.RUECK,
"sum": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.RUECK)
return 0;
return table.moniTab1.ALL.RUECK;
},
"cnt": function(){
return 1;
},
"val": function(){
return table.calc.RUECK.sum();
}
},
X_REFRA: {
"pos": table.bez.REFRA,
"sum": function(){
if(!table.moniTab1.ALL || !table.moniTab1.ALL.REFRA)
return 0;
return table.moniTab1.ALL.REFRA;
},
"cnt": function(){
return 1;
},
"val": function(){
return table.calc.X_REFRA.sum();
}
}
};
table.sum = function(){
return table.calc.ESSEN.sum() + table.calc.WIR.sum() + table.calc.FAHRT.sum() + table.calc.FIX.sum() + table.calc.UE.sum();
}
// receive new base
this.updateBase = function(b){
table.base = b;
$rootScope.$broadcast('data::priceUpdated', table.base);
}
}]);
dataapp.service('moniTab2Data', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.moniTab2 = [];
$http.get("?page=archive&ajax=get-moniTab2-json&id="+cc).success(function(data) {
table.moniTab2 = data;
$rootScope.$broadcast('data::receiptUpdated4', table.moniTab2);
});
table.rowSum = function(row){
return row.cnt*row.price;
};
table.sum = function(){
var ret = 0;
for(var run = 0; run < Object.keys(table.moniTab2).length; run++)
ret += table.rowSum(table.moniTab2[run]);
return ret;
};
}]);
dataapp.service('moniTab3Data', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.moniTab3 = [];
$http.get("?page=archive&ajax=get-moniTab3-json&id="+cc).success(function(data) {
table.moniTab3 = data;
$rootScope.$broadcast('data::receiptUpdated5', table.moniTab3);
});
table.rowSum = function(row){
return row.cnt*row.mul*row.price;
};
table.sum = function(){
var ret = 0;
for(var run = 0; run < Object.keys(table.moniTab3).length; run++) {
ret += table.rowSum(table.moniTab3[run]);
}
return ret;
};
}]);
dataapp.service('moniTabIOData', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.moniTabIO = [];
$http.get("?page=archive&ajax=get-moniTabIO-json&id="+cc).success(function(data) {
table.moniTabIO = data;
$rootScope.$broadcast('data::receiptUpdatedIO', table.moniTabIO);
});
table.colSum = function(col, ecol){
var ret = 0;
for(var nrow in col){
ret += 1*col[nrow].val;
}
for(var row in ecol){
ret += 1*ecol[row].val;
}
return ret;
};
}]);
dataapp.service('moniTabOData', ["$http", "$rootScope", function ($http, $rootScope) {
var table = this;
table.moniTabO = [];
$http.get("?page=archive&ajax=get-other-json&id="+cc).success(function(data) {
table.moniTabO = data;
$rootScope.$broadcast('data::receiptUpdated0', table.moniTabO);
});
}]);
(function() {
var app = angular.module('tab', ['tab1','tab2','moniTab1','moniTab2','moniTab3','moniTabIO']);
app.filter("currency", ["$filter", function($filter) {
return function(input, curSymbol, decPlaces, thouSep, decSep) {
curSymbol = curSymbol || "";
decPlaces = decPlaces || 2;
thouSep = thouSep || " ";
decSep = decSep || ".";
// Check for invalid inputs
var out = isNaN(input) || input === "" || input === null ? 0.0 : input;
//Deal with the minus (negative numbers)
var minus = input < 0;
out = Math.abs(out);
out = $filter("number")(out, decPlaces);
// Replace the thousand and decimal separators.
// This is a two step process to avoid overlaps between the two
if(thouSep != ",") out = out.replace(/\,/g, "T");
if(decSep != ".") out = out.replace(/\./g, "D");
out = out.replace(/T/g, thouSep);
out = out.replace(/D/g, decSep);
// Add the minus and the symbol
if(minus){
return "-" + out + curSymbol;
}else{
return out + curSymbol;
}
}
}]);
})();
(function() {
var app = angular.module('tab1', ['dataapp']);
app.controller("tab1Controller", ["$scope", "$http", "tab1Data", function($scope, $http, tab1Data) {
var table = this;
$scope.dataService = tab1Data;
table.tab1 = $scope.dataService.tab1;
$scope.$on('data::receiptUpdated1', function(event, newTab) {
table.tab1 = newTab;
});
$scope.$watch('table.tab1', function() {
if(table.tab1 && $scope.dataService.tab1){
$scope.dataService.tab1 = table.tab1;
}
});
}]);
})();
(function() {
var app = angular.module('tab2', ['dataapp']);
app.controller("tab2Controller", ["$http", "$scope", "tab2Data", function($http, $scope, tab2Data) {
var table = this;
$scope.dataService = tab2Data;
table.tab2 = $scope.dataService.tab2;
$scope.$on('data::receiptUpdated2', function(event, newTab) {
table.tab2 = newTab;
});
$scope.$watch('table.tab2', function() {
if(table.tab2 && $scope.dataService.tab2){
$scope.dataService.tab2 = table.tab2;
}
});
}]);
})();
(function() {
var app = angular.module('moniTab1', ['dataapp']);
app.controller("moniTab1Controller", ["$http", "$scope", "moniTab1Data", "moniTabOData", function($http, $scope, moniTab1Data, moniTabOData) {
var table = this;
$scope.dataService = moniTab1Data;
$scope.otherDataService = moniTabOData;
table.moniTab1 = $scope.dataService.moniTab1;
table.base = $scope.dataService.base;
table.calc = $scope.dataService.calc;
table.bez = $scope.dataService.bez;
table.amount = $scope.otherDataService.amount;
table.cnt = [];
$scope.$on('data::receiptUpdated3', function(event, newTab) {
table.moniTab1 = newTab;
});
$scope.$on('data::receiptUpdated0', function(event, newTab) {
table.amount = newTab.amount;
table.cnt = newTab.cnt;
});
$scope.$watch('table.moniTab1', function() {
if(table.moniTab1 && $scope.dataService.moniTab1){
$scope.dataService.moniTab1 = table.moniTab1;
}
});
}]);
})();
(function() {
var app = angular.module('moniTab2', ['dataapp']);
app.controller("moniTab2Controller", ["$http", "$scope", "moniTab2Data", function($http, $scope, moniTab2Data) {
var table = this;
$scope.dataService = moniTab2Data;
table.moniTab2 = $scope.dataService.moniTab2;
$scope.$on('data::receiptUpdated4', function(event, newTab) {
table.moniTab2 = newTab;
});
$scope.$watch('table.moniTab2', function() {
if(table.moniTab2 && $scope.dataService.moniTab2){
$scope.dataService.moniTab2 = table.moniTab2;
}
});
}]);
})();
(function() {
var app = angular.module('moniTab3', ['dataapp']);
app.controller("moniTab3Controller", ["$http", "$scope", "moniTab3Data", function($http, $scope, moniTab3Data) {
var table = this;
$scope.dataService = moniTab3Data;
table.moniTab3 = $scope.dataService.moniTab3;
$scope.$on('data::receiptUpdated5', function(event, newTab) {
table.moniTab3 = newTab;
});
$scope.$watch('table.moniTab3', function() {
if(table.moniTab3 && $scope.dataService.moniTab3){
$scope.dataService.moniTab3 = table.moniTab3;
}
});
}]);
})();
(function() {
var app = angular.module('moniTabIO', ['dataapp']);
app.controller("moniTabIOController", ["$http", "$scope", "moniTab2Data", "moniTab3Data", "moniTabIOData", "moniTabOData",
function($http, $scope, moniTab2Data, moniTab3Data, moniTabIOData, moniTabOData) {
var table = this;
$scope.dataService = moniTabIOData;
$scope.moniTab2DataService = moniTab2Data;
$scope.moniTab3DataService = moniTab3Data;
$scope.moniTabODataService = moniTabOData;
table.moniTabIO = $scope.dataService.moniTabIO;
table.extra = {
"in": {
VOR: {"pos": "Vorkasse", "val": 0}
},
"out":{
REC: {"pos": "Herberge", "val": 0},
KAUF: {"pos": "Einkauf", "val": 0},
OUT: {"pos": "Rückzahlungen", "val": 0}
}
};
$scope.$on('data::receiptUpdated0', function(event, newTab) {
table.extra.in.VOR.val = $scope.moniTabODataService.moniTabO.in[0].val;
table.extra.out.OUT.val = $scope.moniTabODataService.moniTabO.out[0].val;
});
$scope.$on('data::receiptUpdated4', function(event, newTab) {
table.extra.out.KAUF.val = $scope.moniTab2DataService.sum();
});
$scope.$on('data::receiptUpdated5', function(event, newTab) {
table.extra.out.REC.val = $scope.moniTab3DataService.sum();
});
$scope.$on('data::receiptUpdatedIO', function(event, newTab) {
table.moniTabIO = newTab;
});
}]);
})();
\ No newline at end of file
<?php
require_once("../config.inc.php");
function generateNavigationItems($page, $menu)
{
$text = '';
foreach($menu as $name => $page)
{
$text .= "<a href='?page=$page'>$name</a>";
}
return $text;
}
function checkIfLogin()
{
if(isset($_GET['logout']))
setLoggedIn("");
if(!isset($_POST['user']) || !isset($_POST['password']))
return;
$user = $_POST['user'];
$password = $_POST['password'];
if (isValidUser($user, $password))
setLoggedIn($user);
}
function isValidUser($user, $password)
{
$config_admins = readUserFile();
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, "{SHA254}") >= 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
{
// TODO: ONLY sha256 yet, others not implemented
}
}
return false;
}
function readUserFile(){
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]];
}
}
} else { }
fclose($handle);
return $ret;
}
function isSuperAdmin(){
$config_admins = readUserFile();
return isset($_SESSION['loggedIn']) && isset($config_admins[$_SESSION['loggedIn']]) && $config_admins[$_SESSION['loggedIn']]['sa'] === "S";
}
function isLoggedIn()
{
return isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] != '';
}
function setLoggedIn($user)
{
if ($user != ""){
comm_admin_verbose(2,"login");
$_SESSION['loggedIn'] = $user;
}else
{
comm_admin_verbose(2,"logout");
session_destroy();
header("location: ..");
}
}
function comm_admin_verbose($level, $text){
global $config_admin_verbose_level;
if($config_admin_verbose_level >= $level) {
if(is_array($text)){
echo "<pre>"; print_r($text); echo "</pre>";
} else
echo $text.'<br />';
}
}
/**
* Puts out Label and Selection box
*
* @param $name
* @param $id
* @param $values
* @param $selected
* @param $subtext
*/
function admin_show_formular_helper_sel($name, $id, $values, $selected, $subtext){
$r = '<label>'.$name.'
<span class="small">'.$subtext.'</span>
</label>
<select name="'.$id.'" id="'.$id.'">';
foreach($values as $val){
$r .= '<option value="'.$val.'"';
if($val == $selected) $r .= ' selected';
$r .= '>'.$val.'</option>';
}
$r .= '</select>';
return $r;
}
/**
* Puts out Label and two selection boxes side by side right below
*
* @param $name
* @param $id
* @param $values
* @param $selected
* @param $id2
* @param $values2
* @param $selected2
* @param $subtext
*/
function admin_show_formular_helper_sel2($name, $id, $values, $selected, $id2, $values2, $selected2, $subtext){
$r = '<label style="text-align:left">'.$name.'
<span class="small">'.$subtext.'</span>
</label><table><tr><td>
<select name="'.$id.'" id="'.$id.'" style="width:110px; text-align: center">';
foreach($values as $val){
$r .= '<option value="'.$val.'"';
if($val == $selected) $r .= ' selected';
$r .='>'.$val.'</option>';
}
$r .= '</select></td><td><select name="'.$id2.'" id="'.$id2.'">';
foreach($values2 as $val){
$r .= '<option value="'.$val.'"';
if($val == $selected2) $r .= ' selected';
$r .='>'.$val.'</option>';
}
$r .= '</select></td></tr></table>';
return $r;
}
function admin_show_formular_helper_input($name, $id, $value, $subtext){
$r = '<label>'.$name.'
<span class="small">'.$subtext.'</span>
</label>
<input type="text" name="'.$id.'" id="'.$id.'" value="'.$value.'" />';
return $r;
}
registration-system/admin/iban.png

353 B

<?php
/**
* Created by PhpStorm.
* User: it
* Date: 8/8/14
* Time: 4:19 PM
*/
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set("display_errors",1);
session_start();
require_once __DIR__ . '/../view/default_admin.php';
class AdminBase extends DefaultAdmin {
const STATE_200 = 0;
const STATE_403 = 1;
const STATE_404 = 2;
const STATE_500 = 3;
protected $isAdmin;
protected $isSudo;
protected $requerestedPage;
/** @var AdminPage */
protected $page;
protected $pageStatus = null;
private static $PAGES = [
'front' => 'Anmeldung',
'overview' => 'Übersicht',
// 'archive' => 'Archive',
'list' => 'Meldeliste',
'jumpOf' => 'Abspringer',
'wl' => 'Warteliste',
'wl_al' => 'Warteliste (Alumnis)',
'cost' => 'Kosten',
'mail' => 'Rundmail',
'notes' => 'Notizen',
'export' => 'Listenexport',
'infos' => 'Infos',
'admin' => 'SA*'
];
private static $PAGE_OVERRIDE = [
'wl' => ['list', ['waitlist' => 'true']],
'wl_al' => ['list', ['alumni' => 'true', 'waitlist' => 'true']],
];
private static $DEFAULT_PAGE = 'overview';
private static $SUPERADMIN_PAGES = ['admin'];
public function __construct() {
parent::__construct();
if (is_null($this->environment->getCurrentTripId()))
throw new Exception('Error on reading current_trip_id file, contact the webadmin!');
$this->isAdmin = $this->environment->isAdmin();
$this->isSudo = $this->environment->isSuperAdmin();
$this->requerestedPage = isset($_GET['page']) ? $_GET['page'] : AdminBase::$DEFAULT_PAGE;
$this->getBachelorstats();
$this->page = $this->getRequestedPage();
}
private function getBachelorstats() {
$this->fahrt = $this->environment->getTrip(true);
$people = $this->fahrt->getBachelors([]);
$wl = 0;
$wl_al = 0;
$list = 0;
$jumpOf = 0;
foreach($people as $b) {
// print_r($b);
if(!$b['on_waitlist'] || $b['on_waitlist'] && $b['transferred']) {
$list++;
}
if($b['backstepped']) {
$jumpOf++;
}
if($b['on_waitlist'] && !$b['transferred'] && $b['studityp'] == "ALUMN") {
$wl_al++;
}
if($b['on_waitlist'] && !$b['transferred'] && $b['studityp'] != "ALUMN") {
$wl++;
}
}
$list = $list-$jumpOf;
AdminBase::$PAGES['list'] = 'Meldeliste('.$list.')';
AdminBase::$PAGES['jumpOf'] = 'Abspringer('.$jumpOf.')';
AdminBase::$PAGES['wl'] = 'Warteliste('.$wl.')';
AdminBase::$PAGES['wl_al'] = 'Warteliste (Alumnis)('.$wl_al.')';
}
private function isLoggedIn() {
return $this->isAdmin or $this->isSudo;
}
private function getRequestedPage() {
if ($this->isLoggedIn()) {
$pagefile = __DIR__ . '/pages_' . $this->requerestedPage . '.php';
if (!isset(AdminBase::$PAGES[$this->requerestedPage]) or
(in_array($this->requerestedPage, AdminBase::$SUPERADMIN_PAGES) and !$this->isSudo) or
!@file_exists($pagefile)
) {
$this->pageStatus = AdminBase::STATE_404;
return null;
} else {
try {
require_once $pagefile;
$classname = 'Admin' . ucfirst($this->requerestedPage) . 'Page';
$this->pageStatus = AdminBase::STATE_200;
return new $classname($this);
} catch (Exception $e) {
$this->pageStatus = AdminBase::STATE_500;
$this->exceptionMessage = $e->getMessage();
return null;
}
}
} else {
$this->pageStatus = AdminBase::STATE_403;
return null;
}
}
protected function echoHeaders() {
if (!empty($this->page))
echo $this->page->getHeaders();
}
protected function echoContent() {
if ($this->pageStatus === AdminBase::STATE_200) {
echo $this->page->getText();
} elseif ($this->pageStatus === AdminBase::STATE_403) {
$this->echoLoginForm();
} elseif ($this->requerestedPage == 'front') {
$this->echoRegistrationPage();
} else {
$this->echoPage404();
}
}
protected function echoHeader() {
if (!empty($this->page))
echo $this->page->getHeader();
}
protected function echoTitle() {
echo 'FSFahrt - Admin Panel';
}
protected function echoFooter() {
if (!empty($this->page))
echo $this->page->getFooter();
}
protected function echoNavigation() {
if ($this->isLoggedIn()) {
echo $this->makeNavigationItems(AdminBase::$PAGES, AdminBase::$PAGE_OVERRIDE);
}
}
private function echoPage404() {
echo '
<div style="background-color:black; color:antiquewhite; font-family: \'Courier New\', Courier, monospace;height: 100%; width: 100%;position:fixed; top:0; padding-top:40px;">
$ get-page ' . $this->requerestedPage . '<br />';
if ($this->pageStatus == AdminBase::STATE_500) {
echo '500 - internal error (' . $this->exceptionMessage . ')<br />';
} else {
echo '404 - page not found (' . $this->requerestedPage . ')<br />';
}
echo 'access level admin: ' . ($this->isAdmin ? 'yes' : 'no') .
'<br /> access level sudo: ' . ($this->isAdmin ? 'yes' : 'no') .
'<br />$ <blink>&#9611;</blink>
</div>';
}
private function echoRegistrationPage() {
$baseurl = $this->environment->sysconf['baseURL'];
$fid = $this->environment->getCurrentTripId();
echo '<style>#admin-content{padding:0}</style>
<a href="' . $baseurl . '?fid=' . $fid . '">' . $baseurl . '?fid=' . $fid . '</a><br />
<iframe src="' . $baseurl . '?fid=' . $fid . '"
style="height:90vh; width:100%; position: absolute; border:0;"></iframe>';
}
require_once("commons_admin.php");
require_once("../frameworks/commons.php");
require_once("pages.php");
require_once("../config.inc.php");
require_once("../frameworks/medoo.php");
require '../lang.php';
$template = file_get_contents("../view/admin_template.html");
$title = "FSFahrt - Admin Panel";
$navigation = "";
$headers = "";
$header = "";
$footer = "";
$text = "";
$ajax = "";
checkIfLogin();
if (isLoggedIn())
{
$menu = array(
"Anmeldung" => "front",
"Übersicht" => "stuff",
"Meldeliste" => "list",
"Warteliste" => "wl",
"Kosten" => "cost",
"Rundmail" => "mail",
"Notizen" => "notes",
"Listenexport" => "export",
"Infos" => "infos",
"SA*" => "admin"
);
$admin_db = 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"]
));
$page = isset($_GET['page']) ? $_GET['page'] : "";
$navigation = generateNavigationItems($page, $menu);
switch($page)
{
case "front":
page_front(); break;
case "":
case "stuff":
page_stuff(); break;
case "list":
page_list(); break;
case "wl":
page_wl(); break;
case "cost":
page_cost(); break;
case "mail":
page_mail(); break;
case "notes":
page_notes(); break;
case "export":
page_export(); break;
case "infos":
page_infos(); break;
case "admin":
if(isSuperAdmin()) page_sa();
else page_404($page);
break;
default:
page_404($page);
public function exec() {
if ($this->pageStatus === AdminBase::STATE_200 and $this->page->ajaxMode) {
echo $this->page->getAjax();
} else {
if (!empty($this->page) and $this->page->template == AdminPage::TEMPLATE_PRINT_FULL) {
$this->renderPrint();
} elseif (!empty($this->page) and $this->page->template == AdminPage::TEMPLATE_PRINT_FULL) {
$this->renderPrintNoHeaders();
} else {
$this->render();
}
}
}
}
else
{
$text .= file_get_contents("../view/admin_login_form.html");
abstract class AdminPage {
const TEMPLATE_DEFAULT = 0;
const TEMPLATE_PRINT_FULL = 1;
const TEMPLATE_PRINT_MIN = 2;
public $printMode = false;
public $ajaxMode = false;
/** @var AdminBase */
protected $base;
/** @var Fahrt */
protected $fahrt;
protected $message_succ;
protected $message_err;
public $template;
abstract public function getHeaders();
abstract public function getHeader();
abstract public function getFooter();
abstract public function getText();
abstract public function getAjax();
/**
* @param $content
* @param $mode string (info, success, warning, error)
* @return string
*/
protected function getMessageBox($content, $mode) {
return '<div class="' . $mode . '">' . $content . '</div>';
}
protected function getMessage($additional = null) {
$ret = '';
$add = '';
if (!empty($additional) and is_array($additional))
$add = '<br />'.implode('<br />', $add);
if (!empty($additional))
$add = '<br />'.$additional;
if (!empty($this->message_succ)) {
$ret .= $this->getMessageBox($this->message_succ.$add, 'success');
}
if (!empty($this->message_err)) {
$ret .= $this->getMessageBox($this->message_err.$add, 'error');
}
return $ret;
}
public function __construct($base) {
$this->environment = Environment::getEnv(true);
$this->ajaxMode = isset($_REQUEST['ajax']);
$this->base = $base;
$this->fahrt = $this->environment->getTrip(true);
$this->message_err = null;
$this->message_succ = null;
$this->template = self::TEMPLATE_DEFAULT;
}
/**
* Puts out Label and Selection box
*
* @param $name
* @param $id
* @param $values
* @param $selected
* @param $subtext
* @return string
*/
protected function getFormSel($name, $id, $values, $selected, $subtext) {
$r = '<label>' . $name . '
<span class="small">' . $subtext . '</span>
</label>
<select name="' . $id . '" id="' . $id . '">';
foreach ($values as $val) {
$r .= '<option value="' . $val . '"';
if ($val == $selected) $r .= ' selected';
$r .= '>' . $val . '</option>';
}
$r .= '</select>';
return $r;
}
/**
* Puts out Label and two selection boxes side by side right below
*
* @param $name
* @param $id
* @param $values
* @param $selected
* @param $id2
* @param $values2
* @param $selected2
* @param $subtext
* @return string
*/
protected function getFormSel2($name, $id, $values, $selected, $id2, $values2, $selected2, $subtext) {
$r = '<label style="text-align:left">' . $name . '
<span class="small">' . $subtext . '</span>
</label><table><tr><td>
<select name="' . $id . '" id="' . $id . '" style="width:110px; text-align: center">';
foreach ($values as $val) {
$r .= '<option value="' . $val . '"';
if ($val == $selected) $r .= ' selected';
$r .= '>' . $val . '</option>';
}
$r .= '</select></td><td><select name="' . $id2 . '" id="' . $id2 . '">';
foreach ($values2 as $val) {
$r .= '<option value="' . $val . '"';
if ($val == $selected2) $r .= ' selected';
$r .= '>' . $val . '</option>';
}
$r .= '</select></td></tr></table>';
return $r;
}
protected function getFormInput($name, $id, $value, $subtext) {
$r = '<label>' . $name .
'<span class="small">' . $subtext . '</span>
</label>
<input type="text" name="' . $id . '" id="' . $id . '" value="' . $value . '" />';
return $r;
}
public function mysql2german($date) {
return $this->base->mysql2german($date);
}
public function resolvePath($path) {
return $this->base->resolvePath($path);
}
}
if(isset($_REQUEST['ajax']))
echo $ajax;
else{
$rep = ["{headers}" => $headers,
"{text}" => $text,
"{navigation}" => $navigation,
"{title}" => $title,
"{header}" => $header,
"{footer}" => $footer];
echo str_replace(array_keys($rep), array_values($rep), $template);
}
\ No newline at end of file
(new AdminBase())->exec();
registration-system/admin/kontonr.png

256 B

<?php
require_once("../frameworks/medoo.php");
require_once("../config.inc.php");
function page_stuff()
{
//global $text;
//$text .= "Übersichtsseite";
require_page("pages_overview.php");
}
function page_front(){
global $text, $config_baseurl, $config_current_fahrt_id;
$text .= '<a href="'.$config_baseurl.'?fid='.$config_current_fahrt_id.'">'.$config_baseurl.'?fid='.$config_current_fahrt_id.'</a><br />';
$text .= '<iframe src="'.$config_baseurl.'?fid='.$config_current_fahrt_id.'" style="height:100%; width:100%;"></iframe>';
}
function page_list(){
require_page("pages_list.php");
}
function page_404($pag)
{
global $text;
$text .='
<div style="background-color:black; color:antiquewhite; font-family: \'Courier New\', Courier, monospace;height: 100%; width: 100%;position:fixed; top:0; padding-top:40px;">
$ get-page '.$pag.'<br />
404 - page not found ('.$pag.')<br />
$ <blink>&#9611;</blink>
</div>';
}
function page_notes(){
require_page("pages_notes.php");
}
function page_mail(){
require_page("pages_mail.php");
}
function page_cost(){
require_page("pages_cost.php");
}
function page_export(){
require_page("pages_export.php");
}
function page_infos(){
require_page("pages_infos.php");
}
function page_sa(){
require_once("pages_sa.php");
}
function page_wl(){
require_once("pages_wl.php");
}
function require_page($page){
if(!@file_exists($page) ) {
page_404($page);
} else {
require_once $page;
}
}
?>
\ No newline at end of file
<?php
class AdminAdminPage extends AdminPage {
public function __construct($base) {
parent::__construct($base);
if (isset($_REQUEST['us_submit'])) {
if (!isset($_REQUEST['users'])) {
$this->message_err = 'Something went wrong with your user file submission!';
} else {
$formatCorrect = true;
foreach(explode(PHP_EOL, $_REQUEST['users']) as $line){
if (!preg_match('/^(S|N) \w+ ({SHA-256})[a-z0-9]+\$[a-z0-9]+ .*$/m', $line)) {
$formatCorrect = false;
break;
}
}
if ($formatCorrect) {
$saveResult = file_put_contents($this->environment->sysconf['adminUsersFile'], $_REQUEST['users']);
if (empty($saveResult)) {
$this->message_err = 'Tried writing to ' . $this->environment->sysconf['adminUsersFile'] . '<br />
Seems there was an error, please check if file hase chmod rw-rw-rw-!';
} else {
$this->message_succ = 'Wrote users file ' . $this->environment->sysconf['adminUsersFile'] . ' with exit code ' . $saveResult;
}
} else {
$this->message_err = 'users.txt format wrong!';
}
}
}
if (isset($_REQUEST['nf_submit'])) {
if (isset($_REQUEST['resubmit'])) {
$this->message_err = 'Nix mit neue Fahrt!';
} else {
try {
$newFahrt = Fahrt::getEmptyFahrt();
$saveResult = $newFahrt->save();
if (is_null($saveResult)) {
throw new Exception('Error beim DB insert!');
} else {
$this->message_succ = 'Neue Fahrt angelegt.';
}
} catch (Exception $e) {
$this->message_err = 'Fehler aufgetreten beim Fahrt anlegen!<br />' . $e->getMessage();
}
}
}
if (isset($_REQUEST['id_submit'])) {
if (!isset($_REQUEST['fid'])) {
$this->message_err = 'Nix mit Fahrt ID ändern!';
} else {
$newFid = trim($_REQUEST['fid']);
if (is_numeric($newFid) and $this->environment->database->has('fahrten', ['fahrt_id' => (int)$newFid])) {
$saveResult = file_put_contents($this->environment->sysconf['currentFahrtFile'], $newFid);
if (empty($saveResult)) {
$this->message_err = 'Fehler beim Fahrt ID speichern in ' . $this->environment->sysconf['currentFahrtFile'] . '<br />
check if file has chmod rw-rw-rw-!';
} else {
$this->message_succ = 'Erfolgreich Fahrt ID ' . $newFid . ' in ' .
$this->environment->sysconf['currentFahrtFile'] . ' gespeichert.<br />
Save code: ' . $saveResult;
}
} else {
$this->message_err = 'Fahrt ID nicht vorhanden oder kein int gegeben! ('.$newFid.')';
}
}
}
if (isset($_REQUEST['arc_submit'])) {
$db = $this->environment->database;
if (!isset($_REQUEST['fid'])) {
$this->message_err = 'Nix mit Fahrt archivieren!';
} else {
$fid = $_REQUEST['fid'];
//TODO: Daten archivieren
if(!$db->has('fahrten', ['fahrt_id[!]' => $fid])) {
$this->message_err = 'Es muss eine mindestens eine Fahrt geben.';
}else{
$insertion = [];
$insertion["fahrt_id"] = $fid;
$insertion["fahrt_name"] = $db->query('SELECT titel FROM fahrten WHERE fahrt_id='.$fid)->fetchAll()[0]['titel'];
$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()
];
$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])]),
'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]])
];
$data['erstis'] = $mitfahrer['merstis']+$mitfahrer['berstis']+$mitfahrer['erstis'];
$data['ratio'] = ['sum' => ($mitfahrer['mentor']+$mitfahrer['alumni']+$mitfahrer['erstis']+$mitfahrer['hoerstis'])];
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioErsti'] = round($mitfahrer['erstis']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioErsti'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioBErsti'] = round($mitfahrer['berstis']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioBErsti'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioMErsti'] = round($mitfahrer['merstis']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioMErsti'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioHoerst'] = round($mitfahrer['hoerstis']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioHoerst'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioHoerstMentoren'] = round(($mitfahrer['hoerstis']+$mitfahrer['mentor'])/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioHoerstMentoren'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioMento'] = round($mitfahrer['mentor']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioMento'] = round(100, 2);
if ($data['ratio']['sum'] > 0)
$data['ratio']['ratioAlumn'] = round($mitfahrer['alumni']/$data['ratio']['sum']*100, 2);
else
$data['ratio']['ratioAlumn'] = round(100, 2);
$insertion['tab1'] = [
'[{"key":"Gesamt","val":"'. $mitfahrer['gesamt'].'('.$mitfahrer['gesamt_all'].')"},'.
'{"key":" Erste Nacht","val":"'.$mitfahrer['erste'].'"},'.
'{"key":" Zweite Nacht","val":"'.$mitfahrer['zweite'].'"},'.
'{"key":" Nitcht-Allesesser","val":"'.($mitfahrer['vege']+$mitfahrer['vega']).'"},'.
'{"key":" Vegetarier","val":"'.$mitfahrer['vege'].'"},'.
'{"key":" Veganer","val":"'.$mitfahrer['vega'].'"},'.
'{"key":" Zurückgetreten","val":"'.$mitfahrer['backstepped'].'"},'.
'{"key":" Personen am Treffpunkt","val":"'.$mitfahrer['treffpunkt'].'"},'.
'{"key":"Warteliste (gesamt)","val":"'.$mitfahrer['on_waitlist'].'"},'.
'{"key":"= Warteliste Alumnis","val":"'.$mitfahrer['wl_al'].'"},'.
'{"key":"= Warteliste Rest","val":"'.$mitfahrer['wl'].'"},'.
'{"key":" Übertragen","val":"'.$mitfahrer['transferred'].'"},'.
'{"key":" Nicht Übertragen","val":"'.$mitfahrer['waiting'].'"}]'
][0];
$insertion['tab2'] = [
'[{"key":"Minderjährige","val":"'. $mitfahrer['virgins'].'"},'.
'{"key":"Erstis","val":"'.$mitfahrer['erste'].'"},'.
'{"key":"Alumnis","val":"'.$mitfahrer['alumni'].'"},'.
'{"key":"Hörstis","val":"'.$mitfahrer['hoerstis'].'"},'.
'{"key":"Orgas","val":"'.$mitfahrer['orgas'].'"},'.
'{"key":"MentorIn","val":"'.$mitfahrer['mentor'].'"},'.
'{"key":"= Anteil Hörstis","val":"'.$data['ratio']['ratioHoerst'].'%"},'.
'{"key":"= Anteil Mentoren","val":"'.$data['ratio']['ratioMento'].'%"},'.
'{"key":"= Anteil Alumnis","val":"'.$data['ratio']['ratioAlumn'].'%"},'.
'{"key":"= Anteil Hörstis + Mentoren","val":"'.$data['ratio']['ratioHoerstMentoren'].'%"},'.
'{"key":"= Anteil Erstis","val":"'.$data['ratio']['ratioErsti'].'%"},'.
'{"key":"=> Anteil Bachelor Erstis","val":"'.$data['ratio']['ratioBErsti'].'%"},'.
'{"key":"=> Anteil Master Erstis","val":"'.$data['ratio']['ratioMErsti'].'%"}]'
][0];
$insertion['moniTab1'] = $db->get('cost', 'tab1', ['fahrt_id' => $fid]);
$insertion['moniTab2'] = $db->get('cost', 'tab2', ['fahrt_id' => $fid]);
$insertion['moniTab3'] = $db->get('cost', 'tab3', ['fahrt_id' => $fid]);
$insertion['moniTabIO'] = $db->get('cost', 'moneyIO', ['fahrt_id' => $fid]);
$mitfahrer['inTake'] = $db->get('cost', 'collected', ['fahrt_id' => $fid]);
$mitfahrer['bezahlt'] = $db->count('bachelor', ['AND' => array_merge($baseW, ['paid[!]' => null])]);
$insertion['moniTabIOExtra'] = [
'{"in":[{"pos":"Vorkasse","val":"'.$mitfahrer['bezahlt']*$mitfahrer['inTake'].'"}],
"out":[{"pos":"Rückzahlungen","val":"'.$_REQUEST['repaidAll'].'"}]}'
][0];
$code = $db->insert('archive', $insertion);
if (is_null($code)) {
$this->message_err = 'Datenbank Speicher Fehler!';
return;
}
//DATEN LÖSCHEN
$db->delete('bachelor', ['fahrt_id'=>$fid]);
$db->delete('fahrten', ['fahrt_id'=>$fid]);
$db->delete('notes', ['fahrt_id'=>$fid]);
$db->delete('cost', ['fahrt_id'=>$fid]);
$newFid = $this->environment->database->query("SELECT fahrt_id FROM `fahrten` LIMIT 1")->fetchAll()[0]['fahrt_id'];
if (is_numeric($newFid) and $db->has('fahrten', ['fahrt_id' => (int)$newFid])) {
$saveResult = file_put_contents($this->environment->sysconf['currentFahrtFile'], $newFid);
if (empty($saveResult)) {
$this->message_err = 'Fehler beim Fahrt ID speichern in ' . $this->environment->sysconf['currentFahrtFile'] . '<br />
check if file has chmod rw-rw-rw-!';
} else {
$this->message_succ = 'Erfolgreich Fahrt ID ' . $newFid . ' in ' .
$this->environment->sysconf['currentFahrtFile'] . ' gespeichert.<br />
Save code: ' . $saveResult;
}
} else {
$this->message_err = 'Fahrt ID nicht vorhanden oder kein int gegeben! ('.$newFid.')';
}
$this->environment->sysconf= 'Alle Daten wurden gelöscht!';
}
}
}
}
private function getUserFileContent() {
if (file_exists($this->environment->sysconf['adminUsersFile']))
return file_get_contents($this->environment->sysconf['adminUsersFile']);
return '';
}
private function getUserFileEditSection() {
return '<h2>Nutzer bearbeiten</h2>
ACHTUNG: Tippfehler können Systemfunktionalität beeinträchtigen! <i>Format: {N|S}⎵USERNAME⎵PASSWORD⎵{0|1}⎵RANDOMSTUFF</i><br />
<i>N = Organisator der Fahrt; S = Superadmin (sieht auch diese Seite)</i><br />
<i>0 = Farbblindenmodus; 1 = Normaler (nicht hässlicher) Modus</i><br />
line regex: "^(S|N) \w+ ({SHA-256})[a-z0-9]+\$[a-z0-9]+ .*$/m" <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">' . $this->getUserFileContent() . '</textarea><br />
<input type="submit" name="us_submit" id="us_submit" value="us_submit" />
</form>';
}
private function getNeueFahrtSection() {
return '<h2>Neue Fahrt anlegen</h2>
<form method="POST" target="?resubmit=not">
<input type="submit" name="nf_submit" value="nf_submit" id="nf_submit" />
</form> ';
}
private function getCurrentFahrtSelectorSection() {
$fahrten = Fahrt::getAlleFahrten();
$current = $this->fahrt->getID();
$ret = '<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: ' . $current . '):</label>
<select name="fid" id="fid">';
foreach ($fahrten as $fahrt) {
$ret .= '<option value="' . $fahrt->getID() . '">' . $fahrt->getID() . ' - ' . $fahrt->getFahrtDetails()['titel'] . '</option>';
}
$ret .= '</select>
<input type="submit" name="id_submit" value="id_submit" id="id_submit" />
</form>';
return $ret;
}
private function getArchiveSelectorSection() {
$fahrten = Fahrt::getAlleFahrten();
$ret = '<h2>Fahrt Archivieren</h2>
Wählt die Fahrt, die Archiviert werden soll.<br>
<b>ACHTUNG: Mit Archivierung einer Fahrt wird ein großteil der Daten unwiederruflich gelöscht.</b>
<form method="POST" >
<label>Archivierungs ID wählen:</label>
<select name="fid" id="fid">
<option value="-1"></option>';
foreach ($fahrten as $fahrt) {
$ret .= '<option value="' . $fahrt->getID() . '">' . $fahrt->getID() . ' - ' . $fahrt->getFahrtDetails()['titel'] . '</option>';
}
$ret .= '</select><br>
<label>Bitte den Wert "Rückzahlungen (getätigt)" eintragen: (Form: "120.00")</label>
<input type="text" name="repaidAll" id="repaidAll"/><br><br>
<input type="submit" name="arc_submit" value="arc_submit" id="arc_submit" />
</form><br>';
return $ret;
}
public function getHeaders() {
return '';
}
public function getHeader() {
return '';
}
public function getFooter() {
return '';
}
public function getText() {
return '<h1>SuperAdmin Panel</h1>' .
$this->getMessage() .
$this->getUserFileEditSection() .
$this->getNeueFahrtSection() .
$this->getCurrentFahrtSelectorSection() .'<br>';
// $this->getArchiveSelectorSection() .'<br>';
}
public function getAjax() {
return '';
}
}
<?php
class AdminArchivePage extends AdminPage {
private $data, $data2, $current;
public function __construct($base) {
parent::__construct($base);
$db = $this->environment->database;
$this->data2 = $db->query('SELECT id, fahrt_name FROM archive')->fetchAll();
if(isset($_POST['cid'])) {
$this->current = $_POST['cid'];
}else if(isset($this->data2[0])) {
$this->current = $this->data2[0]['id'];
}else{
$this->current = "-1";
}
$this->data = $db->get('archive', ['fahrt_name' => $this->current]);
}
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/angular.min.js"></script>
<script type="text/javascript" src="archive.js"></script>
';
}
public function getHeader() {
return '';
}
public function getFooter() {
return '';
}
public function getText() {
if(empty($this->data2)) {
return '<h1>Es wurde bisher keine Fahrt archiviert. Selbst schuld.</h1>';
}
$ret = '
<script type="text/javascript">
var cc = ' . $this->current . ';
</script>
<h1>Fahrten Archive</h1>
<div style="float:left; margin-left: 15px">
<h2>Fahrt wählen</h2>
<form method="POST">
<label>Neue Fahrt wählen (aktuell: ' . $this->current . '): </label>
<select name="cid" id="cid">';
foreach ($this->data2 as $fahrt) {
$ret .= '<option value="' . $fahrt['id'] . '">' . $fahrt['id'].' - '.$fahrt['fahrt_name'] . '</option>';
}
$ret .= '</select>
<input type="submit" name="id_submit" value="id_submit" id="id_submit" />
</form>
<br><hr><br>
<div ng-app="tab">
<table>
<tr>
<td><h4>Mitfahrende</h4></td>
<td width="40px"></td>
<td><h4>Verteilung</h4></td>
</tr>
<tr>
<td>
<div ng-controller="tab1Controller as table">
<table>
<tr ng-repeat="row in table.tab1">
<td>{{row.key || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:center;">{{row.val || "&nbsp;" }}</td>
</tr>
</table>
</div>
</td>
<td></td>
<td>
<div ng-controller="tab2Controller as table">
<table>
<tr ng-repeat="row in table.tab2">
<td>{{row.key || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:center;">{{row.val || "&nbsp;" }}</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<h4>Kosten pro Person</h4>
<div ng-controller="moniTab1Controller as table">
<table>
<tr ng-repeat="row in dataService.calc">
<td>{{row.pos}}</td>
<td width="15px"></td>
<td style="text-align:right;">{{row.cnt()}}</td>
<td width="15px"></td>
<td style="text-align:right;">{{row.val() | currency}}</td>
<td width="15px"></td>
<td style="text-align:right;">{{row.sum() | currency}}</td>
</tr>
<tr>
<td>(Vorkasse)</td><td></td><td></td><td></td><td></td><td></td>
<td>{{table.amount || 0 | currency}}</td>
</tr>
<tr>
<td>Summe</td><td></td><td></td><td></td><td></td><td></td>
<td>{{dataService.sum() | currency}}</td>
</tr>
</table>
</div>
<h4>Einkauf</h4>
<div ng-controller="moniTab2Controller as table">
<table>
<tr ng-repeat="row in table.moniTab2">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.cnt || 1 }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{row.price || 0 | currency}}</td>
<td width="15px"></td>
<td style="text-align:right;">{{dataService.rowSum(row) | currency}}</td>
</tr>
<tr>
<td>Summe</td><td></td><td></td>
<td></td><td></td><td></td>
<td style="text-align:right;">{{dataService.sum() | currency}}</td>
</tr>
</table>
</div>
<h4>Herberge</h4>
<div ng-controller="moniTab3Controller as table">
<table>
<tr ng-repeat="row in table.moniTab3">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.cnt || 1 }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.mul || 1 }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.price || 0 | currency}}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ dataService.rowSum(row) | currency}}</td>
</tr>
<tr>
<td>Summe</td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td>
<td style="text-align:right;">{{dataService.sum() | currency}}</td>
</tr>
</table>
</div>
<h4>In Out</h4>
<div ng-controller="moniTabIOController as table">
<table>
<tr>
<td>
<table>
<tr ng-repeat="row in table.extra.in">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.val || 0 | currency}}</td>
</tr>
<tr ng-repeat="row in table.moniTabIO.in">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.val || 0 | currency}}</td>
</tr>
</table>
</td>
<td width="15px"></td>
<td>
<table>
<tr ng-repeat="row in table.extra.out">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.val || 0 | currency}}</td>
</tr>
<tr ng-repeat="row in table.moniTabIO.out">
<td>{{ row.pos || "&nbsp;" }}</td>
<td width="15px"></td>
<td style="text-align:right;">{{ row.val || 0 | currency}}</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align:right;">{{dataService.colSum(table.moniTabIO.in, table.extra.in) | currency}}</td>
<td></td>
<td style="text-align:right;">{{dataService.colSum(table.moniTabIO.out, table.extra.out) | currency}}</td>
</tr>
</table>
</div>
</div>
<br><br>
</div>
';
return $ret;
}
public function getAjax() {
$id = 1;
$db = $this->environment->database;
$task = $_REQUEST['ajax'];
if(isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
}
if (isset($_REQUEST['data'])) {
$data = $_REQUEST['data'];
} elseif (strpos($task, 'set') !== false && strpos($task, 'json') !== false) {
$data = file_get_contents('php://input');
}
switch ($task) {
case 'get-tab1-json':
header('Content-Type: application/json');
return $db->get('archive', 'tab1', ['id' => $id]);
case 'get-tab2-json':
header('Content-Type: application/json');
return $db->get('archive', 'tab2', ['id' => $id]);
case 'get-moniTab1-json':
header('Content-Type: application/json');
return $db->get('archive', 'moniTab1', ['id' => $id]);
case 'get-moniTab2-json':
header('Content-Type: application/json');
return $db->get('archive', 'moniTab2', ['id' => $id]);
case 'get-moniTab3-json':
header('Content-Type: application/json');
return $db->get('archive', 'moniTab3', ['id' => $id]);
case 'get-moniTabIO-json':
header('Content-Type: application/json');
return $db->get('archive', 'moniTabIO', ['id' => $id]);
case 'get-other-json':
header('Content-Type: application/json');
return $db->get('archive', 'moniTabIOExtra', ['id' => $id]);
}
return '';
}
}
?>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 10/4/14
* Time: 9:36 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;
// AJAX requests up here ============================================================
if(isset($_REQUEST['ajax'])){
$data = "";
$fid = $config_current_fahrt_id;
$task = $_REQUEST['ajax'];
if(isset($_REQUEST['data'])){
$data = $_REQUEST['data'];
} elseif( strpos($task, "set")!==false && strpos($task, "json")!==false ){
$data = file_get_contents("php://input");
}
if(!$admin_db->has("cost", ["fahrt_id" => $fid]))
$admin_db->insert("cost", ["fahrt_id" => $fid, "tab1"=>"", "tab2"=>"", "tab3" => "", "moneyIO"=>"", "collected"=>60]);
switch($task){
// == GETTER ==
case "get-price-json":
header('Content-Type: application/json');
$ajax = $admin_db->get("cost", "tab1", ["fahrt_id" => $fid]);
break;
case "get-shopping-json":
header('Content-Type: application/json');
$ajax = $admin_db->get("cost", "tab2", ["fahrt_id" => $fid]);
break;
case "get-receipt-json":
header('Content-Type: application/json');
$ajax = $admin_db->get("cost", "tab3", ["fahrt_id" => $fid]);
break;
case "get-moneyio-json":
header('Content-Type: application/json');
$ajax = $admin_db->get("cost", "moneyIO", ["fahrt_id" => $fid]);
break;
case "get-other-json":
header('Content-Type: application/json');
$ret['remain'] = $admin_db->select("bachelor", ["forname", "sirname", "bachelor_id", "anday(von)", "abday(bis)", "antyp", "abtyp"],
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid,
"repaid" => NULL
]]);
$ret['back'] = $admin_db->select("bachelor", ["forname", "sirname", "bachelor_id", "anday(von)", "abday(bis)", "antyp", "abtyp"],
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid,
"repaid[!]" => NULL
]]);
$ret['bezahlt']= $admin_db->count("bachelor",
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid,
"paid[!]" => NULL
]]);
$ret['count'] = $admin_db->count("bachelor",
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid
]]);
$ret['cnt']['all'] = $ret['count'];
$ret['cnt']['geman'] = $admin_db->count("bachelor",
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid,
"antyp" => $config_reisearten_o["BUSBAHN"]
]]);
$ret['cnt']['gemab'] = $admin_db->count("bachelor",
["AND"=> [
"backstepped" => NULL,
"fahrt_id" => $fid,
"abtyp" => $config_reisearten_o["BUSBAHN"]
]]);
$ret['amount']= $admin_db->get("cost", "collected",[ "fahrt_id" => $fid]);
$ret['fahrt'] = $admin_db->get("fahrten", ["von", "bis"], ["fahrt_id" => $fid]);
$ret['arten'] = $config_reisearten_o;
if(!$ret['remain'])
$ret['remain'] = [];
if(!$ret['back'])
$ret['back'] = [];
$ajax = json_encode($ret);
break;
// == SETTER ==
case "set-price-json":
$admin_db->update("cost",["tab1" => $data], ["fahrt_id" => $fid]);
break;
case "set-shopping-json":
$admin_db->update("cost",["tab2" => $data], ["fahrt_id" => $fid]);
break;
case "set-receipt-json":
$admin_db->update("cost",["tab3" => $data], ["fahrt_id" => $fid]);
break;
case "set-moneyio-json":
$admin_db->update("cost",["moneyIO" => $data], ["fahrt_id" => $fid]);
break;
case "set-amount":
$admin_db->update("cost",["collected" => $data], ["fahrt_id" => $fid]);
break;
// == DEFAULT ==
default:
break;
}
}
class AdminCostPage extends AdminPage {
// base/static stuff down here ===========================================================
else {
$headers .= '
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/angular.min.js"></script>
<script type="text/javascript" src="../view/js/xeditable.js"></script>
......@@ -138,49 +14,154 @@ else {
<script type="text/javascript" src="pages_cost/pages_cost.js"></script>
<link type="text/css" rel="stylesheet" href="pages_cost/pages_cost.css" />
<link type="text/css" rel="stylesheet" href="../view/css/toastr.css" />';
}
public function getHeader() {
return '';
}
$text .= '
<div ng-app="pages-cost">
<h1>Kostenaufstellung</h1>
public function getFooter() {
return '';
}
<div ng-controller="TablePriceController as table">
<h2>Kosten pro Person</h2>
<table-price></table-price>
public function getText() {
return '
<div ng-app="pages-cost">
<h1>Kostenaufstellung</h1>
<div ng-controller="TablePriceController as table">
<h2>Kosten pro Person</h2>
<table-price></table-price>
</div>
<div ng-controller="TableShoppingController as table">
<h2>Einkaufen</h2>
<table-shopping></table-shopping>
</div>
<div ng-controller="TableReceiptController as table">
<h2>Herbergsrechnung</h2>
<table-receipt></table-receipt>
</div>
<div ng-controller="TableMoneyioController as table">
<h2>Money In/Out</h2>
<table-moneyio></table-moneyio>
</div>
</div>
<div ng-controller="TableShoppingController as table">
<h2>Einkaufen</h2>
<table-shopping></table-shopping>
</div>
<div ng-controller="TableReceiptController as table">
<h2>Herbergsrechnung</h2>
<table-receipt></table-receipt>
<div class="cost-anmerkung">
Hinweise:<br />
<ul>
<li>Zurückgezogene Registrierungen werden hier nicht beachtet! Wenn Bezahlung erhalten unbedingt seperat auf dem Notizzettel verwalten!</li>
<li>Eingesammelter Betrag wird nicht individuell gespeichert. Wird er geändert sind ggf. unterschiedliche Beträge nicht erfasst.</li>
<li>Für falsche Berechnungen wird keine Haftung übernommen. Wenn unsicher -> selbst rechnen und nachprüfen!</li>
<li>Die <strong>effektive</strong> Förderung muss in der "Kosten pro Person"-Tabelle angepasst werden</li>
<li>In der "Kosten pro Person"-Tabelle müssen die <strong>effektiven</strong> Kosten angegeben werden.</li>
<li>Es erfolgt keine Validierung eingegeber Typen. Dezimaltrennzeichen ist ".", nicht ",".</li>
<li>Berechnungen erfolgen mit eingegebener Präzision (ggf. abweichend von der auf zwei Stellen gerundeten Anzeige)</li>
<li>Manche Variablen updaten sich nicht automatisch. Seite neu laden hilft in dem Fall.</li>
<li>Die CSS-Klasse debug blendet debugdaten aus. Zum "Export" können die Werte kopiert werden, wenn man sich die Elemente einblenden lässt.</li>
</ul>
</div>
<p><a href="./pages_cost/log.html" target="_blank">Logfile</a></p>';
}
<div ng-controller="TableMoneyioController as table">
<h2>Money In/Out</h2>
<table-moneyio></table-moneyio>
</div>
</div>
<div class="cost-anmerkung">
Hinweise:<br />
<ul>
<li>Zurückgezogene Registrierungen werden hier nicht beachtet! Wenn Bezahlung erhalten unbedingt seperat auf dem Notizzettel verwalten!</li>
<li>Eingesammelter Betrag wird nicht individuell gespeichert. Wird er geändert sind ggf. unterschiedliche Beträge nicht erfasst.</li>
<li>Für falsche Berechnungen wird keine Haftung übernommen. Wenn unsicher -> selbst rechnen und nachprüfen!</li>
<li>Die <strong>effektive</strong> Förderung muss in der "Kosten pro Person"-Tabelle angepasst werden</li>
<li>In der "Kosten pro Person"-Tabelle müssen die <strong>effektiven</strong> Kosten angegeben werden.</li>
<li>Es erfolgt keine Validierung eingegeber Typen. Dezimaltrennzeichen ist ".", nicht ",".</li>
<li>Berechnungen erfolgen mit eingegebener Präzision (ggf. abweichend von der auf zwei Stellen gerundeten Anzeige)</li>
<li>Manche Variablen updaten sich nicht automatisch. Seite neu laden hilft in dem Fall.</li>
<li>Die CSS-Klasse debug blendet debugdaten aus. Zum "Export" können die Werte kopiert werden, wenn man sich die Elemente einblenden lässt.</li>
</ul>
</div>
';
}
\ No newline at end of file
public function getAjax() {
// some shorthands
$fid = $this->fahrt->getID();
$db = $this->environment->database;
$data = '';
// read payload
$task = $_REQUEST['ajax'];
if (isset($_REQUEST['data'])) {
$data = $_REQUEST['data'];
} elseif (strpos($task, 'set') !== false && strpos($task, 'json') !== false) {
$data = file_get_contents('php://input');
}
// if no data is there yet, add it!
if (!$db->has('cost', ['fahrt_id' => $fid])) {
$db->insert('cost',
['fahrt_id' => $fid, 'tab1' => '', 'tab2' => '', 'tab3' => '', 'moneyIO' => '', 'collected' => 60]);
}
switch ($task) {
// == GETTERS ==
case 'get-price-json':
header('Content-Type: application/json');
return $db->get('cost', 'tab1', ['fahrt_id' => $fid]);
case 'get-shopping-json':
header('Content-Type: application/json');
return $db->get('cost', 'tab2', ['fahrt_id' => $fid]);
case 'get-receipt-json':
header('Content-Type: application/json');
return $db->get('cost', 'tab3', ['fahrt_id' => $fid]);
case 'get-moneyio-json':
header('Content-Type: application/json');
return $db->get('cost', 'moneyIO', ['fahrt_id' => $fid]);
case 'get-other-json':
header('Content-Type: application/json');
$notwaiting = ['on_waitlist' => 0,
'AND' => [
'transferred[!]' => null,
'on_waitlist' => 1
]];
$baseW = ['fahrt_id' => $fid, 'OR' => $notwaiting, 'backstepped' => null];
$ret['remain'] = $db->select('bachelor', ['forname', 'sirname', 'bachelor_id', 'anday(von)', 'abday(bis)', 'antyp', 'abtyp'],
['AND' => array_merge($baseW, ['repaid' => null])]);
$ret['back'] = $db->select('bachelor', ['forname', 'sirname', 'bachelor_id', 'anday(von)', 'abday(bis)', 'antyp', 'abtyp'],
['AND' => array_merge($baseW, ['repaid[!]' => null])]);
$ret['bezahlt'] = $db->count('bachelor',
['AND' => array_merge($baseW, ['paid[!]' => null])]);
$ret['count'] = $db->count('bachelor',
['AND' => $baseW]);
$ret['cnt']['all'] = $ret['count'];
$ret['cnt']['geman'] = $db->count('bachelor',
['AND' => array_merge($baseW, ['antyp' => 'BUSBAHN'])]);
$ret['cnt']['gemab'] = $db->count('bachelor',
['AND' => array_merge($baseW, ['antyp' => 'BUSBAHN'])]);
$ret['amount'] = $db->get('cost', 'collected', ['fahrt_id' => $fid]);
$ret['fahrt'] = $db->get('fahrten', ['von', 'bis'], ['fahrt_id' => $fid]);
$ret['arten'] = $this->environment->oconfig['reisearten'];
if (!$ret['remain'])
$ret['remain'] = [];
if (!$ret['back'])
$ret['back'] = [];
return json_encode($ret);
// == SETTER ==
case 'set-price-json':
$db->update('cost', ['tab1' => $data], ['fahrt_id' => $fid]);
break;
case 'set-shopping-json':
$db->update('cost', ['tab2' => $data], ['fahrt_id' => $fid]);
break;
case 'set-receipt-json':
$db->update('cost', ['tab3' => $data], ['fahrt_id' => $fid]);
break;
case 'set-moneyio-json':
$db->update('cost', ['moneyIO' => $data], ['fahrt_id' => $fid]);
break;
case 'set-amount':
$db->update('cost', ['collected' => $data], ['fahrt_id' => $fid]);
break;
// == DEFAULT ==
default:
break;
}
}
}
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 8/21/14
* Time: 10:50 PM
*/
global $config_studitypen, $config_reisearten, $config_essen, $admin_db, $config_current_fahrt_id, $config_admin_verbose_level, $config_verbose_level, $text, $headers, $ajax;
$headers .= '<script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script>
<script src="../view/js/jquery.tabletojson.js"></script>
<script src="../view/js/jquery.jeditable.js"></script>';
$text .= "<h3>Kalkulation</h3>";
$h1 = array("Position", "Anzahl (normal)", "Satz", "Summe");
$s1[3] = array(1,2);
$t1[2] = " €";
$t1[3] = " €";
$d1 = array(array("Reisekosten", 2, 1.9),
array("Übernachtung (HP)", 2, 17.8),
array("Bettwäsche", 1, 4),
array("Grillen", 1, 0.3),
array("Kurzreisezuschlag", 1, 2));
$text .= html_table($h1, $d1, $s1, $t1, "test");
$text .= '<span id="anc_add">add</span> - <span id="anc_rem">rem</span>';
$text .= "<h2>Einkaufen</h2>";
$h2 = array("Position", "Anzahl", "Satz", "Summe");
$s2[3] = array(1,2);
$t2[2] = " €";
$t2[3] = " €";
$d2 = array(array("Club Mate", 120, 0.69),
array("Chips", 15,0.5),
array("Flips", 15, 0.5),
array("Fanta", 24, 0.39),
array("Wasser", 42, 0.3));
$text .= html_table($h2, $d2, $s2, $t2);
$text .= "<h3>Rechnung</h3>";
$h3 = array("Position", "Menge", "Anzahl", "Satz", "Summe");
$s3[4] = array(1,2,3);
$t3[3] = " €";
$t3[4] = " €";
$d3 = array(
array("Übernachtung", 2, 69, 10.5),
array("Bettwäsche", 1, 75, 4),
array("Grillnutzung", 1, 69, 0.3),
array("Kurzreisezuschlag", 1, 69, 2),
array("Halbpension", 2, 69, 7.3));
$text .= html_table($h3, $d3, $s3, $t3);
$text .= "<h2>Money In/Out</h2>";
$text .= '<div style="float:left">';
$h4 = array("Position", "Summe");
$s4 = array();
$t4[1] = " €";
$d4_out = array(
array("Frauensee", 2815.1),
array("Einkauf", 590.13),
array("Busfahrt", 216),
array("Bäcker", 22.4),
array("Kaution", 100)
);
$d4_in = array(
array("Pfand1", 82.17),
array("Pfand2", 10),
array("Pfand3", 15),
array("Fachschaft (Reste)", 76),
array("Kollekte", 4620),
array("Förderung", 2200),
array("Kaution", 100)
);
$text .= html_table($h4, $d4_out, $s4, $t4);
$text .= '</div><div style="float:left">';
$text .= html_table($h4, $d4_in, $s4, $t4);
$text .= '</div><div style="clear:both"></div>';
$text .="<script type='text/javascript'>
$('#testy').click( function() {
var table = $('#test').tableToJSON(); // Convert the table into a javascript object
console.log(table);
alert(JSON.stringify(table));
});
function ref_editable(){
$('.edita').editable(function(value, settings){return(value);},
{
indicator : '<img src=\'img/indicator.gif\'>',
tooltip : 'Click to edit...',
style : 'inherit',
callback : function(value, settings){
var table = $('#test').tableToJSON(); // Convert the table into a javascript object
console.log(JSON.stringify(table));
}
}
);
}
$(function(){
ref_editable();
var cnt = 2;
$('#anc_add').click(function(){
$('#test>tbody tr').last().after('<tr><td class=\'edita\'>Static Content ['+cnt+']</td><td class=\'edita\'></td><td class=\'edita\'></td><td class=\'edita\'></td></tr>');
cnt++;
ref_editable();
});
$('#anc_rem').click(function(){
if($('#test>tbody tr').size()>1){
$('#test>tbody tr:last-child').remove();
}else{
alert('One row should be present in table');
}
});
});
</script>";
/**
* $headers
* is an array of the headers
* $data
* is an array with the data to output
* $sum
* is an array declaring which cols should be summed up and put below the table,
* second dimension declares which cols need to be multiplied (if no second dimension, just sum at the end)
* $type
* is an array declaring type of data to put behind the value (i.e. €), not all cols need to be declared
*
* return value: variable containing the html code for echo
*/
function html_table($header, $data, $sum = array(), $type = array(), $id=""){
$summy = array();
$ret = "<table class=\"cost-table\" id=\"".$id."\">
<thead>
<tr>\n";
foreach($header as $h)
$ret.= "<th>".$h."</th>\n";
$ret.=" </tr>
</thead>
<tbody>\n";
$cnt = 0;
foreach($data as $row){
$ret.="<tr>";
for($i = 0; $i < count($header); $i++){
$cnt++;
$ret.= "<td".numeric_class($row, $sum, $i)." id='cell".$id.$cnt."'>";
if(isset($row[$i])){
$ret .= prepval($row[$i],(isset($type[$i]) ? $type[$i] : ""));
if(isset($sum[$i])){
if(!isset($summy[$i]))
$summy[$i] = $row[$i];
else
$summy[$i] += $row[$i];
}
} elseif(isset($sum[$i])) {
if(count($sum[$i])>1){
$tmp = NULL;
foreach($sum[$i] as $s){
$tmp = (is_null($tmp)) ? $row[$s] : $tmp*$row[$s];
}
$ret .= prepval($tmp,(isset($type[$i]) ? $type[$i] : ""));
if(!isset($summy[$i]))
$summy[$i] = $tmp;
else
$summy[$i] += $tmp;
} else {
// do nothing, sum at the end
}
}
$ret.="</td>";
}
$ret.="</tr>";
}
$ret.= "</tbody>\n";
if(count($sum)>0){
$ret.= "<tfoot>
<tr>\n";
for($i = 0; $i < count($header); $i++){
if(isset($sum[$i])){
$ret.='<td>'.prepval($summy[$i],(isset($type[$i]) ? $type[$i] : "")).'</td>';
} else {
$ret.='<td class="cost-table-invisible"></td>';
}
}
$ret.= " </tr>
</tfoot>\n";
}
$ret.= "</table>";
return $ret;
}
function prepval($val, $post){
if(strpos($post, "€")!==false)
return number_format($val, 2, ',', ' ').$post;
return $val.$post;
}
function numeric_class($a,$b,$c){
$d = ' class="cost-table-numeric edita"';
if(isset($a[$c])){
if(is_numeric($a[$c]))
return $d;
}
if(isset($b[$c]))
return $d;
return ' class="edita"';
}
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:07.33 - 01.05.2018 | IO(Kuchen, 2 Geld) wurde erstellt.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:26.27 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:26.27 - 01.05.2018 | IO(undefined, undefined Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:29.09 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:29.09 - 01.05.2018 | IO(, 0 Geld) wurde gel&ouml;scht.<br>
21:30.04 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:30.04 - 01.05.2018 | IO(Test, 2 Geld) wurde erstellt.<br>
21:30.10 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(Test, 2 Geld) wurde gel&ouml;scht.<br>
21:30.10 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:30.10 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(terst, 2 Geld) wurde erstellt.<br>
21:31.02 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:31.02 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(&Uuml;bertrag WS 17/18, 132.63 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(terst, 2 Geld) wurde gel&ouml;scht.<br>
21:31.07 - 01.05.2018 | IO(Pfand, 0 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(&Uuml;bertrag WS 18/19, 132.63 Geld) wurde gespeichert.<br>
21:31.07 - 01.05.2018 | IO(Ausgleich, 0 Geld) wurde gespeichert.<br>