SET ECHO ON
SET DEFINE ON
column fcltlogfile new_value fcltlogfile NOPRINT;
select UPPER(USER) || '_AANS#26775_' || to_char(sysdate,'YYYYMMDD_HH24MISS') || '.lst' as fcltlogfile from dual;
spool &fcltlogfile
SET DEFINE OFF

INSERT INTO fac_srtnotificatie (fac_srtnotificatie_code,
                                fac_srtnotificatie_mode,
                                fac_srtnotificatie_oms,
                                fac_srtnotificatie_xmlnode)
    VALUES ('CUST05',
            2,
            'Herinnering bijna verlopen login',
            'perslid');

CREATE OR REPLACE VIEW aaxx_v_noti_non_active_users
(
   sender,
   receiver,
   text,
   code,
   fac_srtnotificatie_key,
   key,
   xkey,
   xemail,
   xmobile
)
AS
   SELECT NULL sender,
          prs_perslid_key receiver,
          'Uw account voor FACILITOR is bijna verlopen. ' text,
          'CUST05' code,
          NULL fac_srtnotificatie_key,
          p.prs_perslid_key key,
          NULL xkey,
          NULL xemail,
          NULL xmobile
     FROM prs_perslid p
    WHERE p.prs_perslid_email IS NOT NULL
      AND TRUNC (SYSDATE) - TRUNC(prs_perslid_aanmaak) >= (90 - 7)
      AND p.prs_perslid_verwijder IS NULL
      AND (TRUNC (p.prs_perslid_login) = TRUNC (SYSDATE - 90 + 7)
        OR p.prs_perslid_login IS NULL)
      AND NOT EXISTS
             (SELECT prs_afdeling_key
                FROM prs_afdeling a
               WHERE a.prs_afdeling_key = p.prs_afdeling_key
                 AND a.prs_afdeling_omschrijving = 'AAFM')
      AND SUBSTR (prs_perslid_oslogin, 1, 1) <> '_';

INSERT INTO fac_notificatie_job (fac_notificatie_job_view,
                                 fac_notificatie_job_oms,
                                 fac_notificatie_job_mode,
                                 fac_notificatie_job_interval,
                                 fac_notificatie_job_nextrun)
    VALUES ('aaxx_v_noti_non_active_users',
            'Notificatie naar users die al enige tijd niet ingelogd waren',
            2,
            24,
            TO_DATE ('2030-01-01 20:00', 'yyyy-mm-dd hh24:mi'));

BEGIN adm.systrackscript('$Id$', '$Revision$', 1); END;
/


COMMIT;
SPOOL OFF
