Timesheets-Server
Timesheets server
Načítám...
Vyhledávám...
Nebylo nic nalezeno
dbt.h
Zobrazit dokumentaci tohoto souboru.
1
6#ifndef _DBT_H_
7#define _DBT_H_
8
9#include <QString>
10#include <QDateTime>
11#include <QDate>
12#include <QCoreApplication>
13#include <QVariantList>
14#include <QVariant>
15#include "version.h"
16
17
18template<typename T>
19QVariantList toList(const QList<T>& input) {
20 QVariantList list;
21 QListIterator<T> iterator(input);
22 while (iterator.hasNext()) {
23 list << iterator.next().toMap();
24 }
25 return list;
26}
27
28
29namespace Dbt {
30
31struct Users {
32 int user;
33 QString login;
34 QString name;
35 QString lang;
36 bool enabled;
37 bool admin;
38 //
39 Users() { user = 0; enabled = false; admin = false; }
40 Users(int id) { user = id; enabled = false; admin = false; }
41 QVariantMap toMap() const;
42 static Users fromMap(const QVariantMap&);
43};
44
45
46struct ClientSettings {
47 bool multiple_timesheets;
48 bool show_price;
49 bool can_change_category;
50 bool edit_categories;
51 bool show_multiple_timesheets;
52 bool show_show_price;
53 bool show_can_change_category;
54 bool show_edit_categories;
55 ClientSettings() {
56 multiple_timesheets = true;
57 show_price = true;
58 can_change_category = true;
59 edit_categories = true;
60 show_multiple_timesheets = true;
61 show_show_price = true;
62 show_can_change_category = true;
63 show_edit_categories = true;
64 }
65 QVariantMap toMap() const;
66 static ClientSettings fromMap(const QVariantMap&);
67};
68
69
70struct ServerInfo {
71 QString name;
72 QString description;
73
74 static ServerInfo fromMap(const QVariantMap&);
75};
76
77
78struct Categories {
79 QString category; // primary key
80 QString parent_category;
81 QString description;
82 QString description_tree;
83 double price;
84 QVariantList users;
85
86 QVariantMap toMap() const;
87 static Categories fromMap(const QVariantMap&);
88 Categories() { price = 0; }
89 Categories(const QString& id) { price = 0; category = id; }
90};
91
92
93struct UsersCategories {
94 int id;
95 QString category;
96 int user;
97
98 QVariantMap toMap() const;
99 static UsersCategories fromMap(const QVariantMap&);
100 UsersCategories() { id = -1; user = -1; }
101 UsersCategories(int i) { id = i; }
102};
103
104
105struct StatusOrder {
106 QVariant id;
107 QVariant category;
108 QVariant previous_status;
109 QVariant next_status;
110
111 QVariantMap toMap() const;
112 static StatusOrder fromMap(const QVariantMap&);
113 StatusOrder(const QString& pid) { id = pid; }
114 StatusOrder() {}
115};
116
117
118struct Statuses {
119 QString status;
120 QString description;
121 QString abbreviation;
122 QString color;
123 bool closed;
124 bool can_be_run;
125 bool ignored;
126 bool can_have_next; // Není součástí tabulky, flag pro generování next
127 QList<Statuses> next;
128
129 QVariantMap toMap() const;
130 static Statuses fromMap(const QVariantMap&);
131 Statuses(const QString& id) { clear(); status = id; }
132 Statuses() { clear(); }
133 void clear() {
134 closed = false;
135 can_be_run = false;
136 ignored = false;
137 can_have_next = false;
138 status = QString();
139 description = QString();
140 abbreviation = QString();
141 color = QString();
142 next.clear();
143 }
144};
145
146
147struct StatusTemplates {
148 int id;
149 QString status;
150 QString category;
151 QString code;
152 QString title;
153 QString description;
154
155 QVariantMap toMap() const;
156 StatusTemplates() { id = -1; }
157};
158
159
160// Tabulky modifikovatelné
161struct Mutable {
162 int id;
163 QVariant user;
164 QVariant ticket;
165 bool modified;
166 bool created;
167 //
168 virtual ~Mutable() {}
169 virtual QVariantMap toMap() const;
170 static Mutable fromMap(const QVariantMap&);
171 Mutable() { id = 0; modified = false; created = false; }
172 Mutable(const QVariant& x) { id = x.toInt(); modified = false; created = false; }
173 Mutable(const Mutable& x) { operator=(x); }
174 Mutable& operator=(const Mutable& x) {
175 id = x.id;
176 user = x.user;
177 ticket = x.ticket;
178 modified = x.modified;
179 created = x.created;
180 return *this;
181 }
182};
183
184
185struct TicketStatus : Mutable {
186 QDateTime date;
187 QString status;
188 QString description;
189 QVariantMap description2;
190 QString status_description;
191 QString status_color;
192 bool status_closed;
193 bool status_can_be_run;
194 bool status_ignored;
195 //
196 virtual ~TicketStatus() {}
197 QVariantMap toMap() const Q_DECL_OVERRIDE;
198 static TicketStatus fromMap(const QVariantMap&);
199 static QList<TicketStatus> fromList(const QVariantList&);
200 TicketStatus() : Mutable() { status_closed = false; status_can_be_run = true; status_ignored = false; }
201 TicketStatus(const QVariant& x) : Mutable(x) { status_closed = false; status_can_be_run = true; status_ignored = false; }
202 TicketStatus(const Mutable& x) : Mutable(x) { status_closed = false; status_can_be_run = true; status_ignored = false; }
203 TicketStatus(const TicketStatus& x) : Mutable() { operator=(x); }
204 TicketStatus& operator=(const TicketStatus& x) {
205 Mutable::operator=(x);
206 date = x.date;
207 status = x.status;
208 description = x.description;
209 description2 = x.description2;
210 status_description = x.status_description;
211 status_color = x.status_color;
212 status_closed = x.status_closed;
213 status_can_be_run = x.status_can_be_run;
214 status_ignored = x.status_ignored;
215 return *this;
216 }
217};
218
219
220struct TicketTimesheets : Mutable {
221 QDateTime date_from;
222 QDateTime date_to;
223 //
224 virtual ~TicketTimesheets() {}
225 QVariantMap toMap() const Q_DECL_OVERRIDE;
226 static TicketTimesheets fromMap(const QVariantMap&);
227 static QList<TicketTimesheets> fromList(const QVariantList&);
228 TicketTimesheets() : Mutable() {}
229 TicketTimesheets(const QVariant& x) : Mutable(x) {}
230 TicketTimesheets(const Mutable& x) : Mutable(x) {}
231 TicketTimesheets(const TicketTimesheets& x) : Mutable() { operator=(x); }
232 TicketTimesheets& operator=(const TicketTimesheets& x) {
233 Mutable::operator=(x);
234 date_from = x.date_from;
235 date_to = x.date_to;
236 return *this;
237 }
238
239};
240
241
242struct TicketFiles : Mutable {
243 QDateTime date;
244 QString name;
245 QString type;
246 QByteArray content;
247
248 virtual ~TicketFiles() {}
249 QVariantMap toMap() const Q_DECL_OVERRIDE;
250 static TicketFiles fromMap(const QVariantMap&);
251 static QList<TicketFiles> fromList(const QVariantList&);
252 TicketFiles() : Mutable() {}
253 TicketFiles(const QVariant& x) : Mutable(x) {}
254 TicketFiles(const Mutable& x) : Mutable(x) {}
255 TicketFiles(const TicketFiles& x) : Mutable() { operator=(x); }
256 TicketFiles& operator=(const TicketFiles& x) {
257 Mutable::operator=(x);
258 date = x.date;
259 name = x.name;
260 type = x.type;
261 content = x.content;
262 return *this;
263 }
264};
265
266
267struct TicketValues : Mutable {
268 QDateTime date;
269 QString name;
270 QVariant value;
271
272 virtual ~TicketValues() {}
273 QVariantMap toMap() const Q_DECL_OVERRIDE;
274 static TicketValues fromMap(const QVariantMap&);
275 static QList<TicketValues> fromList(const QVariantList&);
276 TicketValues() : Mutable() {}
277 TicketValues(const QVariant& x) : Mutable(x) {}
278 TicketValues(const Mutable& x) : Mutable(x) {}
279 TicketValues(const TicketValues& x) : Mutable() { operator=(x); }
280 TicketValues& operator=(const TicketValues& x) {
281 Mutable::operator=(x);
282 date = x.date;
283 name = x.name;
284 value = x.value;
285 return *this;
286 }
287
288};
289
290
291struct Tickets {
292 QVariant ticket;
293 QVariant category;
294 QDateTime date;
295 double price;
296 QString description;
297 int user;
298 bool created;
299 bool modified;
300
301 virtual ~Tickets() {}
302 virtual QVariantMap toMap() const;
303 static Tickets fromMap(const QVariantMap&);
304 Tickets() { user = 0; price = 0; created = false; modified = false; }
305 Tickets(const QVariant& x) { ticket = x; price = 0; created = false; modified = false; }
306 Tickets(const Tickets& x) { operator=(x); }
307 Tickets& operator=(const Tickets& x) {
308 ticket = x.ticket;
309 category = x.category;
310 date = x.date;
311 price = x.price;
312 description = x.description ;
313 user = x.user;
314 created = x.created;
315 modified = x.modified;
316 return *this;
317 }
318
319};
320
321
322struct TicketsVw : Tickets {
323 QList<Dbt::TicketTimesheets> timesheets;
324 QList<Dbt::TicketStatus> statuses;
325 QList<Dbt::TicketFiles> files;
326 QList<Dbt::TicketValues> values;
327
328 virtual ~TicketsVw() {}
329 QVariantMap toMap() const Q_DECL_OVERRIDE;
330 static TicketsVw fromMap(const QVariantMap&);
331 TicketsVw() : Tickets() {}
332 TicketsVw(const QVariant& x) : Tickets(x) { }
333 TicketsVw(const Tickets& x) : Tickets(x) {}
334 TicketsVw(const TicketsVw& x) : Tickets() { operator=(x); }
335 TicketsVw& operator=(const TicketsVw& x) {
336 Tickets::operator=(x);
337 timesheets = x.timesheets;
338 statuses = x.statuses;
339 files = x.files;
340 values = x.values;
341 return *this;
342 }
343
344};
345
346
347struct CategoriesOverview {
348 QString type;
349 int depth;
350 QString category;
351 QString description;
352 int tickets_count;
353 double price;
354 double time;
355 QString ordering;
356
357 CategoriesOverview() { depth = 0; price = 0; time = 0; }
358 QVariantMap toMap() const;
359};
360
361
363 QVariantList categories;
364 QVariantList recent_status;
365 QString status;
366 QString description;
367 static AppendStatuses fromMap(const QVariantMap&);
368 QVariantMap toMap() const;
369};
370
371
372struct OverviewList {
373 QString key;
374 Dbt::Categories category;
375 QList<Dbt::Statuses> statuses;
376
377 OverviewList() {}
378 OverviewList(const QString& x) { key = x; }
379 QVariantMap toMap() const;
380};
381
382
383struct Overview {
384 struct Days {
385 int ticket;
386 QString description;
387 int user;
388 QString user_name;
389 QDateTime date;
390 double hour_price;
391 double duration;
392 double price;
393 QVariantMap toMap() const;
394 Days() { ticket = 0; user = 0; hour_price = 0; duration = 0; price = 0; }
395 };
396 struct Sum {
397 double duration;
398 double price;
399 QVariantMap toMap() const;
400 Sum() { duration = 0; price = 0; }
401 };
402 struct Tickets {
403 int ticket;
404 QString description;
405 int user;
406 QString user_name;
407 double hour_price;
408 double duration;
409 double price;
410 QString status;
411 QVariantMap toMap() const;
412 Tickets() { ticket = 0; user = 0; hour_price = 0; duration = 0; price = 0; }
413 };
414 struct TicketsSum {
415 int ticket;
416 QString description;
417 double duration;
418 double price;
419 QString status;
420 QVariantMap toMap() const;
421 TicketsSum() { ticket = 0; duration = 0; price = 0; }
422 };
423 struct StatusSum {
424 double duration;
425 double price;
426 QString status;
427 QVariantMap toMap() const;
428 StatusSum() { duration = 0; price = 0; }
429 };
430 struct UserSum {
431 double duration;
432 double price;
433 QString user_name;
434 QVariantMap toMap() const;
435 UserSum() { duration = 0; price = 0; }
436 };
437
438 Categories category;
439 QList<Tickets> tickets; // group by ticket, user
440 QList<TicketsSum> ticketsSum; // group by ticket
441 QList<StatusSum> statusSum; // group by status
442 QList<UserSum> userSum; // group by users
443 QList<Days> days; // group by date, user
444 Sum sum; // group by category
445 QVariantMap toMap() const;
446 QString id;
447};
448
449//---------------------------------------------------------------------------------------
450// Docházka
451
452struct Departments {
453 int department;
454 QString abbr;
455 QString description;
456
457 Departments(int d) { department = d; }
458 Departments() { department = 0; }
459 static Departments fromMap(const QVariantMap&);
460 QVariantMap toMap() const;
461};
462
463struct Doors {
464 int door;
465 QString description;
466
467 Doors() { door = 0; }
468 Doors(int x) { door = x; }
469 static Doors fromMap(const QVariantMap&);
470 QVariantMap toMap() const;
471};
472
473struct Rfids {
474 int rfid;
475 QString rfid_id;
476 bool valid;
477 QString note;
478 int employee;
479 QString name;
480 QString surname;
481
482 static Rfids fromMap(const QVariantMap&);
483 Rfids() { rfid = 0; valid = false; employee = 0; }
484 Rfids(int id) { rfid = id; valid = false; employee = 0; }
485 QVariantMap toMap() const;
486};
487
507struct Employees {
508 int employee;
509 QString firstname;
510 QString surname;
511 bool active;
512 int user;
513 QString login;
514 QString work_hours_mode;
515 QString rounding_interval;
516 bool saturdays_paid;
517 bool sundays_paid;
518 bool auto_breaks;
519 bool overtime_paid;
520
521 Employees() {
522 employee = 0;
523 active = false;
524 user = 0;
525 login = "";
526 saturdays_paid = false;
527 sundays_paid = false;
528 auto_breaks = false;
529 overtime_paid = false;
530 }
531 Employees(int x) {
532 employee = x;
533 active = false;
534 user = 0;
535 login = "";
536 saturdays_paid = false;
537 sundays_paid = false;
538 auto_breaks = false;
539 overtime_paid = false;
540 }
541 static Employees fromMap(const QVariantMap&);
542 QVariantMap toMap() const;
543};
544
545struct EventTypes {
546 QString event_type;
547 QString description;
548 bool end_state; // odchod, ukončení předchozího stavu
549 bool passage; // pruchod
550 bool arrival; // příchod do práce
551 bool vacation; // Dovolená
552 bool sick_leave; // nemoc
553 bool compensatory_leave; // náhradní volno
554 bool business_trip; // Služební cesta
555 bool break_time; // Přestávka
556 bool unpaid_leave; // Neplacené volno
557 bool sick_care; // Ošetřování člena rodiny
558 bool doctor; // Návštěva lékaře
559 bool paid_obstacle; // Překázka v práci na straně zaměstnavatele
560
561
562 EventTypes(const QString& id) {
563 clear();
564 event_type = id;
565 }
566
567 EventTypes() {
568 clear();
569 }
570
571 static EventTypes fromMap(const QVariantMap&);
572 QVariantMap toMap() const;
573
574 void clear() {
575 event_type.clear();
576 end_state = false;
577 passage = false;
578 arrival = false;
579 vacation = false;
580 sick_leave = false;
581 compensatory_leave = false;
582 business_trip = false;
583 break_time = false;
584 unpaid_leave = false;
585 sick_care = false;
586 }
587};
588
589struct Events {
590 int event;
591 QString error;
592 QDateTime date;
593 QString event_type;
594 QString event_description;
595 int employee;
596 QString firstname;
597 QString surname;
598 bool valid;
599 QVariant user_edited;
600 QString user_edited_name;
601 QString note;
602
603 Events(int id) { event = id; employee = 0; valid = false; }
604 Events() { event = 0; employee = 0; valid = false; }
605 static Events fromMap(const QVariantMap&);
606 QVariantMap toMap() const;
607};
608
609struct DepartmentHasManager {
610 int department;
611 int user;
612
613 DepartmentHasManager() { department = 0; user = 0; }
614 DepartmentHasManager(int d, int u) { department = d; user = u; }
615 static DepartmentHasManager fromMap(const QVariantMap&);
616 QVariantMap toMap() const;
617};
618
619struct DepartmentHasMember {
620 int department;
621 int employee;
622
623 DepartmentHasMember() { department = 0; employee = 0; }
624 DepartmentHasMember(int d, int e) { department = d; employee = e; }
625 static DepartmentHasMember fromMap(const QVariantMap&);
626 QVariantMap toMap() const;
627};
628
629struct EmployeeCanOpenDoor {
630 int employee;
631 int door;
632
633 EmployeeCanOpenDoor() { employee = 0; door = 0; }
634 EmployeeCanOpenDoor(int e, int d) { employee = e; door = d; }
635 static EmployeeCanOpenDoor fromMap(const QVariantMap&);
636 QVariantMap toMap() const;
637};
638
639struct EmployeeHasRfid {
640 int employee;
641 int rfid;
642
643 EmployeeHasRfid() { employee = 0; rfid = 0; }
644 EmployeeHasRfid(int e, int r) { employee = e; rfid = r; }
645 static EmployeeHasRfid fromMap(const QVariantMap&);
646 QVariantMap toMap() const;
647};
648
649struct Holidays {
650 QDate date;
651 QString description;
652
653 Holidays() { }
654 Holidays(const QDate& d) { date = d; }
655 static Holidays fromMap(const QVariantMap&);
656 QVariantMap toMap() const;
657};
658
659struct WorkCalendar {
660 QDate period;
661 int working_days;
662 int holidays;
663 QString hours8;
664 QString hours85;
665
666 WorkCalendar() { working_days = 0; holidays = 0; }
667 WorkCalendar(const QDate& d) { period = d; working_days = 0; holidays = 0; }
668 static WorkCalendar fromMap(const QVariantMap&);
669 QVariantMap toMap() const;
670};
671
672
673struct AttendanceSummary {
674 // double = interval (hours)
675 QDate month;
676 int employee;
677 QString firstname; // view
678 QString surname; // view
679 int days;
680 bool locked;
681 int locked_user;
682 QString locked_user_name; // view
683 double arrival; // work
684 double vacation;
685 double sick_leave;
686 double compensatory_leave;
687 double business_trip;
688 double break_time;
689 double unpaid_leave;
690 double sick_care;
691 double paid_obstacle;
692 double doctor;
693 double afternoon;
694 double night;
695 double sunday;
696 double saturday;
697 double holiday;
698 int calendar_working_days;
699 int calendar_holidays;
700 AttendanceSummary() {
701 month = QDate();
702 employee = 0;
703 locked = false;
704 locked_user = 0;
705 days = 0;
706 arrival = 0;
707 vacation = 0;
708 sick_leave = 0;
709 compensatory_leave = 0;
710 business_trip = 0;
711 break_time = 0;
712 unpaid_leave = 0;
713 sick_care = 0;
714 paid_obstacle = 0;
715 doctor = 0;
716 afternoon = 0;
717 night = 0;
718 sunday = 0;
719 saturday = 0;
720 holiday = 0;
721 calendar_working_days = 0;
722 calendar_holidays = 0;
723 }
724 static AttendanceSummary fromMap(const QVariantMap&);
725 QVariantMap toMap() const;
726};
727
728
729struct AttendanceDays {
730 int dow; // den v týdnu, odpovídá PgSql
731 bool holiday; // Je svátek?
732 QString holiday_description; //
733 // Začátek
734 QVariant start_event;
735 QDateTime start_date;
736 QString start_event_type;
737 QString start_event_description;
738 QString start_event_note;
739 QString start_event_error;
740 QVariant start_user_edited;
741 QString start_user_edited_name;
742 // Konec
743 QVariant end_event;
744 QDateTime end_date;
745 QString end_event_type;
746 QString end_event_description;
747 QString end_event_note;
748 QString end_event_error;
749 QVariant end_user_edited;
750 QString end_user_edited_name;
751 bool end_generated;
752 double rounded_hours; // interval (hours)
753 double cumulative_hours; // interval (hours)
754 double should_be; // interval (hours)
755 double should_be_cumulative; // interval (hours)
756 //
757 AttendanceDays() {
758 end_generated = false;
759 rounded_hours = 0;
760 cumulative_hours = 0;
761 should_be = 0;
762 should_be_cumulative = 0;
763 }
764 static AttendanceDays fromMap(const QVariantMap&);
765 static QList<AttendanceDays> fromList(const QVariantList&);
766 QVariantMap toMap() const;
767};
768
769
770struct AttendanceChecklist {
771 QDate month;
772 bool can_write;
773 Dbt::Employees employee;
774 QList<Dbt::AttendanceDays> days;
775 Dbt::AttendanceSummary summary_calculated;
776 Dbt::AttendanceSummary summary_saved;
777 static AttendanceChecklist fromMap(const QVariantMap&);
778 QVariantMap toMap() const;
779 AttendanceChecklist() { can_write = false; }
780};
781
782
784 Dbt::Employees employee;
785 QDateTime date;
786 QString event_type;
787 bool present;
788 static AttendancePresent fromMap(const QVariantMap&);
789 QVariantMap toMap() const;
790};
791
792struct AttendanceRecent {
793 int employee;
794 int start_event;
795 QDateTime start_date;
796 QString start_event_type;
797 QString start_note;
798 QString start_error;
799 int start_user_edited;
800 int end_event;
801 QDateTime end_date;
802 QString end_event_type;
803 QString end_note;
804 QString end_error;
805 int end_user_edited;
806 bool end_generated;
807
808 AttendanceRecent() {
809 employee = 0;
810 start_event = 0;
811 start_user_edited = 0;
812 end_event = 0;
813 end_user_edited = 0;
814 end_generated = false;
815 }
816
817 static AttendanceRecent fromMap(const QVariantMap&);
818 QVariantMap toMap() const;
819};
820
821
822struct UserEmployeeAccess {
823 int user;
824 int employee;
825 bool can_write;
826 bool can_read;
827 UserEmployeeAccess() { user = 0; employee = 0; can_write = false; can_read = false; }
828 QVariantMap toMap() const;
829};
830
831}
832
833#endif
Konvertuje null variant na invalid variant - QJsonDocument jinak konvertuje int null hodnoty špatně n...
Definition dbt.cpp:17
QVariantList categories
categories which are appended with new statuse
Definition dbt.h:363
QString description
new status description
Definition dbt.h:366
QString status
new status
Definition dbt.h:365
QVariantList recent_status
recent statuses
Definition dbt.h:364
Zaměstnanec používaný v REST API.
Definition dbt.h:507