home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
tema
/
SW602
/
Winbase
/
EShop_demo
/
ODESLIMAIL.PSM
< prev
next >
Wrap
Text File
|
2000-03-16
|
3KB
|
95 lines
{$$3219928934 . }PROCEDURE OdesliMail(IN idobj INT, IN idkomu INT, IN storno_obj BOOLEAN, IN postoupeni BOOLEAN);
BEGIN
DECLARE Letter,res,i INT;
DECLARE Profile, firma CHAR(100) ;
DECLARE SIduz CHAR(8);
DECLARE typadr char(10);
DECLARE kdo, komu, kolik, subj CHAR(50);
DECLARE co CHAR(2000);
DECLARE heslo, objednavka, kdy CHAR(20);
DECLARE wbaplname CHAR(100);
DECLARE dnes, ted CHAR(30);
SELECT sys_par.vec_mail,sys_par.mail_info INTO subj,co FROM sys_par;
SELECT OBJ_HEADER.cis_eob, date2str(datum_d,3), money2str(K_UHRADE,0) INTO objednavka, kdy, kolik FROM OBJ_HEADER WHERE id_dobj=idobj;
IF storno_obj THEN
BEGIN
SET subj="STORNO objednavky";
SET co="Objednßvka Φφslo "+objednavka+" byla obchodnφm partnerem STORNOV┴NA";
END;
END IF;
IF postoupeni THEN
BEGIN
SET subj="Postoupenß objednßvka";
SET co="Byla Vßm postoupena objednßvka: "+ objednavka;
END;
END IF;
SELECT sys_par.profil INTO Profile FROM sys_par;
CALL log_write("odesφlatel: Profile:"+Profile);
SET firma="nov² zßkaznφk";
if idkomu>=0
THEN
SELECT Obchodnici.mail_adres, Obchodnici.mailtyp, Obchodni_partneri.nazev1 INTO komu, typadr, firma
FROM Obchodni_partneri, Obchodnici
WHERE Obchodni_partneri.id_obchodnika=Obchodnici.id_obchodnika
AND (Obchodni_partneri.id=idkomu);
ELSE
SELECT Obchodnici.mail_adres, Obchodnici.mailtyp INTO komu, typadr
FROM Obchodnici, Default_hodnoty
WHERE Default_hodnoty.obchodnik=Obchodnici.id_obchodnika; END IF;
SET co=co||" "#13#10" firma: "||firma||" "#13#10" Φφslo objednßvky: "||objednavka||" "#13#10" Φßstka k ·hrad∞: "||kolik||" "#13#10" termφn dodßnφ: "||kdy;
SELECT sys_par.aplname, date2str(today,1) , time2str(now,1) INTO wbaplname,dnes, ted FROM sys_par;
IF storno_obj THEN CALL log_write(dnes+" "+ted+" "+wbaplname+" storno objednßvky");
ELSE CALL log_write(dnes+" "+ted+" "+wbaplname+" novß objednßvka ");
END IF;
IF (komu<>"")
THEN BEGIN //0
SET heslo=NULL;
SET i = 0;
nav: LOOP BEGIN
SET res= InitWBmail(Profile,heslo);
IF res <> 511 THEN
LEAVE nav;
END IF;
SET i = i + 1;
IF i > 5 THEN
LEAVE nav;
END IF;
CALL Sleep(20000);
END; END LOOP nav;
IF res<>0 THEN BEGIN CALL log_write("chyba inicializace poÜty "+int2str(res)); CALL mailerr(res); END;
ELSE BEGIN //1
IF komu<>""
THEN BEGIN //01
SET res=LetterCreate(Subj,Co,130,Letter);
IF res<>0 THEN BEGIN CALL log_write("chyba p°i vytvß°enφ dopisu "+int2str(res)); CALL mailerr(res); END;
ELSE BEGIN //2
SET res= LetterAddAddr(Letter,Komu, typadr, FALSE);
IF res<>0 THEN
begin
CALL log_write("chyba adresßta "+int2str(res));
CALL mailerr(res);
end;
ELSE BEGIN //3
SET res= LetterSend(Letter);
IF res<>0 THEN BEGIN CALL log_write("chyba p°i odesφlßnφ poÜtou "+int2str(res)); CALL mailerr(res); END;
END IF; //4
END; END IF; //3
END; END IF; //2
END; END IF; //01
CALL CloseWBMail;
END; END IF; //1
END; END IF; //0
END