| 276 | |
| 277 | -- |
| 278 | -- Lista spraw wraz z kolorowaniem statusy |
| 279 | -- |
| 280 | drop sequence if exists lp; |
| 281 | create temp sequence lp start 1; |
| 282 | SELECT nextval('lp') AS lp, * FROM |
| 283 | (SELECT p.prc_id as keyval, 'PROCESS'::TEXT as clsnam, COALESCE(p.dscrpt, '-') AS dscrpt, p.c_name, p.optime::date, c.name_1, |
| 284 | p.fxterm, p.foreda::date, p.forepa, p.credib, p.rspini, |
| 285 | p.lm_dat::date AS ost_mod, |
| 286 | (CASE WHEN p.currpa != 'PLN' THEN |
| 287 | (SELECT cr_avg FROM currency_exchange_table cet WHERE cet.cursmb = p.currpa ORDER BY crdate LIMIT 1) |
| 288 | ELSE 1 END) * p.forepa AS wartosc_wal, |
| 289 | p.currpa AS waluta, |
| 290 | '<div style="background-color: ' || tops.colour || '; width: 100%; height: 100%; padding: 2px">' || tops.dscrpt || '</div>' AS status |
| 291 | FROM processes_view p |
| 292 | LEFT JOIN contacts c USING(contid) |
| 293 | LEFT JOIN types_of_processes_states tops ON (tops.state_::int = p.pr_sta AND tops.clsnam = 'PROCESS') |
| 294 | WHERE p.is_del IS FALSE AND p.is_fix IS false |
| 295 | AND rspuid = {LOGGED_USR_ID} |
| 296 | AND {FILTER_STRING} |
| 297 | AND forepa > 0 |
| 298 | ORDER BY tops.prior_, p.forepa DESC) AS x |