home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / tema / 602propc / disk5 / data.5 / WINTIME / APPS / I_MAILME.PGM < prev    next >
Text File  |  1996-12-03  |  11KB  |  325 lines

  1. INCLUDE
  2.  
  3. procedure SpustitWinText602(parsablona : string[80]);
  4. {**************************************}
  5. var
  6.   cesta : string[80];
  7.   parwb : string[80];
  8.   parametr : string[160];
  9.   err : short;
  10.   idw : window_id;
  11. begin
  12.   parametr := '/wbase602 '+pathwb+' '+parsablona;
  13.   err := Exec(pathWT,parametr);
  14.   if (err = 2) or (err = 3) then begin
  15.     if YesNo_box('Chyba p°i spuÜt∞nφ programu WinText602','Pravd∞podobn∞ je Üpatn∞ nastavenß cesta k programu'#10'Opravit nynφ?') then
  16.     begin
  17.       Open_view('*PWinText',no_redir,modal_view,0,0,idw);
  18.       repeat Peek_message until idw=0;
  19.       SmazatFrontu;
  20.     end;   
  21.   end else
  22.   if (err < 32) and (err >= 0) then Info_box('Chyba p°i spuÜt∞nφ programu WinText602',int2str(err));
  23.  
  24. end;
  25.  
  26. procedure Napoved;
  27. {**************************************}
  28. begin
  29.   Info_box('Nßpov∞da pro novou Üablonu',
  30.        '1) Upravte otev°en² dokument vΦetn∞ p°ipojen²ch polφ do podoby,'#10'jakou si p°ejete.'
  31.     #10'2) Prove∩te standardn∞ tiskov² nebo faxov² MailMerge.'
  32.  #10#10'Chcete-li Üablonu ulo₧it pro dalÜφ pou₧φvßnφ, prove∩te nßsledujφcφ kroky:'
  33.     #10'3) Ulo₧te dokument jako Üablonu (WPT) s nov²m jmΘnem.'
  34.     #10'4) V Adresß°i dopl≥te Φφslo, jmΘno a popis novΘ Üablony'#10'(menu ┌dr₧ba/èablony).');
  35.  
  36. end;
  37.  
  38. procedure ZapisDoKontaktu(popis : string[40]);
  39. {**************************************}
  40. {zapφÜe informaci o mm do tabulky kontakt∙}
  41.  
  42. var
  43.   i,pocetmm : integer;
  44.   cis : short;
  45.   reck : integer;
  46. begin
  47.    if not Rec_cnt(MailMerge, pocetmm) then begin
  48.      for i := 0 to pocetmm-1 do begin
  49.       Set_status_text('Zapisuji do tabulky kontakt∙...');
  50.       Set_status_nums(i,pocetmm);
  51.        Start_transaction;
  52.        reck := Insert(Tschuzky); Signalize;
  53.        if reck <> -1 then begin
  54.          cis := MailMerge[i].cislo;
  55.          Tschuzky[reck].cislo := MailMerge[i].cislo;
  56.          Tschuzky[reck].dat1 := Today;
  57.          Tschuzky[reck].doba1 := Now;
  58.          Tschuzky[reck].popis1 := popis;
  59.          Tschuzky[reck].vlozil := myName;
  60.          Tschuzky[reck].pozn1 := 'automatick² zßznamnφk';
  61.        end;
  62.        Commit;
  63.      end;
  64.     Set_status_text('');
  65.     Set_status_nums(-1,-1);
  66.    end;
  67. end;
  68.  
  69.  
  70. procedure TiskForm(zaznam : integer);
  71. {**************************************}
  72. {tisk formulß°e - napln∞nφ tabulky MAILMERGE aktußlnφm zßznamem
  73. tlaΦφtko v pohledu Pfirma}
  74.  
  75. var
  76.   u1 : untyped;
  77.   rec2 : integer;
  78.   cestaKSablone : string[60];
  79.   jmenoSablony : string[80];
  80.   pozice : short;
  81.   statement : string[250];
  82.   cf : cursor;              
  83.   id_pom : window_id;
  84.   sab : string[40];
  85.   spom1,spom2,spom3 : string[20];
  86.   id_sab2 : window_id;
  87.   
  88. begin
  89.   zrusitAkci := true;
  90.  
  91.   if Parametry[0].sablonyWT = '' then begin
  92.     Open_view('*SABLO2ADR',-1,0,0,0,id_sab2);
  93.     repeat Peek_message until id_sab2=0;
  94.   end;
  95.   
  96.   Open_view("*Psablona",no_redir,modal_view,0,0,id_form);
  97.   repeat Peek_message until id_form=0;
  98.   SmazatFrontu;
  99.  
  100.   if not ZrusitAkci then begin
  101.     Err_mask(true);
  102.      Parametry[0].template := template;  // zapsßnφ naposled pou₧itΘ Üablony
  103.     Err_mask(false);
  104.     u1 := template;
  105.     rec2 := Look_up(Tsablonywt,"cislo",u1);
  106.     Err_mask(true);
  107.      cestaKSablone := Parametry[0].sablonywt;
  108.     Err_mask(false);
  109.     if cestaKSablone[StrLength(cestaKSablone)] = '\' then StrDelete(cestaKSablone,StrLength(cestaKSablone),1);
  110.     jmenoSablony := cestaKSablone+'\'+Tsablonywt[rec2].jmeno+'.WPT';
  111.  
  112.     if Write_lock_table(MailMerge) then 
  113.       Info_box('Nelze','Tabulka pou₧φvanß pro MailMerge je zamknutß.')
  114.     else begin
  115.       if Delete_all_records(MailMerge) then Signalize
  116.         else Free_deleted(MailMerge);
  117.       if not Get_fcursor(Active_view,cf,nil) then Info_box('Chyba','Get_fcursor')
  118.       else begin
  119.         Start_transaction;  // sdru₧enφ zßpis∙ do transakce za ·Φelem zrychlenφ
  120.          Insert(MailMerge);
  121.          spom1 := cf[zaznam].titul;
  122.          spom2 := cf[zaznam].jmeno;
  123.          spom3 := cf[zaznam].prijmeni;
  124.          MailMerge[0].jmeno  := spom1+' '+spom2+' '+spom3; //nejde spojovat rovnou, proto₧e kurzor je beztypov²
  125.          MailMerge[0].cislo  := cf[zaznam].cislo;
  126.          MailMerge[0].firma  := cf[zaznam].firma;
  127.          MailMerge[0].firma2 := cf[zaznam].firma2;
  128.          MailMerge[0].funkce := cf[zaznam].funkce;
  129.          MailMerge[0].ulice  := cf[zaznam].ulice;
  130.          MailMerge[0].mesto  := cf[zaznam].mesto;
  131.          MailMerge[0].psc    := cf[zaznam].psc;
  132.          MailMerge[0].stat   := cf[zaznam].stat;
  133.          MailMerge[0].tel    := cf[zaznam].telefon[0];
  134.          MailMerge[0].fax    := cf[zaznam].fax[0];
  135.          MailMerge[0].ico    := cf[zaznam].ico;
  136.          MailMerge[0].dic    := cf[zaznam].dic;
  137.         Commit;            // konec transakce
  138.  
  139.         sab := Tsablonywt[rec2].popis;
  140.         ZapisDoKontaktu(sab);                             // automat. zßznamnφk kontakt∙
  141.         SpustitWinText602(jmenoSablony);
  142.         if template = 0 then Napoved;
  143.       end;
  144.     end;
  145.   end;  
  146. end;
  147.  
  148. procedure TiskMailMerge;
  149. {**************************************}
  150. {napln∞nφ tabulky MAILMERGE vÜemi vybran²mi zßznamy}
  151.  
  152. var
  153.   curmm : cursor;            
  154.   err : short;
  155.   pocet,i,rec,rec2 : integer;
  156.   statement : string[250];
  157.   cesta : string[80];
  158.   u1 : untyped;
  159.   cestaKSablone : string[60];
  160.   jmenoSablony : string[80];
  161.   id_pom,id_mm : window_id;
  162.   sab : string[40];
  163.   res : integer;
  164.   spom1,spom2,spom3 : string[20];
  165.   id_sab2 : window_id;
  166.  
  167. begin
  168.   zrusitAkci := true;
  169.  
  170.   if Parametry[0].sablonyWT = '' then begin
  171.     Open_view('*SABLO2ADR',-1,0,0,0,id_sab2);
  172.     repeat Peek_message until id_sab2=0;
  173.   end;
  174.   
  175.   mm := false;
  176.   Open_view("*Psablona",no_redir,modal_view,0,0,id_form);
  177.   repeat Peek_message until id_form=0;
  178.   SmazatFrontu;
  179.  
  180.   if not ZrusitAkci then begin
  181.     Err_mask(true);
  182.      Parametry[0].template := template;
  183.     Err_mask(false);
  184.     u1 := template;
  185.     rec2 := Look_up(Tsablonywt,"cislo",u1);
  186.     Err_mask(true);
  187.      cestaKSablone := Parametry[0].sablonywt;
  188.     Err_mask(false);
  189.     if cestaKSablone[StrLength(cestaKSablone)] = '\' 
  190.          then StrDelete(cestaKSablone,StrLength(cestaKSablone),1);
  191.     jmenoSablony := cestaKSablone+'\'+Tsablonywt[rec2].jmeno+'.WPT';
  192.  
  193.     Set_cursor(1);
  194.     Set_status_text('Vytvß°φm pomocnou tabulku...');
  195.  
  196.     id_pom := Active_view;
  197.     if id_pom <> 0 then begin
  198.       Get_fcursor(id_pom, curmm, nil);      //sejmutφ kurzoru z obrazovky, m∙₧e b²t zm∞n∞n dφky QBE
  199.     end else curmm := curmain;              //nenφ otev°en pohled do dat
  200.     if Rec_cnt(curmm,pocet) then Signalize;
  201.  
  202.     if Write_lock_table(MailMerge) then 
  203.       Info_box('Nelze','Tabulka pou₧φvanß pro MailMerge je zamknutß.')
  204.     else begin
  205.       if Delete_all_records(MailMerge) then Signalize
  206.         else Free_deleted(MailMerge);
  207.       Set_status_text('Zapisuji do  pomocnΘ tabulky...');  
  208.       for i := 0 to pocet-1 do begin
  209.         Set_status_nums(i+1,-1);
  210.         Translate(curmm,i,0,res);
  211.         if res <> -1 then begin          // zßznam v kurzoru nebyl zruÜen
  212.           Start_transactions;  // sdru₧enφ zßpisu na disk do transakce
  213.            rec := Insert(MailMerge);
  214.            spom1 := curmm[i].titul;
  215.            spom2 := curmm[i].jmeno;
  216.            spom3 := curmm[i].prijmeni;
  217.            MailMerge[rec].jmeno  := spom1+' '+spom2+' '+spom3; //nejde spojovat rovnou, proto₧e kurzor je beztypov²
  218.            MailMerge[rec].cislo  := curmm[i].cislo;
  219.            MailMerge[rec].firma  := curmm[i].firma;
  220.            MailMerge[rec].firma2 := curmm[i].firma2;
  221.            MailMerge[rec].funkce := curmm[i].funkce;
  222.            MailMerge[rec].ulice  := curmm[i].ulice;
  223.            MailMerge[rec].mesto  := curmm[i].mesto;
  224.            MailMerge[rec].stat   := curmm[i].stat;
  225.            MailMerge[rec].tel    := curmm[i].telefon[0];
  226.            MailMerge[rec].fax    := curmm[i].fax[0];
  227.            MailMerge[rec].psc    := curmm[i].psc;
  228.            MailMerge[rec].ico    := curmm[i].ico;
  229.            MailMerge[rec].dic    := curmm[i].dic;
  230.           Commit;
  231.         end;
  232.       end;
  233.       Set_status_text('');
  234.  
  235.       Open_view('*MmVybr',no_redir,0,0,0,id_mm);
  236.       repeat Peek_message until id_mm=0;
  237.  
  238.       sab := TsablonyWT[rec2].popis;
  239.       if kon then ZapisDoKontaktu(sab);                 // automat. zßznamnφk kontakt∙
  240.       if mm then begin
  241.         SpustitWinText602(jmenoSablony);
  242.         if template = 0 then Napoved;
  243.       end;  
  244.     end; //  Write_lock
  245.     Set_status_nums(-1,-1);
  246.   end;  
  247. end;
  248.  
  249. procedure OdemknoutMM;
  250. {**************************************}
  251. // odemkne tabulku MailMerge, aby ostatnφ mohli MM pou₧φt
  252. begin
  253.   if Write_unlock_table(MailMerge) then begin
  254.     Info_box('Nelze','Tabulku pro mailmerge nelze odemknout.'#10'Bu∩ nenφ zamknuta nebo ji pou₧φvß n∞kdo jin².');
  255.   end
  256.   else Info_box('Provedeno','OK');
  257. end;
  258.  
  259. procedure Odfaxovat(cislofax : string[20]; jmenofirmy : string[50]);
  260. {**************************************}
  261. var
  262.   g : file;
  263.   name : string[130];
  264.   obsah : string[70];
  265.   parametr : string[120];
  266.   err : short;
  267.   idw : window_id;
  268. begin
  269.  
  270.   name := GetTempDir+'FAX602.TEL';
  271.   Rewrite(g,name);
  272.   WriteLn(g,'[PHONELIST]');
  273.   obsah :=jmenofirmy+'='+cislofax;
  274.   WriteLn(g,obsah);
  275.   Close(g);
  276.  
  277.   if GetProfString('FAX602 - ovladaΦ pro fax','HomeDirFM602','',parametr,120,'WIN.INI') = 0
  278.   then Info_box('Chyba','Nelze nastavit WinFM602! Je nainstalovßn?')
  279.   else begin
  280.     Set_status_text('SpouÜtφm WinFax602, prosφm Φekejte...');
  281.     err := Exec(pathWF,parametr);
  282.     if (err = 2) or (err = 3) then begin
  283.       if YesNo_box('Chyba p°i spuÜt∞nφ programu WinFax602','Pravd∞podobn∞ je Üpatn∞ nastavenß cesta k programu'#10'Opravit nynφ?') then
  284.       begin
  285.         Open_view('*PWinText',no_redir,modal_view,0,0,idw);
  286.         repeat Peek_message until idw=0;
  287.         SmazatFrontu;
  288.       end;   
  289.     end else
  290.     if (err < 32) and (err >= 0) then Info_box('Chyba p°i spuÜt∞nφ programu WinFax602',int2str(err));
  291.   end;
  292. end;
  293.  
  294. procedure Vytocit(cislotel : string[20]; jmenofirmy : string[50]);
  295. {**************************************}
  296. var
  297.   g : file;
  298.   name : string[130];
  299.   obsah : string[70];
  300.   err : short;
  301.   idw : window_id;
  302. begin
  303.  
  304.   name := GetTempDir+'WINM602.TEL';
  305.   Rewrite(g,name);
  306.   WriteLn(g,'[PHONELIST]');
  307.   obsah :=jmenofirmy+'='+cislotel;
  308.   WriteLn(g,obsah);
  309.   Close(g);
  310.  
  311.   Set_status_text('SpouÜtφm WinMana₧er602, prosφm Φekejte...');
  312.   err := Exec(pathWM,'');
  313.   if (err = 2) or (err = 3) then begin
  314.     if YesNo_box('Chyba p°i spuÜt∞nφ programu WinMana₧er602','Pravd∞podobn∞ je Üpatn∞ nastavenß cesta k programu'#10'Opravit nynφ?') then
  315.     begin
  316.       Open_view('*PWinText',no_redir,modal_view,0,0,idw);
  317.       repeat Peek_message until idw=0;
  318.       SmazatFrontu;
  319.     end;   
  320.   end else
  321.   if (err < 32) and (err >= 0) then Info_box('Chyba p°i spuÜt∞nφ programu WinMana₧er602',int2str(err));
  322.  
  323. end;
  324.  
  325.