<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <CODALERTADEF>101</CODALERTADEF>
  <DENUMIRE>Stocuri expirate</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       &apos;?&apos; SMSTo,
       &apos;Art :&apos; || replace(OBJ.DENUMIRE,&apos;&apos;&apos;&apos;,&apos;&quot;&apos;)
       ||&apos;; seria:&apos;||OBJ.serie||&apos;; Data achiz:&apos;||OBJ.dataachiz||&apos;; Stoc:&apos;
       ||coalesce(OBJ.restser,OBJ.rest) ||&apos; &apos;||NUM.Den_UM||&apos;; Furn:&apos;||OBJ.den_part REZULTAT
FROM ( SELECT NOBJ.CODARTICOL, NOBJ.CODOBIECT,NOBJ.DENUMIRE,CODNIRSER,NS.DATAACHIZ, TRUNC(coalesce(NSER.TG,NS.TG) - current_date) NRZILEEXP,
             SER.SERIE,coalesce(NP.DEN_PART,&apos;...&apos;) DEN_PART,NS.REST,NSER.REST RESTSER
       FROM NARTOBJ NOBJ INNER JOIN NART N ON N.CODARTICOL = NOBJ.CODARTICOL AND N.ARETG = 1
                         INNER JOIN NIRSTOC NS ON NOBJ.CODOBIECT = NS.CODOBIECT
       LEFT JOIN NPART NP ON NP.CODPART = NS.FURN
                         LEFT JOIN NIRSER NSER ON NS.CODNIRSTOC = NSER.CODNIRSTOC
                         LEFT JOIN NSERII SER ON SER.CODSERIE = NSER.CODSERIE
       WHERE NS.REST &gt; 0) OBJ
   INNER JOIN NART NA ON NA.CODARTICOL = OBJ.CODARTICOL
   INNER JOIN NUM NUM ON NUM.CODUM = NA.UM
WHERE OBJ.NRZILEEXP &lt;= 0</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>102</CODALERTADEF>
  <DENUMIRE>Stoc sub limita minima</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       OBJ.DENUMIRE ||&apos; min &apos;|| coalesce(OBJ.STOCMIN,0)||&apos; - stoc &apos;|| coalesce(OBJ.REST,0)||&apos; = &apos;||Round(coalesce(OBJ.STOCMIN,0)-coalesce(OBJ.REST,0),2)||&apos; &apos;||NU.Den_UM REZULTAT
FROM ( SELECT NOBJ.CODARTICOL, NOBJ.CODOBIECT, NOBJ.DENUMIRE, coalesce(NAS.STOCMIN,0) STOCMIN, coalesce(SUM(NS.REST),0) REST
       FROM NARTOBJ NOBJ INNER JOIN NARTOBJSUBUNIT NAS ON NAS.CODOBIECT = NOBJ.CODOBIECT
       LEFT  JOIN NIRSTOC NS  ON NS.CODOBIECT = NOBJ.CODOBIECT
       LEFT JOIN NIR N ON NS.CODNIR = N.CODNIR
       LEFT JOIN NGEST NG ON NG.CODGEST = N.GEST
       WHERE NG.CODSUBUNIT = 2
       AND NAS.SUBUNITATE = NG.CODSUBUNIT
       AND coalesce(NAS.STOCMIN,0) &lt;&gt; 0
       GROUP BY NOBJ.CODARTICOL, NOBJ.CODOBIECT, NOBJ.DENUMIRE, coalesce(NAS.STOCMIN,0)) OBJ
  INNER JOIN NART NA ON NA.CODARTICOL = OBJ.CODARTICOL
  INNER JOIN NUM NU ON NU.CODUM = NA.UM
WHERE OBJ.REST &lt; OBJ.STOCMIN</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>104</CODALERTADEF>
  <DENUMIRE>Intrari cu certificat de calitate nesosit in 10 zile</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       &apos;Art :&apos;|| replace(OBJ.DENUMIRE,&apos;&apos;&apos;&apos;,&apos;&quot;&apos;)||&apos;; achiz:&apos;||OBJ.dataachiz||&apos;; Stoc:&apos;||coalesce(OBJ.rest,0)||&apos; (&apos;||coalesce(OBJ.CantNIR,0) ||&apos;) &apos;||NUM.Den_UM REZULTAT
FROM ( SELECT NOBJ.CODARTICOL, NOBJ.CODOBIECT,NOBJ.DENUMIRE,TRUNC(current_date - NS.DATAACHIZ) NrZileAchizitie,ns.dataachiz, ns.cantnir, ns.rest
       FROM NART N INNER JOIN NARTOBJ NOBJ ON N.CODARTICOL = NOBJ.CODARTICOL
       INNER JOIN NIRSTOC NS ON NS.CODOBIECT = NOBJ.CODOBIECT
       INNER JOIN NIRSER NSE ON NSE.CODNIRSTOC = NS.CODNIRSTOC
       LEFT  JOIN IOART1 IO1 ON IO1.CODIOART = NS.CODIOART
       WHERE N.MUSAICALITATE = 1
       AND IO1.ANSTART *12 +IO1.LUNASTART = ( SELECT MAX(ANSTART *12 + LUNASTART)
       FROM IOART1
       WHERE CODIOART = IO1.CODIOART AND ANSTART *12 + LUNASTART &lt;= Extract(Year from current_date)*12+Extract(Month from current_date))
       AND coalesce(NSE.CODCERTIF,0) = 0
       AND to_number(PKG_CATEGCONST.GetValConstanta(&apos;CMatPrime&apos;,to_number(to_char(Extract(Year from current_date),&apos;9999&apos;),&apos;9999&apos;), to_number(to_char(Extract(Month from current_date),&apos;99&apos;),&apos;99&apos;)),&apos;999999999999999999&apos;) = IO1.CONT ) OBJ
  INNER JOIN NART NA ON NA.CODARTICOL = OBJ.CODARTICOL
  INNER JOIN NUM NUM ON NUM.CODUM = NA.UM
WHERE OBJ.NrZileAchizitie &gt; 10 </SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>105</CODALERTADEF>
  <DENUMIRE>Stocuri ce expira in 10 zile</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       &apos;Art :&apos;|| replace(OBJ.DENUMIRE,&apos;&apos;&apos;&apos;,&apos;&quot;&apos;) ||&apos;; seria:&apos;||OBJ.serie||&apos;; Data achiz:&apos;||OBJ.dataachiz||&apos;; Stoc:&apos;||coalesce(OBJ.restser,OBJ.rest) ||&apos; &apos;||NUM.Den_UM||&apos;; Furn:&apos;||OBJ.den_part||&apos;; zile ramase: &apos;||OBJ.NRZILEEXP REZULTAT
FROM ( SELECT NOBJ.CODARTICOL, NOBJ.CODOBIECT,NOBJ.DENUMIRE,CODNIRSER,NS.DATAACHIZ, TRUNC(coalesce(NSER.TG,NS.TG) - current_date) NRZILEEXP,
             SER.SERIE,coalesce(NP.DEN_PART,&apos;...&apos;) DEN_PART,NS.REST,NSER.REST RESTSER
       FROM NARTOBJ NOBJ INNER JOIN NART    N  ON N.CODARTICOL = NOBJ.CODARTICOL AND N.ARETG = 1
                         INNER JOIN NIRSTOC NS ON NOBJ.CODOBIECT = NS.CODOBIECT
       LEFT JOIN NPART NP ON NP.CODPART = NS.FURN
                         LEFT JOIN NIRSER NSER ON NS.CODNIRSTOC = NSER.CODNIRSTOC
                         LEFT JOIN NSERII SER  ON SER.CODSERIE = NSER.CODSERIE
       WHERE NS.REST &gt; 0) OBJ
   INNER JOIN NART NA ON NA.CODARTICOL = OBJ.CODARTICOL
   INNER JOIN NUM NUM ON NUM.CODUM = NA.UM
WHERE OBJ.NRZILEEXP &lt;= 10</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>106</CODALERTADEF>
  <DENUMIRE>Comenzi nefacturate, toate subunitatile</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       Den_Part||&apos; Comanda: &apos;||Document REZULTAT
FROM ( SELECT p.Den_Part, coalesce(c.prefixdoc,&apos;&apos;)||&apos;.&apos;||coalesce(c.Seriadoc,&apos;&apos;)||coalesce(to_char(c.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;)||&apos;/&apos;||to_char(c.datadoc,&apos;dd.mm.yyyy&apos;) as document,
              (SELECT SUM(CASE WHEN C1.RESTACCEPTAT &lt; 0 THEN 0 ELSE C1.RESTACCEPTAT END) FROM COMANDA1 C1 WHERE CODCOMANDA = C.CODCOMANDA) REST
       FROM COMANDA c
            LEFT OUTER JOIN NPART P      ON P.CODPART = C.PARTENER
       WHERE coalesce(C.DISPLIVRARE, 0) = 0
         AND coalesce(C.FARAFACTURA, 0) = 0
         AND coalesce(C.INCHISA,0) = 0
         AND coalesce(C.OPERAT,0)  = 1
         AND C.TIPDOC = 18
         AND C.AN * 12 + C.LUNA &lt;= Extract(Year from current_date)*12+Extract(Month from current_date)) AA
WHERE REST &gt; 0</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>107</CODALERTADEF>
  <DENUMIRE>Lista partenerilor fara adresa de email dar cu facturi scadente </DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos;  MessTo,
       &apos;?&apos;  TaskTo,
       DenumirePartener REZULTAT
FROM
    ( select
        distinct np.DEN_PART DenumirePartener
  from
        iesiri ies
        inner join general  g  on g.coddoc=ies.codies and g.tipdoc=ies.tipdoc
        inner join obligpif o  on o.CODGENERAL = g.codgeneral
        left  join nagenda  na on na.CODAGENDA = ies.codlocatie
        inner join npart    np ON np.CODPART = na.CODPART
  WHERE na.eMail IS NULL and coalesce(o.rest,0)&gt;0 and o.SEMNIFICATIE=200) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>108</CODALERTADEF>
  <DENUMIRE>Scadente cec-uri de incasat</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos;  TaskTo,
       Detalii REZULTAT
FROM
    (
    select coalesce(bank.denumire,&apos;&apos;) || &apos; &apos; || coalesce(t1.doc,&apos;&apos;) || &apos; &apos; || coalesce(to_char(t1.NRDOC,&apos;999999999999999999&apos;),&apos;&apos;) || &apos; din &apos; || coalesce(to_char(t1.DATADOC,&apos;dd.mm.yyyy&apos;),&apos;&apos;) || &apos; scadent la &apos; || coalesce(to_char(t1.datadecont,&apos;dd.mm.yyyy&apos;),&apos;&apos;) ||&apos; |&apos; Detalii
    from trezor1 t1
        INNER JOIN Trezor    tr   ON tr.codtrezor = t1.codtrezor
        INNER JOIN nbankcont nbc  ON nbc.codbankcont = tr.codbanca
        INNER JOIN nbank     bank ON bank.codbank = nbc.codbank
        INNER join general   g    on g.coddoc = t1.codtrezor1
        INNER JOIN obligpif  op   ON op.codgeneral = g.codgeneral
        WHERE
             g.semnificatie = 600
             AND coalesce( op.rest, 0 ) &gt; 0
             AND TRUNC( t1.datadecont - current_date ) &lt; 10
     ) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>109</CODALERTADEF>
  <DENUMIRE>Alerta pentru expirare autorizatii parc auto</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos;  MessTo,
       &apos;?&apos;  TaskTo,
       Detalii Rezultat
FROM
    (SELECT
         na.den_articol,npa.seriec,npa.cilindree,npa.nrinreg,naa.denumire,np2.expira
     from
        nparcaut npa
        left  join nparc2           np2 on npa.codnparcaut= np2.cod
        inner join nartobj          nao on nao.codobiect=npa.codart
        inner join nart             na  on na.codarticol=nao.codarticol
        inner join nautorizatiiauto naa on naa.CODAUTORIZATII=np2.DOC
      WHERE to_date(to_char(current_date,&apos;dd.mm.yyyy&apos;),&apos;dd.mm.yyyy&apos;) + CAST(coalesce(np2.atentie,0) as integer)&gt;np2.expira
        AND to_date(to_char(current_date,&apos;dd.mm.yyyy&apos;),&apos;dd.mm.yyyy&apos;) &lt;= np2.expira
   ) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>110</CODALERTADEF>
  <DENUMIRE>Alerta pentru scadenta ratelor de leasing (data din graficul de pe contract)</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA
</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos;  TaskTo,
       Detalii REZULTAT
FROM
(
SELECT &apos;Contract nr &apos; || coalesce(to_char(c.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;) || &apos; din &apos; || coalesce(to_char(c.datadoc,&apos;dd.mm.yyyy&apos;),&apos;&apos;) || &apos;, Partener &apos; || coalesce(np.den_part,&apos;&apos;)
       || &apos;, scadent la &apos; || coalesce(to_char(c2.data,&apos;dd.mm.yyyy&apos;),&apos;&apos;) Detalii
FROM
       Contract c
       INNER JOIN Contract2 c2 ON c2.codcontract = c.codcontract
       INNER JOIN NPart     np ON np.codpart = c.partener
       WHERE TRUNC( c2.data - current_date ) &lt; 10 and TRUNC( c2.data - current_date )&gt;0
) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>111</CODALERTADEF>
  <DENUMIRE>Alerta pentru scadenta ratelor de leasing (data scadenta din factura generata)</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       &apos;?&apos; MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos;  TaskTo,
       Detalii REZULTAT
FROM
(
SELECT &apos;Contract nr &apos; || coalesce(to_char(c.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;) || &apos; din &apos; || coalesce(to_char(c.datadoc,&apos;dd.mm.yyyy&apos;),&apos;&apos;) || &apos;, Partener &apos; || coalesce(np.den_part,&apos;&apos;)
       || &apos;, Factura nr. &apos; || coalesce(to_char(i.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;) || &apos;/&apos; || coalesce(to_char(i.datadoc,&apos;dd.mm.yyyy&apos;),&apos;&apos;) || &apos;, scadenta la &apos; || coalesce(to_char(op.termen,&apos;dd.mm.yyyy&apos;),&apos;&apos;) Detalii
FROM
       Contract c
       INNER JOIN Contract2 c2 ON c2.codcontract = c.codcontract
       INNER JOIN NPart     np ON np.codpart = c.partener
       INNER JOIN Intrari   i  ON i.codintr = c2.coddoc AND i.tipdoc = c2.tipdoc
       INNER JOIN General   g  ON g.coddoc = i.codintr AND g.tipdoc = i.tipdoc
       INNER JOIN Obligpif  op ON op.codgeneral = g.codgeneral
       WHERE
            TRUNC( op.termen - current_date ) &lt; 10 and TRUNC( op.termen - current_date ) &gt;0
) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>112</CODALERTADEF>
  <DENUMIRE>Scadente depasite clienti - email doar la parteneri</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       eMail MailTo,
       &apos;?&apos;  MessTo,
       &apos;?&apos;  TaskTo,
       replace(DEN_PART,&apos;&apos;&apos;&apos;,&apos;&quot;&apos;)||&apos; doc:&apos;||document||&apos; = &apos;||valoare||&apos; &apos;||Den_Moneda||&apos; Scadent la &apos;||coalesce(to_char(DataScadenta,&apos;dd.mm.yyyy&apos;),&apos;&apos;)||&apos; Rest = &apos;|| coalesce(to_char(rest,&apos;999999999999999999.999999999&apos;),&apos;&apos;)||&apos; &apos;||Den_Moneda REZULTAT
FROM ( select na.eMail email,
              case when coalesce(pe.LOGONNAME, coalesce(pe1.LOGONNAME,0)) = 0 then &apos;?&apos; else (SELECT u.username FROM WINMADMIN.utilizator u WHERE u.codutilizator = coalesce(pe.LOGONNAME, pe1.LOGONNAME)) end Agent,
              np.DEN_PART,nm.Den_Moneda,
              coalesce(ies.prefixdoc,&apos;&apos;)||&apos;.&apos;||coalesce(ies.Seriadoc,&apos;&apos;)||coalesce(to_char(ies.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;)||&apos;/&apos;||coalesce(to_char(ies.datadoc,&apos;dd.mm.yyyy&apos;),&apos;&apos;) as document,
              trunc(current_date - o.termen) ZileDepasire,
       o.termen DataScadenta, o.valoare,o.rest
       from iesiri ies
            inner join general  g    on g.coddoc = ies.codies and g.tipdoc = ies.tipdoc
            inner join NMonede  nm   on nm.CodMoneda = ies.MONEDA
            inner join obligpif o    on o.codgeneral = g.codgeneral
            inner join npart    np   on np.codpart = ies.partener
            left  join NAgenda  na   on na.CODAGENDA = ies.CODLOCATIE
            left  join npers    pe   on pe.CodPers = ies.agent
            left  join nagenda  nag  on nag.codagenda = pe.agenda
            left  join npers    pe1  on pe1.CodPers = na.CODAGENT
            left  join nagenda  nag1 on nag1.codagenda = pe1.agenda
       where coalesce(o.rest,0) &gt; 0 and o.SEMNIFICATIE=200) OBJ where coalesce(email,&apos;?&apos;)&lt;&gt;&apos;?&apos;</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>113</CODALERTADEF>
  <DENUMIRE>Scadente depasite clienti - email doar la agenti</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       eMail MailTo,
       &apos;?&apos;  MessTo,
       &apos;?&apos;  TaskTo,
       replace(DEN_PART,&apos;&apos;&apos;&apos;,&apos;&quot;&apos;)||&apos; doc:&apos;||document||&apos; = &apos;||valoare||&apos; &apos;||Den_Moneda||&apos; Scadent la &apos;||coalesce(to_char(DataScadenta,&apos;dd.mm.yyyy&apos;),&apos;&apos;)||&apos; Rest = &apos;|| coalesce(to_char(rest,&apos;999999999999999999.999999999&apos;),&apos;&apos;)||&apos; &apos;||Den_Moneda REZULTAT
FROM ( select coalesce(nag.email, nag1.email) email,
              case when coalesce(pe.LOGONNAME, coalesce(pe1.LOGONNAME,0)) = 0 then &apos;?&apos; else (SELECT u.username FROM WINMADMIN.utilizator u WHERE u.codutilizator = coalesce(pe.LOGONNAME, pe1.LOGONNAME)) end Agent,
              np.DEN_PART,nm.Den_Moneda,
              coalesce(ies.prefixdoc,&apos;&apos;)||&apos;.&apos;||coalesce(ies.Seriadoc,&apos;&apos;)||coalesce(to_char(ies.nrdoc,&apos;999999999999999999&apos;),&apos;&apos;)||&apos;/&apos;||coalesce(to_char(ies.datadoc,&apos;dd.mm.yyyy&apos;),&apos;&apos;) as document,
              trunc(current_date - o.termen) ZileDepasire,
       o.termen DataScadenta, o.valoare,o.rest
       from iesiri ies
            inner join general  g    on g.coddoc = ies.codies and g.tipdoc = ies.tipdoc
            inner join NMonede  nm   on nm.CodMoneda = ies.MONEDA
            inner join obligpif o    on o.codgeneral = g.codgeneral
            inner join npart    np   on np.codpart = ies.partener
            left  join NAgenda  na   on na.CODAGENDA = ies.CODLOCATIE
            left  join npers    pe   on pe.CodPers = ies.agent
            left  join nagenda  nag  on nag.codagenda = pe.agenda
            left  join npers    pe1  on pe1.CodPers = na.CODAGENT
            left  join nagenda  nag1 on nag1.codagenda = pe1.agenda
       where coalesce(o.rest,0) &gt; 0 and o.SEMNIFICATIE=200) OBJ where coalesce(obj.email,&apos;?&apos;)&lt;&gt;&apos;?&apos; </SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>116</CODALERTADEF>
  <DENUMIRE>Facturi iesire neoperate, introduse in luna curenta</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA
</CODINTERN>
  <SQL>SELECT
       email MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos;  TaskTo,
       &apos;?&apos;  SMSTo,
       Detalii REZULTAT,
       partener, document, tipdocument
FROM
    (
    select
          np.den_part ||&apos;, &apos;||&apos;doc &apos;||i.prefixdoc||&apos;.&apos;||i.Seriadoc||i.nrdoc||&apos;/&apos;||i.datadoc Detalii,
          np.den_part partener, i.prefixdoc||&apos;.&apos;||i.Seriadoc||i.nrdoc||&apos;/&apos;||i.datadoc as document,
          case when i.tipdoc=19 then &apos;Factura iesire&apos;
               when i.tipdoc=20 then &apos;Aviz iesire&apos;
               when i.tipdoc=21 then &apos;Chitanta / bon&apos;
               when i.tipdoc=26 then &apos;Factura la aviz clienti&apos; end TipDocument, nag.email email
    from iesiri i
         INNER JOIN npart    np  ON np.codpart = i.partener
         INNER JOIN npers    npe on npe.logonname=i.userid
         LEFT  JOIN  nagenda nag on nag.codagenda = coalesce(Npe.agenda,0)
         WHERE
           coalesce(i.operat,0)=0 and coalesce(i.anulat,0)=0
           and
           to_date(to_char(i.datacreare,&apos;dd.mm.yyyy&apos;),&apos;dd.mm.yyyy&apos;) between  to_date(to_char(add_months(current_date,-1),&apos;dd.mm.yyyy&apos;),&apos;dd.mm.yyyy&apos;) and to_date(to_char(current_date,&apos;dd.mm.yyyy&apos;),&apos;dd.mm.yyyy&apos;)
     ) OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>114</CODALERTADEF>
  <DENUMIRE>Stocuri la moment</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>  SELECT
     &apos;?&apos; SMSTo,
     &apos;?&apos; MailTo,
     &apos;?&apos; MessTo,
     &apos;?&apos; TaskTo,
     &apos;?&apos; Rezultat,
     Codextern,Denumire as Articol,Den_UM as UM, Stoc as Stoc_disponibil
  FROM
    (
      Select S.CodOBIECT, O.Denumire, O.CodExtern, UM.Den_UM, S.Stoc
         from 
         (
           SELECT CodOBIECT, sum(REST) STOC
           FROM NIRSTOC
         WHERE rest &lt;&gt; 0 AND NOT codioart IN (SELECT DISTINCT codioart from ioart1 where mg = 5)
   group by CodOBIECT) S
  INNER JOIN NARTOBJ O ON O.CODOBIECT = S.CODOBIECT AND Coalesce(O.CodExtern, &apos;?&apos;) &lt;&gt; &apos;?&apos;
  INNER JOIN NART NA ON NA.CODARTICOL=O.CODARTICOL
  INNER JOIN NUM UM ON UM.CODUM=NA.UM
  )OBJ</SQL>
 </ROW>
 <ROW>
  <CODALERTADEF>115</CODALERTADEF>
  <DENUMIRE>Mesaj inregistrare comanda in baza de date</DENUMIRE>
  <CODINTERN>PKG_ALERTE.DO_ALERTA</CODINTERN>
  <SQL>SELECT
       &apos;?&apos; SMSTo,
       coalesce(email,&apos;?&apos;) MailTo,
       &apos;?&apos; MessTo,
       &apos;?&apos; TaskTo,
       &apos;Comanda dvs a fost inregistrata&apos; REZULTAT
 FROM (
       SELECT  na.email
       FROM COMANDA c
            left join nagenda na on na.codagenda=c.codlocatie
       WHERE c.datacreare between current_timestamp - interval &apos;1&apos; hour and current_timestamp)
   OBJ</SQL>
 </ROW>
</ROWSET>
