// ********************************************************************** // Stampa anagrafiche // Control code // *********************************************************************** #include #include #include #include "ba6100.h" // ------- utils -------------------------------------------- TRectype& TAnaprint_app::look_com(const char* cod) { _comuni->curr().zero(); if (*cod) { _comuni->curr().put("COM",cod); _comuni->read(); if (_comuni->bad()) _comuni->curr().zero(); } return _comuni->curr(); } const char* TAnaprint_app::look_tab(const char* tabname, const char* cod, const char* fld) { if (*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 void TAnaprint_app::process_link(int id, const char* txt) { if (id == _ana_link) { TString80 ss = "1|"; ss << txt; TMessage fs(cmd2name("ba4","-1"), MSG_LN, ss); TMailbox m; m.send(fs); TExternal_app ba4(_pr_what == anafis ? "ba4 -1 F" : "ba4 -1 G"); if (ba4.run()) beep(); } else if (id == _dit_link) { TString80 ss = "1|"; ss << txt << "|" << txt; TMessage fs(cmd2name("ba4","-2"), MSG_LN, ss); fs.send(); TExternal_app ba4("ba4 -2"); if (ba4.run()) beep(); } } // ---- 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,"@50g$[r]@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 == 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"); _phone = current_cursor()->curr(LF_ANAG).get("PTELRF"); _phone.trim(); if (!_phone.empty()) _phone << '/'; _phone << current_cursor()->curr(LF_ANAG).get("TELRF"); 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; } 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"); TRectype& cc = look_com(get_field(LF_ANAG,"COMCORR")); 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' ? "Sig." : "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"); _com = cc.get("DENCOM"); _prov = cc.get("PROVCOM"); if (_cap.empty()) _cap = cc.get("CAPCOM"); if (!_address.empty()) 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"); 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.empty()) break; // else fall down case residenza: _address = get_field(LF_ANAG,"INDRES"); _civ = get_field(LF_ANAG,"CIVRES"); _stato = ""; //look_tab("%STA",get_field(LF_ANAG,"STATORES")); _cap = get_field(LF_ANAG,"CAPRES"); cc = look_com(get_field(LF_ANAG,"COMRES")); _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(); } 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("Collegamento archivio anagrafiche: ", 'b'); _dit_link = enable_link("Collegamento archivio ditte: ", 'r'); 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("Collegamento archivio anagrafiche: ", 'b'); _dit_link = enable_link("Collegamento archivio ditte: ", 'r'); _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, "Preparazione archivi\rPrego attendere", FALSE, TRUE, 30); // setup relation _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); _comuni = new TLocalisamfile(LF_COMUNI); // set translated field values set_translation(LF_ANAGFIS,"STATCIV","1","Celibe/Nubile"); set_translation(LF_ANAGFIS,"STATCIV","2","Coniugato/a"); set_translation(LF_ANAGFIS,"STATCIV","3","Vedovo/a"); set_translation(LF_ANAGFIS,"STATCIV","4","Separato/a"); set_translation(LF_ANAGFIS,"STATCIV","5","Divorziato/a"); set_translation(LF_ANAGFIS,"STATCIV","6","Deceduto/a"); set_translation(LF_ANAGFIS,"STATCIV","7","Tutelato/a"); set_translation(LF_ANAGFIS,"STATCIV","8","Figlio/a minore"); set_translation(LF_ANAGFIS,"TITSTU", "1" ,"Nessuno"); set_translation(LF_ANAGFIS,"TITSTU", "2" ,"Lic. Elem."); set_translation(LF_ANAGFIS,"TITSTU", "3" ,"Lic. Media"); set_translation(LF_ANAGFIS,"TITSTU", "4" ,"Diploma"); set_translation(LF_ANAGFIS,"TITSTU", "5" ,"Laurea"); set_translation(LF_ANAGFIS,"SESSO", "M", "Maschio"); set_translation(LF_ANAGFIS,"SESSO", "F", "Femmina"); set_translation(LF_NDITTE,"FREQVIVA","M","Mensile"); set_translation(LF_NDITTE,"FREQVIVA","T","Trimestrale"); set_translation(LF_NDITTE,"DATLAV","1","Si"); set_translation(LF_NDITTE,"DATLAV","2","No"); set_translation(LF_NDITTE,"DATLAV","3","Lavoro Agricolo"); set_translation(LF_ANAGGIU,"STATOSOC","1","Normale attivita'"); set_translation(LF_ANAGGIU,"STATOSOC","2","Liquidazione cessata attivita'"); set_translation(LF_ANAGGIU,"STATOSOC","3", "Fallimento o Liquidazione coatta amm."); set_translation(LF_ANAGGIU,"STATOSOC","4","Estinto"); set_translation(LF_ANAGGIU,"SITSOC","1","Inizio"); set_translation(LF_ANAGGIU,"SITSOC","2","Liquidazione"); set_translation(LF_ANAGGIU,"SITSOC","3","Termine liquidazione"); set_translation(LF_ANAGGIU,"SITSOC","4","Estinzione"); set_translation(LF_ANAGGIU,"SITSOC","5","Trasf. IRPEG"); set_translation(LF_ANAGGIU,"SITSOC","6","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; delete _comuni; return TRUE; } int ba6100(int argc, char* argv[]) { TAnaprint_app app; app.run(argc, argv, "Stampa Anagrafiche"); return 0; }