Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
ExchangeRequestowner
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
1<?php
2
3namespace BO\Zmsdb\Query;
4
5use BO\Zmsentities\Exchange;
6
7class ExchangeRequestowner extends Base
8{
9    /**
10     * @var String TABLE mysql table reference
11     */
12    const TABLE = 'statistik';
13
14    const REQUESTTABLE = 'request';
15
16    const QUERY_READ_REPORT = '
17    SELECT
18        o.KundenID as subjectid,
19        DATE_FORMAT(statistikJoin.`datum`, :groupby) as date,
20        (
21            CASE
22              WHEN statistikJoin.anliegenid = -1 THEN \'' . Exchange::REQUEST_STAT_NAME_UNCATEGORIZED . '\'
23              WHEN statistikJoin.anliegenid = 0 THEN \'' . Exchange::REQUEST_STAT_NAME_NONEXISTENT . '\'
24              ELSE r.name
25            END
26        ) as name,
27        SUM(statistikJoin.requestscount) as requestscount,
28        AVG(statistikJoin.processingtime) as processingtime
29    FROM ' . Organisation::TABLE . ' o
30        INNER JOIN (
31            SELECT
32                s.anliegenid,
33                s.kundenid,
34                COUNT(s.anliegenid) as requestscount,
35                AVG(s.processing_time) as processingtime,
36                s.`datum`
37            FROM ' . self::TABLE . ' s
38            WHERE s.kundenid = :ownerid AND s.`datum` BETWEEN :datestart AND :dateend
39            GROUP BY s.`datum`, s.anliegenid
40        ) as statistikJoin ON statistikJoin.`kundenid` = o.KundenID
41        LEFT JOIN ' . self::REQUESTTABLE . ' r ON r.id = statistikJoin.anliegenid
42    WHERE o.`KundenID` = :ownerid AND statistikJoin.`datum` BETWEEN :datestart AND :dateend
43    GROUP BY DATE_FORMAT(statistikJoin.`datum`, :groupby), name, statistikJoin.anliegenid
44    ORDER BY r.name, statistikJoin.anliegenid
45    ';
46
47    const QUERY_SUBJECTS = '
48      SELECT
49          o.`KundenID` as subject,
50          periodstart,
51          periodend,
52          o.`Organisationsname` AS description
53      FROM ' . Organisation::TABLE . ' AS o
54          INNER JOIN
55            (
56              SELECT
57                s.`kundenid` as ownerid,
58                MIN(s.`datum`) AS periodstart,
59                MAX(s.`datum`) AS periodend
60              FROM ' . self::TABLE . ' s
61              group by ownerid
62            )
63          maxAndminDate ON maxAndminDate.`ownerid` = o.`KundenID`
64      GROUP BY o.`KundenID`
65      ORDER BY o.`KundenID` ASC
66    ';
67
68    const QUERY_PERIODLIST_MONTH = '
69        SELECT date
70        FROM ' . Organisation::TABLE . ' AS o
71            INNER JOIN (
72              SELECT
73                kundenid,
74                DATE_FORMAT(`datum`,"%Y-%m") AS date
75              FROM ' . self::TABLE . '
76            ) s ON s.kundenid = o.KundenID
77        WHERE s.`kundenid` = :ownerid
78        GROUP BY date
79        ORDER BY date ASC
80    ';
81}