Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
OverallCalendar
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
1<?php
2
3namespace BO\Zmsdb\Query;
4
5class OverallCalendar extends Base
6{
7    const TABLE = 'gesamtkalender';
8
9    const INSERT_MULTI = '
10        INSERT IGNORE INTO gesamtkalender
11            (scope_id, availability_id, time, seat, status)
12        VALUES %s
13    ';
14
15    const DELETE_FREE_RANGE = '
16        DELETE FROM gesamtkalender
17         WHERE scope_id = :scope_id
18           AND availability_id = :availability_id  
19           AND status   = "free"
20           AND time    >= :begin
21           AND time    <  :finish
22    ';
23
24    const DELETE_ALL_BEFORE = '
25        DELETE FROM gesamtkalender
26         WHERE time < :threshold
27    ';
28
29    const FIND_FREE_SEAT = '
30        SELECT seat
31          FROM gesamtkalender
32         WHERE scope_id = :scope
33           AND time >= :start
34           AND time <  :end
35           AND status = "free"
36         GROUP BY seat
37        HAVING COUNT(*) = :units
38         ORDER BY seat
39         LIMIT 1
40    ';
41
42    const BLOCK_SEAT_RANGE = '
43        UPDATE gesamtkalender
44           SET process_id = :pid,
45               slots      = CASE
46                              WHEN time = :start THEN :units
47                              ELSE NULL
48                            END,
49               status     = "termin"
50         WHERE scope_id = :scope
51           AND seat     = :seat
52           AND time    >= :start
53           AND time    <  :end
54    ';
55
56    const UNBOOK_PROCESS = '
57        UPDATE gesamtkalender
58           SET process_id = NULL,
59               slots      = NULL,
60               status     = "free"
61         WHERE scope_id   = :scope_id
62           AND process_id = :process_id
63    ';
64
65    const SELECT_RANGE = '
66        SELECT g.scope_id, g.time, g.availability_id, g.seat, g.status, g.process_id, g.slots, g.updated_at, 
67               s.Bezeichnung as scope_name, s.standortkuerzel as scope_short
68          FROM gesamtkalender g
69          JOIN standort s ON g.scope_id = s.StandortID
70         WHERE g.scope_id IN (%s)            
71           AND g.time BETWEEN :from AND :until
72         ORDER BY g.scope_id, g.time, g.seat
73    ';
74
75    const SELECT_RANGE_UPDATED = '
76        SELECT g.scope_id, g.time, g.availability_id, g.seat, g.status, g.process_id, g.slots, g.updated_at, 
77               s.Bezeichnung as scope_name, s.standortkuerzel as scope_short
78          FROM gesamtkalender g
79          JOIN standort s ON g.scope_id = s.StandortID
80         WHERE g.scope_id IN (%s)
81           AND g.time BETWEEN :from AND :until
82           AND g.updated_at > :updatedAfter
83         ORDER BY g.scope_id, g.time, g.seat
84    ';
85}