1997-03-20 10:33:28 +00:00
|
|
|
|
#include <form.h>
|
|
|
|
|
#include <mask.h>
|
|
|
|
|
#include <printapp.h>
|
|
|
|
|
|
|
|
|
|
#include "medici.h"
|
|
|
|
|
#include <comuni.h>
|
|
|
|
|
|
|
|
|
|
#include "at6.h"
|
|
|
|
|
#include "at6100a.h"
|
|
|
|
|
|
|
|
|
|
enum ts { undefined = 0, elenco = 1, etichette = 2 };
|
|
|
|
|
|
|
|
|
|
// definizione form per etichette
|
|
|
|
|
class TMed_form : public TForm
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual TCursor* cursor() const;
|
|
|
|
|
virtual TRelation* relation() const;
|
|
|
|
|
TPrint_section& get_body() { return section('B'); } ;
|
|
|
|
|
TMed_form(): TForm() {};
|
|
|
|
|
TMed_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "")
|
|
|
|
|
: TForm(form,code,editlevel,desc) {};
|
|
|
|
|
virtual ~TMed_form() {};
|
|
|
|
|
};
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
class TStampaMedici : public TPrintapp
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
TRelation* _rel;
|
|
|
|
|
TMask* _msk;
|
|
|
|
|
TMed_form* _form_eti;
|
|
|
|
|
int _cur1, _cur2;
|
|
|
|
|
TParagraph_string _cognome_nome, _dencom, _indirizzo;
|
|
|
|
|
TDate _data_stampa;
|
1997-12-05 16:26:15 +00:00
|
|
|
|
ts _tipostampa;
|
|
|
|
|
int _etlarghezza, _etcolonne;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool user_create();
|
|
|
|
|
virtual bool user_destroy();
|
|
|
|
|
virtual bool set_print(int m);
|
|
|
|
|
virtual void set_page(int file, int cnt);
|
|
|
|
|
virtual bool preprocess_page (int file, int counter);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void crea_intestazione();
|
1997-08-01 14:49:53 +00:00
|
|
|
|
TStampaMedici() : _data_stampa(TODAY), _indirizzo("",25), _dencom("",25), _cognome_nome("",40) {}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
HIDDEN inline TStampaMedici& app() { return (TStampaMedici&) main_app(); }
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
TCursor* TMed_form::cursor() const { return app().current_cursor(); }
|
|
|
|
|
|
|
|
|
|
TRelation* TMed_form::relation() const { return cursor()->relation(); }
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
void TStampaMedici::set_page(int file, int cnt)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
// costruzione etichette
|
1997-12-05 16:26:15 +00:00
|
|
|
|
switch (_tipostampa)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
case etichette:
|
1997-12-05 16:26:15 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
TPrint_section& corpo = _form_eti->get_body();
|
1997-12-05 16:26:15 +00:00
|
|
|
|
for (int r=1;r<=_etcolonne;r++)
|
|
|
|
|
{
|
|
|
|
|
if (current_cursor()->pos()<current_cursor()->items())
|
|
|
|
|
{
|
|
|
|
|
force_setpage(TRUE);
|
|
|
|
|
corpo.update();
|
|
|
|
|
for (word i = 0; i < corpo.height(); i++)
|
|
|
|
|
{
|
|
|
|
|
TPrintrow& riga = corpo.row(i);
|
|
|
|
|
TString256 riga1 = riga.row();
|
|
|
|
|
riga1.cut(_etlarghezza);
|
|
|
|
|
int colonna = ((r-1)*_etlarghezza);
|
|
|
|
|
TString16 formato;
|
|
|
|
|
formato << '@' << colonna << "g";
|
|
|
|
|
riga1.insert(formato,0);
|
|
|
|
|
set_row(i+1,riga1);
|
|
|
|
|
}
|
|
|
|
|
if (r < _etcolonne)
|
|
|
|
|
++(*current_cursor());
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case elenco:
|
|
|
|
|
{
|
|
|
|
|
set_row(1,"@0g@pn",FLD(LF_MEDICI,MED_CODMED,"######"));
|
|
|
|
|
set_row(1,"@7g#a",&_cognome_nome);
|
|
|
|
|
set_row(1,"@48g#a",&_indirizzo);
|
|
|
|
|
set_row(1,"@74g#a",&_dencom);
|
|
|
|
|
set_row(1,"@100g@S",FLD(LF_MEDICI,MED_TELAMB));
|
|
|
|
|
set_row(1,"@116g@S",FLD(LF_MEDICI,MED_TELABI));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
bool TStampaMedici::preprocess_page(int file, int counter)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1997-12-05 16:26:15 +00:00
|
|
|
|
if (_tipostampa==elenco)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
TString80 nome = current_cursor()->curr().get(MED_COGNOME);
|
|
|
|
|
nome << " ";
|
|
|
|
|
nome << current_cursor()->curr().get(MED_NOME);
|
|
|
|
|
_cognome_nome = nome;
|
|
|
|
|
TString256 localita = "";
|
|
|
|
|
localita << current_cursor()->curr("LCP").get("S0");
|
|
|
|
|
if (localita.not_empty() && localita.ok())
|
|
|
|
|
localita << " - ";
|
|
|
|
|
localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM);
|
|
|
|
|
_dencom = localita;
|
|
|
|
|
_indirizzo = current_cursor()->curr(LF_MEDICI).get(MED_INDIRIZZO);
|
|
|
|
|
}
|
1997-12-05 16:26:15 +00:00
|
|
|
|
if (_tipostampa==etichette)
|
|
|
|
|
if (printer().rows_left() < _form_eti->get_body().height())
|
|
|
|
|
printer().formfeed();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
bool TStampaMedici::set_print(int)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1997-12-05 16:26:15 +00:00
|
|
|
|
_tipostampa = undefined;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
KEY tasto;
|
|
|
|
|
tasto = _msk->run();
|
|
|
|
|
switch (tasto)
|
|
|
|
|
{
|
|
|
|
|
case F_ELENCO:
|
1997-12-05 16:26:15 +00:00
|
|
|
|
_tipostampa = elenco;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case F_ETICHETTE:
|
1997-12-05 16:26:15 +00:00
|
|
|
|
_tipostampa = etichette;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1997-12-05 16:26:15 +00:00
|
|
|
|
if (_tipostampa != undefined)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
long codfr, codto;
|
|
|
|
|
TString80 cogfr, cogto;
|
|
|
|
|
const int sort = _msk->get_int(F_SORT);
|
|
|
|
|
reset_files();
|
|
|
|
|
add_file(LF_MEDICI);
|
|
|
|
|
if (sort == 1)
|
|
|
|
|
{
|
|
|
|
|
codfr = _msk->get_long(F_CODFR);
|
|
|
|
|
codto = _msk->get_long(F_CODTO);
|
|
|
|
|
select_cursor(_cur1);
|
|
|
|
|
TLocalisamfile& fl = current_cursor()->file(LF_MEDICI);
|
|
|
|
|
TRectype da(fl.curr());
|
|
|
|
|
TRectype a(fl.curr());
|
|
|
|
|
da.zero();
|
|
|
|
|
a.zero();
|
|
|
|
|
da.put(MED_CODMED, codfr);
|
|
|
|
|
a.put(MED_CODMED, codto);
|
|
|
|
|
current_cursor()->setregion(da, a);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (sort == 2)
|
|
|
|
|
{
|
|
|
|
|
cogfr = _msk->get(F_COGFR);
|
|
|
|
|
cogto = _msk->get(F_COGTO);
|
|
|
|
|
select_cursor(_cur2);
|
|
|
|
|
TLocalisamfile& fl = current_cursor()->file(LF_MEDICI);
|
|
|
|
|
TRectype da(fl.curr());
|
|
|
|
|
TRectype a(fl.curr());
|
|
|
|
|
da.zero();
|
|
|
|
|
a.zero();
|
|
|
|
|
da.put(MED_COGNOME, cogfr);
|
|
|
|
|
a.put (MED_COGNOME, cogto);
|
|
|
|
|
current_cursor()->setregion(da, a);
|
|
|
|
|
}
|
|
|
|
|
reset_print();
|
|
|
|
|
crea_intestazione();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
void TStampaMedici::crea_intestazione()
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
reset_header();
|
1997-12-05 16:26:15 +00:00
|
|
|
|
if (_tipostampa == elenco)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
TString sep(132);
|
|
|
|
|
TString16 data_stampa;
|
|
|
|
|
sep.fill('-');
|
|
|
|
|
set_header(1, (const char *) sep);
|
|
|
|
|
sep = "";
|
|
|
|
|
sep << "Pag. @#";
|
|
|
|
|
sep.right_just(132);
|
|
|
|
|
set_header(2,(const char*) sep);
|
|
|
|
|
set_header(2,"@0gARCHIVIO MEDICI@104gDATA");
|
|
|
|
|
data_stampa = _data_stampa.string();
|
|
|
|
|
set_header(2,"@109g%10s", (const char*) data_stampa);
|
|
|
|
|
sep = "";
|
|
|
|
|
sep.fill('-');
|
|
|
|
|
set_header(3, (const char *) sep);
|
|
|
|
|
set_header(5,"@0gCodice@7gCognome e nome@48gIndirizzo@74gLocalit<69>/Comune@100gTel. amb.@116gTel. abi.");
|
|
|
|
|
set_header(6,"@0g------@7g----------------------------------------@48g-------------------------");
|
|
|
|
|
set_header(6,"@74g-------------------------@100g---------------@116g---------------");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
bool TStampaMedici::user_create()
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
_rel = new TRelation(LF_MEDICI);
|
|
|
|
|
_rel->add(LF_COMUNI, "COM==COM");
|
|
|
|
|
_rel->add("LCP", "CODTAB==LOCALITA");
|
|
|
|
|
_cur1 = add_cursor(new TCursor(_rel, "", 1)); //cursore ordinamento per codice
|
|
|
|
|
_cur2 = add_cursor(new TCursor(_rel, "", 2)); //cursore ordinamento per cognome e nome
|
|
|
|
|
_msk = new TMask("at6100a");
|
|
|
|
|
_form_eti = new TMed_form("AT_ETMED");
|
1997-12-05 16:26:15 +00:00
|
|
|
|
TConfig config(CONFIG_STUDIO);
|
|
|
|
|
TString16 etformato = config.get("EtFormato");
|
|
|
|
|
_etlarghezza = config.get_int("EtLarghezza");
|
|
|
|
|
_etcolonne = config.get_int("EtColonne");
|
1997-03-20 10:33:28 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-01 14:49:53 +00:00
|
|
|
|
bool TStampaMedici::user_destroy()
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1998-08-07 10:23:34 +00:00
|
|
|
|
delete _form_eti;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
delete _msk;
|
|
|
|
|
delete _rel;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int at6100(int argc, char* argv[])
|
|
|
|
|
{
|
1997-08-01 14:49:53 +00:00
|
|
|
|
TStampaMedici a;
|
|
|
|
|
a.run(argc, argv, "Stampa Tabella Medici");
|
1997-03-20 10:33:28 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|