#include #include #include #include #include #include "../include/mov.h" #include "../cg/cglib01.h" #include "tcconf.h" class TTS_confditta : public TConfig_application { char _current; static bool check_fields(TMask_field& f, KEY k); // @cmember:(INTERNAL) Salva i parametri dalla maschera virtual void save_mask(bool tosave); virtual void load_mask(); public: // @cmember Disabilita la verifica del modulo in chiave virtual bool check_autorization() const { return FALSE; } virtual bool preprocess_config (TMask& mask, TConfig& config); virtual bool postprocess_config (TMask& mask, TConfig& config); virtual bool user_create( ); virtual bool user_destroy( ); TTS_confditta() : TConfig_application( CONFIG_DITTA ){ } virtual ~TTS_confditta( ){ } }; bool sh_notify(TSheet_field& s, int r, KEY k) { if (k == K_TAB) { TMask& m = s.mask(); const bool use_pcn = m.get_bool(F_USECMPCN); const int r = s.selected(); TMask & mr = s.sheet_mask(); TToken_string & row = s.row(r); row.add(use_pcn ? "X" : " ", 4); s.check_row(r); } return true; } bool TTS_confditta::check_fields(TMask_field& f, KEY k) { return true; } void TTS_confditta::load_mask() { TMask* mask = get_mask(); if (mask != NULL) { TConfig_application::load_mask(); TConfig& config = *get_config(); TSheet_field& si = mask->sfield(F_SHEET_IVA); const bool use_pcn = config.get_bool("TSUSECMPCN"); int i = 0; si.set_notify(sh_notify); for (i = 0; config.exist("TSGIVA", i); i++) { TToken_string& row = si.row(i); row.add(config.get("TSGIVA", NULL, i)); row.add(config.get("TSCIVA", NULL, i)); row.add(config.get("TSSIVA", NULL, i)); row.add(use_pcn ? "X" : " ", 4); si.check_row(i); } TSheet_field& sr = mask->sfield(F_SHEET_RIT); sr.set_notify(sh_notify); for (i = 0; config.exist("TSGRIT", i); i++) { TToken_string& row = sr.row(i); row.add(config.get("TSGRIT", NULL, i)); row.add(config.get("TSCRIT", NULL, i)); row.add(config.get("TSSRIT", NULL, i)); row.add(use_pcn ? "X" : " ", 4); sr.check_row(i); } } } void TTS_confditta::save_mask(bool tosave) { if (tosave) { const TMask & m = *get_mask(); if (m.get_bool(F_RIPRISTINO)) { const TDate from(m.get(F_ULTINVIO)); TEsercizi_contabili esc; const TEsercizio & e = esc.esercizio(esc.date2esc(from)); const TDate to(e.fine()); TString query = "USE MOV KEY 2 SELECT INVIATO==\"X\""; query << "\nFROM DATAREG=#DATA_DA"; query << "\nTO DATAREG=#DATA_AL"; TISAM_recordset mov(query); mov.set_var("#DATA_DA", TVariant(from)); mov.set_var("#DATA_AL", TVariant(to)); if (mov.items() >0L) { TProgind pi(mov.items(), TR("Ripristino movimenti"), true, true); TLocalisamfile cgmov(LF_MOV); for (bool ok = mov.move_first(); ok; ok = mov.move_next()) { if (!pi.addstatus(1)) break; const long numreg = mov.get(MOV_NUMREG).as_int(); cgmov.put(MOV_NUMREG, numreg); if (cgmov.read(_isequal, _lock) == NOERR) { cgmov.zero(MOV_INVIATO); cgmov.rewrite(); } } } } TConfig& config = *get_config(); int i = 0; for (i = 0; config.exist("TSGIVA", i); i++) { config.remove("TSGIVA", i); config.remove("TSCIVA", i); config.remove("TSSIVA", i); } TSheet_field& si = m.sfield(F_SHEET_IVA); FOR_EACH_SHEET_ROW(si, j, row) { config.set("TSGIVA", row->get(0), NULL, true, j); config.set("TSCIVA", row->get(1), NULL, true, j); config.set("TSSIVA", row->get(2), NULL, true, j); } for (i = 0; config.exist("TSGRIT", i); i++) { config.remove("TSGRIT", i); config.remove("TSCRIT", i); config.remove("TSSRIT", i); } TSheet_field& sr = m.sfield(F_SHEET_RIT); FOR_EACH_SHEET_ROW(sr, jr, rowr) { config.set("TSGRIT", rowr->get(0), NULL, true, jr); config.set("TSCRIT", rowr->get(1), NULL, true, jr); config.set("TSSRIT", rowr->get(2), NULL, true, jr); } } TConfig_application::save_mask(tosave); } bool TTS_confditta::preprocess_config (TMask& mask, TConfig& config) { return true; } bool TTS_confditta::postprocess_config (TMask& mask, TConfig& config) { return true; } bool TTS_confditta::user_create( ) { TConfig conf(CONFIG_DITTA); conf.set( "EdMask", "tc0300a", "tc"); return true; } bool TTS_confditta::user_destroy( ) { return true; } int tc0300(int argc, char* argv[]) { TTS_confditta appc; appc.run(argc, argv, TR("Parametri ditta TeamSystem")); return 0; }