Compare commits

..

No commits in common. "44a94b70073ae9399103331abc097bb16baa0236" and "bb83ae3074fb62fa42407f0833ec63cc0cc570bf" have entirely different histories.

22 changed files with 31 additions and 108809 deletions

View File

@ -21,9 +21,6 @@
#include "period_year.h" #include "period_year.h"
#include "payment_rate.h" #include "payment_rate.h"
#include "atb_project.h" #include "atb_project.h"
#include "tariff_daily_ticket.h"
#include <QVector>
using namespace std; using namespace std;
using namespace rapidjson; using namespace rapidjson;
@ -44,7 +41,6 @@ public:
multimap<int, ATBPeriodYear> YearPeriod; multimap<int, ATBPeriodYear> YearPeriod;
multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime; multimap<int, ATBWeekDaysWorktime> WeekDaysWorktime;
multimap<int, ATBPaymentOption> PaymentOption; multimap<int, ATBPaymentOption> PaymentOption;
multimap<int, ATBDailyTicket> DailyTicket;
/// <summary> /// <summary>
/// Parse JSON string /// Parse JSON string
@ -53,8 +49,7 @@ public:
/// <returns>Returns operation status bool (OK | FAIL) </returns> /// <returns>Returns operation status bool (OK | FAIL) </returns>
bool ParseJson(Configuration* cfg, const char* json); bool ParseJson(Configuration* cfg, const char* json);
ATBPaymentOption const &getPaymentOptions(); ATBPaymentOption const & getPaymentOptions();
QVector<ATBDailyTicket> const &getDailyTickets() const;
private: private:
/// <summary> /// <summary>

View File

@ -2,8 +2,6 @@
#define TARIFF_CUSTOMER_H_INCLUDED #define TARIFF_CUSTOMER_H_INCLUDED
#include <QString> #include <QString>
#include <QDebug>
#include <QDebugStateSaver>
struct ATBCustomer { struct ATBCustomer {
enum class CustomerType {ADULT=1000, CHILD, TEEN}; enum class CustomerType {ADULT=1000, CHILD, TEEN};
@ -12,30 +10,6 @@ struct ATBCustomer {
CustomerType cust_type; CustomerType cust_type;
QString cust_label; QString cust_label;
friend QDebug operator<<(QDebug debug, ATBCustomer const &customer) {
QDebugStateSaver saver(debug);
switch(customer.cust_type) {
case ATBCustomer::CustomerType::ADULT:
debug.nospace()
<< " cust_type: " << "CustomerType::ADULT" << "\n"
<< "cust_label: " << customer.cust_label << "\n";
break;
case ATBCustomer::CustomerType::CHILD:
debug.nospace()
<< " cust_type: " << "CustomerType::CHILD" << "\n"
<< "cust_label: " << customer.cust_label << "\n";
break;
case ATBCustomer::CustomerType::TEEN:
debug.nospace()
<< " cust_type: " << "CustomerType::TEEN" << "\n"
<< "cust_label: " << customer.cust_label << "\n";
break;
}
return debug;
}
}; };
#endif // TARIFF_CUSTOMER_H_INCLUDED #endif // TARIFF_CUSTOMER_H_INCLUDED

View File

@ -3,80 +3,29 @@
#include <QString> #include <QString>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QVector>
#include <QDebugStateSaver>
struct DailyTicket {
#include "tariff_customer.h" DailyTicket() = default;
#include "tariff_time_range.h"
#include "tariff_timebase.h"
struct ATBDailyTicket {
ATBDailyTicket() = default;
int daily_ticket_payment_option_id; int daily_ticket_payment_option_id;
int daily_ticket_unit_id; int daily_ticket_unit_id;
double daily_ticket_price; double daily_ticket_price;
ATBTimeBase::TimeBaseType daily_ticket_tbase_type; int daily_ticket_tbase_id; // time base setting for ticket:
// time base setting for ticket: // 1: absolute: using time stamps
// absolute: using time stamps // 2: relative: use offsets from
// relative: use offsets from
// some reference time point, // some reference time point,
// typically "start time". // typically "start time".
ATBCustomer::CustomerType daily_ticket_clearance_customer_type; QVector<int> daily_ticket_clearance_type; // who is allowed to buy the ticket:
// who is allowed to buy the ticket:
// list of customer types // list of customer types
int daily_ticket_weekday_range; // [mon-sun] QTime daily_ticket_from_min; // used in case time base == 1
int daily_ticket_special_day_range; QTime daily_ticket_to_max;
int daily_ticket_from_offset_min; // used in case time base == 2
friend QDebug operator<<(QDebug debug, ATBDailyTicket const &ticket) { int daily_ticket_to_offset_max;
QDebugStateSaver saver(debug);
debug.nospace()
<< " daily_ticket_payment_option_id: " << ticket.daily_ticket_payment_option_id << "\n"
<< " daily_ticket_unit_id: " << ticket.daily_ticket_unit_id << "\n"
<< " daily_ticket_price: " << ticket.daily_ticket_price << "\n";
switch(ticket.daily_ticket_tbase_type) {
case ATBTimeBase::TimeBaseType::ABSOLUTE:
debug.nospace()
<< " daily_ticket_tbase_type: " << "TimeBaseType::ABSOLUTE" << "\n";
break;
case ATBTimeBase::TimeBaseType::RELATIVE:
debug.nospace()
<< " daily_ticket_tbase_type: " << "TimeBaseType::RELATIVE" << "\n";
break;
}
switch(ticket.daily_ticket_clearance_customer_type) {
case ATBCustomer::CustomerType::ADULT:
debug.nospace()
<< "daily_ticket_clearance_customer_type: " << "CustomerType::ADULT" << "\n";
break;
case ATBCustomer::CustomerType::CHILD:
debug.nospace()
<< "daily_ticket_clearance_customer_type: " << "CustomerType::CHILD" << "\n";
break;
case ATBCustomer::CustomerType::TEEN:
debug.nospace()
<< "daily_ticket_clearance_customer_type: " << "CustomerType::TEEN" << "\n";
break;
default:
debug.nospace()
<< "daily_ticket_clearance_customer_type: " << "CustomerType::???" << "\n";
break;
}
debug.nospace()
<< " daily_ticket_weekday_range: " << ticket.daily_ticket_weekday_range << "\n"
<< " daily_ticket_special_day_range: " << ticket.daily_ticket_special_day_range << "\n";
return debug;
}
}; };
#endif // TARIFF_DAILY_TICKET_H_INCLUDED #endif // TARIFF_DAILY_TICKET_H_INCLUDED

View File

@ -1,3 +1,4 @@
// #pragma once
/// <summary> /// <summary>
/// Duration data /// Duration data
@ -8,6 +9,4 @@ public:
int pun_id; int pun_id;
std::string pun_label; std::string pun_label;
int pun_duration; int pun_duration;
int pun_duration_min;
int pun_duration_max;
}; };

View File

@ -7,8 +7,8 @@
/// Time range definition /// Time range definition
/// </summary> /// </summary>
class TariffTimeRange { class TariffTimeRange {
QTime m_time_from; // if m_time_from == m_time_until, then the time range QTime m_time_from;
QTime m_time_until; // actually is the time point m_time_from QTime m_time_until;
public: public:

View File

@ -2,8 +2,6 @@
#define TARIFF_TIME_BASE_H_INCLUDED #define TARIFF_TIME_BASE_H_INCLUDED
#include <QString> #include <QString>
#include <QDebug>
#include <QDebugStateSaver>
struct ATBTimeBase { struct ATBTimeBase {
enum class TimeBaseType {ABSOLUTE=0, RELATIVE=1}; enum class TimeBaseType {ABSOLUTE=0, RELATIVE=1};
@ -11,30 +9,6 @@ struct ATBTimeBase {
ATBTimeBase() = default; ATBTimeBase() = default;
TimeBaseType tbase_type; TimeBaseType tbase_type;
QString tbase_label; QString tbase_label;
friend QDebug operator<<(QDebug debug, ATBTimeBase const &timeBase) {
QDebugStateSaver saver(debug);
switch(timeBase.tbase_type) {
case ATBTimeBase::TimeBaseType::ABSOLUTE:
debug.nospace()
<< " tbase_type: " << "TimeBaseType::ABSOLUTE" << "\n"
<< "tbase_label: " << timeBase.tbase_label << "\n";
break;
case ATBTimeBase::TimeBaseType::RELATIVE:
debug.nospace()
<< " tbase_type: " << "TimeBaseType::RELATIVE" << "\n"
<< "tbase_label: " << timeBase.tbase_label << "\n";
break;
default:
debug.nospace()
<< " tbase_type: " << "TimeBaseType::???" << "\n";
break;
}
return debug;
}
}; };
#endif // TARIFF_TIME_BASE_H_INCLUDED #endif // TARIFF_TIME_BASE_H_INCLUDED

View File

@ -1,27 +1,8 @@
#ifndef TIME_RANGE_HEADER_H_INCLUDED #pragma once
#define TIME_RANGE_HEADER_H_INCLUDED #include <ctime>
#include <QString> class ATBTimeRange {
#include <QDateTime> public:
#include <QDebug> time_t time_from;
#include <QDebugStateSaver> time_t time_to;
struct ATBTimeRange {
int time_range_id;
QTime time_range_from;
QTime time_range_to;
friend QDebug operator<<(QDebug debug, ATBTimeRange const &timeRange) {
QDebugStateSaver saver(debug);
debug.nospace()
<< " time_range_id: " << timeRange.time_range_id << "\n"
<< "time_range_from: " << timeRange.time_range_from.toString(Qt::ISODate) << "\n"
<< " time_range_to: " << timeRange.time_range_to.toString(Qt::ISODate) << "\n";
return debug;
}
}; };
#endif // TIME_RANGE_HEADER_H_INCLUDED

View File

@ -35,30 +35,10 @@ extern "C" char* strptime(const char* s,
#define SZEGED (0) #define SZEGED (0)
#define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (1)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
int main() { int main() {
#if NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM==1
std::ifstream input("/tmp/tariff_naz.json");
std::stringstream sstr;
while(input >> sstr.rdbuf());
std::string json(sstr.str());
Configuration cfg;
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
cout << endl;
if (isParsed) {
// Calculator calculator;
}
#endif
#if NEUHAUSER_LINSINGER_MASCHINENBAU==1 #if NEUHAUSER_LINSINGER_MASCHINENBAU==1
std::ifstream input("/tmp/tariff_linsinger_maschinenbau.json"); std::ifstream input("/tmp/tariff_linsinger_maschinenbau.json");

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,31 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>Greetings friend</title>
</head>
<body>
<div class="container">
<h2>Hello {{name}}</h2>
<form class="form-inline">
<div class="form-group">
<label for="name">Enter your name:</label>
<!-- binded input to 'name' -->
<input v-model="name" type="text" class="form-control" id="name" placeholder="Name">
</div>
</form>
</div>
<!-- displays all data within Vue instance filtered through JSON -->
<pre>{{ $data | json }}</pre>
</body>
<!-- cdn that contains all contents of Vue.js -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
new Vue({
el: 'body',
data: {
//empty variable each binded to input
name: "",
},
})
</script>
</html>

View File

@ -1,37 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>Greetings user</title>
</head>
<body>
<div class="container">
<!-- the || is the logical operator OR -->
<div v-if="gender== 'male' || gender == 'female'">
<h1>Hello,
<!-- render span if 'gender' equals to 'male' -->
<span v-show="gender == 'male'">Mister {{name}}.</span>
<!-- render span if 'gender' equals to 'female' -->
<span v-if="gender == 'female'">Miss {{name}}.</span>
</h1>
</div>
<!-- v-else immediately follows v-if block to work -->
<h1 v-else>So you can't decide. Fine!</h1>
<!-- show inputs -->
<label for="gender">Enter your gender:</label>
<input v-model="gender" class="form-control" id="gender"></input>
<label for="name">Enter your name:</label>
<input v-model="name" class="form-control" id="name"></input>
</div>
<pre>{{ $data | json }}</pre>
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
new Vue({
el: 'body',
data: {
gender: "female",
name: "Universe",
},
})
</script>
</html>

View File

@ -1,47 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>People of Gaul</title>
</head>
<body>
<div class="container">
<h1>People of Gaul</h1>
<ul class="list-group">
<!-- render filtered array items using 'v-for' -->
<!-- 'orderBy' is a built in filter used for ordering by 'age'-->
<li v-for="person in people | orderBy 'age' " class="list-group-item">
{{person.name}} {{person.age}}
</li>
</ul>
<h1>"Old" People of Gaul</h1>
<ul class="list-group">
<!-- render filtered array items -->
<li v-for="person in people | old " class="list-group-item">
<!-- custom filter 'old' -->
{{person.name}} {{person.age}}
</li>
</ul>
</div>
<pre>{{ $data | json }}</pre>
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
//custom filter 'old' returns an array of items that satisfy the given condition
Vue.filter('old', function (people) {
return people.filter(function (item) {
return item.age > 55;
});
})
new Vue({
el: 'body',
data: {
people: [
{name: "Obelix", age: 31},
{name: "Asterix", age: 32},
{name: "Majestix", age: 62},
{name: "Julius Caesar", age: 56},
]
},
})
</script>
</html>

View File

@ -1,59 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>The Elections</title>
</head>
<!-- listening for keyboard event -->
<body @keyup.c="clear">
<div class="container">
<h1>People of Vue</h1>
<ul class="list-group">
<li v-for="candidate in candidates" class="list-group-item">
{{candidate.name}} {{candidate.votes}}
<!-- increase votes 'on:click'-->
<button class="btn btn-default" @click="candidate.votes++">Vote</button>
</li>
</ul>
<!-- display the name of the 'mayor' using a computed property-->
<h2>Our mayor is {{mayor.name}}!</h2>
<pre>{{ $data | json }}</pre>
<pre>{{ mayor | json }}</pre>
</div>
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
var vm = new Vue({
el: 'body',
data: {
candidates: [
{name: "Mr. Black", votes: 140},
{name: "Mr. White", votes: 135},
{name: "Mr. Pink", votes: 145},
{name: "Mr. Brown", votes: 130},
]
},
computed: {
mayor: function () {
//first we sort the array descending
var candidatesSorted = this.candidates.sort(function (a, b) {
return b.votes - a.votes;
});
//the mayor will be the first item
return candidatesSorted[0];
}
},
methods: {
//this method runs when the key 'c' is pressed
clear: function () {
//Turn votes of all candidate to 0 using map() function.
this.candidates = this.candidates.map(function (candidate) {
candidate.votes = 0;
return candidate;
})
}
}
})
</script>
</html>

View File

@ -1,80 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>Horse-drawn Chariots</title>
</head>
<body>
<div class="container">
<h1>Chariot shopping</h1>
<ul class="list-group">
<!-- '.sync' ensures two-way binding between child's property and parent's one -->
<chariot v-for="chariot in chariots" :chariot="chariot" :selected.sync="selected"></chariot>
</ul>
<pre>{{ $data | json }}</pre>
</div>
<!-- component template -->
<template id="chariot-template">
<li class="list-group-item">
<h4>"{{ chariot.name }}" chariot has <strong>{{ chariot.horses }}</strong> horse(s)!</h4>
<!-- 'disabled' attribute is applied conditionally -->
<button @click="rideChariot(chariot)" class="btn btn-primary" :disabled="isSelectedChariot">
{{ action }}
</button>
</li>
</template>
<!-- end component template -->
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
Vue.component('chariot', {
props: ['chariot', 'selected'],
template: "#chariot-template",
methods: {
rideChariot: function (chariot) {
this.selected = chariot;
},
},
computed: {
//is true when the chariot has more horses than the selected one
hasMoreHorses: function () {
return this.selected.horses < this.chariot.horses
},
//is true when the chariot is the selected one
isSelectedChariot: function () {
return this.selected.name == this.chariot.name
},
//is true when there is no chariot selected
noChariot: function () {
return this.selected.name == null;
},
//define the action for each chariot
action: function () {
if (this.noChariot) {
action = 'Pick Chariot'
} else if (this.isSelectedChariot) {
action = 'Riding!'
} else if (this.hasMoreHorses) {
action = 'Hire Horses'
} else {
action = 'Dismiss Horses'
}
return action;
}
}
});
var vm = new Vue({
el: 'body',
data: {
chariots: [
{name: "Olympus", horses: 4},
{name: "Sagitta", horses: 3},
{name: "Icarus", horses: 2},
{name: "Abraxas", horses: 1},
],
//the currently selected 'chariot'
selected: {}
},
})
</script>
</html>

View File

@ -1,35 +0,0 @@
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<title>Paint Me</title>
</head>
<!-- binding body style to an object -->
<body :style="bgColor">
<div id="app">
<div class="container">
<h1>Paint this background!</h1>
<input type="color" v-model="bgColor.backgroundColor" />
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script type="text/javascript">
new Vue({
el: 'body',
data: {
bgColor: {
backgroundColor: "#00cc00"
}
}
});
</script>
<style type="text/css">
.centered {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
}
</style>
</html>

View File

@ -1,76 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>movies</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<main>
<div class="container">
<h1>movies</h1>
<div id="v-app">
<table class="table table-striped">
<tr>
<th>#</th>
<th>Title</th>
<th>Director</th>
<th>Actions</th>
</tr>
<tr v-for="movie in movies" is="movie" :movie="movie"></tr>
</table>
<template id="template-movie-raw">
<tr>
<td>
{{movie.id}}
</td>
<td class="col-md-6">
<input v-if="movie.editing" v-model="movie.title" class="form-control">
</input>
<!--in other occasions show the movie title-->
<span v-else>
{{movie.title}}
</span>
</td>
<td>
<input v-if="movie.editing" v-model="movie.director" class="form-control">
</input>
<!--in other occasions show the movie director-->
<span v-else>
{{movie.director}}
</span>
</td>
<td>
<div class="btn-group" v-if="!movie.editing">
<button @click="editMovie(movie)" class="btn btn-default">Edit</button>
<button @click="deleteMovie(movie)" class="btn btn-danger">Delete</button>
</div>
<div class="btn-group" v-else>
<!--If the movie is taken from the db then it will have an id-->
<button v-if="movie.id" class="btn btn-primary" @click="updateMovie(movie)">Update movie
</button>
<!--If the movie is new we want to store it-->
<button v-else class="btn btn-success" @click="storeMovie(movie)">Save New movie</button>
<!--Always show cancel-->
<button @click="movie.editing=false" class="btn btn-default">Cancel</button>
</div>
</td>
</tr>
</template>
<p class="lead">Here's a list of all your movies.
<button @click="createMovie()" class="btn btn-primary">Add a new one?</button>
</p>
<pre>{{ $data | json }}</pre>
</div>
</div>
</main>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/0.7.0/vue-resource.js"></script>
<script src='/js/app.js' type="text/javascript"></script>
</body>
</html>

Binary file not shown.