campo-sirio/ba/ba6100.cpp
alex d52681f795 Patch level : 10.0 265
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Riportata la versione 3.2 patch 1353


git-svn-id: svn://10.65.10.50/trunk@18581 c028cbd2-c16b-5b4b-a496-9718f37d4682
2009-03-23 10:37:33 +00:00

595 lines
17 KiB
C++
Executable File

// **********************************************************************
// Stampa anagrafiche
// Control code
// ***********************************************************************
#include <progind.h>
#include <recarray.h>
#include "ba6100.h"
#include "anagr.h"
#include "nditte.h"
// ------- utils --------------------------------------------
const TRectype& TAnaprint_app::look_com(const char* cod, const char* sta)
{
TString8 key;
if (sta && *sta)
key << sta;
key << '|';
if (cod && *cod)
key << cod;
return cache().get(LF_COMUNI, key);
}
const char* TAnaprint_app::look_tab(const char* tabname, const char* cod,
const char* fld)
{
if (cod == NULL || *cod == 0)
return "";
TTable tab(tabname);
tab.curr().zero();
tab.curr().put("CODTAB",cod);
tab.read();
if (tab.bad()) tab.curr().zero();
return tab.curr().get(fld);
}
// link
bool TAnaprint_app::process_link(int id, const char* txt)
{
bool reload = false;
if (id == _ana_link)
{
TRectype persona(LF_ANAG);
persona.put(ANA_TIPOA, _pr_what == anafis ? 'F' : 'G');
persona.put(ANA_CODANAGR, atol(txt));
TString8 hint; hint.format("ba4 -1 %c", _pr_what == anafis ? 'F' : 'G');
reload = persona.edit(LF_ANAG, NULL, hint);
}
else if (id == _dit_link)
{
TRectype ditta(LF_NDITTE);
ditta.put(NDT_CODDITTA, atol(txt));
reload = ditta.edit(LF_NDITTE, NULL, "ba4 -2");
}
return reload;
}
// ---- here we go -------------------------------------------------
void TAnaprint_app::set_page(int file, int cnt)
{
switch(file)
{
case LF_ANAG:
case LF_NDITTE:
if (_pr_type == elenco)
{
if (_pr_what != nditte && file == LF_NDITTE)
{
set_row(1,"@58g$[v]@pN$[n]@66g@S", FLD(LF_NDITTE,"CODDITTA","@@@@@"),
FLD(LF_NDITTE,"RAGSOC"));
set_row(2,"");
}
else
set_elenco();
}
else if (_pr_type == rubriche) set_rubriche();
else if (_pr_type == schede)
{
if (_pr_what != nditte && file == LF_NDITTE)
set_scheda_ditta();
else
set_schede();
}
else if (_pr_type == etichette) set_etichette();
break;
case LF_ATTIV:
set_scheda_attiv();
break;
case LF_UNLOC:
set_scheda_unloc();
break;
case LF_SOCI:
set_scheda_socio();
break;
}
}
bool TAnaprint_app::preprocess_page(int file, int counter)
{
// non stampa la prima ditta se sta facendo l'elenco visto
// che la stampa a fianco dell'anagrafica
if (file == LF_NDITTE && _pr_type == elenco && _inclditte
&& _pr_what != nditte)
if (current_cursor()->is_first_match(LF_NDITTE))
return FALSE;
if (_pr_type == elenco || _pr_type == rubriche)
{
_surname_name = current_cursor()->curr(LF_ANAG).get("RAGSOC");
_surname_name.strip_double_spaces();
}
if (_pr_type == rubriche)
{
// vale per ditte, anagiu, anafis
_com = current_cursor()->curr(LF_ANAG).get("COMRES");
if (_com.empty())
_com = current_cursor()->curr(LF_ANAG).get("COMRF");
if (_pr_what == nditte)
{
_phone = current_cursor()->curr(LF_NDITTE).get("PTEL");
_phone.trim();
if (!_phone.empty()) _phone << '/';
_phone << current_cursor()->curr(LF_NDITTE).get("TEL");
}
if (_phone.empty() || _pr_what != nditte)
{
_phone = current_cursor()->curr(LF_ANAG).get("PTELRF");
_phone.trim();
if (!_phone.empty()) _phone << '/';
_phone << current_cursor()->curr(LF_ANAG).get("TELRF");
}
const TRectype& cc = look_com(_com);
_com = cc.get("DENCOM");
_cap = cc.get("CAPCOM");
_prov = cc.get("PROVCOM");
}
else if (_pr_type == etichette)
preprocess_etichette();
return TRUE;
}
print_action TAnaprint_app::postprocess_page(int file, int counter)
{
printer().current_row(); // verificare
if (file == LF_ANAG && _pr_type == schede && _inclditte)
printer().formfeed();
return NEXT_PAGE;
}
bool mask_reset_fields(TMask_field& mf, KEY k)
{
if (k == K_SPACE)
{
TMask& m = mf.mask();
TAnaprint_app& a = (TAnaprint_app&)main_app();
m.set(FLD_BA6B_INDROW, a._ind_row);
m.set(FLD_BA6B_INDCOL, a._ind_col);
m.set(FLD_BA6B_PIVROW, a._piv_row);
m.set(FLD_BA6B_PIVCOL, a._piv_col);
m.set(FLD_BA6B_CODROW, a._cod_row);
m.set(FLD_BA6B_CODCOL, a._cod_col);
m.set(FLD_BA6B_TOTROW, a._rows_et);
m.set(FLD_BA6B_TOTCOL, a._cols_et);
m.set(CHK_BA6B_PIVA, a._is_piv ? "X" : " ");
m.set(CHK_BA6B_CODICE, a._is_cod ? "X": " ");
}
return TRUE;
}
void TAnaprint_app::preprocess_etichette()
{
// everything goes into strings
_name = get_field(LF_ANAG,"RAGSOC");
_cod = get_field(LF_ANAG,"CODANAGR");
_cofi = get_field(LF_ANAG,"COFI");
if (_cofi.empty())
_cofi = get_field(LF_ANAG,"PAIV");
if (_pr_what == anafis)
{
_surname = _name.mid(30); _surname.trim();
_name = _name.cut(30); _name.trim();
_sex = get_field(LF_ANAGFIS,"SESSO")[0] == 'M' ? TR("Sig.") : TR("Sig.ra");
}
switch (_ind_what)
{
case corrispondenza:
{
_address = get_field(LF_ANAG,"INDCORR");
_civ = get_field(LF_ANAG,"CIVCORR");
_stato = look_tab("%STA",get_field(LF_ANAG,"STATOCORR"));
_cap = get_field(LF_ANAG,"CAPCORR");
_loc = get_field(LF_ANAG,"LOCCORR");
const TRectype& cc = look_com(get_field(LF_ANAG,"COMCORR"));
_com = cc.get("DENCOM");
_prov = cc.get("PROVCOM");
if (_cap.empty())
_cap = cc.get("CAPCOM");
if (_address.full())
break;
// else fall down
}
case domfisc:
{
_address = get_field(LF_ANAG,"INDRF");
_civ = get_field(LF_ANAG,"CIVRF");
_stato = "" ; // look_tab("%STA",get_field(LF_ANAG,"STATORF"));
_cap = get_field(LF_ANAG,"CAPRF");
const TRectype& cc = look_com(get_field(LF_ANAG,"COMRF"));
_loc = "";
_com = cc.get("DENCOM");
_prov = cc.get("PROVCOM");
if (_cap.empty())
_cap = cc.get("CAPCOM");
if (_address.full())
break;
// else fall down
}
case residenza:
{
_address = get_field(LF_ANAG,"INDRES");
_civ = get_field(LF_ANAG,"CIVRES");
_stato = get_field(LF_ANAG,"STATORES");
_cap = get_field(LF_ANAG,"CAPRES");
const TRectype& cc = look_com(get_field(LF_ANAG,"COMRES"), _stato);
_loc = "";
_com = cc.get("DENCOM");
_prov = cc.get("PROVCOM");
if (_cap.empty())
_cap = cc.get("CAPCOM");
}
break;
}
}
void TAnaprint_app::init_print()
{
reset_print();
reset_files();
// select cursor and main file
switch(_pr_what)
{
case anafis:
select_cursor(cfis());
add_file(LF_ANAG);
break;
case anagiu:
select_cursor(cgiu());
add_file(LF_ANAG);
break;
case nditte:
select_cursor(cdit());
add_file(LF_NDITTE);
break;
}
force_setpage(_pr_type == schede);
// setup secondary links
if (_inclditte)
{
switch(_pr_type)
{
case elenco:
if (_pr_what != nditte)
add_file(LF_NDITTE);
break;
case schede:
if (_pr_what != nditte)
add_file(LF_NDITTE);
add_file(LF_ATTIV,LF_NDITTE);
add_file(LF_UNLOC,LF_NDITTE);
add_file(LF_SOCI, LF_NDITTE);
break;
default:
break;
}
}
set_headers();
set_footers();
}
bool TAnaprint_app::set_print(int)
{
TMask mask("ba6100a.msk");
// set print type
switch (mask.run())
{
case K_ESC:
case K_QUIT:
return FALSE;
case BUT_BA6_ELENCO:
_pr_type = elenco;
// cio' che e' blu collega al modulo anagrafiche
_ana_link = enable_link(TR("Collegamento archivio anagrafiche: "), 'b');
_dit_link = enable_link(TR("Collegamento archivio ditte: "), 'v');
break;
case BUT_BA6_SCHEDE:
disable_links();
_pr_type = schede;
break;
case BUT_BA6_ETICHETTE:
disable_links();
if (_pr_what != nditte)
{
_pr_type = etichette;
// set additionals
TMask mask2("ba6100b.msk");
mask2.set_workfile("ba6100.set");
mask2.set_handler(BUT_BA6B_RESET, mask_reset_fields);
if (fexist("ba6100b.set"))
{
mask2.load();
_ind_what = (in)mask2.get_int(RDB_BA6B_INDIR);
_ind_row = mask2.get_int(FLD_BA6B_INDROW);
_piv_row = mask2.get_int(FLD_BA6B_PIVROW);
_cod_row = mask2.get_int(FLD_BA6B_CODROW);
_rows_et = mask2.get_int(FLD_BA6B_TOTROW);
_ind_col = mask2.get_int(FLD_BA6B_INDCOL);
_piv_col = mask2.get_int(FLD_BA6B_PIVCOL);
_cod_col = mask2.get_int(FLD_BA6B_CODCOL);
_cols_et = mask2.get_int(FLD_BA6B_TOTCOL);
_is_piv = mask2.get(CHK_BA6B_PIVA) == "X";
_is_cod = mask2.get(CHK_BA6B_CODICE) == "X";
}
else
{
mask2.set(FLD_BA6B_INDROW,_ind_row);
mask2.set(FLD_BA6B_INDCOL,_ind_col);
mask2.set(FLD_BA6B_PIVROW,_piv_row);
mask2.set(FLD_BA6B_PIVCOL,_piv_col);
mask2.set(FLD_BA6B_CODROW,_cod_row);
mask2.set(FLD_BA6B_CODCOL,_cod_col);
mask2.set(FLD_BA6B_TOTROW,_rows_et);
mask2.set(FLD_BA6B_TOTCOL,_cols_et);
mask2.set(CHK_BA6B_PIVA,_is_piv ? "X" : " ");
mask2.set(CHK_BA6B_CODICE,_is_cod ?"X": " ");
}
if (mask2.run() == K_ESC)
return FALSE;
_ind_what = (in)mask2.get_int(RDB_BA6B_INDIR);
_ind_row = mask2.get_int(FLD_BA6B_INDROW);
_piv_row = mask2.get_int(FLD_BA6B_PIVROW);
_cod_row = mask2.get_int(FLD_BA6B_CODROW);
_rows_et = mask2.get_int(FLD_BA6B_TOTROW);
_ind_col = mask2.get_int(FLD_BA6B_INDCOL);
_piv_col = mask2.get_int(FLD_BA6B_PIVCOL);
_cod_col = mask2.get_int(FLD_BA6B_CODCOL);
_cols_et = mask2.get_int(FLD_BA6B_TOTCOL);
_is_piv = mask2.get(CHK_BA6B_PIVA) == "X";
_is_cod = mask2.get(CHK_BA6B_CODICE) == "X";
if (_frpos) delete _frpos;
_frpos = new bool[_rows_et];
memset(_frpos,FALSE,sizeof(_frpos));
_frpos[_ind_row-1] = TRUE;
_frpos[_ind_row] = TRUE;
if (_is_piv) _frpos[_piv_row-1] = TRUE;
if (_is_cod) _frpos[_cod_row-1] = TRUE;
for (int jk = 0; jk < _rows_et; jk++)
if (!_frpos[jk]) set_row(jk+1,"");
// save settings
if (mask2.get(CHK_BA6B_SAVE) == "X")
mask2.save();
}
break;
case BUT_BA6_RUBRICHE:
_ana_link = enable_link(TR("Collegamento archivio anagrafiche: "), 'b');
_dit_link = enable_link(TR("Collegamento archivio ditte: "), 'v');
_pr_type = rubriche;
break;
}
_pr_what = (pw)atoi(mask.get(RDB_BA6_TYPE));
_sort = atoi(mask.get(RDB_BA6_SORT));
_inclditte = (bool)(mask.get(CHK_BA6_INCLDI) == "X");
TString cod_from(5), cod_to(5);
switch(_pr_what)
{
case anafis:
case anagiu:
select_cursor(_pr_what == anafis ? cfis() : cgiu());
if (_sort == 1)
{
cod_from = mask.get(_pr_what == anafis ? FLD_ANF_CODFR
: FLD_ANG_CODFR);
cod_to = mask.get(_pr_what == anafis ? FLD_ANF_CODTO
: FLD_ANG_CODTO);
}
else
{
cod_from = mask.get(_pr_what == anafis ? FLD_ANF_RAGSOCFR
: FLD_ANG_RAGSOCFR);
cod_to = mask.get(_pr_what == anafis ? FLD_ANF_RAGSOCTO
: FLD_ANG_RAGSOCTO);
}
{
TLocalisamfile& fl = current_cursor()->file(LF_ANAG);
TRectype tr1(fl.curr());
TRectype tr2(fl.curr());
tr1.zero(); tr2.zero();
tr1.put("TIPOA", _pr_what == anafis ? "F" : "G");
tr2.put("TIPOA", _pr_what == anafis ? "F" : "G");
if (!cod_from.empty() || !cod_to.empty())
{
if (_sort == 1)
{
if (cod_from.not_empty())
{
tr1.put("CODANAGR",cod_from);
tr2.put("CODANAGR",cod_to);
}
}
else
{
if (cod_from.not_empty())
{
tr1.put("RAGSOC",cod_from);
tr2.put("RAGSOC",cod_to);
}
}
}
current_cursor()->setregion(tr1, tr2);
}
break;
case nditte:
select_cursor(cdit());
if (_sort == 1)
{
cod_from = mask.get(FLD_DITTE_CODFR);
cod_to = mask.get(FLD_DITTE_CODTO);
}
else
{
cod_from = mask.get(FLD_DITTE_RAGSOCFR);
cod_to = mask.get(FLD_DITTE_RAGSOCTO);
}
if (!cod_from.empty() || !cod_to.empty())
{
TLocalisamfile& fl = current_cursor()->file(LF_NDITTE);
TRectype tr1(fl.curr());
TRectype tr2(fl.curr());
tr1.zero(); tr2.zero();
if (_sort == 1)
{
tr1.put("CODDITTA",cod_from);
tr2.put("CODDITTA",cod_to);
}
else
{
tr1.put("RAGSOC",cod_from);
tr2.put("RAGSOC",cod_to);
}
current_cursor()->setregion(tr1, tr2);
}
break;
}
// setup links and set headers
init_print();
// enable_print_menu();
return TRUE;
}
bool TAnaprint_app::user_create()
{
_bk_ditta = _bk_ana = _bk_socio = _bk_attiv = _bk_registro = _bk_unloc = -1;
TToken_string rxp(40);
TProgind p(5, TR("Preparazione archivi\rPrego attendere"), FALSE, TRUE);
// setup relation
open_files(LF_COMUNI, LF_ANAG, LF_ANAGFIS, LF_ANAGGIU, LF_NDITTE, 0);
_rel_fis = new TRelation(LF_ANAG);
_rel_giu = new TRelation(LF_ANAG);
_rel_dit = new TRelation(LF_NDITTE);
p.addstatus(1);
rxp.add("CODANAGR==CODANAGR");
_rel_fis->add(LF_ANAGFIS,rxp);
_rel_giu->add(LF_ANAGGIU,rxp);
rxp.add("TIPOA==TIPOA");
_rel_fis->add(LF_NDITTE, rxp, 4);
_rel_giu->add(LF_NDITTE, rxp, 4);
_rel_dit->add(LF_ANAG, rxp);
p.addstatus(1);
// add unloc & attiv
rxp = "CODDITTA==CODDITTA";
_rel_fis->add(LF_ATTIV, rxp, 1, LF_NDITTE);
_rel_fis->add(LF_UNLOC, rxp, 1, LF_NDITTE);
_rel_giu->add(LF_ATTIV, rxp, 1, LF_NDITTE);
_rel_giu->add(LF_UNLOC, rxp, 1, LF_NDITTE);
_rel_dit->add(LF_ATTIV, rxp, 1);
_rel_dit->add(LF_UNLOC, rxp, 1);
_rel_fis->add(LF_SOCI, rxp, 4, LF_NDITTE);
_rel_giu->add(LF_SOCI, rxp, 4, LF_NDITTE);
_rel_dit->add(LF_SOCI, rxp, 4);
p.addstatus(1);
_cfis1 = add_cursor(new TCursor(_rel_fis, "", 1));
_cgiu1 = add_cursor(new TCursor(_rel_giu, "", 1));
_cdit1 = add_cursor(new TCursor(_rel_dit, "", 1));
_cfis2 = add_cursor(new TCursor(_rel_fis, "", 2));
_cgiu2 = add_cursor(new TCursor(_rel_giu, "", 2));
_cdit2 = add_cursor(new TCursor(_rel_dit, "", 2));
p.addstatus(1);
// set translated field values
set_translation(LF_ANAGFIS,"STATCIV","1",TR("Celibe/Nubile"));
set_translation(LF_ANAGFIS,"STATCIV","2",TR("Coniugato/a"));
set_translation(LF_ANAGFIS,"STATCIV","3",TR("Vedovo/a"));
set_translation(LF_ANAGFIS,"STATCIV","4",TR("Separato/a"));
set_translation(LF_ANAGFIS,"STATCIV","5",TR("Divorziato/a"));
set_translation(LF_ANAGFIS,"STATCIV","6",TR("Deceduto/a"));
set_translation(LF_ANAGFIS,"STATCIV","7",TR("Tutelato/a"));
set_translation(LF_ANAGFIS,"STATCIV","8",TR("Figlio/a minore"));
set_translation(LF_ANAGFIS,"TITSTU", "1" ,TR("Nessuno"));
set_translation(LF_ANAGFIS,"TITSTU", "2" ,TR("Lic. Elem."));
set_translation(LF_ANAGFIS,"TITSTU", "3" ,TR("Lic. Media"));
set_translation(LF_ANAGFIS,"TITSTU", "4" ,TR("Diploma"));
set_translation(LF_ANAGFIS,"TITSTU", "5" ,TR("Laurea"));
set_translation(LF_ANAGFIS,"SESSO", "M", TR("Maschio"));
set_translation(LF_ANAGFIS,"SESSO", "F", TR("Femmina"));
set_translation(LF_NDITTE,"FREQVIVA","M",TR("Mensile"));
set_translation(LF_NDITTE,"FREQVIVA","T",TR("Trimestrale"));
set_translation(LF_NDITTE,"DATLAV","1",TR("Si"));
set_translation(LF_NDITTE,"DATLAV","2",TR("No"));
set_translation(LF_NDITTE,"DATLAV","3",TR("Lavoro Agricolo"));
set_translation(LF_ANAGGIU,"STATOSOC","1",TR("Normale attivita'"));
set_translation(LF_ANAGGIU,"STATOSOC","2",TR("Liquidazione cessata attivita'"));
set_translation(LF_ANAGGIU,"STATOSOC","3",TR("Fallimento o Liquidazione coatta amm."));
set_translation(LF_ANAGGIU,"STATOSOC","4",TR("Estinto"));
set_translation(LF_ANAGGIU,"SITSOC","1",TR("Inizio"));
set_translation(LF_ANAGGIU,"SITSOC","2",TR("Liquidazione"));
set_translation(LF_ANAGGIU,"SITSOC","3",TR("Termine liquidazione"));
set_translation(LF_ANAGGIU,"SITSOC","4",TR("Estinzione"));
set_translation(LF_ANAGGIU,"SITSOC","5",TR("Trasf. IRPEG"));
set_translation(LF_ANAGGIU,"SITSOC","6",TR("Normale"));
set_fillchar('_');
set_wait_threshold(0);
p.addstatus(1);
return TRUE;
}
bool TAnaprint_app::user_destroy()
{
if (_rel_fis) delete _rel_fis;
if (_rel_giu) delete _rel_giu;
if (_rel_dit) delete _rel_dit;
if (_frpos) delete _frpos;
return TRUE;
}
int ba6100(int argc, char* argv[])
{
TAnaprint_app app;
app.run(argc, argv, TR("Stampa Anagrafiche"));
return 0;
}