| 5 | | class ExchangeWaitingscope extends \BO\Zmsbackend\Query\Base |
| 6 | | { |
| 7 | | |
| 8 | | |
| 9 | | |
| 10 | | const string TABLE = 'wartenrstatistik'; |
| 11 | | |
| 12 | | const string WAITING_VALUES = " |
| 13 | | AVG(hour_00_waiting_time_spontaneous) as hour_00_waiting_time_spontaneous, |
| 14 | | AVG(hour_01_waiting_time_spontaneous) as hour_01_waiting_time_spontaneous, |
| 15 | | AVG(hour_02_waiting_time_spontaneous) as hour_02_waiting_time_spontaneous, |
| 16 | | AVG(hour_03_waiting_time_spontaneous) as hour_03_waiting_time_spontaneous, |
| 17 | | AVG(hour_04_waiting_time_spontaneous) as hour_04_waiting_time_spontaneous, |
| 18 | | AVG(hour_05_waiting_time_spontaneous) as hour_05_waiting_time_spontaneous, |
| 19 | | AVG(hour_06_waiting_time_spontaneous) as hour_06_waiting_time_spontaneous, |
| 20 | | AVG(hour_07_waiting_time_spontaneous) as hour_07_waiting_time_spontaneous, |
| 21 | | AVG(hour_08_waiting_time_spontaneous) as hour_08_waiting_time_spontaneous, |
| 22 | | AVG(hour_09_waiting_time_spontaneous) as hour_09_waiting_time_spontaneous, |
| 23 | | AVG(hour_10_waiting_time_spontaneous) as hour_10_waiting_time_spontaneous, |
| 24 | | AVG(hour_11_waiting_time_spontaneous) as hour_11_waiting_time_spontaneous, |
| 25 | | AVG(hour_12_waiting_time_spontaneous) as hour_12_waiting_time_spontaneous, |
| 26 | | AVG(hour_13_waiting_time_spontaneous) as hour_13_waiting_time_spontaneous, |
| 27 | | AVG(hour_14_waiting_time_spontaneous) as hour_14_waiting_time_spontaneous, |
| 28 | | AVG(hour_15_waiting_time_spontaneous) as hour_15_waiting_time_spontaneous, |
| 29 | | AVG(hour_16_waiting_time_spontaneous) as hour_16_waiting_time_spontaneous, |
| 30 | | AVG(hour_17_waiting_time_spontaneous) as hour_17_waiting_time_spontaneous, |
| 31 | | AVG(hour_18_waiting_time_spontaneous) as hour_18_waiting_time_spontaneous, |
| 32 | | AVG(hour_19_waiting_time_spontaneous) as hour_19_waiting_time_spontaneous, |
| 33 | | AVG(hour_20_waiting_time_spontaneous) as hour_20_waiting_time_spontaneous, |
| 34 | | AVG(hour_21_waiting_time_spontaneous) as hour_21_waiting_time_spontaneous, |
| 35 | | AVG(hour_22_waiting_time_spontaneous) as hour_22_waiting_time_spontaneous, |
| 36 | | AVG(hour_23_waiting_time_spontaneous) as hour_23_waiting_time_spontaneous, |
| 37 | | AVG(hour_00_estimated_waiting_time_spontaneous) as hour_00_estimated_waiting_time_spontaneous, |
| 38 | | AVG(hour_01_estimated_waiting_time_spontaneous) as hour_01_estimated_waiting_time_spontaneous, |
| 39 | | AVG(hour_02_estimated_waiting_time_spontaneous) as hour_02_estimated_waiting_time_spontaneous, |
| 40 | | AVG(hour_03_estimated_waiting_time_spontaneous) as hour_03_estimated_waiting_time_spontaneous, |
| 41 | | AVG(hour_04_estimated_waiting_time_spontaneous) as hour_04_estimated_waiting_time_spontaneous, |
| 42 | | AVG(hour_05_estimated_waiting_time_spontaneous) as hour_05_estimated_waiting_time_spontaneous, |
| 43 | | AVG(hour_06_estimated_waiting_time_spontaneous) as hour_06_estimated_waiting_time_spontaneous, |
| 44 | | AVG(hour_07_estimated_waiting_time_spontaneous) as hour_07_estimated_waiting_time_spontaneous, |
| 45 | | AVG(hour_08_estimated_waiting_time_spontaneous) as hour_08_estimated_waiting_time_spontaneous, |
| 46 | | AVG(hour_09_estimated_waiting_time_spontaneous) as hour_09_estimated_waiting_time_spontaneous, |
| 47 | | AVG(hour_10_estimated_waiting_time_spontaneous) as hour_10_estimated_waiting_time_spontaneous, |
| 48 | | AVG(hour_11_estimated_waiting_time_spontaneous) as hour_11_estimated_waiting_time_spontaneous, |
| 49 | | AVG(hour_12_estimated_waiting_time_spontaneous) as hour_12_estimated_waiting_time_spontaneous, |
| 50 | | AVG(hour_13_estimated_waiting_time_spontaneous) as hour_13_estimated_waiting_time_spontaneous, |
| 51 | | AVG(hour_14_estimated_waiting_time_spontaneous) as hour_14_estimated_waiting_time_spontaneous, |
| 52 | | AVG(hour_15_estimated_waiting_time_spontaneous) as hour_15_estimated_waiting_time_spontaneous, |
| 53 | | AVG(hour_16_estimated_waiting_time_spontaneous) as hour_16_estimated_waiting_time_spontaneous, |
| 54 | | AVG(hour_17_estimated_waiting_time_spontaneous) as hour_17_estimated_waiting_time_spontaneous, |
| 55 | | AVG(hour_18_estimated_waiting_time_spontaneous) as hour_18_estimated_waiting_time_spontaneous, |
| 56 | | AVG(hour_19_estimated_waiting_time_spontaneous) as hour_19_estimated_waiting_time_spontaneous, |
| 57 | | AVG(hour_20_estimated_waiting_time_spontaneous) as hour_20_estimated_waiting_time_spontaneous, |
| 58 | | AVG(hour_21_estimated_waiting_time_spontaneous) as hour_21_estimated_waiting_time_spontaneous, |
| 59 | | AVG(hour_22_estimated_waiting_time_spontaneous) as hour_22_estimated_waiting_time_spontaneous, |
| 60 | | AVG(hour_23_estimated_waiting_time_spontaneous) as hour_23_estimated_waiting_time_spontaneous, |
| 61 | | AVG(hour_00_way_time_spontaneous) as hour_00_way_time_spontaneous, |
| 62 | | AVG(hour_01_way_time_spontaneous) as hour_01_way_time_spontaneous, |
| 63 | | AVG(hour_02_way_time_spontaneous) as hour_02_way_time_spontaneous, |
| 64 | | AVG(hour_03_way_time_spontaneous) as hour_03_way_time_spontaneous, |
| 65 | | AVG(hour_04_way_time_spontaneous) as hour_04_way_time_spontaneous, |
| 66 | | AVG(hour_05_way_time_spontaneous) as hour_05_way_time_spontaneous, |
| 67 | | AVG(hour_06_way_time_spontaneous) as hour_06_way_time_spontaneous, |
| 68 | | AVG(hour_07_way_time_spontaneous) as hour_07_way_time_spontaneous, |
| 69 | | AVG(hour_08_way_time_spontaneous) as hour_08_way_time_spontaneous, |
| 70 | | AVG(hour_09_way_time_spontaneous) as hour_09_way_time_spontaneous, |
| 71 | | AVG(hour_10_way_time_spontaneous) as hour_10_way_time_spontaneous, |
| 72 | | AVG(hour_11_way_time_spontaneous) as hour_11_way_time_spontaneous, |
| 73 | | AVG(hour_12_way_time_spontaneous) as hour_12_way_time_spontaneous, |
| 74 | | AVG(hour_13_way_time_spontaneous) as hour_13_way_time_spontaneous, |
| 75 | | AVG(hour_14_way_time_spontaneous) as hour_14_way_time_spontaneous, |
| 76 | | AVG(hour_15_way_time_spontaneous) as hour_15_way_time_spontaneous, |
| 77 | | AVG(hour_16_way_time_spontaneous) as hour_16_way_time_spontaneous, |
| 78 | | AVG(hour_17_way_time_spontaneous) as hour_17_way_time_spontaneous, |
| 79 | | AVG(hour_18_way_time_spontaneous) as hour_18_way_time_spontaneous, |
| 80 | | AVG(hour_19_way_time_spontaneous) as hour_19_way_time_spontaneous, |
| 81 | | AVG(hour_20_way_time_spontaneous) as hour_20_way_time_spontaneous, |
| 82 | | AVG(hour_21_way_time_spontaneous) as hour_21_way_time_spontaneous, |
| 83 | | AVG(hour_22_way_time_spontaneous) as hour_22_way_time_spontaneous, |
| 84 | | AVG(hour_23_way_time_spontaneous) as hour_23_way_time_spontaneous, |
| 85 | | MAX(hour_00_waiting_count_spontaneous) as hour_00_waiting_count_spontaneous, |
| 86 | | MAX(hour_01_waiting_count_spontaneous) as hour_01_waiting_count_spontaneous, |
| 87 | | MAX(hour_02_waiting_count_spontaneous) as hour_02_waiting_count_spontaneous, |
| 88 | | MAX(hour_03_waiting_count_spontaneous) as hour_03_waiting_count_spontaneous, |
| 89 | | MAX(hour_04_waiting_count_spontaneous) as hour_04_waiting_count_spontaneous, |
| 90 | | MAX(hour_05_waiting_count_spontaneous) as hour_05_waiting_count_spontaneous, |
| 91 | | MAX(hour_06_waiting_count_spontaneous) as hour_06_waiting_count_spontaneous, |
| 92 | | MAX(hour_07_waiting_count_spontaneous) as hour_07_waiting_count_spontaneous, |
| 93 | | MAX(hour_08_waiting_count_spontaneous) as hour_08_waiting_count_spontaneous, |
| 94 | | MAX(hour_09_waiting_count_spontaneous) as hour_09_waiting_count_spontaneous, |
| 95 | | MAX(hour_10_waiting_count_spontaneous) as hour_10_waiting_count_spontaneous, |
| 96 | | MAX(hour_11_waiting_count_spontaneous) as hour_11_waiting_count_spontaneous, |
| 97 | | MAX(hour_12_waiting_count_spontaneous) as hour_12_waiting_count_spontaneous, |
| 98 | | MAX(hour_13_waiting_count_spontaneous) as hour_13_waiting_count_spontaneous, |
| 99 | | MAX(hour_14_waiting_count_spontaneous) as hour_14_waiting_count_spontaneous, |
| 100 | | MAX(hour_15_waiting_count_spontaneous) as hour_15_waiting_count_spontaneous, |
| 101 | | MAX(hour_16_waiting_count_spontaneous) as hour_16_waiting_count_spontaneous, |
| 102 | | MAX(hour_17_waiting_count_spontaneous) as hour_17_waiting_count_spontaneous, |
| 103 | | MAX(hour_18_waiting_count_spontaneous) as hour_18_waiting_count_spontaneous, |
| 104 | | MAX(hour_19_waiting_count_spontaneous) as hour_19_waiting_count_spontaneous, |
| 105 | | MAX(hour_20_waiting_count_spontaneous) as hour_20_waiting_count_spontaneous, |
| 106 | | MAX(hour_21_waiting_count_spontaneous) as hour_21_waiting_count_spontaneous, |
| 107 | | MAX(hour_22_waiting_count_spontaneous) as hour_22_waiting_count_spontaneous, |
| 108 | | MAX(hour_23_waiting_count_spontaneous) as hour_23_waiting_count_spontaneous, |
| 109 | | AVG(hour_00_waiting_time_appointment) as hour_00_waiting_time_appointment, |
| 110 | | AVG(hour_01_waiting_time_appointment) as hour_01_waiting_time_appointment, |
| 111 | | AVG(hour_02_waiting_time_appointment) as hour_02_waiting_time_appointment, |
| 112 | | AVG(hour_03_waiting_time_appointment) as hour_03_waiting_time_appointment, |
| 113 | | AVG(hour_04_waiting_time_appointment) as hour_04_waiting_time_appointment, |
| 114 | | AVG(hour_05_waiting_time_appointment) as hour_05_waiting_time_appointment, |
| 115 | | AVG(hour_06_waiting_time_appointment) as hour_06_waiting_time_appointment, |
| 116 | | AVG(hour_07_waiting_time_appointment) as hour_07_waiting_time_appointment, |
| 117 | | AVG(hour_08_waiting_time_appointment) as hour_08_waiting_time_appointment, |
| 118 | | AVG(hour_09_waiting_time_appointment) as hour_09_waiting_time_appointment, |
| 119 | | AVG(hour_10_waiting_time_appointment) as hour_10_waiting_time_appointment, |
| 120 | | AVG(hour_11_waiting_time_appointment) as hour_11_waiting_time_appointment, |
| 121 | | AVG(hour_12_waiting_time_appointment) as hour_12_waiting_time_appointment, |
| 122 | | AVG(hour_13_waiting_time_appointment) as hour_13_waiting_time_appointment, |
| 123 | | AVG(hour_14_waiting_time_appointment) as hour_14_waiting_time_appointment, |
| 124 | | AVG(hour_15_waiting_time_appointment) as hour_15_waiting_time_appointment, |
| 125 | | AVG(hour_16_waiting_time_appointment) as hour_16_waiting_time_appointment, |
| 126 | | AVG(hour_17_waiting_time_appointment) as hour_17_waiting_time_appointment, |
| 127 | | AVG(hour_18_waiting_time_appointment) as hour_18_waiting_time_appointment, |
| 128 | | AVG(hour_19_waiting_time_appointment) as hour_19_waiting_time_appointment, |
| 129 | | AVG(hour_20_waiting_time_appointment) as hour_20_waiting_time_appointment, |
| 130 | | AVG(hour_21_waiting_time_appointment) as hour_21_waiting_time_appointment, |
| 131 | | AVG(hour_22_waiting_time_appointment) as hour_22_waiting_time_appointment, |
| 132 | | AVG(hour_23_waiting_time_appointment) as hour_23_waiting_time_appointment, |
| 133 | | AVG(hour_00_estimated_waiting_time_appointment) as hour_00_estimated_waiting_time_appointment, |
| 134 | | AVG(hour_01_estimated_waiting_time_appointment) as hour_01_estimated_waiting_time_appointment, |
| 135 | | AVG(hour_02_estimated_waiting_time_appointment) as hour_02_estimated_waiting_time_appointment, |
| 136 | | AVG(hour_03_estimated_waiting_time_appointment) as hour_03_estimated_waiting_time_appointment, |
| 137 | | AVG(hour_04_estimated_waiting_time_appointment) as hour_04_estimated_waiting_time_appointment, |
| 138 | | AVG(hour_05_estimated_waiting_time_appointment) as hour_05_estimated_waiting_time_appointment, |
| 139 | | AVG(hour_06_estimated_waiting_time_appointment) as hour_06_estimated_waiting_time_appointment, |
| 140 | | AVG(hour_07_estimated_waiting_time_appointment) as hour_07_estimated_waiting_time_appointment, |
| 141 | | AVG(hour_08_estimated_waiting_time_appointment) as hour_08_estimated_waiting_time_appointment, |
| 142 | | AVG(hour_09_estimated_waiting_time_appointment) as hour_09_estimated_waiting_time_appointment, |
| 143 | | AVG(hour_10_estimated_waiting_time_appointment) as hour_10_estimated_waiting_time_appointment, |
| 144 | | AVG(hour_11_estimated_waiting_time_appointment) as hour_11_estimated_waiting_time_appointment, |
| 145 | | AVG(hour_12_estimated_waiting_time_appointment) as hour_12_estimated_waiting_time_appointment, |
| 146 | | AVG(hour_13_estimated_waiting_time_appointment) as hour_13_estimated_waiting_time_appointment, |
| 147 | | AVG(hour_14_estimated_waiting_time_appointment) as hour_14_estimated_waiting_time_appointment, |
| 148 | | AVG(hour_15_estimated_waiting_time_appointment) as hour_15_estimated_waiting_time_appointment, |
| 149 | | AVG(hour_16_estimated_waiting_time_appointment) as hour_16_estimated_waiting_time_appointment, |
| 150 | | AVG(hour_17_estimated_waiting_time_appointment) as hour_17_estimated_waiting_time_appointment, |
| 151 | | AVG(hour_18_estimated_waiting_time_appointment) as hour_18_estimated_waiting_time_appointment, |
| 152 | | AVG(hour_19_estimated_waiting_time_appointment) as hour_19_estimated_waiting_time_appointment, |
| 153 | | AVG(hour_20_estimated_waiting_time_appointment) as hour_20_estimated_waiting_time_appointment, |
| 154 | | AVG(hour_21_estimated_waiting_time_appointment) as hour_21_estimated_waiting_time_appointment, |
| 155 | | AVG(hour_22_estimated_waiting_time_appointment) as hour_22_estimated_waiting_time_appointment, |
| 156 | | AVG(hour_23_estimated_waiting_time_appointment) as hour_23_estimated_waiting_time_appointment, |
| 157 | | AVG(hour_00_way_time_appointment) as hour_00_way_time_appointment, |
| 158 | | AVG(hour_01_way_time_appointment) as hour_01_way_time_appointment, |
| 159 | | AVG(hour_02_way_time_appointment) as hour_02_way_time_appointment, |
| 160 | | AVG(hour_03_way_time_appointment) as hour_03_way_time_appointment, |
| 161 | | AVG(hour_04_way_time_appointment) as hour_04_way_time_appointment, |
| 162 | | AVG(hour_05_way_time_appointment) as hour_05_way_time_appointment, |
| 163 | | AVG(hour_06_way_time_appointment) as hour_06_way_time_appointment, |
| 164 | | AVG(hour_07_way_time_appointment) as hour_07_way_time_appointment, |
| 165 | | AVG(hour_08_way_time_appointment) as hour_08_way_time_appointment, |
| 166 | | AVG(hour_09_way_time_appointment) as hour_09_way_time_appointment, |
| 167 | | AVG(hour_10_way_time_appointment) as hour_10_way_time_appointment, |
| 168 | | AVG(hour_11_way_time_appointment) as hour_11_way_time_appointment, |
| 169 | | AVG(hour_12_way_time_appointment) as hour_12_way_time_appointment, |
| 170 | | AVG(hour_13_way_time_appointment) as hour_13_way_time_appointment, |
| 171 | | AVG(hour_14_way_time_appointment) as hour_14_way_time_appointment, |
| 172 | | AVG(hour_15_way_time_appointment) as hour_15_way_time_appointment, |
| 173 | | AVG(hour_16_way_time_appointment) as hour_16_way_time_appointment, |
| 174 | | AVG(hour_17_way_time_appointment) as hour_17_way_time_appointment, |
| 175 | | AVG(hour_18_way_time_appointment) as hour_18_way_time_appointment, |
| 176 | | AVG(hour_19_way_time_appointment) as hour_19_way_time_appointment, |
| 177 | | AVG(hour_20_way_time_appointment) as hour_20_way_time_appointment, |
| 178 | | AVG(hour_21_way_time_appointment) as hour_21_way_time_appointment, |
| 179 | | AVG(hour_22_way_time_appointment) as hour_22_way_time_appointment, |
| 180 | | AVG(hour_23_way_time_appointment) as hour_23_way_time_appointment, |
| 181 | | MAX(hour_00_waiting_count_appointment) as hour_00_waiting_count_appointment, |
| 182 | | MAX(hour_01_waiting_count_appointment) as hour_01_waiting_count_appointment, |
| 183 | | MAX(hour_02_waiting_count_appointment) as hour_02_waiting_count_appointment, |
| 184 | | MAX(hour_03_waiting_count_appointment) as hour_03_waiting_count_appointment, |
| 185 | | MAX(hour_04_waiting_count_appointment) as hour_04_waiting_count_appointment, |
| 186 | | MAX(hour_05_waiting_count_appointment) as hour_05_waiting_count_appointment, |
| 187 | | MAX(hour_06_waiting_count_appointment) as hour_06_waiting_count_appointment, |
| 188 | | MAX(hour_07_waiting_count_appointment) as hour_07_waiting_count_appointment, |
| 189 | | MAX(hour_08_waiting_count_appointment) as hour_08_waiting_count_appointment, |
| 190 | | MAX(hour_09_waiting_count_appointment) as hour_09_waiting_count_appointment, |
| 191 | | MAX(hour_10_waiting_count_appointment) as hour_10_waiting_count_appointment, |
| 192 | | MAX(hour_11_waiting_count_appointment) as hour_11_waiting_count_appointment, |
| 193 | | MAX(hour_12_waiting_count_appointment) as hour_12_waiting_count_appointment, |
| 194 | | MAX(hour_13_waiting_count_appointment) as hour_13_waiting_count_appointment, |
| 195 | | MAX(hour_14_waiting_count_appointment) as hour_14_waiting_count_appointment, |
| 196 | | MAX(hour_15_waiting_count_appointment) as hour_15_waiting_count_appointment, |
| 197 | | MAX(hour_16_waiting_count_appointment) as hour_16_waiting_count_appointment, |
| 198 | | MAX(hour_17_waiting_count_appointment) as hour_17_waiting_count_appointment, |
| 199 | | MAX(hour_18_waiting_count_appointment) as hour_18_waiting_count_appointment, |
| 200 | | MAX(hour_19_waiting_count_appointment) as hour_19_waiting_count_appointment, |
| 201 | | MAX(hour_20_waiting_count_appointment) as hour_20_waiting_count_appointment, |
| 202 | | MAX(hour_21_waiting_count_appointment) as hour_21_waiting_count_appointment, |
| 203 | | MAX(hour_22_waiting_count_appointment) as hour_22_waiting_count_appointment, |
| 204 | | MAX(hour_23_waiting_count_appointment) as hour_23_waiting_count_appointment |
| 205 | | "; |
| 206 | | const QUERY_READ_DAY = " |
| 207 | | SELECT |
| 208 | | standortid, |
| 209 | | `datum` AS datum, |
| 210 | | " . self::WAITING_VALUES . " |
| 211 | | FROM " . self::TABLE . " |
| 212 | | WHERE |
| 213 | | `standortid` IN (:scopeid) AND |
| 214 | | `datum` BETWEEN :datestart AND :dateend |
| 215 | | GROUP BY `datum` |
| 216 | | ORDER BY `datum` ASC |
| 217 | | "; |
| 218 | | |
| 219 | | |
| 220 | | const QUERY_READ_MONTH = " |
| 221 | | SELECT |
| 222 | | standortid, |
| 223 | | DATE_FORMAT(`datum`, '%Y-%m') as datum, |
| 224 | | " . self::WAITING_VALUES . " |
| 225 | | FROM " . self::TABLE . " |
| 226 | | WHERE |
| 227 | | `standortid` = :scopeid AND |
| 228 | | `datum` BETWEEN :datestart AND :dateend |
| 229 | | GROUP BY DATE_FORMAT(`datum`, '%Y-%m') |
| 230 | | ORDER BY DATE_FORMAT(`datum`, '%Y-%m') ASC |
| 231 | | "; |
| 232 | | |
| 233 | | const QUERY_READ_QUARTER = " |
| 234 | | SELECT |
| 235 | | standortid, |
| 236 | | CONCAT(YEAR(w.`datum`),'-',QUARTER(w.`datum`)) as datum, |
| 237 | | " . self::WAITING_VALUES . " |
| 238 | | FROM " . self::TABLE . " w |
| 239 | | WHERE |
| 240 | | w.`standortid` = :scopeid AND |
| 241 | | w.`datum` BETWEEN :datestart AND :dateend |
| 242 | | GROUP BY CONCAT(YEAR(w.`datum`),'-',QUARTER(w.`datum`)) |
| 243 | | ORDER BY CONCAT(YEAR(w.`datum`),'-',QUARTER(w.`datum`)) ASC |
| 244 | | "; |
| 245 | | |
| 246 | | const QUERY_SUBJECTS = ' |
| 247 | | SELECT |
| 248 | | scope.`StandortID` as subject, |
| 249 | | periodstart, |
| 250 | | periodend, |
| 251 | | CONCAT(scope.`Bezeichnung`, " ", scope.`standortinfozeile`) AS description |
| 252 | | FROM ' . \BO\Zmsbackend\Query\Scope::TABLE . ' AS scope |
| 253 | | INNER JOIN |
| 254 | | ( |
| 255 | | SELECT |
| 256 | | w.standortid as scopeid, |
| 257 | | MIN(w.`datum`) AS periodstart, |
| 258 | | MAX(w.`datum`) AS periodend |
| 259 | | FROM ' . self::TABLE . ' w |
| 260 | | group by scopeid |
| 261 | | ) |
| 262 | | maxAndminDate ON maxAndminDate.`scopeid` = scope.`StandortID` |
| 263 | | GROUP BY scope.`StandortID` |
| 264 | | ORDER BY scope.`StandortID` ASC, periodstart DESC |
| 265 | | '; |
| 266 | | |
| 267 | | const QUERY_PERIODLIST_DAY = ' |
| 268 | | SELECT |
| 269 | | `datum` |
| 270 | | FROM ' . self::TABLE . ' AS w |
| 271 | | WHERE `standortid` = :scopeid |
| 272 | | ORDER BY `datum` ASC |
| 273 | | '; |
| 274 | | |
| 275 | | const QUERY_PERIODLIST_MONTH = ' |
| 276 | | SELECT DISTINCT DATE_FORMAT(`datum`,"%Y-%m") AS date |
| 277 | | FROM ' . self::TABLE . ' AS w |
| 278 | | WHERE `standortid` = :scopeid |
| 279 | | ORDER BY `datum` ASC |
| 280 | | '; |
| 281 | | |
| 282 | | const QUERY_CREATE = ' |
| 283 | | INSERT INTO ' . self::TABLE . ' SET |
| 284 | | `standortid` = :scopeid, |
| 285 | | `datum` = :date |
| 286 | | '; |
| 287 | | |
| 288 | | |
| 289 | | |
| 290 | | |
| 291 | | |
| 292 | | public static function getQuerySelectByDateTime(\DateTimeInterface $date, bool $withAppointment = false): string |
| 293 | | { |
| 294 | | $hourSuffix = $withAppointment ? 'appointment' : 'spontaneous'; |
| 295 | | |
| 296 | | $query = sprintf( |
| 297 | | "SELECT |
| 298 | | `hour_%s_estimated_waiting_time_%s` AS waitingcalculated, |
| 299 | | `hour_%s_waiting_count_%s` AS waitingcount, |
| 300 | | `hour_%s_waiting_time_%s` AS waitingtime, |
| 301 | | `hour_%s_way_time_%s` AS waytime |
| 302 | | FROM %s |
| 303 | | WHERE `standortid` = :scopeid |
| 304 | | AND `datum` = :date |
| 305 | | AND :hour IS NOT NULL |
| 306 | | ", |
| 307 | | $date->format('H'), |
| 308 | | $hourSuffix, |
| 309 | | $date->format('H'), |
| 310 | | $hourSuffix, |
| 311 | | $date->format('H'), |
| 312 | | $hourSuffix, |
| 313 | | $date->format('H'), |
| 314 | | $hourSuffix, |
| 315 | | self::TABLE |
| 316 | | ); |
| 317 | | return $query; |
| 318 | | } |
| 319 | | |
| 320 | | |
| 321 | | |
| 322 | | |
| 323 | | |
| 324 | | public static function getQueryUpdateByDateTime(\DateTimeInterface $date, bool $withAppointment = false): string |
| 325 | | { |
| 326 | | $hourSuffix = $withAppointment ? 'appointment' : 'spontaneous'; |
| 327 | | |
| 328 | | $query = sprintf( |
| 329 | | "UPDATE %s |
| 330 | | SET |
| 331 | | `hour_%s_estimated_waiting_time_%s`= :waitingcalculated, |
| 332 | | `hour_%s_waiting_count_%s` = :waitingcount, |
| 333 | | `hour_%s_waiting_time_%s` = :waitingtime, |
| 334 | | `hour_%s_way_time_%s` = :waytime |
| 335 | | WHERE `standortid` = :scopeid |
| 336 | | AND `datum` = :date |
| 337 | | AND :hour IS NOT NULL |
| 338 | | ", |
| 339 | | self::TABLE, |
| 340 | | $date->format('H'), |
| 341 | | $hourSuffix, |
| 342 | | $date->format('H'), |
| 343 | | $hourSuffix, |
| 344 | | $date->format('H'), |
| 345 | | $hourSuffix, |
| 346 | | $date->format('H'), |
| 347 | | $hourSuffix |
| 348 | | ); |
| 349 | | return $query; |
| 350 | | } |
| 351 | | } |