diff --git a/at/agaat.men b/at/agaat.men index 9d5370e94..8e3856bb8 100755 --- a/at/agaat.men +++ b/at/agaat.men @@ -116,6 +116,7 @@ Item_09 = "Stampe singole", "at7 -2", "" Item_10 = "Stampe per codice", "at7 -3", "" Item_11 = "Tessere associative complessive", "at7 -0", "" Item_12 = "Tessere associative singole", "at7 -1", "" +Item_13 = "Moduli intestati", "at9 -4", "" [AVIS_0042] Caption = "Stampe sanitarie" diff --git a/at/at0100.cpp b/at/at0100.cpp index 514791072..808652a77 100755 --- a/at/at0100.cpp +++ b/at/at0100.cpp @@ -68,7 +68,7 @@ protected: virtual int rewrite(const TMask& m); virtual int read(TMask& m); virtual bool remove(); - virtual bool changing_mask(int mode) { return FALSE; } + virtual bool changing_mask(int mode) { return false; } virtual TMask* get_mask( int mode = 0) { return _msk; } virtual TRelation* get_relation() const { return _rel; } virtual void on_firm_change(); @@ -192,8 +192,8 @@ void d_datepross(TSheet_field& s) TDate dataaf(NULLDATE); // data prossima af calcolata TDate dataultsi(NULLDATE); // data ultima donazione si - bool id_si = FALSE; // il soggetto è idoneo per si? - bool id_af = FALSE; // il soggetto è idoneo per af? + bool id_si = false; // il soggetto è idoneo per si? + bool id_af = false; // il soggetto è idoneo per af? modstato = modstato_tcs(stato); if (modstato == 'I' || modstato == 'F') // il soggetto è idoneo @@ -355,8 +355,8 @@ void TGestioneSoggetti::calcola_donazioni(TMask& mask, TSheet_field& s) void TGestioneSoggetti::init_insert_mode(TMask& m) { - m.set(F_NOTIZIARIO,TRUE); - m.set(F_BENEM,TRUE); + m.set(F_NOTIZIARIO, true); + m.set(F_BENEM, true); m.hide(F_RICPARZ); } @@ -382,9 +382,9 @@ bool TGestioneSoggetti::donazioni_handler(TMask_field& f, KEY k) TSheet_field& s = (TSheet_field&)f; const int n = s.items()-1; if (n >= 0) - s.select(n, TRUE); + s.select(n, true); } - return TRUE; + return true; } bool TGestioneSoggetti::controlli_handler(TMask_field& f, KEY k) @@ -394,9 +394,9 @@ bool TGestioneSoggetti::controlli_handler(TMask_field& f, KEY k) TSheet_field& s = (TSheet_field&)f; const int n = s.items()-1; if (n >= 0) - s.select(n, TRUE); + s.select(n, true); } - return TRUE; + return true; } bool TGestioneSoggetti::idoneita_handler(TMask_field& f, KEY k) @@ -406,9 +406,9 @@ bool TGestioneSoggetti::idoneita_handler(TMask_field& f, KEY k) TSheet_field& s = (TSheet_field&)f; const int n = s.items()-1; if (n >= 0) - s.select(n, TRUE); + s.select(n, true); } - return TRUE; + return true; } bool TGestioneSoggetti::storico_handler(TMask_field& f, KEY k) @@ -418,9 +418,9 @@ bool TGestioneSoggetti::storico_handler(TMask_field& f, KEY k) TSheet_field& s = (TSheet_field&)f; const int n = s.items()-1; if (n >= 0) - s.select(n, TRUE); + s.select(n, true); } - return TRUE; + return true; } bool TGestioneSoggetti::benem_handler(TMask_field& f, KEY k) @@ -430,9 +430,9 @@ bool TGestioneSoggetti::benem_handler(TMask_field& f, KEY k) TSheet_field& s = (TSheet_field&)f; const int n = s.items()-1; if (n >= 0) - s.select(n, TRUE); + s.select(n, true); } - return TRUE; + return true; } bool TGestioneSoggetti::datadon_handler(TMask_field& f, KEY k) @@ -453,7 +453,7 @@ bool TGestioneSoggetti::datadon_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TGestioneSoggetti::datacon_handler(TMask_field& f, KEY k) @@ -488,7 +488,7 @@ bool TGestioneSoggetti::datacon_handler(TMask_field& f, KEY k) if (datacon < datastato) return f.yesno_box("ATTENZIONE! Data controllo inferiore alla data stato AF.;Vuoi continuare?"); } - return TRUE; + return true; } bool TGestioneSoggetti::donprecsi_handler(TMask_field& f, KEY k) @@ -522,7 +522,7 @@ bool TGestioneSoggetti::donprecsi_handler(TMask_field& f, KEY k) } oldprecsi = donprecsi; } - return TRUE; + return true; } bool TGestioneSoggetti::donprecaf_handler(TMask_field& f, KEY k) @@ -541,7 +541,7 @@ bool TGestioneSoggetti::donprecaf_handler(TMask_field& f, KEY k) } oldprecaf = donprecaf; } - return TRUE; + return true; } bool TGestioneSoggetti::datanasc_handler(TMask_field& f, KEY k) @@ -571,7 +571,7 @@ bool TGestioneSoggetti::datanasc_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TGestioneSoggetti::catdon_handler(TMask_field& f, KEY k) @@ -583,7 +583,7 @@ bool TGestioneSoggetti::catdon_handler(TMask_field& f, KEY k) if (cache().get("CTD",m.get(F_CATDON)).get_bool("B0")) f.warning_box("ATTENZIONE: il soggetto ha almeno una categoria non donatori. Verificare!"); } - return TRUE; + return true; } bool TGestioneSoggetti::dataconv_handler(TMask_field& f, KEY k) @@ -614,20 +614,20 @@ bool TGestioneSoggetti::dataconv_handler(TMask_field& f, KEY k) } else { - app()._nuovaconv = TRUE; + app()._nuovaconv = true; f.mask().field(F_STAMPATACONV).enable(); } } else { - app()._nuovaconv = TRUE; + app()._nuovaconv = true; f.mask().field(F_STAMPATACONV).enable(); } } else f.mask().set(F_DATACONV, app()._oldconv); } - return TRUE; + return true; } bool TGestioneSoggetti::eseguigen_handler(TMask_field& f, KEY k) @@ -660,7 +660,7 @@ bool TGestioneSoggetti::eseguigen_handler(TMask_field& f, KEY k) else f.error_box("Non e' possibile generare meno di 1 donazione"); } - return TRUE; + return true; } bool TGestioneSoggetti::nome_handler(TMask_field& f, KEY k) @@ -687,7 +687,7 @@ bool TGestioneSoggetti::nome_handler(TMask_field& f, KEY k) m.field(F_ES_CODICE).on_key(K_TAB); } } - return TRUE; + return true; } bool TGestioneSoggetti::collega_handler(TMask_field& f, KEY k) @@ -727,7 +727,7 @@ bool TGestioneSoggetti::collega_handler(TMask_field& f, KEY k) m.hide(-1); } } - return TRUE; + return true; } bool TGestioneSoggetti::nuova_handler(TMask_field& f, KEY k) @@ -745,7 +745,7 @@ bool TGestioneSoggetti::nuova_handler(TMask_field& f, KEY k) m.show(F_FAMIGLIARI); m.hide(-1); } - return TRUE; + return true; } bool TGestioneSoggetti::famiglia_handler(TMask_field& f, KEY k) @@ -788,13 +788,13 @@ bool TGestioneSoggetti::famiglia_handler(TMask_field& f, KEY k) for (int r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = app()._sfamiglia->row(r,TRUE); + TRectype& rec = app()._sfamiglia->row(r,true); rec.put(FAM_GRADOPAR, row.get(0)); rec.put(FAM_CODFAM, row.get()); } } } - return TRUE; + return true; } bool TGestioneSoggetti::genera_handler(TMask_field& f, KEY k) @@ -829,7 +829,7 @@ bool TGestioneSoggetti::genera_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TGestioneSoggetti::ricparz_handler(TMask_field& f, KEY k) @@ -875,7 +875,7 @@ bool TGestioneSoggetti::ricparz_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TGestioneSoggetti::convoc_handler(TMask_field& f, KEY k) @@ -903,7 +903,7 @@ bool TGestioneSoggetti::convoc_handler(TMask_field& f, KEY k) sconv.run(); } } - return TRUE; + return true; } void TGestioneSoggetti::tipocon_set_row(TMask& m) @@ -1058,7 +1058,7 @@ bool TGestioneSoggetti::idoncon_handler(TMask_field& f, KEY k) if (is_idon_one(idon,IDON_AF)) m.field(F_C_INTAF).enable(); } - return TRUE; + return true; } bool TGestioneSoggetti::tipocon_handler(TMask_field& f, KEY k) @@ -1074,7 +1074,7 @@ bool TGestioneSoggetti::tipocon_handler(TMask_field& f, KEY k) m.set(F_C_RESPONSAB, user()); } } - return TRUE; + return true; } bool TGestioneSoggetti::idosos_handler(TMask_field& f, KEY k) @@ -1090,12 +1090,12 @@ bool TGestioneSoggetti::idosos_handler(TMask_field& f, KEY k) m.set(F_I_RESPONSAB, user()); } } - return TRUE; + return true; } bool TGestioneSoggetti::gruppo_handler(TMask_field& f, KEY k) { - bool ok = TRUE; + bool ok = true; if (f.to_check(k)) { const TString gr = f.get(); @@ -1111,7 +1111,7 @@ bool TGestioneSoggetti::gruppo_handler(TMask_field& f, KEY k) bool TGestioneSoggetti::rhantid_handler(TMask_field& f, KEY k) { - bool ok = TRUE; + bool ok = true; if (f.to_check(k)) { const TString gr = f.get(); @@ -1127,7 +1127,7 @@ bool TGestioneSoggetti::rhantid_handler(TMask_field& f, KEY k) bool TGestioneSoggetti::kell_handler(TMask_field& f, KEY k) { - bool ok = TRUE; + bool ok = true; if (f.to_check(k)) { const TString gr = f.get(); @@ -1143,7 +1143,7 @@ bool TGestioneSoggetti::kell_handler(TMask_field& f, KEY k) bool TGestioneSoggetti::fenotiporh_handler(TMask_field& f, KEY k) { - bool ok = TRUE; + bool ok = true; if (f.to_check(k)) { const TString gr = f.get(); @@ -1159,7 +1159,7 @@ bool TGestioneSoggetti::fenotiporh_handler(TMask_field& f, KEY k) bool TGestioneSoggetti::du_handler(TMask_field& f, KEY k) { - bool ok = TRUE; + bool ok = true; if (f.to_check(k)) { const TString gr = f.get(); @@ -1264,7 +1264,7 @@ bool TGestioneSoggetti::user_create() _dataisc = config.get_bool("DataIsc"); _ctrlpass = config.get_bool("CtrlPass"); _permesso = richiesta_password(); - return TRUE; + return true; } bool TGestioneSoggetti::user_destroy() @@ -1285,7 +1285,7 @@ bool TGestioneSoggetti::user_destroy() delete _donaz; delete _rel; delete _msk; - return TRUE; + return true; } const char* TGestioneSoggetti::get_next_key() @@ -1305,7 +1305,7 @@ bool TGestioneSoggetti::remove() // annulla convocazioni del soggetto // alla fine: cancella il soggetto! - bool ok = TRUE; + bool ok = true; int err; ok = yesno_box("ATTENZIONE!\nCon questa operazione si elimina definitivamente tutta la scheda del soggetto.\nConfermare l'eliminazione?"); @@ -1343,13 +1343,13 @@ bool TGestioneSoggetti::remove() return (ok && err==NOERR); } else - return TRUE; + return true; } int TGestioneSoggetti::read(TMask& m) { _famatt = _famprec = 0; - _nuovaconv = FALSE; + _nuovaconv = false; _oldconv = NULLDATE; int err = TRelation_application::read(m); if (err == NOERR) @@ -1416,6 +1416,7 @@ int TGestioneSoggetti::read(TMask& m) row.add(riga.get(CON_PROSSDATA)); row.add(riga.get(CON_MOTIVO)); row.add(riga.get(CON_RESPONSAB)); + row.add(riga.get(CON_SINGOLI)); } TGestioneSoggetti::tipocon_set_sheet(s); s.force_update(); @@ -1540,18 +1541,18 @@ int TGestioneSoggetti::write(const TMask& m) { long curcod = m.get_long(F_CODICE); if (curcod > _lastcod) _lastcod = curcod; - return TGestioneSoggetti::scrivi(m, FALSE); + return TGestioneSoggetti::scrivi(m, false); } int TGestioneSoggetti::rewrite(const TMask& m) { - return TGestioneSoggetti::scrivi(m, TRUE); + return TGestioneSoggetti::scrivi(m, true); } int TGestioneSoggetti::scrivi(const TMask& m, bool ri) { // questo trucco è autorizzato dal capo! - bool ok = TRUE; + bool ok = true; int err = NOERR; TMask& hmask = (TMask&) m; if (ok) @@ -1574,7 +1575,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) rconvoc.put(RCV_DATACONV, dataconv); if (rconvoc.read() == NOERR) { - rconvoc.put(RCV_ANNULLATO, TRUE); + rconvoc.put(RCV_ANNULLATO, true); int err = rconvoc.rewrite(); } const TDate datanulla(NULLDATE); @@ -1616,7 +1617,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) for (int r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = _sdonazioni->row(r,TRUE); + TRectype& rec = _sdonazioni->row(r,true); rec.put(DON_DATADON, row.get(0)); rec.put(DON_TIPODON, row.get()); // 1 rec.put(DON_LUOGODON, row.get()); // 2 @@ -1659,7 +1660,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) for (r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = _scontrolli->row(r,TRUE); + TRectype& rec = _scontrolli->row(r,true); rec.put(CON_DATACON, row.get(0)); rec.put(CON_TIPOCON, row.get()); rec.put(CON_IDON1, row.get()); @@ -1672,6 +1673,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) rec.put(CON_PROSSDATA, row.get()); rec.put(CON_MOTIVO, row.get()); rec.put(CON_RESPONSAB, row.get()); + rec.put(CON_SINGOLI, row.get()); } err = ri ? _scontrolli->rewrite() : _scontrolli->write(); } @@ -1692,7 +1694,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) for (r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = _sidoneita->row(r,TRUE); + TRectype& rec = _sidoneita->row(r,true); rec.put(IDO_DATAIDO, row.get(0)); rec.put(IDO_TIPOIDO, row.get()); rec.put(IDO_IDO_SOS, row.get()); @@ -1723,7 +1725,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) for (r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = _sbenemerenze->row(r,TRUE); + TRectype& rec = _sbenemerenze->row(r,true); rec.put(BEN_TIPOBEN, row.get(0)); rec.put(BEN_DATAMAT, row.get(2)); rec.put(BEN_BONUS, row.get()); @@ -1750,7 +1752,7 @@ int TGestioneSoggetti::scrivi(const TMask& m, bool ri) for (int r=s.items(); r>0; r--) { TToken_string& row = s.row(r-1); - TRectype& rec = _sstorico->row(r,TRUE); + TRectype& rec = _sstorico->row(r,true); rec.put(STO_DATAISC, row.get(0)); rec.put(STO_DATADIM, row.get()); rec.put(STO_CODSEZ, row.get()); @@ -2202,13 +2204,13 @@ bool TGestioneSoggetti::famiglia_notify(TSheet_field& s, int r, KEY k) } break; } - return TRUE; + return true; } bool TGestioneSoggetti::donazioni_notify(TSheet_field& s, int r, KEY k) { static TToken_string oldrow; - bool modified = FALSE; + bool modified = false; TMask& mask = s.mask(); if (k == K_CTRL+K_DEL) // avvenuta cancellazione riga { @@ -2219,7 +2221,7 @@ bool TGestioneSoggetti::donazioni_notify(TSheet_field& s, int r, KEY k) if (data == mask.get_date(F_DATAULTDON) || data == mask.get_date(F_DATAULTSI) || data == mask.get_date(F_DATAULTAF)) - modified = TRUE; + modified = true; if (is_donaz(tipo,IDON_SI)) { totdon = mask.get_int(F_TOTDONSI); @@ -2271,10 +2273,10 @@ bool TGestioneSoggetti::donazioni_notify(TSheet_field& s, int r, KEY k) || olddata == mask.get_date(F_DATAULTAF) || actdata > mask.get_date(F_DATAULTSI) || actdata > mask.get_date(F_DATAULTAF)) - modified = TRUE; + modified = true; } if (oldtipo != acttipo) - modified = TRUE; + modified = true; } break; case K_CTRL+K_INS: // avvenuto inserimento riga (ancora vuota) @@ -2294,20 +2296,20 @@ bool TGestioneSoggetti::donazioni_notify(TSheet_field& s, int r, KEY k) } if (modified) app().calcola_donazioni(mask, s); - return TRUE; + return true; } bool TGestioneSoggetti::controlli_notify(TSheet_field& s, int r, KEY k) { - static bool delete_l = FALSE; // flag per cancellazione ultima riga + static bool delete_l = false; // flag per cancellazione ultima riga static TToken_string oldrow; - bool modified = FALSE; + bool modified = false; TMask& mask = s.mask(); if (k == K_CTRL+K_DEL) // avvenuta cancellazione riga { if (delete_l) - modified = TRUE; - delete_l = FALSE; + modified = true; + delete_l = false; } else { @@ -2333,7 +2335,7 @@ bool TGestioneSoggetti::controlli_notify(TSheet_field& s, int r, KEY k) s.force_update(); } if (modstato_tcs(oldtipo) != 'N' || modstato_tcs(acttipo) != 'N') - modified = TRUE; + modified = true; } break; case K_DEL: // richiesta di cancellazione riga @@ -2341,7 +2343,7 @@ bool TGestioneSoggetti::controlli_notify(TSheet_field& s, int r, KEY k) oldrow = s.row(r); const TString16 oldtipo(oldrow.get(1)); if (r == (s.items()-1) && modstato_tcs(oldtipo) != 'N') - delete_l = TRUE; + delete_l = true; return app()._permesso; } break; @@ -2352,17 +2354,17 @@ bool TGestioneSoggetti::controlli_notify(TSheet_field& s, int r, KEY k) TSheet_field& i = (TSheet_field&)mask.field(F_IDONEITA); c_reord(s, i); } - return TRUE; + return true; } bool TGestioneSoggetti::idoneita_notify(TSheet_field& s, int r, KEY k) { static TToken_string oldrow; - bool modified = FALSE; + bool modified = false; TMask& mask = s.mask(); if (k == K_CTRL+K_DEL) // avvenuta cancellazione riga - modified = TRUE; + modified = true; else { switch (k) @@ -2389,7 +2391,7 @@ bool TGestioneSoggetti::idoneita_notify(TSheet_field& s, int r, KEY k) s.force_update(); } if (olddata!=actdata || oldtipo!=acttipo || oldidosos!=actidosos) - modified = TRUE; + modified = true; } break; case K_DEL: @@ -2401,7 +2403,7 @@ bool TGestioneSoggetti::idoneita_notify(TSheet_field& s, int r, KEY k) TSheet_field& c = (TSheet_field&)mask.field(F_CONTROLLI); c_reord(c,s); } - return TRUE; + return true; } @@ -2410,7 +2412,7 @@ bool TGestioneSoggetti::benemerenze_notify(TSheet_field& s, int r, KEY k) if (k == K_ENTER) { } - return TRUE; + return true; } bool TGestioneSoggetti::storico_notify(TSheet_field& s, int r, KEY k) @@ -2418,7 +2420,7 @@ bool TGestioneSoggetti::storico_notify(TSheet_field& s, int r, KEY k) if (k == K_ENTER) { } - return TRUE; + return true; } bool TGestioneSoggetti::richiesta_password() @@ -2433,7 +2435,7 @@ bool TGestioneSoggetti::richiesta_password() { mask.enable(F_CONTROLLI); mask.enable(F_IDONEITA); - return TRUE; + return true; } else { @@ -2444,8 +2446,8 @@ bool TGestioneSoggetti::richiesta_password() } } else - return TRUE; - return FALSE; + return true; + return false; } int at0100(int argc, char* argv[]) diff --git a/at/at0100a.h b/at/at0100a.h index 26b0fe1ed..b10e130db 100755 --- a/at/at0100a.h +++ b/at/at0100a.h @@ -198,6 +198,22 @@ #define F_C_PROSSDATA 110 #define F_C_MOTIVO 111 #define F_C_RESPONSAB 112 +#define F_C_SCS1 113 +#define F_C_SCS2 114 +#define F_C_SCS3 115 +#define F_C_SCS4 116 +#define F_C_SCS5 117 +#define F_C_SCS6 118 +#define F_C_SCS7 119 +#define F_C_SCS8 120 +#define F_C_SCS9 121 +#define F_C_SCS10 122 +#define F_C_SCS11 123 +#define F_C_SCS12 124 +#define F_C_SCS13 125 +#define F_C_SCS14 126 +#define F_C_SCS15 127 + #define F_C_DESC_TIPOCON 151 #define F_C_DESC_IDON1 152 #define F_C_DESC_IDON2 153 diff --git a/at/at0100a.uml b/at/at0100a.uml index 9542055cc..a2a4d0621 100755 --- a/at/at0100a.uml +++ b/at/at0100a.uml @@ -2357,7 +2357,7 @@ ENDPAGE ENDMASK -PAGE "Controlli sanitari" -1 -1 75 20 +PAGE "Controlli sanitari" -1 -1 75 22 GRUPBOX DLG_NULL 73 4 BEGIN @@ -2514,7 +2514,7 @@ BEGIN HELP "Data controllo" END -GROUPBOX DLG_NULL 73 4 +GROUPBOX DLG_NULL 73 6 BEGIN PROMPT 1 15 "Dati complementari" END @@ -2541,6 +2541,231 @@ BEGIN FIELD LF_CONTSAN->RESPONSAB END +STRING F_C_SCS1 2 +BEGIN + PROMPT 2 18 "Singoli cont." + FIELD LF_CONTSAN->SINGOLI[1,2] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS1 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS1 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS2 2 +BEGIN + PROMPT 20 18 "" + FIELD LF_CONTSAN->SINGOLI[3,4] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS2 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS2 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS3 2 +BEGIN + PROMPT 25 18 "" + FIELD LF_CONTSAN->SINGOLI[5,6] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS3 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS3 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS4 2 +BEGIN + PROMPT 30 18 "" + FIELD LF_CONTSAN->SINGOLI[7,8] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS4 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS4 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS5 2 +BEGIN + PROMPT 35 18 "" + FIELD LF_CONTSAN->SINGOLI[9,10] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS5 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS5 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS6 2 +BEGIN + PROMPT 40 18 "" + FIELD LF_CONTSAN->SINGOLI[11,12] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS6 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS6 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS7 2 +BEGIN + PROMPT 45 18 "" + FIELD LF_CONTSAN->SINGOLI[13,14] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS7 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS7 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS8 2 +BEGIN + PROMPT 50 18 "" + FIELD LF_CONTSAN->SINGOLI[15,16] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS8 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS8 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS9 2 +BEGIN + PROMPT 15 19 "" + FIELD LF_CONTSAN->SINGOLI[17,18] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS9 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS9 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS10 2 +BEGIN + PROMPT 20 19 "" + FIELD LF_CONTSAN->SINGOLI[19,20] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS10 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS10 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS11 2 +BEGIN + PROMPT 25 19 "" + FIELD LF_CONTSAN->SINGOLI[21,22] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS11 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS11 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS12 2 +BEGIN + PROMPT 30 19 "" + FIELD LF_CONTSAN->SINGOLI[23,24] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS12 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS12 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS13 2 +BEGIN + PROMPT 35 19 "" + FIELD LF_CONTSAN->SINGOLI[25,26] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS13 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS13 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS14 2 +BEGIN + PROMPT 40 19 "" + FIELD LF_CONTSAN->SINGOLI[27,28] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS14 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS14 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + +STRING F_C_SCS15 2 +BEGIN + PROMPT 45 19 "" + FIELD LF_CONTSAN->SINGOLI[29,30] + FLAGS "U" + USE SCS + INPUT CODTAB F_C_SCS15 + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_C_SCS15 CODTAB + CHECKTYPE NORMAL + WARNING "Codice singolo controllo non presente" + HELP "Singolo controllo sanitario" +END + STRING F_C_DESC_TIPOCON 30 25 BEGIN PROMPT 24 3 "" diff --git a/at/at9.cpp b/at/at9.cpp index cdaada365..33b5623e6 100755 --- a/at/at9.cpp +++ b/at/at9.cpp @@ -20,6 +20,8 @@ int main(int argc,char** argv) rt = at9300(argc,argv) ; break; // Aggiornamento archivi da estrazione case 3: rt = at9400(argc,argv) ; break; // Aggiornamento soggetti + case 4: + rt = at9500(argc,argv) ; break; // stampa moduli intestati default: error_box(usage, argv[0]) ; break; } diff --git a/at/at9.h b/at/at9.h index 7c24b5067..ce5bee503 100755 --- a/at/at9.h +++ b/at/at9.h @@ -5,6 +5,7 @@ int at9100(int argc, char* argv[]); // statistica soggetti sospesi (NON UTILIZZA int at9200(int argc, char* argv[]); // Parma: estrazione archivi per aggiornamento int at9300(int argc, char* argv[]); // Parma: aggiornamento archivi da estrazione int at9400(int argc, char* argv[]); // aggiornamento sit. sogg. +int at9500(int argc, char* argv[]); // stampa moduli intestati #endif // __AT9_H diff --git a/at/at9500.cpp b/at/at9500.cpp new file mode 100755 index 000000000..244cf1483 --- /dev/null +++ b/at/at9500.cpp @@ -0,0 +1,76 @@ +#include +#include +#include + +#include "at9.h" +#include "at9500a.h" + +class TMaskModInt : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TMaskModInt() : TAutomask("at9500a") { } + virtual ~TMaskModInt() { } +}; + +bool TMaskModInt::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + return TRUE; +} + +class TTModInt : public TSkeleton_application +{ + virtual bool check_autorization() const {return false;} + virtual const char * extra_modules() const {return "at";} + +protected: + virtual void main_loop(); + +public: +}; + +void TTModInt::main_loop() +{ + TMaskModInt m; + while (m.run() != K_QUIT) + { + TReport_book book; + TReport rep; + TFilename report_name("at9500b"); + + report_name.ext("rep"); + report_name.custom_path(); + if (rep.load(report_name)) + { + TRecordset * r = rep.recordset(); + if (r != NULL) + { + TVariant var; + var = m.get(F_S_CODICE); + r->set_var("#F_CODICE", var); + var = m.get(F_S_TESTO1); + r->set_var("#F_TESTO1", var); + var = m.get(F_S_TESTO2); + r->set_var("#F_TESTO2", var); + var = m.get(F_S_TESTO3); + r->set_var("#F_TESTO3", var); + var = m.get(F_S_TESTO4); + r->set_var("#F_TESTO4", var); + var = m.get(F_S_TESTO5); + r->set_var("#F_TESTO5", var); + } + book.add(rep); + if (book.pages() > 0) + book.print_or_preview(); + } + } +} + +int at9500(int argc, char* argv[]) +{ + TTModInt a; + a.run(argc, argv, "Stampa moduli intestati"); + return 0; +} diff --git a/at/at9500a.h b/at/at9500a.h new file mode 100755 index 000000000..97373d4d6 --- /dev/null +++ b/at/at9500a.h @@ -0,0 +1,18 @@ +// pagina soggetti +#define F_S_CODICE 101 +#define F_S_COGNOME 102 +#define F_S_NOME 103 +#define F_S_DATANASC 104 +#define F_S_CODSEZ 105 +#define F_S_CODSOT 106 +#define F_S_CATDON 107 +#define F_S_TESSAVIS 108 +#define F_S_TESTO1 109 +#define F_S_TESTO2 110 +#define F_S_TESTO3 111 +#define F_S_TESTO4 112 +#define F_S_TESTO5 113 + +#define F_S_DENSEZ 211 +#define F_S_DENSOT 212 +#define F_S_DESC_CATDON 213 diff --git a/at/at9500a.uml b/at/at9500a.uml new file mode 100755 index 000000000..642018796 --- /dev/null +++ b/at/at9500a.uml @@ -0,0 +1,184 @@ +#include "at9500a.h" + +TOOLBAR "" 0 20 0 2 + +BUTTON DLG_PRINT 9 2 +BEGIN + PROMPT -12 -11 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -11 "" +END + +ENDPAGE + +PAGE "Stampa moduli intestati" -1 -1 78 20 + +GROUPBOX DLG_NULL 77 5 +BEGIN + PROMPT 1 0 "" + FLAGS "R" +END + +NUMBER F_S_CODICE 8 +BEGIN + PROMPT 2 1 "Codice " + FLAGS "RG" + USE LF_SOGGETTI KEY 1 + INPUT CODICE F_S_CODICE + DISPLAY "Codice@8" CODICE + DISPLAY "Cognome@25" COGNOME + DISPLAY "Nome@25" NOME + DISPLAY "Nato il@10" DATANASC + DISPLAY "Sez." CODSEZ + DISPLAY "Sot." CODSOT + DISPLAY "C." CATDON + DISPLAY "Tessera" TESSAVIS + DISPLAY "Gr.AB0" GRUPPOAB0 + DISPLAY "Rh " RHANTID + DISPLAY "Int.SI" INTSI + OUTPUT F_S_CODICE CODICE + OUTPUT F_S_COGNOME COGNOME + OUTPUT F_S_NOME NOME + OUTPUT F_S_DATANASC DATANASC + OUTPUT F_S_CODSEZ CODSEZ + OUTPUT F_S_CODSOT CODSOT + OUTPUT F_S_CATDON CATDON + OUTPUT F_S_TESSAVIS TESSAVIS + CHECKTYPE NORMAL + ADD RUN at0 -0 +END + +STRING F_S_COGNOME 25 +BEGIN + PROMPT 2 2 "Cognome e nome " + USE LF_SOGGETTI KEY 2 + INPUT COGNOME F_S_COGNOME + INPUT NOME F_S_NOME + INPUT DATANASC F_S_DATANASC + DISPLAY "Cognome@25" COGNOME + DISPLAY "Nome@25" NOME + DISPLAY "Nato il@10" DATANASC + DISPLAY "Codice@8" CODICE + DISPLAY "Sez." CODSEZ + DISPLAY "Sot." CODSOT + DISPLAY "C." CATDON + DISPLAY "Tessera" TESSAVIS + DISPLAY "Gr.AB0" GRUPPOAB0 + DISPLAY "Rh " RHANTID + DISPLAY "Int.SI" INTSI + OUTPUT F_S_CODICE CODICE + OUTPUT F_S_COGNOME COGNOME + OUTPUT F_S_NOME NOME + OUTPUT F_S_DATANASC DATANASC + OUTPUT F_S_CODSEZ CODSEZ + OUTPUT F_S_CODSOT CODSOT + OUTPUT F_S_CATDON CATDON + OUTPUT F_S_TESSAVIS TESSAVIS + HELP "Cognome del soggetto" + ADD RUN at0 -0 +END + +STRING F_S_NOME 25 +BEGIN + PROMPT 46 2 "" + COPY ALL F_S_COGNOME + HELP "Nome del soggetto" + CHECKTYPE NORMAL + ADD RUN at0 -0 +END + +DATE F_S_DATANASC +BEGIN + PROMPT 2 3 "Nato il " + FLAGS "D" +END + +GROUPBOX DLG_NULL 77 4 +BEGIN + PROMPT 1 5 "Dati associativi" +END + +STRING F_S_CODSEZ 2 +BEGIN + PROMPT 2 6 "Sez. " + FLAGS "D" +END + +STRING F_S_DENSEZ 25 +BEGIN + PROMPT 12 6 "" + FLAGS "D" +END + +STRING F_S_CODSOT 2 +BEGIN + PROMPT 40 6 "Sot. " + FLAGS "D" + USE LF_SEZIONI + INPUT CODSEZ F_S_CODSEZ + INPUT CODSOT F_S_CODSOT + OUTPUT F_S_DENSEZ DENSEZ + OUTPUT F_S_DENSOT DENSOT + CHECKTYPE NORMAL +END + +STRING F_S_DENSOT 25 +BEGIN + PROMPT 50 6 "" + FLAGS "D" +END + +STRING F_S_CATDON 2 +BEGIN + PROMPT 2 7 "Cat. " + FLAGS "D" + USE CTD + INPUT CODTAB F_S_CATDON + OUTPUT F_S_DESC_CATDON S0 + CHECKTYPE NORMAL +END + +STRING F_S_TESSAVIS 10 +BEGIN + PROMPT 52 7 "Tessera AVIS " + FLAGS "D" +END + +STRING F_S_DESC_CATDON 25 +BEGIN + PROMPT 12 7 "" + FLAGS "D" +END + +STRING F_S_TESTO1 70 +BEGIN + PROMPT 2 9 "" +END + +STRING F_S_TESTO2 70 +BEGIN + PROMPT 2 10 "" +END + +STRING F_S_TESTO3 70 +BEGIN + PROMPT 2 11 "" +END + +STRING F_S_TESTO4 70 +BEGIN + PROMPT 2 12 "" +END + +STRING F_S_TESTO5 70 +BEGIN + PROMPT 2 13 "" +END + + +ENDPAGE + +ENDMASK diff --git a/at/contsan.h b/at/contsan.h index 08e02c9a1..7811e9369 100755 --- a/at/contsan.h +++ b/at/contsan.h @@ -14,3 +14,4 @@ #define CON_PROSSDATA "PROSSDATA" #define CON_MOTIVO "MOTIVO" #define CON_RESPONSAB "RESPONSAB" +#define CON_SINGOLI "SINGOLI" diff --git a/at/f93.dir b/at/f93.dir index 695125a86..4ab957a06 100755 --- a/at/f93.dir +++ b/at/f93.dir @@ -1,3 +1,3 @@ 93 0 -$contsan|0|0|100|17|Controlli sanitari AVIS||| +$contsan|0|0|130|17|Controlli sanitari AVIS||| diff --git a/at/f93.trr b/at/f93.trr index 6b691f198..3e329472a 100755 --- a/at/f93.trr +++ b/at/f93.trr @@ -1,5 +1,5 @@ 93 -14 +15 CODICE|3|8|0|Codice soggetto PROGCON|2|3|0|Progressivo controllo DATACON|5|8|0|Data controllo @@ -14,6 +14,7 @@ PROSSTIPO|1|2|0|Prossimo tipo di controllo (programmato e/o presunto) PROSSDATA|5|8|0|Data prossimo tipo MOTIVO|1|4|0|Motivo (per controlli che modificano lo stato) RESPONSAB|1|50|0|Responsabile (per controlli che modificano lo stato) +SINGOLI|1|30|0|Singoli controlli 2 CODICE+PROGCON| DATACON+CODICE|X diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index 14a9bebae..8f150cdb6 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -863,12 +863,10 @@ void TManutenzione_app::update_dir() const int update_items = (orig_items < items) ? orig_items : items; TString prompt(128); - if (is_com) prompt << TR("Aggiornamento direttorio comune"); + if (is_com) + prompt << TR("Aggiornamento dati comuni"); else - { - prompt << TR("Aggiornamento direttorio della ditta "); - prompt << atol(pref) <<"."; - } + prompt << TR("Aggiornamento ditta") << ' ' << atol(pref) << '.'; TProgind p(update_items ? update_items : 1, prompt, false, true); p.setstatus(1); diff --git a/ba/ba3100.cpp b/ba/ba3100.cpp index 77abe5ee8..2e71b0f16 100755 --- a/ba/ba3100.cpp +++ b/ba/ba3100.cpp @@ -1,7 +1,3 @@ -#include -#include -#include -#include #include #include #include @@ -11,15 +7,17 @@ #include "batbreg.h" #include "batbcam.h" #include "batbdel.h" -#define F_NUM 104 #include "batbval.h" #include "batbver.h" #include "batbnoc.h" #include "batbnot.h" + +#define F_NUM 104 #define F_PREZZO 107 #define REG_JOURNAL 5 #define REG_DICHINT 10 + #define TAB_BANCHE "%BAN" #define TAB_CAMBI "CAM" #define TAB_DELEGHE "%DEL" diff --git a/ba/ba6.cpp b/ba/ba6.cpp index 2e4534277..383bc1492 100755 --- a/ba/ba6.cpp +++ b/ba/ba6.cpp @@ -1,24 +1,17 @@ #include -#include - #include "ba6.h" -#define usage "Errore - uso : %s -[0,1]" - int main(int argc,char** argv) { - const int r = (argc > 1) ? atoi(&argv[1][1]) : -1; + const int r = argc > 1 ? (argv[1][1]-'0') : 0; switch (r) { - case 0: - ba6100(argc,argv) ; break; case 1: - ba6200(argc,argv) ; break; + ba6200(argc,argv); break; default: - error_box(usage, argv[0]) ; break; + ba6100(argc,argv); break; } - exit(0); return 0; } diff --git a/ba/ba7.cpp b/ba/ba7.cpp index 21decbc9c..c6838e013 100755 --- a/ba/ba7.cpp +++ b/ba/ba7.cpp @@ -8,14 +8,12 @@ int main(int argc, char** argv) switch (r) { case 1: - ba7200(argc, argv) ; break; + ba7200(argc, argv); break; case 2: - ba7300(argc, argv) ; break; - case 0: + ba7300(argc, argv); break; default: - ba7100(argc, argv) ; break; + ba7100(argc, argv); break; } - exit(0); return 0; } diff --git a/ba/ba8.cpp b/ba/ba8.cpp index 3d0d68c09..84d6cf1e0 100755 --- a/ba/ba8.cpp +++ b/ba/ba8.cpp @@ -10,6 +10,7 @@ int main(int argc, char** argv) case 2: ba8300(argc, argv); break; // Report Generator case 3: ba8400(argc, argv); break; // Form Converter case 4: ba8500(argc, argv); break; // Report Printer + case 5: ba8600(argc, argv); break; // Ricerca documenti archiviati default: ba8100(argc, argv); break; // Record Selector } return 0; diff --git a/ba/ba8200.cpp b/ba/ba8200.cpp index e6b8b1892..2e9928df5 100755 --- a/ba/ba8200.cpp +++ b/ba/ba8200.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,16 +7,12 @@ #include #include #include -#include -#include #include #include #include -#include #include #include "../sqlite/sqlite3.h" - #include "ba8200.h" /////////////////////////////////////////////////////////// @@ -930,10 +926,14 @@ void TQuery_mask::save_as(TRecordsetExportFormat fmt) } FILE_SPEC fs; - xvt_fsys_convert_str_to_dir(path, &fs.dir); - strcpy(fs.type, ext); +/* xvt_fsys_convert_str_to_dir(path, &fs.dir); strcpy(fs.name, get(F_CODICE)); - strcpy(fs.creator, "AGA"); + strcpy(fs.type, ext); + strcpy(fs.creator, "AGA"); */ + path.add(get(F_CODICE)); path.ext(ext); + xvt_fsys_convert_str_to_fspec(path, &fs); + + xvt_fsys_save_dir(); const bool good = xvt_dm_post_file_save(&fs, TR("Esportazione")) == FL_OK; xvt_fsys_restore_dir(); diff --git a/ba/ba8500.cpp b/ba/ba8500.cpp index c0cf61f4b..dd53ee5fd 100755 --- a/ba/ba8500.cpp +++ b/ba/ba8500.cpp @@ -48,7 +48,7 @@ bool get_xml_attr(const TString& line, const char* attr, TString& value) bool get_xml_child(const TString& line, const char* tag, TString& value) { - TString str; str << '<' << tag << '>'; + TString80 str; str << '<' << tag << '>'; const int pos = line.find(str); if (pos >= 0) { diff --git a/ba/ba8600.cpp b/ba/ba8600.cpp new file mode 100755 index 000000000..edba2c1d7 --- /dev/null +++ b/ba/ba8600.cpp @@ -0,0 +1,235 @@ +#include "ba8.h" + +#include +#include +#include +#include +#include +#include + +#include "ba8600a.h" + +/////////////////////////////////////////////////////////// +// TGoogle_mask +/////////////////////////////////////////////////////////// + +class TGoogle_mask : public TAutomask +{ + TFilename _base_dir; + clock_t _next_update; + +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + virtual void on_idle(); + + void query_firm(int anno, long ditta); + void query_year(int anno); + void query(); + +public: + TGoogle_mask(const TFilename& base_dir); +}; + +void TGoogle_mask::on_idle() +{ + if (_next_update > 0 && clock() >= _next_update) + query(); +} + +bool TGoogle_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case DLG_USER: + if (e == fe_button) + { + const TMask& m = o.mask(); + TFilename name = _base_dir; + name.add(m.get(102)); + name.add(m.get(101)); + name.add(m.get(103)); + xvt_sys_goto_url(name, "open"); + } + break; + case F_SHEET: + if (e == se_query_add || e == se_query_del) + return false; + break; + case DLG_ELABORA: + if (e == fe_button) + query(); + break; + default: + break; + } + if (e == fe_modify && jolly ==0) + _next_update = clock() + 5*CLOCKS_PER_SEC; + + return true; +} + +void TGoogle_mask::query_firm(int anno, long firm) +{ + const TString& tipodoc = get(F_TIPODOC); + const long codcf = get_long(F_CLIFO); + TSheet_field& sheet = sfield(F_SHEET); + + TFilename name = _base_dir; + TString8 str; + str.format("%04d", anno); name.add(str); + str.format("%05ldA", firm); name.add(str); + + xvt_fsys_save_dir(); + DIRECTORY dir; xvt_fsys_convert_str_to_dir(name, &dir); + xvt_fsys_set_dir(&dir); + + SLIST files = xvt_fsys_list_files("", "*.*", FALSE); + for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e)) + { + TToken_string file(xvt_slist_get(files, e, NULL), '_'); + if (file.items() < 3) + continue; + + if (tipodoc.full() && tipodoc.compare(file.get(1), -1, true) != 0) + continue; + + if (codcf > 0 && codcf != file.get_long(3)) + continue; + + TToken_string& row = sheet.row(-1); + row.add(firm); + row.add(anno); + row.add(file); + } + xvt_slist_destroy(files); + + xvt_fsys_restore_dir(); +} + +void TGoogle_mask::query_year(int anno) +{ + const long firm = get_long(F_DITTA); + if (firm <= 0) + { + TFilename name = _base_dir; + TString8 str; str.format("%04d", anno); + name.add(str); + name.add("?????A"); + + SLIST files = xvt_fsys_list_files(DIR_TYPE, name, TRUE); + for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e)) + { + const TFilename name = xvt_slist_get(files, e, NULL); + const long firm = atol(name.name()); + query_firm(anno, firm); + } + xvt_slist_destroy(files); + } + else + query_firm(anno, firm); +} + +void TGoogle_mask::query() +{ + _next_update = 0; + + TWait_cursor hourglass; + + TSheet_field& sheet = sfield(F_SHEET); + sheet.destroy(); + + int anno = get_int(F_ANNO); + if (anno < 1000) + { + TFilename name = _base_dir; + name.add("????"); + SLIST files = xvt_fsys_list_files(DIR_TYPE, name, TRUE); + for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e)) + { + const TFilename dirname = xvt_slist_get(files, e, NULL); + anno = atoi(dirname.right(4)); + if (anno >= 1000) + query_year(anno); + } + xvt_slist_destroy(files); + } + else + query_year(anno); + + sheet.force_update(); + _next_update = 0; +} + +TGoogle_mask::TGoogle_mask(const TFilename& base_dir) + : _base_dir(base_dir), _next_update(0) +{ + TSheet_field::set_line_number_width(7); + read_mask("ba8600a", 0, 1); + set_handlers(); +} + +/////////////////////////////////////////////////////////// +// TGoogle_app +/////////////////////////////////////////////////////////// + +class TGoogle_app : public TSkeleton_application +{ + TGoogle_mask* _mask; + +public: + virtual bool create(); + virtual void main_loop(); + virtual bool destroy(); +}; + +bool TGoogle_app::create() +{ + TConfig ini("servers/servers.ini", "Spotlight"); + TFilename name = ini.get("Data"); + bool ok = name.exist(); + if (!ok) + { + name = firm2dir(-1); + name.add("spotlight"); + TString msg; + msg << TR("Il server di archiviazione non e' configurato") + << ":\n" << TR("si desidera usare la seguente cartella?") + << '\n' << name; + ok = yesno_box(msg); + if (!ok) + { + DIRECTORY dir; xvt_fsys_convert_str_to_dir(name, &dir); + ok = xvt_dm_post_dir_sel(&dir) == FL_OK; + if (ok) + xvt_fsys_convert_dir_to_str(&dir, name.get_buffer(), name.size()); + } + if (ok) + { + ok = xvt_fsys_mkdir(name) != 0; + if (ok) + ini.set("Data", name); + } + } + + _mask = ok ? new TGoogle_mask(name) : NULL; + + return ok && TSkeleton_application::create(); +} + +void TGoogle_app::main_loop() +{ + _mask->run(); +} + +bool TGoogle_app::destroy() +{ + delete _mask; + return TSkeleton_application::destroy(); +} + +int ba8600(int argc, char* argv[]) +{ + TGoogle_app app; + app.run(argc, argv, TR("Ricerca documenti archiviati")); + return 0; +} \ No newline at end of file diff --git a/ba/ba8600a.h b/ba/ba8600a.h new file mode 100755 index 000000000..8ea7d0f56 --- /dev/null +++ b/ba/ba8600a.h @@ -0,0 +1,8 @@ +#define F_DITTA 201 +#define F_FIRMRAGSOC 202 +#define F_ANNO 203 +#define F_TIPODOC 204 +#define F_TIPOCF 205 +#define F_CLIFO 206 +#define F_CLIRAGSOC 207 +#define F_SHEET 300 diff --git a/ba/ba8600a.uml b/ba/ba8600a.uml new file mode 100755 index 000000000..149214616 --- /dev/null +++ b/ba/ba8600a.uml @@ -0,0 +1,132 @@ +#include "ba8600a.h" + +TOOLBAR "Toolbar" 0 -2 0 2 + +BUTTON DLG_ELABORA 10 2 +BEGIN + PROMPT -12 -11 "~Elabora" + PICTURE BMP_ELABORA +END + +BUTTON DLG_QUIT 10 2 +BEGIN + PROMPT -22 -11 "" +END + +ENDPAGE + +PAGE "Ricerca documenti" 0 0 0 -2 + +NUMBER F_DITTA 5 +BEGIN + PROMPT 1 1 "Ditta " + FLAGS "F" + USE LF_NDITTE + INPUT CODDITTA F_DITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione Sociale@60" RAGSOC + OUTPUT F_DITTA CODDITTA + OUTPUT F_FIRMRAGSOC RAGSOC + CHECKTYPE NORMAL +END + +STRING F_FIRMRAGSOC 50 +BEGIN + PROMPT 24 1 "" + USE LF_NDITTE KEY 2 + INPUT RAGSOC F_FIRMRAGSOC + DISPLAY "Ragione Sociale@60" RAGSOC + DISPLAY "Codice" CODDITTA + COPY OUTPUT F_DITTA + CHECKTYPE NORMAL +END + +NUMBER F_ANNO 4 +BEGIN + PROMPT 1 2 "Anno " + FLAGS "A" +END + +STRING F_TIPODOC 10 +BEGIN + PROMPT 41 2 "Tipo documento " + FLAGS "U" +END + +LIST F_TIPOCF 1 9 +BEGIN + PROMPT 1 3 "" + ITEM "C|Cliente" + ITEM "F|Fornitore" +END + +NUMBER F_CLIFO 6 +BEGIN + PROMPT 14 3 "" + USE LF_CLIFO + INPUT TIPOCF F_TIPOCF SELECT + INPUT CODCF F_CLIFO + DISPLAY "Codice" CODCF + DISPLAY "Ragione Sociale@50" RAGSOC + OUTPUT F_CLIFO CODCF + OUTPUT F_CLIRAGSOC RAGSOC + CHECKTYPE NORMAL + ADD RUN CG0 -1 F_TIPOCF +END + +STRING F_CLIRAGSOC 50 +BEGIN + PROMPT 24 3 "" + USE LF_CLIFO KEY 2 + INPUT TIPOCF F_TIPOCF SELECT + INPUT RAGSOC F_CLIRAGSOC + DISPLAY "Ragione Sociale@50" RAGSOC + DISPLAY "Codice" CODCF + COPY OUTPUT F_CLIFO + CHECKTYPE NORMAL + ADD RUN CG0 -1 F_TIPOCF +END + +SPREADSHEET F_SHEET +BEGIN + PROMPT 0 5 "" + ITEM "Ditta" + ITEM "Anno" + ITEM "File@80" +END + +ENDPAGE + +ENDMASK + +PAGE "File" -1 -1 78 4 + +NUMBER 101 5 +BEGIN + PROMPT 1 1 "Ditta " +END + +NUMBER 102 4 +BEGIN + PROMPT 21 1 "Anno " +END + +STRING 103 256 70 +BEGIN + PROMPT 1 2 "File " +END + +BUTTON 100 10 2 +BEGIN + PROMPT -12 -1 "~Collega" + PICTURE BMP_LINK +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK diff --git a/cg/cg1600.cpp b/cg/cg1600.cpp index caf0b0762..cde1805b5 100755 --- a/cg/cg1600.cpp +++ b/cg/cg1600.cpp @@ -200,13 +200,14 @@ class TStampa_IVdirettiva : public TPrintapp real _nuovo_tot_saldo_d, _nuovo_tot_saldo_a; int _i; bool _reset_righe_stampa,_totale_attivita_gia_stampato,_totale_passivita_gia_stampato,_statopatr_no_stamp; - bool _sbilancio_ordine, _quadratura; + bool _sbilancio_ordine, _quadratura, _prima_dopo; long _items_sort; TString tmp; // Stringa per porcate galattiche - protected: +protected: void aggiungi_anno(int anno, TDate& inizio, TDate& fine); + virtual void on_config_change(); public: @@ -292,6 +293,12 @@ int TStampa_IVdirettiva::date2esc(const TDate& d) return ese.date2esc(d); } +void TStampa_IVdirettiva::on_config_change() +{ + TConfig ini(CONFIG_DITTA, "cg1600"); + _prima_dopo = ini.get_bool("PrimaDopoImposte"); +} + void TStampa_IVdirettiva::set_bil_key(bil_ivd* b, char sezione, char lettera, const char* numero_romano, const char * numero, bool conti_ordine, int gruppo, int conto, @@ -2148,14 +2155,14 @@ void TStampa_IVdirettiva::stampa_risultato_prima_delle_imposte() } // Guy was here 05/03/2004: La prima imposta a volte e' gia' stata sommata - const real te = _totale_economico; // - _sale; + const real te = _totale_economico - (_prima_dopo ? _sale : ZERO); set_row (_i,"@4g%s@81g%r", TR("Risultato prima delle imposte"), &te); if (raff) { // Guy was here 10/03/2004: La prima imposta a volte e' gia' stata sommata anche qui - const real te = _totale_economico_raf; // - _salerafr; + const real te = _totale_economico_raf - (_prima_dopo ? _salerafr : ZERO); set_row (_i,"@111g%r", &te); } diff --git a/include/applicat.cpp b/include/applicat.cpp index f8d49e563..c366124fb 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -699,7 +699,6 @@ void TApplication::enable_menu_item( // // @flag TRUE | Viene abilitata la voce del menu' // @flag FALSE | Viene disabilitata la voce del menu' - { xvt_menu_set_item_enabled(TASK_WIN, item, on); xvt_menu_update(TASK_WIN); @@ -829,7 +828,7 @@ void TApplication::open_files(int logicnum, ...) { va_list marker; va_start(marker, logicnum); - while (logicnum > 0 && logicnum < 1000) + while (logicnum >= LF_USER && logicnum < LF_EXTERNAL) { if (_used_files.objptr(logicnum) == NULL) _used_files.add(new TLocalisamfile(logicnum), logicnum); @@ -838,7 +837,7 @@ void TApplication::open_files(int logicnum, ...) } bool TApplication::get_next_pdf(int anno, long ditta, const char* codnum, - long numdoc, TFilename& pdf) const + long numdoc, long codcf, TFilename& pdf) const { bool ok = dongle().active(RSAUT); if (ok) @@ -862,22 +861,32 @@ bool TApplication::get_next_pdf(int anno, long ditta, const char* codnum, { if (ditta < 0) ditta = get_firm(); - pdf.add(format("%05ld", ditta)); + pdf.add(format("%05ldA", ditta)); + if (!pdf.exist()) + ok = xvt_fsys_mkdir(pdf) != 0; - if (codnum == NULL || *codnum <= ' ') - codnum = "report"; - pdf << '_' << _name << '_' << codnum << '_'; - - if (numdoc <= 0) + if (ok) { - time_t lt; time(<); - struct tm& loc = *localtime(<); - pdf << format("%02d%02d%02d%02d%02d", - loc.tm_mon, loc.tm_mday, loc.tm_hour, loc.tm_min, loc.tm_sec); + pdf.add(_name); + if (codnum == NULL || *codnum <= ' ') + codnum = "report"; + pdf << '_' << codnum; + + if (numdoc <= 0) + { + time_t lt; time(<); + struct tm& loc = *localtime(<); + pdf << format("_%02d%02d%02d%02d%02d", + loc.tm_mon, loc.tm_mday, loc.tm_hour, loc.tm_min, loc.tm_sec); + } + else + pdf << format("_%010ld", numdoc); + + if (codcf > 0) + pdf << format("_%07ld", codcf); + + pdf.ext("pdf"); } - else - pdf << format("%010ld", numdoc); - pdf.ext("pdf"); } return ok; diff --git a/include/applicat.h b/include/applicat.h index f562996d9..e6ef17046 100755 --- a/include/applicat.h +++ b/include/applicat.h @@ -120,7 +120,7 @@ public: { return _create_ok; } // @cmember Risposta alla selezione Stampa del menu File virtual void print(); - virtual bool get_next_pdf(int anno, long ditta, const char* codnum, long numdoc, TFilename& pdf) const; + virtual bool get_next_pdf(int anno, long ditta, const char* codnum, long numdoc, long codcf, TFilename& pdf) const; virtual bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn, TString& subj, TString& text, TToken_string& attach, bool& ui) const; diff --git a/include/dongle.cpp b/include/dongle.cpp index 4fc3ec35d..51a6f8e98 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -247,7 +247,7 @@ void TDongle::set_developer_permissions() _max_users = 1; _last_update = TDate(TODAY); - _year_assist = 2100; + _year_assist = 3000; } diff --git a/include/golem.cpp b/include/golem.cpp index d0a2882c6..4fe9bc3ee 100755 --- a/include/golem.cpp +++ b/include/golem.cpp @@ -45,9 +45,9 @@ bool goto_url(const char* url) if (app.not_empty()) { app << " \"" << url << '"'; - long error = xvt_sys_execute(app, FALSE, FALSE); //verificare + long error = xvt_sys_execute(app, false, false); //verificare if (error > 32) - return TRUE; + return true; else link.set(ext, ""); } @@ -149,7 +149,7 @@ bool TGolem_mask::file_handler(TMask_field& f, KEY k) m.set(S_ALIAS, file); } - return TRUE; + return true; } bool TGolem_mask::link_handler(TMask_field& f, KEY k) @@ -175,7 +175,7 @@ bool TGolem_mask::link_handler(TMask_field& f, KEY k) } else url.cut(0); - m.set(S_FILE, url, TRUE); // ... memorizza il suo nome ... + m.set(S_FILE, url, true); // ... memorizza il suo nome ... m.reset(S_LINK); // Non puo' essere un collegamento } else @@ -184,14 +184,14 @@ bool TGolem_mask::link_handler(TMask_field& f, KEY k) if (url.not_empty()) { - bool open = TRUE; + bool open = true; if (id == DLG_PRINT) open = !print_url(url); if (open) goto_url(url); } } - return TRUE; + return true; } bool TGolem_mask::main_link_handler(TMask_field& f, KEY k) @@ -207,7 +207,7 @@ bool TGolem_mask::main_link_handler(TMask_field& f, KEY k) link_handler(link, K_SPACE); } } - return TRUE; + return true; } bool TGolem_mask::sheet_notify(TSheet_field& s, int r, KEY k) @@ -256,7 +256,7 @@ bool TGolem_mask::ole_handler(TMask_field& f, KEY k) edit_url(file); } } - return TRUE; + return true; } TGolem_mask::TGolem_mask() @@ -361,7 +361,7 @@ void TGolem_field::set_window_data(const char* data) } bool TGolem_field::is_editable() const -{ return FALSE; } +{ return false; } void TGolem_field::parse_head(TScanner& scanner) { @@ -426,7 +426,7 @@ bool TGolem_field::autosave(TRelation& r) if (old_file != new_file) { const bool was_stored = old_row.get_char(2) <= ' ' && - golem_path.compare(old_file, golem_path.len(), TRUE) == 0; + golem_path.compare(old_file, golem_path.len(), true) == 0; const bool tobe_stored = new_row.get_char(2) <= ' '; if (was_stored && fexist(old_file)) ::remove(old_file); @@ -442,7 +442,7 @@ bool TGolem_field::autosave(TRelation& r) // Cancella il file originale se temporaneo TFilename tmp; tmp.tempdir(); - if (tmp.compare(new_file, tmp.len(), TRUE) == 0) + if (tmp.compare(new_file, tmp.len(), true) == 0) ::remove(new_file); } } @@ -455,7 +455,7 @@ bool TGolem_field::autosave(TRelation& r) bool TGolem_field::on_key(KEY key) { - bool ok = TRUE; + bool ok = true; if (key == K_SPACE) { TMask* msk = new TGolem_mask; @@ -550,7 +550,7 @@ const TFilename& TGolem_window::get_current_file(TFilename& fn) const void TGolem_window::update() { - bool drawn = FALSE; + bool drawn = false; TField_window::update(); @@ -558,7 +558,7 @@ void TGolem_window::update() if (file.not_empty() && file.exist()) { const TString16 ext = file.ext(); - if (ext.compare("bmp", -1, TRUE) == 0) + if (ext.compare("bmp", -1, true) == 0) { TImage img(file); if (img.ok()) @@ -582,7 +582,7 @@ void TGolem_window::update() const TPoint orig = origin(); img.draw(win(), -int(orig.x), -int(orig.y)); } - drawn = TRUE; + drawn = true; } } } @@ -700,11 +700,11 @@ void TGolem_window::handler(WINDOW win, EVENT* ep) TGolem_window::TGolem_window(int x, int y, int dx, int dy, WINDOW parent, TGolem_client_field* owner) : TField_window(x, y, dx, dy, parent, owner), _last_handle(0) { - _pixmap = TRUE; + _pixmap = true; #ifdef WIN32 // verificare HWND nat = (HWND)xvt_vobj_get_attr(win(), ATTR_NATIVE_WINDOW); - ::DragAcceptFiles(nat, TRUE); + ::DragAcceptFiles(nat, true); #endif } @@ -714,7 +714,7 @@ TGolem_window::~TGolem_window() if (_last_handle) ::PostMessage(HWND(_last_handle), WM_CLOSE, 0, 0); HWND nat = (HWND)xvt_vobj_get_attr(win(), ATTR_NATIVE_WINDOW); - ::DragAcceptFiles(nat, FALSE); + ::DragAcceptFiles(nat, false); #endif } @@ -739,11 +739,11 @@ bool TGolem_client_field::parse_item(TScanner& scan) _driver = (TGolem_field*)&m.fld(pos); TString16 msg; msg.format("PUSH,%d", dlg()); - _driver->message(0, TRUE)->add(msg); + _driver->message(0, true)->add(msg); } else yesnofatal_box("Non esiste il campo driver %d", driver); - return TRUE; + return true; } return TWindowed_field::parse_item(scan); } @@ -815,7 +815,7 @@ LPMAPIRESOLVENAME lpfnMAPIResolveName = NULL; bool TMAPI_session::load_mapi() { if (_hlibMAPI) // Check in already loaded - return TRUE; + return true; // Check if MAPI is installed on the system BOOL MAPI_installed = ::GetProfileInt("Mail", "MAPI", 0); @@ -833,20 +833,20 @@ bool TMAPI_session::load_mapi() return error_box("Errore di caricamento di %s: %lu", szMAPIDLL, err); } - if (!(lpfnMAPILogon = (LPMAPILOGON)GetProcAddress (_hlibMAPI, "MAPILogon"))) return FALSE; - if (!(lpfnMAPILogoff = (LPMAPILOGOFF)GetProcAddress (_hlibMAPI, "MAPILogoff"))) return FALSE; - if (!(lpfnMAPISendMail = (LPMAPISENDMAIL)GetProcAddress (_hlibMAPI, "MAPISendMail"))) return FALSE; - if (!(lpfnMAPISendDocuments = (LPMAPISENDDOCUMENTS) GetProcAddress (_hlibMAPI, "MAPISendDocuments"))) return FALSE; - if (!(lpfnMAPIFindNext = (LPMAPIFINDNEXT)GetProcAddress (_hlibMAPI, "MAPIFindNext"))) return FALSE; - if (!(lpfnMAPIReadMail = (LPMAPIREADMAIL)GetProcAddress (_hlibMAPI, "MAPIReadMail"))) return FALSE; - if (!(lpfnMAPISaveMail = (LPMAPISAVEMAIL)GetProcAddress (_hlibMAPI, "MAPISaveMail"))) return FALSE; - if (!(lpfnMAPIDeleteMail = (LPMAPIDELETEMAIL)GetProcAddress (_hlibMAPI, "MAPIDeleteMail"))) return FALSE; - if (!(lpfnMAPIFreeBuffer = (LPMAPIFREEBUFFER)GetProcAddress (_hlibMAPI, "MAPIFreeBuffer"))) return FALSE; - if (!(lpfnMAPIAddress = (LPMAPIADDRESS)GetProcAddress (_hlibMAPI, "MAPIAddress"))) return FALSE; - if (!(lpfnMAPIDetails = (LPMAPIDETAILS)GetProcAddress (_hlibMAPI, "MAPIDetails"))) return FALSE; - if (!(lpfnMAPIResolveName = (LPMAPIRESOLVENAME)GetProcAddress (_hlibMAPI, "MAPIResolveName"))) return FALSE; + if (!(lpfnMAPILogon = (LPMAPILOGON)GetProcAddress (_hlibMAPI, "MAPILogon"))) return false; + if (!(lpfnMAPILogoff = (LPMAPILOGOFF)GetProcAddress (_hlibMAPI, "MAPILogoff"))) return false; + if (!(lpfnMAPISendMail = (LPMAPISENDMAIL)GetProcAddress (_hlibMAPI, "MAPISendMail"))) return false; + if (!(lpfnMAPISendDocuments = (LPMAPISENDDOCUMENTS) GetProcAddress (_hlibMAPI, "MAPISendDocuments"))) return false; + if (!(lpfnMAPIFindNext = (LPMAPIFINDNEXT)GetProcAddress (_hlibMAPI, "MAPIFindNext"))) return false; + if (!(lpfnMAPIReadMail = (LPMAPIREADMAIL)GetProcAddress (_hlibMAPI, "MAPIReadMail"))) return false; + if (!(lpfnMAPISaveMail = (LPMAPISAVEMAIL)GetProcAddress (_hlibMAPI, "MAPISaveMail"))) return false; + if (!(lpfnMAPIDeleteMail = (LPMAPIDELETEMAIL)GetProcAddress (_hlibMAPI, "MAPIDeleteMail"))) return false; + if (!(lpfnMAPIFreeBuffer = (LPMAPIFREEBUFFER)GetProcAddress (_hlibMAPI, "MAPIFreeBuffer"))) return false; + if (!(lpfnMAPIAddress = (LPMAPIADDRESS)GetProcAddress (_hlibMAPI, "MAPIAddress"))) return false; + if (!(lpfnMAPIDetails = (LPMAPIDETAILS)GetProcAddress (_hlibMAPI, "MAPIDetails"))) return false; + if (!(lpfnMAPIResolveName = (LPMAPIRESOLVENAME)GetProcAddress (_hlibMAPI, "MAPIResolveName"))) return false; - return TRUE; + return true; } void TMAPI_session::unload_mapi() @@ -879,7 +879,7 @@ bool TMAPI_session::open() xvt_fsys_set_dir(&dir); // Ripristina dir corrente } - return TRUE; + return true; } void TMAPI_session::close() @@ -911,13 +911,13 @@ bool TMAPI_session::send(MapiMessage& msg, FLAGS flags) bool TMAPI_session::remove(const TString& id) { - bool ok = FALSE; + bool ok = false; if (open()) { LONG err = lpfnMAPIDeleteMail(_hSession, _hWnd, (char*)(const char*)id, 0L, 0L); if (err == SUCCESS_SUCCESS) - ok = TRUE; + ok = true; else error_box("Can't delete mail message: %ld", err); } @@ -1029,7 +1029,7 @@ bool TMail_message::send(TMAPI_session& lhSession, bool hide_ui) return ok; #else - return TRUE; + return true; #endif } @@ -1039,7 +1039,7 @@ bool TMail_message::send(bool hide_ui) TMAPI_session lhSession; // Open MAPI session return send(lhSession, hide_ui); #else - return TRUE; + return true; #endif } @@ -1049,7 +1049,7 @@ bool TMail_message::remove(TMAPI_session& lhSession) bool ok = _id.not_empty() && lhSession.remove(_id); return ok; #else - return TRUE; + return true; #endif } @@ -1059,7 +1059,7 @@ bool TMail_message::remove() TMAPI_session lhSession; // Open MAPI session return remove(lhSession); #else - return TRUE; + return true; #endif } @@ -1171,7 +1171,7 @@ int TMail_messages::get(const char* senderFilter, const char* body = NULL; const char* recipient = NULL; - bool should_add = TRUE; + bool should_add = true; if (should_add) { const MapiRecipDesc* pSender = pMessage->lpOriginator; @@ -1228,12 +1228,12 @@ bool TMail_messages::send(bool hide_ui) { #ifdef WIN32 //verificare TMAPI_session lhSession; - bool ok = TRUE; + bool ok = true; for (int i = 0; i < items(); i++) ok &= msg(i).send(lhSession, hide_ui); return ok; #else - return TRUE; + return true; #endif } @@ -1241,12 +1241,12 @@ bool TMail_messages::remove() { #ifdef WIN32 //verificare TMAPI_session lhSession; - bool ok = TRUE; + bool ok = true; for (int i = 0; ok && i < items(); i++) ok &= msg(i).remove(lhSession); return ok; #else - return TRUE; + return true; #endif } diff --git a/include/golem.h b/include/golem.h index 26f4bf302..e2bbd8b04 100755 --- a/include/golem.h +++ b/include/golem.h @@ -28,7 +28,7 @@ protected: bool add_recipient_ex(const char* recipient, int type); public: // Semiprotected: You don't have access to TMAPI_session - bool send(TMAPI_session& lhSession, bool hide_ui = FALSE); + bool send(TMAPI_session& lhSession, bool hide_ui = false); bool remove(TMAPI_session& lhSession); public: @@ -43,7 +43,7 @@ public: TMail_message& operator = (const char* msg) { destroy(); add(msg); return *this; } TMail_message& operator = (const TString& msg) { destroy(); add(msg); return *this; } - bool send(bool hide_ui = FALSE); + bool send(bool hide_ui = false); bool remove(); const TString& sender() const { return _sender; } @@ -66,9 +66,9 @@ class TMail_messages : public TArray { public: int get(const char* sender = NULL, const char* subject = NULL, - const char* body = NULL, bool attachments = FALSE, bool mark_as_read = FALSE); + const char* body = NULL, bool attachments = false, bool mark_as_read = false); - bool send(bool hide_ui = TRUE); + bool send(bool hide_ui = true); bool remove(); TMail_message& msg(int i) @@ -81,56 +81,4 @@ public: virtual ~TMail_messages() { } }; -// @doc EXTERNAL - -// @class TDDE | Classe per la gestione del DDE -// -// @base public | TObject -class TDDE : public TObject - -// @comm Attualmente utilizzato all'avvio di PRASSI per comunicare al Program Manager il nome -// dell'utente in modo da comunicarlo a tutti i programmi PRASSI avviati in seguito. - -// @author:(INTERNAL) Guido - -// @access:(INTERNAL) Private Member -{ - // @cmember:(INTERNAL) Handle della finestra Windows - word _hwnd; - // @cmember:(INTERNAL) Handle della finestra del server DDE - word _server; - // @cmember:(INTERNAL) Puntatore alla funzione di gestione dei messaggi - long _old_hook; - -// @access Public Member -public: - virtual bool do_initiate(word id, const TString& topic) { return FALSE; } - virtual bool do_execute(word id, const TString& cmd) { return FALSE; } - virtual bool do_ack(word id) { _server = id; return TRUE; } - virtual bool do_terminate(word id) { return FALSE; } - virtual bool do_custom_message(word msg, word wparam, long lparam) { return FALSE; } - virtual const char* get_app_name() const { return NULL; } - virtual const char* get_topics() const { return NULL; } - - // @cmember Stabilisce il collegamento dell'

per i

indicati - bool initiate(const char* app, const char* topic); - // @cmember Esegue il comando

- bool execute(const char* cmd) const; - // @cmember Lancia il server ed esegue un comando - bool execute(const char* app, const char* topic, const char* cmd, const char* filename = NULL); - // @cmember Chiude la connessione - void terminate(); - - - // @cmember Inizia a fornire i servizi di DDE server - bool start_server(); - - word hwnd() const { return _hwnd; } - - // @cmember Costruttore - TDDE(); - // @cmember Distruttore - virtual ~TDDE(); -}; - #endif diff --git a/include/netsock.cpp b/include/netsock.cpp index 3b12b84c9..d6dcf3909 100755 --- a/include/netsock.cpp +++ b/include/netsock.cpp @@ -1094,3 +1094,34 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca return ok; } + +/////////////////////////////////////////////////////////// +// TDDEClient +/////////////////////////////////////////////////////////// + +TConnection* TDDEClient::OnQueryConnection(const char* service, const char* server) +{ + TConnection* conn = NULL; + CONNID id = aga_dde_connect(server, service, ""); + if (id != 0) + conn = new TConnection(this, id); + return conn; +} + +bool TDDEClient::OnRemoveConnection(CONNID id) +{ + aga_dde_terminate(id); + return true; +} + + +byte* TDDEClient::GetBuffer(unsigned int& dwSize) +{ return NULL; } + +void TDDEClient::ReleaseBuffer() +{ } + +bool TDDEClient::Execute(CONNID id, const char* cmd) +{ + return aga_dde_execute(id, cmd) == 0; +} diff --git a/include/netsock.h b/include/netsock.h index 1ff4e2a8e..aa03edc5b 100755 --- a/include/netsock.h +++ b/include/netsock.h @@ -54,9 +54,20 @@ public: bool HttpSoap(CONNID id, const char* query); bool HttpPostFile(CONNID id, const char* remote, const char* local, const char* authorization = NULL); - TSocketClient(); virtual ~TSocketClient(); }; +class TDDEClient : public TLanClient +{ +protected: + virtual TConnection* OnQueryConnection(const char* service, const char* server); + virtual bool OnRemoveConnection(CONNID id); + virtual byte* GetBuffer(unsigned int& dwSize); + virtual void ReleaseBuffer(); + +public: + virtual bool Execute(CONNID id, const char* cmd); +}; + #endif diff --git a/include/netutils.cpp b/include/netutils.cpp index b922359eb..201eb0a29 100755 --- a/include/netutils.cpp +++ b/include/netutils.cpp @@ -22,19 +22,19 @@ bool TLanManager::HasConnections() const bool TLanManager::Request(CONNID id, const char* cmd) { TConnection* conn = GetConnection(id) ; - return conn ? conn->Request(cmd) : FALSE; + return conn ? conn->Request(cmd) : false; } bool TLanManager::Execute(CONNID id, const char* cmd) { TConnection* conn = GetConnection(id) ; - return conn ? conn->Execute(cmd) : FALSE; + return conn ? conn->Execute(cmd) : false; } // Physically disconnect bool TLanManager::OnRemoveConnection(CONNID id) { - return TRUE; + return true; } CONNID TLanManager::AddConnection(TConnection* pConn) @@ -44,7 +44,7 @@ CONNID TLanManager::AddConnection(TConnection* pConn) { id = pConn->Id(); TString16 key; key.format("%lu", id); - m_mapConn.add(key, pConn, TRUE); + m_mapConn.add(key, pConn, true); } return id; } @@ -52,12 +52,12 @@ CONNID TLanManager::AddConnection(TConnection* pConn) bool TLanManager::RemoveConnection(CONNID id) { TConnection* pConn = GetConnection(id); - bool ok = FALSE; + bool ok = false; if (pConn != NULL && OnRemoveConnection(id)) { TString16 key; key.format("%lu", id); m_mapConn.remove(key); - ok = TRUE; + ok = true; } return ok; @@ -136,13 +136,13 @@ CONNID TLanClient::QueryConnection(const char* service, const char* server) bool TLanClient::Execute(CONNID id, const char* cmd) { TConnection* pConn = GetConnection(id); - return pConn ? pConn->Execute(cmd) : FALSE; + return pConn ? pConn->Execute(cmd) : false; } bool TLanClient::Request(CONNID id, const char* cmd) { TConnection* pConn = GetConnection(id); - return pConn ? pConn->Request(cmd) : FALSE; + return pConn ? pConn->Request(cmd) : false; } bool TLanClient::RequestString(CONNID id, const char* cmd, TString& res) @@ -208,7 +208,7 @@ int TConnection::ParseCommand(const char* cmd, TString_array& argv) { argv.destroy(); - bool is_quoted = FALSE; + bool is_quoted = false; char end_quote = '\0'; TString token; const char* token_start = NULL; @@ -223,7 +223,7 @@ int TConnection::ParseCommand(const char* cmd, TString_array& argv) token = token_start; *c = end_quote; end_quote = '\0'; - is_quoted = TRUE; + is_quoted = true; } continue; } @@ -249,7 +249,7 @@ int TConnection::ParseCommand(const char* cmd, TString_array& argv) token_start = NULL; token = ""; - is_quoted = FALSE; + is_quoted = false; continue; } @@ -279,4 +279,3 @@ bool TConnection::Request(const char* cmd) TString_array argv; return ParseCommand(cmd, argv) > 0; } - diff --git a/include/odbcrset.cpp b/include/odbcrset.cpp index e87b68e36..1ba7de5bc 100755 --- a/include/odbcrset.cpp +++ b/include/odbcrset.cpp @@ -1,5 +1,6 @@ #include #include +#include #include /////////////////////////////////////////////////////////// @@ -378,14 +379,15 @@ TRecordset* create_recordset(const TString& sql) if (sql.full()) { if (sql.starts_with("US", true)) - rex = new TISAM_recordset(sql); + rex = new TISAM_recordset(sql); else + if (sql.starts_with("ODBC", true)) + rex = new TODBC_recordset(sql); + if (sql.starts_with("CSV", true)) + rex = new TCSV_recordset(sql); + if (sql.starts_with("AS400", true)) + rex = new TAS400_recordset(sql); else - { - if (sql.starts_with("ODBC", true)) - rex = new TODBC_recordset(sql); - else - rex = new TSQL_recordset(sql); - } + rex = new TSQL_recordset(sql); } return rex; } diff --git a/include/report.cpp b/include/report.cpp index 64a5cbffc..bee0207c6 100755 --- a/include/report.cpp +++ b/include/report.cpp @@ -5,6 +5,7 @@ #include #include #include + #include #include #include @@ -1262,9 +1263,10 @@ bool TReport_field::load_field() const TFieldtypes ft = var_type(); if (ft != _nullfld) { - section().report().evaluate(_field, _var, ft); - if (_var.is_empty() && _alt_field.not_empty()) - section().report().evaluate(_alt_field, _var, ft); + TReport& rep = section().report(); + rep.evaluate(_field, _var, ft); + if (_var.is_empty() && _alt_field.full()) + rep.evaluate(_alt_field, _var, ft); } else _var.set_null(); @@ -1304,7 +1306,7 @@ COLOR TReport_field::link_color() const void TReport_field::get_currency(TCurrency& cur) const { - if (_codval.not_empty()) + if (_codval.full()) { TVariant val; section().report().evaluate(_codval, val, _alfafld); @@ -1390,7 +1392,7 @@ const TString& TReport_field::formatted_text() const } break; default: - if (_picture.not_empty()) + if (_picture.full()) { TString& tmp = get_tmp_string(); if (_picture.find('#') >= 0) @@ -2383,8 +2385,7 @@ bool TReport::set_usr_val(const TString& name, const TVariant& var) else str++; } - const TFixed_string n(str); - TReport_field* fld = field(n); + TReport_field* fld = field(str); if (fld != NULL) { fld->set(var); diff --git a/include/spotlite.cpp b/include/spotlite.cpp index 8b6b8d0d1..71d072401 100755 --- a/include/spotlite.cpp +++ b/include/spotlite.cpp @@ -10,7 +10,7 @@ // Funzione per generare il nome di un file da archiviare bool spotlite_generate_name(const char* codnum, TFilename& pdf) { - bool ok = main_app().get_next_pdf(0, -1, codnum, 0, pdf); + bool ok = main_app().get_next_pdf(0, -1, codnum, 0, 0, pdf); if (ok && pdf.exist()) { TString msg; @@ -28,27 +28,32 @@ KEY spotlite_ask_name(TFilename& pdf) const bool can_arc = dongle().active(RSAUT); msk.enable(DLG_PDF, can_arc); - bool arc = can_arc; - if (arc) - arc = can_arc && main_app().get_next_pdf(0, 0, NULL, 1, pdf); - msk.enable(DLG_ARCHIVE, arc); - + TString80 export_name; + const bool gnp = main_app().get_next_pdf(0, 0, NULL, 1, 0, pdf); + if (gnp) + { + pdf.ext(""); + export_name = pdf.name(); + } + if (export_name.blank()) + export_name = "export"; + + msk.enable(DLG_ARCHIVE, can_arc && gnp); msk.enable(DLG_EMAIL, can_arc); msk.show(DLG_EMAIL, can_arc && dongle().active(EEAUT)); pdf.tempdir(); - msk.set(F_PRINTER, pdf); - msk.set(F_FORM, "export"); + msk.set(F_PRINTER, pdf); // Cartella dei file da esportare + msk.set(F_FORM, export_name); // Nome standard del file da esportare KEY key = msk.run(); if (key != K_ESC && key != K_QUIT) { pdf = msk.get(F_PRINTER); if (!pdf.exist()) pdf.tempdir(); - - if (msk.field(F_FORM).empty()) - msk.set(F_FORM, "export"); - pdf.add(msk.get(F_FORM)); + if (!msk.field(F_FORM).empty()) + export_name = msk.get(F_FORM); + pdf.add(export_name); pdf.ext("pdf"); switch (key) diff --git a/include/tabapp.cpp b/include/tabapp.cpp index ccc178792..f040e18d5 100755 --- a/include/tabapp.cpp +++ b/include/tabapp.cpp @@ -77,7 +77,10 @@ TString& TTable_application::get_mask_name(TString& t) const TMask* TTable_application::set_mask(TMask* m) { if (_msk != NULL) + { delete _msk; + _msk = NULL; + } if (m != NULL) { @@ -87,9 +90,11 @@ TMask* TTable_application::set_mask(TMask* m) else { // alloca la maschera standard come maschera della applicazione - TFilename name; - get_mask_name(name); - _msk = new TMask(name); + TFilename name; get_mask_name(name); name.ext("msk"); + if (name.custom_path()) + _msk = new TMask(name); + else + error_box(FR("Impossibile trovare la maschera %s"), (const char*)name); } return _msk; } @@ -97,13 +102,14 @@ TMask* TTable_application::set_mask(TMask* m) bool TTable_application::user_create() { if (argc() < 3) - return FALSE; + return false; _tabname = argv(2); _tabname.upper(); _rel = new TRelation(_tabname); - set_mask(); + if (set_mask() == NULL) + return false; const int campi = _msk->fields(); for (int i = 0; i < campi; i++) @@ -116,10 +122,8 @@ bool TTable_application::user_create() } } - TFilename rpt; - get_mask_name(rpt); - rpt.ext("rpt"); - if (rpt.exist()) + TFilename rpt; get_mask_name(rpt); rpt.ext("rpt"); + if (rpt.custom_path()) enable_menu_item(M_FILE_PRINT); TString title; @@ -198,6 +202,18 @@ bool TMultirel_application::find(word k) void TMultirel_application::init_insert_mode(TMask& m) { + TLocalisamfile multi(LF_MULTIREL); + + file().curr().zero(); + for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false)) + { + if ((!e->in_group(1)) && (e->shown() || e->ghost())) + e->autosave(*get_relation()); + } + + multi.curr() = file().curr(); + if (multi.read(_isgteq) == NOERR && multi.curr() == file().curr()) + set_descr(m, multi.get("DATA")); for (int i = m.fields() - 1; i >= 0; i--) { TMask_field& c = m.fld(i); @@ -206,12 +222,27 @@ void TMultirel_application::init_insert_mode(TMask& m) TEdit_field& e = (TEdit_field&)c; e.enable(); - if (e.browse() != NULL) + if (e.browse() != NULL && !e.browse()->cursor()->file().empty()) + e.enable_check(); + } + } +} + +void TMultirel_application::init_modify_mode(TMask& m) +{ + for (int i = m.fields() - 1; i >= 0; i--) + { + TMask_field& c = m.fld(i); + if (c.in_group(1) && c.is_edit()) + { + TEdit_field& e = (TEdit_field&)c; + + e.enable(); + if (e.browse() != NULL && !e.browse()->cursor()->file().empty()) e.enable_check(); _second = e.get(); } } - } int TMultirel_application::rewrite(const TMask& m) @@ -247,7 +278,7 @@ bool TMultirel_application::user_create() FOR_EACH_MASK_FIELD((*_msk), i, f) { - if (f->in_key(1)) + if (f->in_key(1) && !f->in_group(1)) { set_search_field(f->dlg()); break; diff --git a/include/tabapp.h b/include/tabapp.h index 0ce79947d..d86be1c92 100755 --- a/include/tabapp.h +++ b/include/tabapp.h @@ -102,7 +102,7 @@ protected: // @cmember Inizializza la maschera per il modo inserimento virtual void init_insert_mode(TMask& m); // @cmember Inizializza la maschera per il modo modifica - virtual void init_modify_mode(TMask& m) { init_insert_mode(m);} + virtual void init_modify_mode(TMask& m); // @cmember Inizializzazione dei dati dell'utente virtual bool user_create() ; // @cmember Distruzione dei dati dell'utente @@ -111,6 +111,8 @@ protected: virtual void print(); // @cmember Riscrive sulla relazione i valori dalla maschera

virtual int rewrite(const TMask& m); + // @cmember imposta sulla maschera la descrizione + virtual void set_descr(TMask & m, const TString & desc) {} // @access Public Member public: diff --git a/include/textset.cpp b/include/textset.cpp index 24d58fa82..ef076eed9 100755 --- a/include/textset.cpp +++ b/include/textset.cpp @@ -549,30 +549,36 @@ const TVariant& TAS400_recordset::get(const char* column) const TRecnotype TAS400_recordset::new_rec(const char* trc) { - CHECK(record_length() > 0, "Lunghezza record nulla"); - TString str(record_length(), ' '); - const TRecnotype n = TText_recordset::new_rec(str); - if (trc && (int)strlen(trc) == key_length()) - { - TArray* info = (TArray*)_trc.objptr(trc); - if (info != NULL) // Se il tracciato e' noto, riempio di zeri i campi opportuni - { - FOR_EACH_ARRAY_ITEM_BACK((*info), i, obj) - { - const TAS400_column_info& ci = *(const TAS400_column_info*)obj; - if (ci._default.is_null()) - { - if (ci._type == _intzerofld || ci._type == _longzerofld) - set_field(ci, NULL_VARIANT); - } - else - set_field(ci, ci._default); - } - } - row(n).overwrite(trc, key_position()); - } + CHECK(record_length() > 0, "Lunghezza record nulla"); - return n; + if (trc && (int)strlen(trc) == record_length()) + return TText_recordset::new_rec(trc); + else + { + const TString str(record_length(), ' '); + const TRecnotype n = TText_recordset::new_rec(str); + + if (trc && (int)strlen(trc) == key_length()) + { + TArray* info = (TArray*)_trc.objptr(trc); + if (info != NULL) // Se il tracciato e' noto, riempio di zeri i campi opportuni + { + FOR_EACH_ARRAY_ITEM_BACK((*info), i, obj) + { + const TAS400_column_info& ci = *(const TAS400_column_info*)obj; + if (ci._default.is_null()) + { + if (ci._type == _intzerofld || ci._type == _longzerofld) + set_field(ci, NULL_VARIANT); + } + else + set_field(ci, ci._default); + } + } + row(n).overwrite(trc, key_position()); + } + return n; + } } const TString& TAS400_recordset::rec_type(TRecnotype r) const diff --git a/include/utility.cpp b/include/utility.cpp index 07b6e95f2..f21d95ad4 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -226,7 +226,7 @@ int list_files( for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e)) { - char* f = xvt_slist_get(files, e, NULL); + const char* f = xvt_slist_get(files, e, NULL); if (dir.not_empty()) { mask = dir; diff --git a/mg/anamag.h b/mg/anamag.h index 3ec793536..584cac718 100755 --- a/mg/anamag.h +++ b/mg/anamag.h @@ -67,6 +67,8 @@ #define ANAMAG_DATAVDIST "DATAVDIST" #define ANAMAG_VALDIST "VALDIST" #define ANAMAG_GOLEM "GOLEM" +#define ANAMAG_REPARTO "REPARTO" +#define ANAMAG_STAGIONE "STAGIONE" #define NULL_CODART "_****_" diff --git a/ps/pd0666100.cpp b/ps/pd0666100.cpp index 331424fce..c83c88136 100755 --- a/ps/pd0666100.cpp +++ b/ps/pd0666100.cpp @@ -5,12 +5,18 @@ #include #include #include +#include +#include +#include #include #include "../cg/cglib01.h" +#include #include #include +#include +#include /////////////////////////////////////////////////////////// @@ -23,37 +29,98 @@ class TEsporta_SAP_mask : public TAutomask public: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); TEsporta_SAP_mask(); + ~TEsporta_SAP_mask(); }; bool TEsporta_SAP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { -/* switch (o.dlg()) + switch (o.dlg()) { + case F_NEXTNUMC: + if (e == fe_init) + { + const int n = get(F_LASTDATAC) != get(F_TODAY) ? 1 : get_int(F_LASTNUMC)+1; + TString4 str; str.format("%02d", n); + o.set(str); + } + break; + case F_NEXTNUMF: + if (e == fe_init) + { + const int n = get(F_LASTDATAF) != get(F_TODAY) ? 1 : get_int(F_LASTNUMF)+1; + TString4 str; str.format("%02d", n); + o.set(str); + } + break; default: break; - }*/ + } return true; } TEsporta_SAP_mask::TEsporta_SAP_mask() : TAutomask("pd0666100a") { + //carica i parametri del file di configurazione + TConfig configfile("pd0666conf.ini", "MAIN"); + for (int i = 0; i < fields() ; i++) + { + TMask_field& f = fld(i); + const TFieldref* fr = f.field(); + if (fr != NULL) + f.set(configfile.get(fr->name())); + } + //file dei clienti.. - TFilename file; - file.tempdir(); - file.add("clienti.xls"); - set(F_CLIFILE, file); + TFilename file; + if (get(F_CLIFILE).empty()) + { + file.tempdir(); + file.add("clienti.xls"); + set(F_CLIFILE, file); + } //..dei fornitori.. - file.tempdir(); - file.add("fornitori.xls"); - set(F_FORNFILE, file); + if (get(F_FORNFILE).empty()) + { + file.tempdir(); + file.add("fornitori.xls"); + set(F_FORNFILE, file); + } //..e delle partite - file.tempdir(); - file.add("partite.xls"); - set(F_PARTFILE, file); + if (get(F_PARTFILEC).empty()) + { + file.tempdir(); + file.add("partitec.xls"); + set(F_PARTFILEC, file); + } + + if (get(F_PARTFILEF).empty()) + { + file.tempdir(); + file.add("partitef.xls"); + set(F_PARTFILEF, file); + } + } +TEsporta_SAP_mask::~TEsporta_SAP_mask() +{ + //carica i parametri del file di configurazione + TConfig configfile("pd0666conf.ini", "MAIN"); + for (int i = 0; i < fields() ; i++) + { + TMask_field& f = fld(i); + const TFieldref* fr = f.field(); + if (fr != NULL) + configfile.set(fr->name(), f.get()); + } +} + +///////////////////////////////////////////////////////////// +// Recordset specifici per i dati da trasferire +///////////////////////////////////////////////////////////// +//Clienti class TEsporta_SAP_clienti_recordset : public TAS400_recordset { public: @@ -64,8 +131,8 @@ TEsporta_SAP_clienti_recordset::TEsporta_SAP_clienti_recordset() : TAS400_recordset("AS400(512)") { create_field("KTOKD", -1, 4, _alfafld); //zicc o zicu - create_field("NAME1", -1, 30, _alfafld); //ragsoc1 - create_field("NAME2", -1, 20, _alfafld); //ragsoc2 + create_field("NAME1", -1, 50, _alfafld); //ragsoc1 + create_field("NAME2", -1, 5, _alfafld); //ragsoc2 create_field("SORTL", -1, 1, _alfafld); //campo non richiesto? create_field("STRAS", -1, 45, _alfafld); //via+numero create_field("ORT01", -1, 35, _alfafld); //localita' @@ -79,18 +146,18 @@ TEsporta_SAP_clienti_recordset::TEsporta_SAP_clienti_recordset() create_field("TELF2", -1, 40, _alfafld); //somma prefisso+telefono ptel2+tel2 create_field("LZONE", -1, 10, _alfafld); //non l'abbiamo create_field("VBUND", -1, 1, _alfafld); //non l'abbiamo - create_field("STCD1", -1, 16, _alfafld); //non l'abbiamo;cofi + create_field("STCD1", -1, 16, _alfafld); //cofi create_field("STCD2", -1, 16, _alfafld); //non l'abbiamo create_field("BRSCH", -1, 2, _alfafld); //non l'abbiamo create_field("STCEG", -1, 14, _alfafld); //statopaiv+p.iva create_field("STKZN", -1, 1, _alfafld); //tipopers create_field("BUSAB", -1, 2, _alfafld); //non l'abbiamo create_field("XAUSZ", -1, 1, _alfafld); //non l'abbiamo - create_field("AKONT", -1, 8, _alfafld); //conto da tabella! + create_field("AKONT", -1, 8, _alfafld, true, "41001000"); //conto da tabella! create_field("FDGRV", -1, 5, _alfafld); //non l'abbiamo create_field("ZTERM", -1, 4, _alfafld); //codpag? create_field("ZAMIM", -1, 1, _alfafld); //non l'abbiamo - create_field("ZWELS", -1, 4, _alfafld); //codpag ancora? + create_field("ZWELS", -1, 4, _alfafld); //metodopag create_field("VZSKZ", -1, 2, _alfafld); //non l'abbiamo create_field("EIKTO", -1, 6, _alfafld); //nostro codcf create_field("XZVER", -1, 1, _alfafld); //non l'abbiamo @@ -99,13 +166,101 @@ TEsporta_SAP_clienti_recordset::TEsporta_SAP_clienti_recordset() create_field("MAHNA", -1, 4, _alfafld); //non l'abbiamo } +//Forinitori +class TEsporta_SAP_fornitori_recordset : public TAS400_recordset +{ +public: + TEsporta_SAP_fornitori_recordset(); +}; + +TEsporta_SAP_fornitori_recordset::TEsporta_SAP_fornitori_recordset() +: TAS400_recordset("AS400(512)") +{ + create_field("ACCVE", -1, 6, _alfafld); //codcf + create_field("ACCOUNT", -1, 4, _alfafld); //z00? + create_field("NAME1", -1, 50, _alfafld); //ragsoc1 + create_field("NAME2", -1, 5, _alfafld); //ragsoc2 + create_field("SORTL", -1, 10, _alfafld); //sort non l'abbiamo (ricalt?) + create_field("STREET", -1, 35, _alfafld); //indcf + create_field("HOUSEN", -1, 10, _alfafld); //civcf + create_field("DISTR", -1, 35, _alfafld); //localita' + create_field("ZIP", -1, 5, _alfafld); //cap + create_field("CITY", -1, 50, _alfafld); //dencom + create_field("COUNTRY", -1, 3, _alfafld); //codice paese + create_field("REGION", -1, 2, _alfafld); //provincia + create_field("LANG", -1, 1, _alfafld); //codlin + create_field("TEL", -1, 40, _alfafld); //pref+tel + create_field("TEL2", -1, 40, _alfafld); //pref+tel + create_field("FAX", -1, 40, _alfafld); //pref+fax + create_field("TAXC1", -1, 16, _alfafld); //cofi + create_field("TAXC2", -1, 16, _alfafld); //non l'abbiamo + create_field("VATRN", -1, 14, _alfafld); //statopaiv+iva + create_field("TIPOP", -1, 1, _alfafld); //tipopers + create_field("SEX", -1, 1, _alfafld); //sesso! + create_field("BIRTHL", -1, 50, _alfafld); //luogo nascita + create_field("BIRTHD", -1, 10, _alfafld); //data nascita + create_field("PROF", -1, 1, _alfafld); //professione non l'abbiamo + create_field("BANKC", -1, 2, _alfafld); //stato banca non l'abbiamo (stato?) + create_field("BANKK", -1, 10, _alfafld); //abi+cab + create_field("BANKA", -1, 20, _alfafld); //contocorrente + create_field("RECON", -1, 10, _alfafld); //tabella trascodifica necessaria + create_field("PLANG", -1, 1, _alfafld); //non l'abbiamo + create_field("PREVAN", -1, 1, _alfafld); //non l'abbiamo + create_field("SORTK", -1, 1, _alfafld); //non l'abbiamo + create_field("PAYTR", -1, 4, _alfafld); //tabella trascodifica + create_field("PAYMT", -1, 1, _alfafld); //tabella trascodifica + create_field("WTAXC2", -1, 1, _alfafld); //non l'abbiamo + create_field("WTAXT2", -1, 1, _alfafld); //non l'abbiamo + create_field("WTAXS2", -1, 1, _alfafld); //non l'abbiamo + create_field("CHKDB", -1, 1, _alfafld); //non l'abbiamo +} + + +//Partite +class TEsporta_SAP_partite_recordset : public TAS400_recordset +{ +public: + TEsporta_SAP_partite_recordset(); +}; + +TEsporta_SAP_partite_recordset::TEsporta_SAP_partite_recordset() +: TAS400_recordset("AS400(512)") +{ +//record di tipo BBKPF+BBSEG(1)+BBSEG(2) + create_field("BLDAT", -1, 8, _alfafld); //datadoc (gg/mm/aa) + create_field("BLART", -1, 2, _alfafld); //tipi doc da tabella trascodifica + create_field("BUKRS", -1, 4, _alfafld, true, "0706"); //0706 + create_field("BUDAT", -1, 8, _alfafld); //31/03/07 + create_field("WAERS", -1, 5, _alfafld, true, "EUR"); //EUR + create_field("XBLNR", -1, 16, _alfafld); //numdoc + create_field("BKTXT", -1, 25, _alfafld); //descr + + create_field("NEWBS", -1, 2, _alfafld); //chiavi contabili da tabella trascodifica + create_field("NEWKO", -1, 17, _alfafld); //conto di contropartita da tabella trascodifica + create_field("WRBTR", -1, 16, _alfafld); //imponibile con .2 decimals + create_field("ZUONR", -1, 18, _alfafld); //datareg del documento + create_field("ZTERM", -1, 4, _alfafld, true, "C000"); //?? + create_field("ZFBDT", -1, 8, _alfafld); //data di scadenza??? + create_field("ZLSCH", -1, 1, _alfafld, true, "E"); // '/' + create_field("SGTXT", -1, 50, _alfafld); //descrizione testata documento + + create_field("ZNEWBS", -1, 2, _alfafld); + create_field("ZNEWKO", -1, 17, _alfafld); + create_field("ZWRBTR", -1, 16, _alfafld); + create_field("ZZUONR", -1, 18, _alfafld); + //create_field("ZZTERM", -1, 4, _alfafld); non la si vuole al secondo giro? + create_field("ZZFBDT", -1, 8, _alfafld); + create_field("ZZLSCH", -1, 1, _alfafld); + create_field("ZSGTXT", -1, 50, _alfafld); +} + /////////////////////////////////////////////////////////// -// TEsporta_SAP +// TEsporta_SAP applicazione /////////////////////////////////////////////////////////// class TEsporta_SAP_app : public TSkeleton_application { - TAssoc_array _codpag; + TAssoc_array _codpag_c, _codpag_f; protected: virtual bool check_autorization() const {return false;} @@ -113,11 +268,16 @@ protected: virtual void main_loop(); bool is_cofi(const TString& cofi) const; + const TRectype& find_comune(const TRecordset& clifo) const; + const TString& find_dencom_nasc(TString& codcom) const; + bool check_clifo(const char tipo, const long codcf) const; + const TString& format_data(const TDate& data) const; + const TString& trova_il_codsap(const char tipo, const char sezione) const; public: void esporta_clienti(const TString& path) const; void esporta_fornitori(const TString& path) const; - void esporta_partite(const TString& path) const; + void esporta_partite(const TMask& msk, const char tipo) const; }; @@ -143,6 +303,38 @@ bool TEsporta_SAP_app::is_cofi(const TString& cofi) const return i < 0; } +//Clienti +const TRectype& TEsporta_SAP_app::find_comune(const TRecordset& clifo) const +{ + TToken_string ws; + if (clifo.get(CLI_COMCF).is_empty()) + { + ws = " "; + ws.add(cap2comune(clifo.get(CLI_CAPCF).as_string(), + clifo.get(CLI_LOCCF).as_string())); + } + else + { + ws = clifo.get(CLI_STATOCF).as_string(); + ws.add(clifo.get(CLI_COMCF).as_string() ,1); + } + const TRectype& com_rec = cache().get(LF_COMUNI, ws); + return com_rec; +} + + +bool TEsporta_SAP_app::check_clifo(const char tipo, const long codcf) const +{ + TLocalisamfile mov(LF_MOV); + mov.setkey(3); + mov.put(MOV_TIPO, tipo); + mov.put(MOV_CODCF, codcf); + mov.put(MOV_DATAREG, "20050101"); + int err = mov.read(_isgteq); + return err == NOERR && mov.get_long(MOV_CODCF) == codcf; +} + + void TEsporta_SAP_app::esporta_clienti(const TString& path) const { TString query; @@ -155,114 +347,99 @@ void TEsporta_SAP_app::esporta_clienti(const TString& path) const const int cazzoni = clienti_campo.items(); TProgind pi(cazzoni, "Trasferimento clienti...", true, true); - TString workstring; + TString ws; for (bool ok = clienti_campo.move_first(); ok; ok = clienti_campo.move_next()) { if (!pi.addstatus(1)) break; + const long codcf = clienti_campo.get(CLI_CODCF).as_int(); + if (!check_clifo('C', codcf)) + continue; + //creazione di un nuovo record di tipo clienti.. - clienti_sap.new_rec(); + clienti_sap.new_rec(""); //..e successivo riempimento - const long conto = clienti_campo.get(CLI_CONTO).as_int(); //ktokd + const long conto = clienti_campo.get(CLI_CONTO).as_int(); //ktokd if (conto == 8 || conto == 9) clienti_sap.set("KTOKD", TVariant("ZICC")); else clienti_sap.set("KTOKD", TVariant("ZICU")); - workstring = clienti_campo.get(CLI_RAGSOC).as_string(); //name1 e name2 - clienti_sap.set("NAME1", TVariant(workstring.left(30))); - clienti_sap.set("NAME2", TVariant(workstring.mid(30))); + clienti_sap.set("NAME1", clienti_campo.get(CLI_RAGSOC)); //name1 e name2 - workstring = clienti_campo.get(CLI_INDCF).as_string(); //stras - workstring << " " << clienti_campo.get(CLI_CIVCF).as_string(); - clienti_sap.set("STRAS", TVariant(workstring)); + ws = clienti_campo.get(CLI_INDCF).as_string(); //stras + ws << " " << clienti_campo.get(CLI_CIVCF).as_string(); + clienti_sap.set("STRAS", TVariant(ws)); //pocci su comune localita' provincia - if (clienti_campo.get(CLI_COMCF).is_empty()) - { - workstring = cap2comune(clienti_campo.get(CLI_CAPCF).as_string(), - clienti_campo.get(CLI_LOCCF).as_string()); - workstring.insert(" |"); - } - else - { - workstring = clienti_campo.get(CLI_STATOCF).as_string(); - workstring << "|" << clienti_campo.get(CLI_COMCF).as_string(); - } - const TRectype& com_rec = cache().get(LF_COMUNI, workstring); + const TRectype& com_rec = find_comune(clienti_campo); const TString& dencom = com_rec.get(COM_DENCOM); - workstring = clienti_campo.get(CLI_LOCCF).as_string(); //ort01 + ws = clienti_campo.get(CLI_LOCCF).as_string(); //ort01 if (dencom.full()) { - if (workstring.blank()) - workstring = dencom; + if (ws.blank()) + ws = dencom; else { - workstring.upper(); - if (xvt_str_fuzzy_compare(workstring, dencom) < 0.75) - workstring << ", " << dencom; + ws.upper(); + if (xvt_str_fuzzy_compare(ws, dencom) < 0.75) + ws << ", " << dencom; } } - clienti_sap.set("ORT01", TVariant(workstring)); + clienti_sap.set("ORT01", TVariant(ws)); - workstring = clienti_campo.get(CLI_CAPCF).as_string(); //pstlz - clienti_sap.set("PSTLZ", TVariant(workstring)); + clienti_sap.set("PSTLZ", clienti_campo.get(CLI_CAPCF)); //pstlz - workstring = clienti_campo.get(CLI_STATOCF).as_string(); //land1 - clienti_sap.set("LAND1", TVariant(workstring)); + clienti_sap.set("LAND1", clienti_campo.get(CLI_STATOCF)); //land1 - workstring = com_rec.get(COM_PROVCOM); //regio - clienti_sap.set("REGIO", TVariant(workstring)); + clienti_sap.set("REGIO", TVariant(com_rec.get(COM_PROVCOM))); //regio - workstring = clienti_campo.get(CLI_CODLIN).as_string(); //spras - clienti_sap.set("SPRAS", TVariant(workstring)); + clienti_sap.set("SPRAS", clienti_campo.get(CLI_CODLIN)); //spras - workstring = clienti_campo.get(CLI_PTELEX).as_string(); //telx1 - workstring << clienti_campo.get(CLI_TELEX).as_string(); - clienti_sap.set("TELX1", TVariant(workstring)); + ws = clienti_campo.get(CLI_PTELEX).as_string(); //telx1 + ws << clienti_campo.get(CLI_TELEX).as_string(); + clienti_sap.set("TELX1", TVariant(ws)); - workstring = clienti_campo.get(CLI_PTEL).as_string(); //telf1 - workstring << clienti_campo.get(CLI_TEL).as_string(); - clienti_sap.set("TELF1", TVariant(workstring)); + ws = clienti_campo.get(CLI_PTEL).as_string(); //telf1 + ws << clienti_campo.get(CLI_TEL).as_string(); + clienti_sap.set("TELF1", TVariant(ws)); - workstring = clienti_campo.get(CLI_PFAX).as_string(); //telfx - workstring << clienti_campo.get(CLI_FAX).as_string(); - clienti_sap.set("TELFX", TVariant(workstring)); + ws = clienti_campo.get(CLI_PFAX).as_string(); //telfx + ws << clienti_campo.get(CLI_FAX).as_string(); + clienti_sap.set("TELFX", TVariant(ws)); - workstring = clienti_campo.get(CLI_PTEL2).as_string(); //telf2 - workstring << clienti_campo.get(CLI_TEL2).as_string(); - clienti_sap.set("TELF2", TVariant(workstring)); - - workstring = clienti_campo.get(CLI_COFI).as_string(); //stcd1 - clienti_sap.set("STCD1", TVariant(workstring)); - - if (is_cofi(workstring)) //stkzn + ws = clienti_campo.get(CLI_PTEL2).as_string(); //telf2 + ws << clienti_campo.get(CLI_TEL2).as_string(); + clienti_sap.set("TELF2", TVariant(ws)); + + ws = clienti_campo.get(CLI_COFI).as_string(); + clienti_sap.set("STCD1", TVariant(ws)); //stcd1 + + if (is_cofi(ws)) //stkzn clienti_sap.set("STKZN", TVariant("X")); - workstring = clienti_campo.get(CLI_STATOPAIV).as_string(); //stceg - workstring << clienti_campo.get(CLI_PAIV).as_string(); - clienti_sap.set("STCEG", TVariant(workstring)); + ws = clienti_campo.get(CLI_STATOPAIV).as_string(); //stceg + ws << clienti_campo.get(CLI_PAIV).as_string(); + clienti_sap.set("STCEG", TVariant(ws)); - if (conto == 8 || conto == 9) //akont - clienti_sap.set("AKONT", TVariant("8/9")); + ws = clienti_campo.get(CLI_CODPAG).as_string(); //zterm + TString* codpag = (TString*)_codpag_c.objptr(ws); + if (codpag == NULL) //deve gestire la condpag assente + ws = "R007"; else - clienti_sap.set("AKONT", TVariant("7")); + ws = *codpag; + clienti_sap.set("ZTERM", TVariant(ws)); - workstring = clienti_campo.get(CLI_CODPAG).as_string(); //zterm - TString* codpag = (TString*)_codpag.objptr(workstring); - if (codpag == NULL) - workstring = "R000"; + if (ws == "R000") //zwels + clienti_sap.set("ZWELS", TVariant("2")); else - workstring = *codpag; - clienti_sap.set("ZTERM", TVariant(workstring)); + clienti_sap.set("ZWELS", TVariant("D")); + + clienti_sap.set("EIKTO", clienti_campo.get(CLI_CODCF)); //eikto - clienti_sap.set("ZWELS", TVariant("D")); //zwels - - workstring = clienti_campo.get(CLI_CODCF).as_string(); //eikto - clienti_sap.set("EIKTO", TVariant(workstring)); - } + } //for(move_first().. //scrivitore in formato xls clienti_sap.save_as(path, fmt_silk); @@ -272,31 +449,372 @@ void TEsporta_SAP_app::esporta_clienti(const TString& path) const } -void TEsporta_SAP_app::esporta_fornitori(const TString& path) const +//Fornitori +const TString& TEsporta_SAP_app::find_dencom_nasc(TString& codcom) const { + TToken_string key; + key.add(" "); + key.add(codcom); + return cache().get(LF_COMUNI, key, COM_DENCOM); } -void TEsporta_SAP_app::esporta_partite(const TString& path) const +void TEsporta_SAP_app::esporta_fornitori(const TString& path) const { + TString query; + query << "USE CLIFO"; + query << "\nFROM TIPOCF='F'"; + query << "\nTO TIPOCF='F'"; + TISAM_recordset fornitori_campo(query); + + TEsporta_SAP_fornitori_recordset fornitori_sap; + + const int cazzoni = fornitori_campo.items(); + TProgind pi(cazzoni, "Trasferimento fornitori...", true, true); + TString ws; + for (bool ok = fornitori_campo.move_first(); ok; ok = fornitori_campo.move_next()) + { + if (!pi.addstatus(1)) + break; + + const long codcf = fornitori_campo.get(CLI_CODCF).as_int(); + if (!check_clifo('F', codcf)) + continue; + + //creazione di un nuovo record di tipo fornitori.. + fornitori_sap.new_rec(); + //..e successivo riempimento + fornitori_sap.set("ACCVE", codcf); //codcf + + const long conto = fornitori_campo.get(CLI_CONTO).as_int(); //account e recon + switch (conto) + { + case 1: + fornitori_sap.set("ACCOUNT", TVariant("Z009")); + fornitori_sap.set("RECON", TVariant("40001000")); + break; + case 2: + fornitori_sap.set("ACCOUNT", TVariant("Z003")); + if (fornitori_campo.get(CLI_OCCAS).as_bool()) + fornitori_sap.set("RECON", TVariant("43009006")); + else + fornitori_sap.set("RECON", TVariant("43009051")); + break; + case 3: + fornitori_sap.set("ACCOUNT", TVariant("Z007")); + fornitori_sap.set("RECON", TVariant("40001001")); + break; + case 13: + fornitori_sap.set("ACCOUNT", TVariant("Z001")); + fornitori_sap.set("RECON", TVariant("40001000")); + break; + default: + fornitori_sap.set("ACCOUNT", TVariant("")); + fornitori_sap.set("RECON", TVariant("")); + break; + } + + fornitori_sap.set("NAME1", fornitori_campo.get(CLI_RAGSOC)); //name1 e name2 + + fornitori_sap.set("STREET", fornitori_campo.get(CLI_INDCF)); //street + + fornitori_sap.set("HOUSEN", fornitori_campo.get(CLI_CIVCF)); //housen + + //pocci su comune localita' provincia + const TRectype& com_rec = find_comune(fornitori_campo); + + fornitori_sap.set("DISTR", fornitori_campo.get(CLI_LOCCF)); //distr + + fornitori_sap.set("ZIP", fornitori_campo.get(CLI_CAPCF)); //zip + + fornitori_sap.set("CITY", TVariant(com_rec.get(COM_DENCOM))); //city + + fornitori_sap.set("COUNTRY", fornitori_campo.get(CLI_STATOCF)); //country + + fornitori_sap.set("REGION", TVariant(com_rec.get(COM_PROVCOM))); //region + + fornitori_sap.set("LANG", fornitori_campo.get(CLI_CODLIN)); //lang + + ws = fornitori_campo.get(CLI_PTEL).as_string(); //tel + ws << fornitori_campo.get(CLI_TEL).as_string(); + fornitori_sap.set("TEL", TVariant(ws)); + + ws = fornitori_campo.get(CLI_PTEL2).as_string(); //tel2 + ws << fornitori_campo.get(CLI_TEL2).as_string(); + fornitori_sap.set("TEL2", TVariant(ws)); + + ws = fornitori_campo.get(CLI_PFAX).as_string(); //fax + ws << fornitori_campo.get(CLI_FAX).as_string(); + fornitori_sap.set("FAX", TVariant(ws)); + + ws = fornitori_campo.get(CLI_COFI).as_string(); //taxc1 + fornitori_sap.set("TAXC1", TVariant(ws)); + + //pocci per le persone fisiche (luogo e data nascita, sesso ed amenita' simili) + if (is_cofi(ws)) + { + fornitori_sap.set("TIPOP", TVariant("X")); //tipop + + ws = fornitori_campo.get(CLI_CODANAGPER).as_string(); + const TRectype& anafis_rec = cache().get(LF_ANAGFIS, ws); + if (anafis_rec.get(ANF_SESSO) == "M") //sex + fornitori_sap.set("SEX", TVariant("1")); + else + fornitori_sap.set("SEX", TVariant("2")); + + ws = fornitori_campo.get(CLI_COMNASC).as_string(); //birthl + //se il luogo di nascita e' nel file clifo... + if (ws.full()) + ws = find_dencom_nasc(ws); + //..senno' puo' essere in anagrafica persone fisiche + else + { + ws = anafis_rec.get(ANF_COMNASC); + if (ws.full()) + ws = find_dencom_nasc(ws); + } + fornitori_sap.set("BIRTHL", TVariant(ws)); + + TDate datanasc = fornitori_campo.get(CLI_DATANASC).as_date(); //birthd + //se la data di nascita non e' nel clifo puo' essere in anagrafica persone fisiche + if (datanasc.empty()) + datanasc = anafis_rec.get_date(ANF_DATANASC); + fornitori_sap.set("BIRTHD", TVariant(datanasc)); + + } //if(is_cofi(... + + ws = fornitori_campo.get(CLI_STATOPAIV).as_string(); //vatrn + ws << fornitori_campo.get(CLI_PAIV).as_string(); + fornitori_sap.set("VATRN", TVariant(ws)); + +/* ws = fornitori_campo.get(CLI_CODABI).as_string(); //bankk + ws << fornitori_campo.get(CLI_CODCAB).as_string(); + fornitori_sap.set("BANKK", TVariant(ws)); + + fornitori_sap.set("BANKA", fornitori_campo.get(CLI_NUMCC));*/ //banka + + ws = fornitori_campo.get(CLI_CODPAG).as_string(); //paytr e paymt + TToken_string* codpag = (TToken_string*)_codpag_f.objptr(ws); + if(codpag != NULL) + { + fornitori_sap.set("PAYTR", TVariant(codpag->get(0))); + fornitori_sap.set("PAYMT", TVariant(codpag->get(1))); + } + else //il codice non esiste in tabella! + { + fornitori_sap.set("PAYTR", TVariant("")); + fornitori_sap.set("PAYMT", TVariant("")); + } + + } //for(move_first().. + + //scrivitore in formato xls + fornitori_sap.save_as(path, fmt_silk); +#ifdef DBG + xvt_sys_goto_url(path, "open"); +#endif } + +const TString& TEsporta_SAP_app::format_data(const TDate& data) const +{ + TString& ws = get_tmp_string(); + //nuovo modo + ws.format("%02d%02d%04d", data.day(), data.month(), data.year()); + return ws; +} + +const TString& TEsporta_SAP_app::trova_il_codsap(const char tipo, const char sezione) const +{ + TString& ws = get_tmp_string(); + if (tipo == 'C') + { + if (sezione == 'A') + ws = "04"; + else + ws = "50"; + } + else + { + if (sezione == 'A') + ws = "34"; + else + ws = "40"; + } + return ws; +} + +//Partite +void TEsporta_SAP_app::esporta_partite(const TMask& msk, const char tipo) const +{ + TString query; + query << "USE PART"; + query << "\nSELECT CHIUSA!=\"X\""; + if (tipo == 'C') + { + query << "\nFROM TIPOC=C"; + query << "\nTO TIPOC=C"; + } + else + { + query << "\nFROM TIPOC=F"; + query << "\nTO TIPOC=F"; + } + + TISAM_recordset partite_campo(query); + + TEsporta_SAP_partite_recordset partite_sap; + + const int cazzoni = partite_campo.items(); + TProgind pi(cazzoni, "Trasferimento partite...", true, true); + TString ws; + TDate data; + TVariant datadoc, numdoc, descr, datareg; + for (bool ok = partite_campo.move_first(); ok; ok = partite_campo.move_next()) + { + if (!pi.addstatus(1)) + break; + + long nriga = partite_campo.get(PART_NRIGA).as_int(); + if (nriga < 9999) + { + if (partite_campo.get(PART_TIPOMOV).as_int() == 1) + { + datadoc = partite_campo.get(PART_DATADOC); + numdoc = partite_campo.get(PART_NUMDOC); + descr = partite_campo.get(PART_DESCR); + + datareg = partite_campo.get(PART_DATAREG); + } + } + else //e' la riga saldo + { + //creazione di un nuovo record di tipo partite.. + //record tipo BBKPF+BBSEG(1)+BBSEG(2) + partite_sap.new_rec(""); + + data = datadoc.as_date(); + ws = format_data(data); + partite_sap.set("BLDAT", TVariant(ws)); + partite_sap.set("BLART", TVariant(tipo == 'C' ? "CA" : "V1")); + data = msk.get_date(F_TODAY); + ws = format_data(data); + partite_sap.set("BUDAT", TVariant(ws)); + partite_sap.set("XBLNR", numdoc); + partite_sap.set("BKTXT", TVariant(tipo == 'C' ? "CONV. P.A. CLIENTI" : "CONV. P.A. FORNITORI")); + + + const char sezione = partite_campo.get(PART_SEZ).as_string()[0]; + + //ws = trova_il_codsap(tipo, sezione); + partite_sap.set("NEWBS", TVariant(tipo == 'C' ? "04" : "34")); + //ws = trova_il_codsap(tipo, sezione == 'A' ? 'D' : 'A'); + partite_sap.set("ZNEWBS", TVariant(tipo == 'C' ? "50" : "40")); + + partite_sap.set("NEWKO", partite_campo.get(PART_SOTTOCONTO)); + partite_sap.set("ZNEWKO", TVariant(tipo == 'C' ? "48999998" : "48999999")); + + ws = partite_campo.get(PART_IMPORTO).as_string(); + ws.replace('.', ','); + partite_sap.set("WRBTR", TVariant(ws)); + partite_sap.set("ZWRBTR", TVariant(ws)); + + + data = datareg.as_date(); + ws = format_data(data); + partite_sap.set("ZFBDT", TVariant(ws)); + + partite_sap.set("SGTXT", descr); + partite_sap.set("ZSGTXT", descr); + + } //else di if(nriga<9999... + } //for(move_first().. + + + //scrivitore in formato xls + TString path; + if (tipo == 'C') + path = msk.get(F_PARTFILEC); + else + path = msk.get(F_PARTFILEF); + + partite_sap.save_as(path, fmt_silk); +#ifdef DBG + xvt_sys_goto_url(path, "open"); +/* + //se volessimo il report... + TAS400_report rep(partite_sap); + TReport_book book; + book.add(rep); + book.preview();*/ +#endif +} + + + void TEsporta_SAP_app::main_loop() { - //crea tabella trascodifica - _codpag.add("BB", new TString("R000")); - _codpag.add("B09", new TString("R002")); - _codpag.add("B01", new TString("R003")); - _codpag.add("BB09", new TString("R004")); - _codpag.add("B05", new TString("R004")); - _codpag.add("B07", new TString("R005")); - _codpag.add("B03", new TString("R007")); - _codpag.add("B04", new TString("R007")); - _codpag.add("B11", new TString("R007")); - _codpag.add("BB30", new TString("R007")); - _codpag.add("B08", new TString("R009")); - _codpag.add("BB60", new TString("R009")); - _codpag.add("B10", new TString("R010")); - _codpag.add("BB90", new TString("R010")); + open_files(LF_CLIFO, LF_MOV, LF_PARTITE, LF_COMUNI, 0); + + //crea tabella trascodifica clienti + //condizione di pagamento + _codpag_c.add("BB", new TString("R000")); + _codpag_c.add("B09", new TString("R002")); + _codpag_c.add("B01", new TString("R003")); + _codpag_c.add("BB09", new TString("R004")); + _codpag_c.add("B05", new TString("R004")); + _codpag_c.add("B07", new TString("R005")); + _codpag_c.add("B03", new TString("R007")); + _codpag_c.add("B04", new TString("R007")); + _codpag_c.add("B11", new TString("R007")); + _codpag_c.add("BB30", new TString("R007")); + _codpag_c.add("B08", new TString("R009")); + _codpag_c.add("BB60", new TString("R009")); + _codpag_c.add("B10", new TString("R010")); + _codpag_c.add("BB90", new TString("R010")); + + //crea tabella trascodifica fornitori + _codpag_f.add("BB", new TToken_string("P000|E")); + _codpag_f.add("RB", new TToken_string("P000|I")); + _codpag_f.add("RD", new TToken_string("P000|G")); + _codpag_f.add("RD0", new TToken_string("P000|G")); + _codpag_f.add("RD1", new TToken_string("P000|G")); + _codpag_f.add("RID", new TToken_string("P000|G")); + _codpag_f.add("", new TToken_string("P000|O")); //pagamento in contanti + _codpag_f.add("B09", new TToken_string("P002|E")); + _codpag_f.add("RB4", new TToken_string("P002|I")); + _codpag_f.add("RD03", new TToken_string("P002|G")); + _codpag_f.add("RD8", new TToken_string("P002|G")); + _codpag_f.add("B01", new TToken_string("P003|E")); + _codpag_f.add("RB5", new TToken_string("P003|I")); + _codpag_f.add("RD7", new TToken_string("P003|G")); + _codpag_f.add("BB09", new TToken_string("P004|E")); + _codpag_f.add("RB09", new TToken_string("P004|I")); + _codpag_f.add("RB7", new TToken_string("P004|I")); + _codpag_f.add("RB9", new TToken_string("P004|I")); + _codpag_f.add("RD10", new TToken_string("P004|G")); + _codpag_f.add("RD90", new TToken_string("P004|G")); + _codpag_f.add("RDD", new TToken_string("P004|G")); + _codpag_f.add("B07", new TToken_string("P005|E")); + _codpag_f.add("RBA", new TToken_string("P005|I")); + _codpag_f.add("RDE", new TToken_string("P005|G")); + _codpag_f.add("B03", new TToken_string("P007|E")); + _codpag_f.add("B04", new TToken_string("P007|E")); + _codpag_f.add("B11", new TToken_string("P007|E")); + _codpag_f.add("BB30", new TToken_string("P007|E")); + _codpag_f.add("RB3", new TToken_string("P007|I")); + _codpag_f.add("RD2", new TToken_string("P007|G")); + _codpag_f.add("RD30", new TToken_string("P007|G")); + _codpag_f.add("B08", new TToken_string("P009|E")); + _codpag_f.add("BB60", new TToken_string("P009|E")); + _codpag_f.add("RB6", new TToken_string("P009|I")); + _codpag_f.add("RD3", new TToken_string("P009|G")); + _codpag_f.add("RD60", new TToken_string("P009|G")); + _codpag_f.add("B10", new TToken_string("P047|E")); + _codpag_f.add("BB90", new TToken_string("P047|E")); + _codpag_f.add("RB61", new TToken_string("P047|I")); + _codpag_f.add("RD4", new TToken_string("P047|G")); + _codpag_f.add("RD41", new TToken_string("P048|G")); + TEsporta_SAP_mask m; @@ -306,8 +824,22 @@ void TEsporta_SAP_app::main_loop() esporta_clienti(m.get(F_CLIFILE)); if (m.get_bool(F_FORNITORI)) esporta_fornitori(m.get(F_FORNFILE)); - if (m.get_bool(F_PARTITE)) - esporta_partite(m.get(F_PARTFILE)); + + if (m.get_bool(F_PARTITEC)) + { + esporta_partite(m, 'C'); + m.set(F_LASTDATAC, m.get(F_TODAY)); + m.set(F_LASTNUMC, m.get(F_NEXTNUMC)); + } + if (m.get_bool(F_PARTITEF)) + { + esporta_partite(m, 'F'); + m.set(F_LASTDATAF, m.get(F_TODAY)); + m.set(F_LASTNUMF, m.get(F_NEXTNUMF)); + } + + + } } diff --git a/ps/pd0666100a.h b/ps/pd0666100a.h index dfc75ba8c..e79a2fb72 100755 --- a/ps/pd0666100a.h +++ b/ps/pd0666100a.h @@ -2,5 +2,17 @@ #define F_CLIFILE 102 #define F_FORNITORI 103 #define F_FORNFILE 104 -#define F_PARTITE 105 -#define F_PARTFILE 106 + +#define F_PARTITEC 105 +#define F_PARTFILEC 106 +#define F_LASTDATAC 107 +#define F_LASTNUMC 108 +#define F_NEXTNUMC 109 + +#define F_PARTITEF 110 +#define F_PARTFILEF 111 +#define F_LASTDATAF 112 +#define F_LASTNUMF 113 +#define F_NEXTNUMF 114 + +#define F_TODAY 115 diff --git a/ps/pd0666100a.uml b/ps/pd0666100a.uml index 958bc3a45..f154902fb 100755 --- a/ps/pd0666100a.uml +++ b/ps/pd0666100a.uml @@ -1,56 +1,119 @@ #include "pd0666100a.h" -PAGE "Trasferimento a SAP per Medicasa" -1 -1 72 12 +PAGE "Trasferimento a SAP per Medicasa" -1 -1 72 19 -GROUPBOX DLG_NULL 70 4 +GROUPBOX DLG_NULL 71 4 BEGIN - PROMPT 1 1 "@bEsportazione clenti / fornitori" + PROMPT 1 2 "@bEsportazione clenti / fornitori" END BOOLEAN F_CLIENTI BEGIN - PROMPT 2 2 "Clienti" + PROMPT 2 3 "Clienti" MESSAGE FALSE DISABLE,F_CLIFILE MESSAGE TRUE ENABLE,F_CLIFILE END STRING F_CLIFILE 128 50 BEGIN - PROMPT 14 2 "File " + PROMPT 14 3 "File " CHECKTYPE REQUIRED + FIELD CLIFILE END BOOLEAN F_FORNITORI BEGIN - PROMPT 2 3 "Fornitori" + PROMPT 2 4 "Fornitori" MESSAGE FALSE DISABLE,F_FORNFILE MESSAGE TRUE ENABLE,F_FORNFILE END STRING F_FORNFILE 128 50 BEGIN - PROMPT 14 3 "File " + PROMPT 14 4 "File " CHECKTYPE REQUIRED + FIELD FORNFILE END -GROUPBOX DLG_NULL 70 4 +GROUPBOX DLG_NULL 71 10 BEGIN - PROMPT 1 5 "@bEsportazione partite" + PROMPT 1 6 "@bEsportazione partite" END -BOOLEAN F_PARTITE +BOOLEAN F_PARTITEC BEGIN - PROMPT 2 6 "Partite" - MESSAGE FALSE DISABLE,F_PARTFILE - MESSAGE TRUE ENABLE,F_PARTFILE + PROMPT 2 7 "Partite clienti " + MESSAGE FALSE DISABLE,F_PARTFILEC + MESSAGE TRUE ENABLE,F_PARTFILEC END -STRING F_PARTFILE 128 50 +STRING F_PARTFILEC 128 40 BEGIN - PROMPT 14 6 "File " + PROMPT 24 7 "File " CHECKTYPE REQUIRED + FIELD PARTFILEC END +DATE F_LASTDATAC +BEGIN + PROMPT 2 8 "Data ultimo invio " + FLAGS "D" + FIELD LASTDATAC +END + +NUMBER F_LASTNUMC 3 +BEGIN + PROMPT 40 8 "Numero ultimo invio " + FLAGS "D" + FIELD LASTNUMC +END + +NUMBER F_NEXTNUMC 3 +BEGIN + PROMPT 2 9 "Numero invio da effettuare " +END + +BOOLEAN F_PARTITEF +BEGIN + PROMPT 2 12 "Partite fornitori " + MESSAGE FALSE DISABLE,F_PARTFILEF + MESSAGE TRUE ENABLE,F_PARTFILEF +END + +STRING F_PARTFILEF 128 40 +BEGIN + PROMPT 24 12 "File " + CHECKTYPE REQUIRED + FIELD PARTFILEF +END + +DATE F_LASTDATAF +BEGIN + PROMPT 2 13 "Data ultimo invio " + FLAGS "D" + FIELD LASTDATAF +END + +NUMBER F_LASTNUMF 3 +BEGIN + PROMPT 40 13 "Numero ultimo invio " + FLAGS "D" + FIELD LASTNUMF +END + +NUMBER F_NEXTNUMF 3 +BEGIN + PROMPT 2 14 "Numero invio da effettuare " +END + + +DATE F_TODAY +BEGIN + PROMPT 2 16 "Data invio da effettuare " + FLAGS "A" +END + + BUTTON DLG_ELABORA 10 2 BEGIN PROMPT -12 -1 "" diff --git a/ps/pd0666conf.ini b/ps/pd0666conf.ini index 7014b5844..1ee89ffbc 100755 --- a/ps/pd0666conf.ini +++ b/ps/pd0666conf.ini @@ -1,4 +1,9 @@ [MAIN] -PATH = C:\temp\ -FILE = -LASTDATA = +CLIFILE = +FORNFILE = +LASTDATAC = +LASTDATAF = +LASTNUMC = +LASTNUMF = +PARTFILEC = +PARTFILEF = diff --git a/ps/pg0001.cpp b/ps/pg0001.cpp new file mode 100755 index 000000000..8f678c822 --- /dev/null +++ b/ps/pg0001.cpp @@ -0,0 +1,19 @@ +#include + +#include "pg0001.h" + +int main(int argc, char** argv) +{ + int n = argc > 1 ? atoi(argv[1]+1) : 0; + switch(n) + { + case 1: + pg0001200(argc, argv); break; //ricezione movimenti da .... e invio a TS (SIPAG) + case 0: + default: + // pg0001100(argc, argv); + break; //ricezione fatture da paghe (SIPAG) + } + exit(0); + return 0; +} \ No newline at end of file diff --git a/ps/pg0001.h b/ps/pg0001.h new file mode 100755 index 000000000..f4bddae3e --- /dev/null +++ b/ps/pg0001.h @@ -0,0 +1,2 @@ +int pg0001100(int argc, char* argv[]); +int pg0001200(int argc, char* argv[]); diff --git a/ps/pg0001100.cpp b/ps/pg0001100.cpp new file mode 100755 index 000000000..926c6a90f --- /dev/null +++ b/ps/pg0001100.cpp @@ -0,0 +1,283 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "pg0001.h" +#include "pg0001100a.h" + +#include "textset.h" + + +#include "clifo.h" +#include "comuni.h" +#include "doc.h" +#include "rdoc.h" + +#include "..\cg\cglib01.h" +#include "..\ve\velib.h" + + +/////////////////////////////////////////////////////////// +// TPaghe_textset +/////////////////////////////////////////////////////////// + +class TPaghe_recset : public TAS400_recordset +{ + TAssoc_array _index; + +protected: + void add_field(const char* name = "Filler", char tipo = 'a', int len = 0, int from = -1, + const char* def = NULL); + +public: + TPaghe_recset(const char * query); +}; + +void TPaghe_recset::add_field(const char* name, char tipo, int len, int from, + const char* def) +{ + const bool required = false; + const TFieldtypes t = tipo == 'n' ? _longzerofld : _alfafld; + const int pos = from - 1; + if (def && *def) + { + CHECKS(def == NULL || (int)strlen(def) <= len, "Invalid default value ", def); + TVariant var(def); var.convert_to(t); + create_field(name, pos, len, t, required, var); + } + else + create_field(name, pos, len, t, required); +} + + +TPaghe_recset::TPaghe_recset(const char * query) + : TAS400_recordset(TString("AS400(221)\n") << query) +{ + const char a = 'a'; + const char n = 'n'; + const bool o = true; + const bool f = false; + + add_field("CLA01", n, 4, 1); + add_field("CLM01", n, 2, 5); + add_field("CLAZI", n, 9, 7); + add_field("CLF01", a, 4, 16); + add_field("CLCZN", a, 1, 20); + add_field("CLCTR", a, 4, 21); + add_field("CLNCD", n, 3, 25); + add_field("CLILR", n, 11,28); + add_field("CLTEL", a, 1, 39); + add_field("CLANN", a, 1, 40); + add_field("CLDTC", n, 6, 41); + add_field("CLA02", n, 4, 47); + add_field("CLM02", n, 2, 51); + add_field("CLAZ1", n, 9, 53); + add_field("CLPRG", n, 6, 62); + add_field("CLDTV", n, 6, 68); + add_field("CLF02", a, 3, 74); + add_field("CLCDQ", a, 4, 77); + add_field("CLCF1", n, 9, 81); + add_field("CLCF2", n, 9, 90); + add_field("CLCLC", n, 11,99); + add_field("CLRTN", n, 9, 110); + add_field("CLFAT", a, 1, 119); + add_field("CLFSP", a, 1, 120); + add_field("CLTPL", a, 2, 121); +} + +// TAutomask + +class TPaghe2Doc_mask : public TAutomask +{ +protected: + bool on_field_event(TOperable_field& o, TField_event e, long jolly); +public: + TPaghe2Doc_mask(); + virtual ~TPaghe2Doc_mask(){}; +}; + +TPaghe2Doc_mask::TPaghe2Doc_mask() :TAutomask ("pg0001100a") +{ +} + +bool TPaghe2Doc_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) +{ + return TRUE; +} + +HIDDEN bool browse_file_handler(TMask_field& f, KEY k) +{ + if (k == K_F9) + { + FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC)); + strcpy(fs.type, ""); + strcpy(fs.name, f.get()); + xvt_fsys_get_default_dir(&fs.dir); + xvt_fsys_save_dir(); + if (xvt_dm_post_file_open(&fs, TR("Selezione file")) == FL_OK) + { + TFilename n; + xvt_fsys_convert_dir_to_str(&fs.dir, n.get_buffer(n.size()), n.size()); + n.add(fs.name); + f.set(n); + } + xvt_fsys_restore_dir(); + f.set_focus(); + } + + return TRUE; +} + +/////////////////////////////////////////////////////////// +// TPaghe2Doc application +/////////////////////////////////////////////////////////// + +class TPaghe2Doc : public TSkeleton_application +{ + TPaghe2Doc_mask* _m; + TLog_report* _log; + bool _errors_logged; + +protected: + virtual TRecordset& pagheset(const TMask& m); + +public: + virtual bool create(); + virtual bool destroy(); + virtual void main_loop(); + void add_doc(const TRecordset& paghe); + + int get_numdoc(const TString& numdocrif, const TDate datadoc, const TString& _codnum, const TString& tipodoc, const long codcf); + //int add_riga_doc(TDocumento* doc, TConfig& config); + TPaghe2Doc() {} +}; + +TPaghe2Doc& app() { return (TPaghe2Doc&) main_app(); } + + +bool TPaghe2Doc::create() +{ + _m = new TPaghe2Doc_mask(); + _m->set_handler(F_INPATH, browse_file_handler); + return TSkeleton_application::create (); +} + +bool TPaghe2Doc::destroy() +{ + delete _m; + return TApplication::destroy(); +} + +void TPaghe2Doc::add_doc(const TRecordset& paghe) +{ + /* + TString msg; msg << TR("Registrazione n.") << ' ' << mov.get(MOV_NUMREG); + log(0, msg); + if (new_rec("0")) + { + char tipocf = mov.get(MOV_TIPO).as_string()[0]; + long codcf = mov.get(MOV_CODCF).as_int(); + + add_clifor(tipocf, codcf); + add_header(mov); + + const bool moviva = !mov.get(MOV_REG).is_empty(); + + if (moviva) + { + add_datiiva(mov); + add_tot_fattura(mov); + add_conti_ricavo_costo(mov); + } + add_ratei_risconti(mov); // Non ce li abbiamo micca! + add_ulteriori(mov); + add_diversi(mov, moviva); + } + */ +} + +TRecordset& TPaghe2Doc::pagheset(const TMask& m) +{ + TString query("SELECT * FROM "); + TFilename name = m.get(F_INPATH); + name.add(m.get(F_INFILE)); + query << name; + TRecordset* paghe = new TPaghe_recset(query); + return *paghe; +} + +void TPaghe2Doc::main_loop() +{ + KEY tasto; + tasto = _m->run(); + if (tasto == K_ENTER) + { + const char* const title = TR("Importazione documenti da paghe"); + _log = new TLog_report(title); + _errors_logged = false; + TRecordset& paghe = pagheset(*_m); + TProgind pi(paghe.items(), TR("Scansione registrazioni"), true, true); + + TConfig* docum=NULL; + TDocumento* doc=NULL; + + bool error = false; + int ntransac=0; // numero trasnsazione per creare file .ini + int nriga=0; // numero riga doc. + int oldanno = -1; + int oldmese = -1; + long oldcodcf = -1; + for (bool ok = paghe.move_first(); ok; ok = paghe.move_next()) + { + if (!pi.addstatus(1)) + break; + const int annocomp = paghe.get("CLA01").as_int(); + const int mesecomp = paghe.get("CLM01").as_int(); + const long codcf = paghe.get("CLAZI").as_int(); + if ((annocomp != oldanno) || (mesecomp != oldmese) || (codcf != oldcodcf)) + { + if (docum != NULL) + { + delete docum; + docum = NULL; + } + if (error) // cancello il file perch'e la transazione non e' andata bene + { + TFilename pgfile; pgfile.tempdir(); + pgfile.add(format("pg000%03d.ini",ntransac)); + if (pgfile.exist()) + remove_file(pgfile); + } + error = false; + //add_testata(paghe); + } + //add_riga(paghe); + } + TReport_book book; + book.add(*_log); + book.preview(); + + bool save = true; + if (_errors_logged) + { + save = yesno_box(TR("Sono stati riscontrati uno o piu' errori:\n" + "Si desidera creare i documenti ugualmente?")); + } + delete _log; + _log = NULL; + } +} + + +int pg0001100(int argc, char* argv[]) +{ + TPaghe2Doc app; + app.run(argc, argv, TR("Ricezione fatture da paghe")); + return TRUE; +} + + diff --git a/ps/pg0001100a.h b/ps/pg0001100a.h new file mode 100755 index 000000000..f4dbb5c6a --- /dev/null +++ b/ps/pg0001100a.h @@ -0,0 +1,6 @@ +// documenti da paghe + +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_INPATH 103 +#define F_INFILE 104 diff --git a/ps/pg0001100a.uml b/ps/pg0001100a.uml new file mode 100755 index 000000000..b1f70568e --- /dev/null +++ b/ps/pg0001100a.uml @@ -0,0 +1,57 @@ +#include "pg0001100a.h" + +PAGE "Importazione documenti da paghe" -1 -1 78 20 + +GROUPBOX DLG_NULL 76 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 76 5 +BEGIN + PROMPT 2 4 "Sorgente" +END + +STRING F_INPATH 256 39 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD PagheInPath +END + +STRING F_INFILE 18 +BEGIN + PROMPT 3 6 "File " + FIELD PagheInFile +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK diff --git a/ps/pg0001200.cpp b/ps/pg0001200.cpp new file mode 100755 index 000000000..6fd7e4b46 --- /dev/null +++ b/ps/pg0001200.cpp @@ -0,0 +1,941 @@ +#include "pg0001.h" +#include "pg0001200a.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "..\tc\tc0700.h" + +/////////////////////////////////////////////////////////// +// TClifo_recset +/////////////////////////////////////////////////////////// + +class TClifo_recset : public TAS400_recordset +{ + TAssoc_array _index; + +protected: + void add_field(const char* name = "Filler", int from = -1, char tipo = 'a', + int len = 0, const char* def = NULL); + +public: + bool find(char tipocf, long codcf); + + TClifo_recset(const char * query); +}; + +void TClifo_recset::add_field(const char* name, int from, char tipo, int len, const char* def) +{ + const bool required = false; + const TFieldtypes t = tipo == 'n' ? _longzerofld : _alfafld; + const int pos = from - 1; + if (def && *def) + { + CHECKS(def == NULL || (int)strlen(def) <= len, "Invalid default value ", def); + TVariant var(def); var.convert_to(t); + create_field(name, pos, len, t, required, var); + } + else + create_field(name, pos, len, t, required); +} + + +TClifo_recset::TClifo_recset(const char * query) + : TAS400_recordset(TString("AS400(213)\n") << query) +{ + const char a = 'a'; + const char n = 'n'; + const bool o = true; + const bool f = false; + + add_field(CLI_TIPOCF, 1, a, 1); + add_field(CLI_CODCF, 2, n, 6); + add_field("LIBERO", 8, a, 10); + add_field(CLI_RAGSOC, 18, a, 50); + add_field(CLI_INDCF, 68, a, 30); + add_field(CLI_CAPCF, 98, n, 5); + add_field(CLI_LOCCF, 103, a, 25); + add_field("PROV", 128, a, 2); + add_field("LIBERO2", 130, a, 9); + add_field(CLI_COFI, 139, a, 16); + add_field("LIBERO3", 155, a, 35); + add_field(CLI_PAIV, 190, a, 11); + add_field("FINE-RECORD", 211, a, 2, "\r\n"); // terminatore record + + TString16 pos, key; + + for (bool ok = move_first(); ok; ok = move_next()) + { + pos.format("%ld", current_row()); + key.format("%c|%ld", get(CLI_TIPOCF).as_string()[0], get(CLI_CODCF).as_int()); + + _index.add(key, pos); + } +} + +bool TClifo_recset::find(char tipocf, long codcf) +{ + TString16 key; + + key.format("%c|%ld", tipocf, codcf); + + TString * s = (TString *) _index.objptr(key); + long pos = 0L; + const bool ok = s && s->full(); + + if (ok) + pos = atoi(*s); + move_to(pos); + return ok; +} + +class TMov_recset; + +/////////////////////////////////////////////////////////// +// TIVA_recset +/////////////////////////////////////////////////////////// + +class TIVA_recset : public TAS400_recordset +{ + + TRecnotype _first, _last; + long _numreg; + +private: + void add_field(const char* name = "Filler", int from = -1, char tipo = 'a', + int len = 0, const char* def = NULL); + +public: + bool find(long numreg); + virtual const TVariant& get(const char* column_name) const; + virtual bool move_to(TRecnotype pos); + + TIVA_recset(TMov_recset & mov); +}; + +/////////////////////////////////////////////////////////// +// TRMov_recset +/////////////////////////////////////////////////////////// + +class TRMov_recset : public TAS400_recordset +{ + TRecnotype _first, _last; + long _numreg; + +private: + void add_field(const char* name = "Filler", int from = -1, char tipo = 'a', + int len = 0, const char* def = NULL); + + +public: + bool find(long numreg); + virtual const TVariant& get(const char* column_name) const; + virtual bool move_to(TRecnotype pos); + + TRMov_recset(TMov_recset & mov); +}; + +/////////////////////////////////////////////////////////// +// TMov_recset +/////////////////////////////////////////////////////////// + +class TMov_recset : public TAS400_recordset +{ +protected: + void add_field(const char* name = "Filler", int from = -1, char tipo = 'a', + int len = 0, const char* def = NULL); + +public: + bool vendite() const { return get("TIPOR").as_int() == 2;} + bool acquisti() const { return !vendite();} + bool fattura() const { return get("TIPOM").as_int() == 0;} + bool nota_credito() const { return !fattura();} + virtual const TVariant& get(const char* column_name) const; + + TMov_recset(const char * query, TArray & recsets); +}; + +void TMov_recset::add_field(const char* name, int from, char tipo, int len, const char* def) +{ + const bool required = false; + const TFieldtypes t = tipo == 'n' ? _longzerofld : _alfafld; + const int pos = from - 1; + + if (def && *def) + { + CHECKS(def == NULL || (int)strlen(def) <= len, "Invalid default value ", def); + TVariant var(def); var.convert_to(t); + create_field(name, pos, len, t, required, var); + } + else + create_field(name, pos, len, t, required); +} + +const TVariant& TMov_recset::get(const char* column_name) const +{ + TString16 fname(column_name); + TVariant& var = get_tmp_var(); + + if (fname == MOV_TIPO) + { + var = vendite() ? "C" : "F"; + return var; + } + else + if (fname == MOV_REG) + { + var = vendite() ? "V00" : "A00"; + return var; + } + else + if (fname == MOV_CODCF) + { + if (vendite()) + fname = fattura() ? "S1" : "S2"; + else + fname = fattura() ? "S2" : "S1"; + } + else + if (fname == MOV_CODCAUS) + { + int ccaus; + + if (vendite()) + ccaus = fattura() ? 1 : 2; + else + ccaus = fattura() ? 11 : 12; + var.set(ccaus); + return var; + } + + var = TAS400_recordset::get(fname); + + if (fname == MOV_DATAREG || fname == MOV_DATADOC) + { + const TDate d(atol(var.as_string()) + 20000000L); + + var.set(d); + } + else + if (fname == MOV_TOTDOC || fname == RMI_IMPONIBILE || + fname == RMI_IMPOSTA) + { + const real r = var.as_real() / CENTO; + + var.set(r); + } + return var; +} + +TMov_recset::TMov_recset(const char * query, TArray & recsets) + : TAS400_recordset(TString("AS400(543)\n") << query) +{ + const char a = 'a'; + const char n = 'n'; + + add_field("TIPOR", 1, n, 1); + add_field("L00", 2, a, 6); + add_field("L01", 8, n, 1); + add_field("L02", 9, n, 4); + add_field("NUMREG", 13, n, 7); + add_field("L03", 20, n, 2); + add_field("PROG", 22, n, 1); + add_field("L04", 23, n, 2); + add_field("L05", 25, a, 2); + add_field(MOV_DATAREG, 27, a, 6); + add_field(MOV_DATADOC, 33, a, 6); + add_field("L07", 39, a, 1); + add_field(MOV_PROTIVA, 40, n, 7); + add_field(MOV_NUMDOC, 47, n, 9); + add_field("L08", 56, a, 6); + add_field("L09", 62, a, 1); + add_field(MOV_CODCAUS, 63, n, 2); + add_field(RMI_CODIVA, 65, n, 2); + add_field("TIPOM", 67, n, 1); + add_field("L10", 68, a, 18); + add_field("G1", 86, a, 2); + add_field("C1", 88, a, 2); + add_field("S1", 90, n, 7); + add_field("L11", 97, n, 6); + add_field("G2", 103, a, 2); + add_field("C2", 105, a, 2); + add_field("S2", 107, n, 7); + add_field("L12", 114, n, 6); + add_field("G3", 120, a, 2); + add_field("C3", 122, a, 2); + add_field("S3", 124, n, 7); + add_field("L13", 131, a, 152); + add_field("ANNO", 283, n, 4); + add_field("NUMDOC1", 287, a, 13); + add_field("L15", 300, a, 18); + add_field("CODICEE", 318, a, 1); + add_field("L16", 319, a, 29); + add_field("L17", 348, a, 20); + add_field("L18", 368, a, 68); + add_field("L19", 131, a, 152); + add_field("L20", 436, n, 1); + add_field("L21", 437, a, 24); + add_field("L22", 461, a, 39); + add_field("ANNULLATO", 500, a, 1); + add_field("L23", 501, a, 5); + add_field(RMI_IMPONIBILE, 506, n, 11); + add_field(RMI_IMPOSTA, 517, n, 9); + add_field(MOV_TOTDOC, 526, n, 11); + add_field("L24", 537, n, 5); + add_field("FINE-RECORD", 541, a, 2, "\r\n"); // terminatore record + + bool ok; + + for (ok = move_last(); ok;) + { + const int p = current_row(); + + if (get("ANNULLATO").as_string()[0] == 'A') + { + destroy(p); + if (p <= last()) + move_to(p); + else + move_last(); + } + else + ok = move_prev(); + } + + long numreg = 0L; + + for (ok = move_first(); ok; ok = move_next()) + { + if (get("PROG").as_int() == 1) + numreg++; + set(MOV_NUMREG, numreg); + } + + recsets.add(new TIVA_recset(*this), LF_RMOVIVA); + recsets.add(new TRMov_recset(*this), LF_RMOV); + + for (ok = move_last(); ok;) + { + const int p = current_row(); + + if (get("PROG").as_int() > 1) + { + destroy(p); + if (p <= last()) + move_to(p); + else + move_last(); + } + else + ok = move_prev(); + } +} + +/////////////////////////////////////////////////////////// +// TIVA_recset +/////////////////////////////////////////////////////////// + +void TIVA_recset::add_field(const char* name, int from, char tipo, int len, const char* def) +{ + const bool required = false; + const TFieldtypes t = tipo == 'n' ? _longzerofld : _alfafld; + const int pos = from - 1; + + if (def && *def) + { + CHECKS(def == NULL || (int)strlen(def) <= len, "Invalid default value ", def); + TVariant var(def); var.convert_to(t); + create_field(name, pos, len, t, required, var); + } + else + create_field(name, pos, len, t, required); +} + +bool TIVA_recset::find(long numreg) +{ + if (numreg != _numreg) + { + _first = _last = -1L; + + bool ok = false; + TRecnotype f = 0L, l = last(); + TRecnotype pos = f + (l - f) / 2; + + while (!ok && f <= l) + { + TAS400_recordset::move_to(pos); + + const long n = get(RMI_NUMREG).as_int(); + + if (n > numreg) + l = pos - 1; + else + if (n < numreg) + f = pos + 1; + else + { + f = pos; + ok = true; + } + pos = f + (l - f) / 2; + } + if (ok) + { + bool ok1 = TAS400_recordset::move_to(f); + + while (ok1 && numreg == get(RMV_NUMREG).as_int()) + { + f = current_row(); + ok1 = TAS400_recordset::move_prev(); + } + ok1 = TAS400_recordset::move_to(f); + while (ok1 && numreg == get(RMV_NUMREG).as_int()) + { + l = current_row(); + ok1 = TAS400_recordset::move_next(); + } + _first = f; + _last = l; + _numreg = numreg; + } + return ok; + } + return true; +} + +const TVariant& TIVA_recset::get(const char* column_name) const +{ + TString16 fname(column_name); + + if (fname == RMI_IMPONIBILE || fname == RMI_IMPOSTA) + { + TVariant& var = get_tmp_var(); + + var = TAS400_recordset::get(fname); + + const real r = var.as_real() / CENTO; + + var.set(r); + return var; + } + return TAS400_recordset::get(fname); +} + +bool TIVA_recset::move_to(TRecnotype pos) +{ + if (_first < 0L) + return TAS400_recordset::move_to(pos); + if (pos == 0L) + pos = _first; + if (pos <= _last) + return TAS400_recordset::move_to(pos); + return false; +} + +TIVA_recset::TIVA_recset(TMov_recset & mov) + :TAS400_recordset("AS400(60)\n"), + _first(-1L), _last(-1L), _numreg(-1L) +{ + const char a = 'a'; + const char n = 'n'; + TVariant var; + + add_field(RMI_NUMREG, 1, n, 7); + add_field(RMI_NUMRIG, 8, n, 3); + add_field(RMI_CODIVA, 11, n, 3); + add_field(RMI_IMPONIBILE, 14, n, 15); // 18 + add_field(RMI_IMPOSTA, 29, n, 15); // 18 + add_field(RMI_TIPODET, 44, n, 1); + add_field(RMI_TIPOCR, 45, n, 1); + add_field(RMI_INTRA, 46, a, 1); + add_field(RMI_TIPOATT, 47, n, 1); + add_field(RMI_TIPOC, 48, a, 1); + add_field(RMI_GRUPPO, 49, n, 3); + add_field(RMI_CONTO, 52, n, 3); // 18 + add_field(RMI_SOTTOCONTO, 55, n, 6); + TString4 fgr, fco, fso; + + for (bool ok = mov.move_first(); ok; ok = mov.move_next()) + { + new_rec(); + set(RMI_NUMREG, mov.get(MOV_NUMREG)); + set(RMI_NUMRIG, mov.get("PROG")); + + int civa = mov.get(RMI_CODIVA).as_int(); + + if (civa == 0) + civa = 310; + var.set(civa); + set(RMI_CODIVA, var); + set(RMI_IMPONIBILE, mov.TAS400_recordset::get(RMI_IMPONIBILE)); + set(RMI_IMPOSTA, mov.TAS400_recordset::get(RMI_IMPOSTA)); + if (mov.vendite()) + { + if (mov.fattura()) + { + fgr = "G2"; fco = "C2"; fso = "S2"; + } + else + { + fgr = "G1"; fco = "C1"; fso = "S1"; + } + } + else + { + if (mov.fattura()) + { + fgr = "G1"; fco = "C1"; fso = "S1"; + } + else + { + fgr = "G2"; fco = "C2"; fso = "S2"; + } + } + set(RMI_GRUPPO, mov.get(fgr)); + set(RMI_CONTO, mov.get(fco)); + set(RMI_SOTTOCONTO,mov.get(fso)); + } +} + +/////////////////////////////////////////////////////////// +// TRMov_recset +/////////////////////////////////////////////////////////// + +void TRMov_recset::add_field(const char* name, int from, char tipo, int len, const char* def) +{ + const bool required = false; + const TFieldtypes t = tipo == 'n' ? _longzerofld : _alfafld; + const int pos = from - 1; + + if (def && *def) + { + CHECKS(def == NULL || (int)strlen(def) <= len, "Invalid default value ", def); + TVariant var(def); var.convert_to(t); + create_field(name, pos, len, t, required, var); + } + else + create_field(name, pos, len, t, required); +} + +bool TRMov_recset::find(long numreg) +{ + if (numreg != _numreg) + { + _first = _last = -1L; + + bool ok = false; + TRecnotype f = 0L, l= last(); + TRecnotype pos = f + (l - f) / 2; + + while (!ok && f <= l) + { + TAS400_recordset::move_to(pos); + + const long n = get(RMV_NUMREG).as_int(); + + if (n > numreg) + l = pos - 1; + else + if (n < numreg) + f = pos + 1; + else + { + f = pos; + ok = true; + } + pos = f + (l - f) / 2; + } + if (ok) + { + bool ok1 = TAS400_recordset::move_to(f); + + while (ok1 && numreg == get(RMV_NUMREG).as_int()) + { + f = current_row(); + ok1 = TAS400_recordset::move_prev(); + } + ok1 = TAS400_recordset::move_to(f); + while (ok1 && numreg == get(RMV_NUMREG).as_int()) + { + l = current_row(); + ok1 =TAS400_recordset:: move_next(); + } + _first = f; + _last = l; + _numreg = numreg; + } + return ok; + } + return true; +} + +const TVariant& TRMov_recset::get(const char* column_name) const +{ + TString16 fname(column_name); + + if (fname == RMI_IMPONIBILE || fname == RMI_IMPOSTA) + { + TVariant& var = get_tmp_var(); + + var = TAS400_recordset::get(fname); + + const real r = var.as_real() / CENTO; + + var.set(r); + return var; + } + return TAS400_recordset::get(fname); +} + +bool TRMov_recset::move_to(TRecnotype pos) +{ + if (_first < 0L) + return TAS400_recordset::move_to(pos); + if (pos == 0L) + pos = _first; + if (pos <= _last) + return TAS400_recordset::move_to(pos); + return false; +} + +TRMov_recset::TRMov_recset(TMov_recset & mov) + :TAS400_recordset("AS400(99)\n"), + _first(-1L), _last(-1L), _numreg(-1L) + +{ + const char a = 'a'; + const char n = 'n'; + TVariant var; + int row = 1; + TString4 fgr, fco, fso; + TVariant sez, tipo; + + add_field(RMV_NUMREG, 1, n, 7); + add_field(RMV_NUMRIG, 8, n, 3); + add_field(RMV_SEZIONE, 11, a, 1); + add_field(RMV_TIPOC, 12, a, 1); + add_field(RMV_GRUPPO, 13, n, 3); + add_field(RMV_CONTO, 16, n, 3); + add_field(RMV_SOTTOCONTO, 19, n, 6); + add_field(RMV_DESCR, 25, a, 50); + add_field(RMV_IMPORTO, 85, n, 15); // 18 + + for (bool ok = mov.move_first(); ok; ok = mov.move_next()) + { + const int prog = mov.get("PROG").as_int(); + + if (prog == 1) + { + row = 1; + + // 1o conto cliente/fornitore solo sul primo record + new_rec(); + set(RMV_NUMREG, mov.get(MOV_NUMREG)); + + var.set(row++); + set(RMV_NUMRIG, var); + if (mov.vendite()) + { + if (mov.fattura()) + { + fgr = "G1"; fco = "C1"; fso = "S1"; + sez = "D"; + } + else + { + fgr = "G2"; fco = "C2"; fso = "S2"; + sez = "A"; + } + } + else + { + if (mov.fattura()) + { + fgr = "G2"; fco = "C2"; fso = "S2"; + sez = "A"; + } + else + { + fgr = "G1"; fco = "C1"; fso = "S1"; + sez = "D"; + } + } + set(RMV_SEZIONE, sez); + tipo = mov.vendite() ? "C" : "F"; + set(RMV_TIPOC, tipo); + set(RMV_GRUPPO, mov.get(fgr)); + set(RMV_CONTO, mov.get(fco)); + set(RMV_SOTTOCONTO,mov.get(fso)); + set(RMV_IMPORTO, mov.TAS400_recordset::get(MOV_TOTDOC)); + } + else + int i = 0; + + // 2o conto costo/ricavo + new_rec(); + set(RMV_NUMREG, mov.get(MOV_NUMREG)); + var.set(row++); + set(RMV_NUMRIG, var); + if (mov.vendite()) + { + if (mov.fattura()) + { + fgr = "G2"; fco = "C2"; fso = "S2"; + sez = "A"; + } + else + { + fgr = "G1"; fco = "C1"; fso = "S1"; + sez = "D"; + } + } + else + { + if (mov.fattura()) + { + fgr = "G1"; fco = "C1"; fso = "S1"; + sez = "D"; + } + else + { + fgr = "G2"; fco = "C2"; fso = "S2"; + sez = "A"; + } + } + set(RMV_SEZIONE, sez); + set(RMV_GRUPPO, mov.get(fgr)); + set(RMV_CONTO, mov.get(fco)); + set(RMV_SOTTOCONTO,mov.get(fso)); + set(RMV_IMPORTO, mov.TAS400_recordset::get(RMI_IMPONIBILE)); + + // 3o conto IVA + if (!mov.TAS400_recordset::get(RMI_IMPOSTA).as_real().is_zero()) + { + new_rec(); + set(RMV_NUMREG, mov.get(MOV_NUMREG)); + var.set(row++); + set(RMV_NUMRIG, var); + if (mov.vendite()) + sez = mov.fattura() ? "A" : "D"; + else + sez = mov.fattura() ? "D" : "A"; + set(RMV_SEZIONE, sez); + set(RMV_GRUPPO, mov.get("G3")); + set(RMV_CONTO, mov.get("C3")); + set(RMV_SOTTOCONTO,mov.get("S3")); + set(RMV_IMPORTO, mov.TAS400_recordset::get(RMI_IMPOSTA)); + } + else + int i = 0; + } +} + +/////////////////////////////////////////////////////////// +// TMaestri_mask +/////////////////////////////////////////////////////////// + +class TMaestri_mask : public TAutomask +{ +private: + void serialize(bool bSave); +protected: + bool on_field_event(TOperable_field& o, TField_event e, long jolly); +public: + TMaestri_mask(); + virtual ~TMaestri_mask(); +}; + +TMaestri_mask::TMaestri_mask() : TAutomask("pg0001200a") +{ + serialize(false); +} + +TMaestri_mask::~TMaestri_mask() +{ + serialize(true); +} + +bool TMaestri_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) +{ + return TRUE; +} + +HIDDEN bool browse_file_handler(TMask_field& f, KEY k) +{ + if (k == K_F9) + { + FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC)); + strcpy(fs.type, ""); + strcpy(fs.name, f.get()); + xvt_fsys_get_default_dir(&fs.dir); + xvt_fsys_save_dir(); + if (xvt_dm_post_file_open(&fs, TR("Selezione file")) == FL_OK) + { + TFilename n; + xvt_fsys_convert_dir_to_str(&fs.dir, n.get_buffer(n.size()), n.size()); + n.add(fs.name); + f.set(n); + } + xvt_fsys_restore_dir(); + f.set_focus(); + } + + return TRUE; +} + +void TMaestri_mask::serialize(bool bSave) +{ + const char* defpar = "tc"; + TConfig ini(CONFIG_DITTA, defpar); + for (int i = fields()-1; i >= 0; i--) + { + TMask_field& f = fld(i); + const TFieldref* fr = f.field(); + if (fr != NULL) + { + if (bSave) + fr->write(ini, defpar, f.get()); + else + f.set(fr->read(ini, defpar)); + } + } +} + +/////////////////////////////////////////////////////////// +// TMaestri_sender +/////////////////////////////////////////////////////////// +class TMaestri_sender : public TTS_sender +{ + TMaestri_mask * _mask; + +protected: + virtual TRecordset & movrecset(const TMask & m); + virtual TRecordset & rmovrecset(const TRecordset & mov); + virtual TRecordset & rivarecset(const TRecordset & mov); + virtual const TRecordset & clirecset(const char tipocf, const long codcf); + virtual const char * decode_causale(const TRecordset& mov); + virtual bool test_swap(const TRecordset& mov) { return false; } + virtual bool swap_ritsoc(const TRecordset& mov) { return false; } + virtual TMask * get_mask(); + virtual const char * extra_modules() const {return "ba";} + +public: + virtual void update_parameters(const TMask & m, TRecordset & mov) {} + TMaestri_sender() : _mask(NULL) {} +}; + +TMaestri_sender& app() { return (TMaestri_sender&)main_app(); } + +TMask * TMaestri_sender::get_mask() +{ + if (_mask == NULL) + _mask = new TMaestri_mask; + + return _mask; +} + +const char * TMaestri_sender::decode_causale(const TRecordset& mov) +{ + const int codcaus = mov.get(MOV_CODCAUS).as_int(); + + switch (codcaus) + { + case 1: + return "Fattura di vendita"; + case 2: + return "Nota di credito a cliente"; + case 11: + return "Fattura di acquisto"; + case 12: + return "Nota di credito da fornitore"; + default: + break; + } + return ""; +} + +TRecordset & TMaestri_sender::movrecset(const TMask & m) +{ + + TRecordset * mov = get_recset(LF_MOV); + + if (mov == NULL) + { + TString query("SELECT * FROM "); + TMask * m = get_mask(); + TFilename name = m->get(F_INPATH); + + name.add(m->get(F_INFILEM)); + query << name; + + mov = set_recset(LF_MOV, new TMov_recset(query, recsets())); + } + + return *mov; +} + +TRecordset & TMaestri_sender::rmovrecset(const TRecordset & mov) +{ + TRMov_recset * rmov = (TRMov_recset *) get_recset(LF_RMOV); + CHECK(rmov != NULL, "Recordset righe contabili non inizializzato"); + long numreg = mov.get(MOV_NUMREG).as_int(); + + rmov->find(numreg); + return *rmov; +} + +TRecordset & TMaestri_sender::rivarecset(const TRecordset & mov) +{ + TIVA_recset * rmoviva = (TIVA_recset *) get_recset(LF_RMOVIVA); + CHECK(rmoviva != NULL, "Recordset righe IVA non inizializzato"); + long numreg = mov.get(MOV_NUMREG).as_int(); + + rmoviva->find(numreg); + return *rmoviva; +} + +const TRecordset& TMaestri_sender::clirecset(const char tipocf, const long codcf) +{ + TClifo_recset * clifo = (TClifo_recset *) get_recset(LF_CLIFO); + + if (clifo == NULL) + { + TString query("SELECT * FROM "); + TMask * m = get_mask(); + TFilename name = m->get(F_INPATH); + + name.add(m->get(F_INFILEA)); + query << name; + + clifo = (TClifo_recset *) set_recset(LF_CLIFO, new TClifo_recset(query)); + } + + if (!clifo->find(tipocf, codcf)) + { + TString msg(tipocf == 'C' ? "Cliente " : "Fornitore "); + + msg << codcf << " assente"; + app().log(2, msg); + } + + return *clifo; +} + +int pg0001200(int argc, char* argv[]) +{ + TMaestri_sender app; + app.run(argc, argv, "Invio a TeamSystem"); + return 0; +} diff --git a/ps/pg0001200a.h b/ps/pg0001200a.h new file mode 100755 index 000000000..048c7f1eb --- /dev/null +++ b/ps/pg0001200a.h @@ -0,0 +1,9 @@ +// invio dati da ebc ad teamsystem + +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_INPATH 103 +#define F_INFILEA 104 +#define F_INFILEM 107 +#define F_PATH 105 +#define F_FILE 106 diff --git a/ps/pg0001200a.uml b/ps/pg0001200a.uml new file mode 100755 index 000000000..3f237de27 --- /dev/null +++ b/ps/pg0001200a.uml @@ -0,0 +1,82 @@ +#include "pg0001200a.h" + +PAGE "Creazione file per TeamSystem" -1 -1 78 20 + +GROUPBOX DLG_NULL 76 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 76 5 +BEGIN + PROMPT 2 4 "Sorgenti" +END + +STRING F_INPATH 256 39 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD TSMInPath +END + +STRING F_INFILEA 18 +BEGIN + PROMPT 3 6 "File anagrafica " + FIELD TSMInFileA +END + +STRING F_INFILEM 18 +BEGIN + PROMPT 3 7 "File movimenti " + FIELD TSMInFileM +END + +GROUPBOX DLG_NULL 76 4 +BEGIN + PROMPT 2 9 "Destinazione" +END + +STRING F_PATH 256 39 +BEGIN + PROMPT 3 10 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD TSMDestPath +END + +STRING F_FILE 18 +BEGIN + PROMPT 3 11 "File " + FIELD TSMDestFile +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK diff --git a/ps/ps0544200.cpp b/ps/ps0544200.cpp index a4809ea25..5e7ef359c 100755 --- a/ps/ps0544200.cpp +++ b/ps/ps0544200.cpp @@ -146,6 +146,12 @@ void TServus_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS valore = qta.string(0,2); valore.strip("."); } + else + { + real qta = app().riga_doc_curr().get_real(RDOC_QTAGG1); + valore = qta.string(0,2); + valore.strip("."); + } } else if (code == "_ANNO") { @@ -227,6 +233,16 @@ void TServus_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS valore = totale.string(0,2); valore.strip("."); } + else if (code == "_UPPERCASE") + { + valore = str; + valore.upper(); + } + else if (code == "_PERCENTUALE") + { + real perc(str); + valore = perc.string(0,0); + } else NFCHECK("Macro non definita: %s", (const char *)code); str = valore; diff --git a/ps/ps0544200.ini b/ps/ps0544200.ini index c261db53f..07db434b6 100755 --- a/ps/ps0544200.ini +++ b/ps/ps0544200.ini @@ -425,7 +425,8 @@ NAME(8) = PARTECIPAZIONE CLIENTE PAGAMENTO TYPE(8) = NUMERO LENGTH(8) = 8 POSITION(8) = 69 -FIELD(8) = 34->SCONTO +FIELD(8) = 34->QTAGG1 +MESSAGE(8) = _PERCENTUALE NAME(9) = IDENTIFICATORE PAGAMENTO TYPE(9) = STRINGA @@ -455,6 +456,7 @@ TYPE(13) = STRINGA LENGTH(13) = 1 POSITION(13) = 88 FIELD(13) = 34->CODAGG1[1,1] +MESSAGE(13) = _UPPERCASE NAME(14) = RICONOSCIMENTO PAGAMENTO TYPE(14) = STRINGA @@ -541,6 +543,8 @@ NAME(8) = PARTECIPAZIONE CLIENTE PARTICOLARI TYPE(8) = NUMERO LENGTH(8) = 5 POSITION(8) = 40 +FIELD(8) = 34->QTAGG1 +MESSAGE(8) = _PERCENTUALE NAME(9) = PREZZO VENDITA TYPE(9) = IMPORTO @@ -554,7 +558,6 @@ TYPE(10) = STRINGA LENGTH(10) = 1 POSITION(10) = 53 - NAME(11) = FILLER TYPE(11) = STRINGA LENGTH(11) = 6 @@ -593,6 +596,7 @@ TYPE(16) = STRINGA LENGTH(16) = 1 POSITION(16) = 88 FIELD(16) = 34->CODAGG1[1,1] +MESSAGE(16) = _UPPERCASE NAME(17) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI TYPE(17) = STRINGA @@ -680,6 +684,7 @@ TYPE(10) = STRINGA LENGTH(10) = 1 POSITION(10) = 88 FIELD(10) = 34->CODAGG1[1,1] +MESSAGE(10) = _UPPERCASE NAME(11) = RICONOSCIMENTO ASSEGNAZIONI PARTICOLARI TYPE(11) = STRINGA diff --git a/ps/pt0195100.cpp b/ps/pt0195100.cpp index 6d86471ac..7f69c2b12 100755 --- a/ps/pt0195100.cpp +++ b/ps/pt0195100.cpp @@ -307,11 +307,12 @@ bool TImpDoc0195::transfer_testata() _clienti->put(CLI_LOCCF, comune); else _clienti->put(CLI_COMCF, codcom); - + + const TString& cf = curr.get(19); + _clienti->put(CLI_COFI, cf); //codice fiscale const TString& stato_e_piva = curr.get(20); _clienti->put(CLI_STATOPAIV, stato_e_piva.left(2)); _clienti->put(CLI_PAIV, stato_e_piva.mid(2)); //partita iva - _clienti->put(CLI_COFI, stato_e_piva.mid(2)); //codice fiscale const TString8 codabi = curr.get(21).left(5); _clienti->put(CLI_CODABI, codabi); diff --git a/ps/pt0195100t.ini b/ps/pt0195100t.ini index f1067f662..590f22937 100755 --- a/ps/pt0195100t.ini +++ b/ps/pt0195100t.ini @@ -138,7 +138,7 @@ TYPE(18) = STRINGA POSITION(18) = 237 LENGTH(18) = 30 -NAME(19) = TNAZIO +NAME(19) = TNAZIO // CODICE FISCALE TYPE(19) = STRINGA POSITION(19) = 267 LENGTH(19) = 30 diff --git a/server/authoriz.cpp b/server/authoriz.cpp index 87e8c806a..a67277e06 100755 --- a/server/authoriz.cpp +++ b/server/authoriz.cpp @@ -363,7 +363,10 @@ void TAuthorizationServer::GenerateModules(wxString& strFilename) th.AddChild("th").SetAttr("width", "7%") << "N."; th.AddChild("th").SetAttr("width", "8%") << "Module"; th.AddChild("th").SetAttr("width", "70%") << "Description"; - th.AddChild("th").SetAttr("width", "15%") << "De/Activate"; + + const bool bNormalUser = m_Dongle.Number() > 0; + if (bNormalUser) + th.AddChild("th").SetAttr("width", "15%") << "De/Activate"; const wxString strAut = GetModulesFilename(); wxFileInputStream aut(strAut); @@ -384,7 +387,7 @@ void TAuthorizationServer::GenerateModules(wxString& strFilename) tr.AddChild("td").SetAttr("align", "center") << strCode; TXmlItem& td = tr.AddChild("td"); td.AddChild(bOn ? "b" : "i") << strDesc; - if (nModule > 0) + if (bNormalUser && nModule > 0) { const char* prompt = bOn ? "Deactivate" : "Activate"; const wxString href = wxString::Format("%s?%d", prompt, nModule); diff --git a/server/dongle.cpp b/server/dongle.cpp index c90aeee94..4148d37da 100755 --- a/server/dongle.cpp +++ b/server/dongle.cpp @@ -352,7 +352,7 @@ inline void reset_bit(unsigned short& w, unsigned char b) TDongle::TDongle() : _hardware(_dongle_unknown), _type(_no_dongle), _serno(0xFFFF), - _max_users(1), _year_assist(2002), _dirty(false) + _max_users(1), _year_assist(2007), _dirty(false) { memset(_eprom, 0, sizeof(_eprom)); } @@ -436,7 +436,7 @@ bool TDongle::hardlock_login(bool test_all_keys) _type = _aga_dongle; } HL_LOGOUT(); - ok = HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK; + ok = HL_LOGIN(USERADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK; if (ok) { @@ -527,7 +527,7 @@ bool TDongle::hardlock_login(bool test_all_keys) _max_users = 4; _last_update = wxDateTime::Now(); - _year_assist = _last_update.GetYear(); + _year_assist = 3000; } } else @@ -550,19 +550,15 @@ bool TDongle::eutron_login(bool test_all_keys) _eutron_key->command = LOCATING_MODE; #endif - _eutron_key->status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here! - - const char* labels[5] = { "AGA.INFORMATICA", "AGA.PRASSI", "AGA.PROCOM", - "AGA.CAMPO", "25EBAI" }; - TDongleType types[5] = { _aga_dongle, _prassi_dongle, _procom_dongle, - _user_dongle, _developer_dongle }; - for (int k = test_all_keys ? 0 : 3; k < 5; k++) + const char* labels[3] = { "AGA.INFORMATICA", "AGA.CAMPO", "25EBAI" }; + TDongleType types[3] = { _aga_dongle, _user_dongle, _developer_dongle }; + for (int k = test_all_keys ? 0 : 1; k < 3; k++) { memset(_eutron_key->label, 0, LABEL_LENGTH); memcpy(_eutron_key->label, labels[k], strlen(labels[k])); memset(_eutron_key->password, 0, PASSWORD_LENGTH); memcpy(_eutron_key->password, ::encode(labels[k]), strlen(labels[k])); - + _eutron_key->status = ST_NONE_KEY; // Don't leave ST_OK = 0 here! smartlink(_eutron_key); ok = _eutron_key->status == ST_OK; if (ok) @@ -625,6 +621,7 @@ bool TDongle::eutron_login(bool test_all_keys) _max_users = 4; _module.set(255); // Last module on key _module.set(); // Activate all modules + _year_assist = 3000; } } else diff --git a/server/mondrian.ico b/server/mondrian.ico deleted file mode 100755 index 2310c5d27..000000000 Binary files a/server/mondrian.ico and /dev/null differ diff --git a/tc/tc0300.cpp b/tc/tc0300.cpp index be7416a56..2ede4e842 100755 --- a/tc/tc0300.cpp +++ b/tc/tc0300.cpp @@ -37,17 +37,33 @@ bool TTS_confditta::check_fields(TMask_field& f, KEY k) void TTS_confditta::load_mask() { TMask* mask = get_mask(); - if (mask==NULL) return; - TConfig_application::load_mask(); - TConfig& config = *get_config(); - TSheet_field& s = mask->sfield(F_SHEET_IVA); - for (int i=0;config.exist("TSGIVA", i);i++) + + if (mask != NULL) { - TToken_string& row = s.row(i); - row.add(config.get("TSGIVA", NULL, i)); - row.add(config.get("TSCIVA", NULL, i)); - row.add(config.get("TSSIVA", NULL, i)); - s.check_row(i); + TConfig_application::load_mask(); + TConfig& config = *get_config(); + TSheet_field& si = mask->sfield(F_SHEET_IVA); + int i = 0; + + 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)); + si.check_row(i); + } + + TSheet_field& sr = mask->sfield(F_SHEET_RIT); + + 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)); + sr.check_row(i); + } } } @@ -96,19 +112,39 @@ void TTS_confditta::save_mask(bool tosave) } TConfig& config = *get_config(); - for (int i = 0; config.exist("TSGIVA", i); i++) + 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& s = m.sfield(F_SHEET_IVA); - FOR_EACH_SHEET_ROW(s, j, row) + + 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); } diff --git a/tc/tc0300a.uml b/tc/tc0300a.uml index 4a8d74e89..f12153a31 100755 --- a/tc/tc0300a.uml +++ b/tc/tc0300a.uml @@ -94,29 +94,23 @@ BEGIN FIELD TSRNOHCLI END -BOOLEAN F_SENDCG -BEGIN - PROMPT 2 14 "Trasferisci le righe contabili invece delle contropartite" - FIELD TSSENDCG -END - BOOLEAN F_RIPRISTINO BEGIN - PROMPT 2 16 "Ripristina alla data" + PROMPT 2 14 "Ripristina alla data" MESSAGE FALSE DISABLE,F_ULTINVIO MESSAGE TRUE ENABLE,F_ULTINVIO END DATE F_ULTINVIO BEGIN - PROMPT 42 16 "Data ultimo invio " + PROMPT 42 14 "Data ultimo invio " FIELD TSULTINV FLAGS "D" END ENDPAGE -PAGE "Configurazione conti" -1 -1 0 0 +PAGE "Configurazione conti IVA" -1 -1 0 0 SPREADSHEET F_SHEET_IVA BEGIN @@ -129,6 +123,19 @@ END ENDPAGE +PAGE "Configurazione conti ritenute" -1 -1 0 0 + +SPREADSHEET F_SHEET_RIT +BEGIN + PROMPT 0 2 "Conti ritenute fiscali e sociali" + ITEM "Gr." + ITEM "Co." + ITEM "Sottoc." + ITEM "Descrizione Conto@50" +END + +ENDPAGE + ENDMASK PAGE "" -1 -1 68 11 @@ -221,3 +228,92 @@ ENDPAGE ENDMASK +PAGE "" -1 -1 68 11 + +NUMBER SI_GRUPPO 3 +BEGIN + PROMPT 1 3 "Gruppo " + HELP "Codice del gruppo" + USE LF_PCON KEY 1 SELECT (CONTO="") + INPUT GRUPPO SI_GRUPPO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Descrizione@50" DESCR + CHECKTYPE NORMAL + OUTPUT SI_GRUPPO GRUPPO + OUTPUT SI_DESCR DESCR + WARNING "Gruppo assente" + CHECKTYPE NORMAL +END + +NUMBER SI_CONTO 3 +BEGIN + PROMPT 15 3 "Conto " + HELP "Codice del conto" + USE LF_PCON KEY 1 SELECT SOTTOCONTO="" + INPUT GRUPPO SI_GRUPPO + INPUT CONTO SI_CONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + CHECKTYPE NORMAL + OUTPUT SI_CONTO CONTO + OUTPUT SI_GRUPPO GRUPPO + OUTPUT SI_DESCR DESCR + WARNING "Conto assente" + CHECKTYPE NORMAL +END + +NUMBER SI_SOTTOCONTO 6 +BEGIN + PROMPT 29 3 "Sottoconto " + HELP "Codice del sottoconto" + USE LF_PCON + INPUT GRUPPO SI_GRUPPO + INPUT CONTO SI_CONTO + INPUT SOTTOCONTO SI_SOTTOCONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT SI_SOTTOCONTO SOTTOCONTO + OUTPUT SI_GRUPPO GRUPPO + OUTPUT SI_CONTO CONTO + OUTPUT SI_DESCR DESCR + CHECKTYPE NORMAL + WARNING "Sottoconto assente" +END + +STRING SI_DESCR 50 +BEGIN + PROMPT 1 5 "Descrizione " + HELP "Indicare la descrizione della riga" + USE LF_PCON KEY 2 + INPUT DESCR SI_DESCR + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + OUTPUT SI_SOTTOCONTO SOTTOCONTO + OUTPUT SI_CONTO CONTO + OUTPUT SI_GRUPPO GRUPPO + OUTPUT SI_DESCR DESCR +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -13 -1 "" +END + +BUTTON DLG_DELREC 10 2 +BEGIN + PROMPT -23 -1 "" +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -33 -1 "" +END + +ENDPAGE + +ENDMASK diff --git a/tc/tc0500.cpp b/tc/tc0500.cpp index 2814499f7..3e43f1749 100755 --- a/tc/tc0500.cpp +++ b/tc/tc0500.cpp @@ -1,4 +1,5 @@ #include +#include #include "tc0.h" #include "tcts.h" @@ -12,7 +13,6 @@ protected: //magico metodo per impedire la navigazione su tabelle diverse da quella corrente del cursore virtual bool has_filtered_cursor() const { return true; } - public: TTeamSystem_multirel_app() {} @@ -26,7 +26,6 @@ void TTeamSystem_multirel_app::get_mask_name(TString& tabname) const tabname.overwrite("ts", 2); } - int tc0500(int argc, char* argv[]) { TTeamSystem_multirel_app a; diff --git a/tc/tc0700.cpp b/tc/tc0700.cpp index fcf475c47..4ab2c363e 100755 --- a/tc/tc0700.cpp +++ b/tc/tc0700.cpp @@ -1,15 +1,10 @@ #include "tc0.h" +#include "tc0700.h" #include "tc0700a.h" -#include #include -#include #include -#include -#include #include -#include -#include #include #include @@ -29,16 +24,6 @@ /////////////////////////////////////////////////////////// // TRiclassifica_cache /////////////////////////////////////////////////////////// -class TRiclassifica_cache : public TCache -{ - TLocalisamfile _multirel; -protected: - virtual TObject* key2obj(const char* key); -public: - const char * sdecode(const char* tab, const TString& cod); - long decode(const char* tab, const TString& cod); - TRiclassifica_cache() : _multirel(LF_MULTIREL) { _multirel.setkey(2);} -}; TObject* TRiclassifica_cache::key2obj(const char* key) { @@ -73,114 +58,6 @@ const char * TRiclassifica_cache::sdecode(const char* tab, const TString& cod) return ric ? (const char *) *ric : ""; } -/////////////////////////////////////////////////////////// -// TTS_textset -/////////////////////////////////////////////////////////// - -class TTS_textset : public TAS400_recordset -{ - TAssoc_array _contatori; - -protected: - long add_count(const char* tipo, long n = 1); - -protected: - void add_field(const char* trc, const char* name = "Filler", int len = 0, char tipo = 'a', - int from = -1, const char* def = NULL); - -public: - virtual bool destroy(TRecnotype r); - virtual const TString& rec_type(TRecnotype r = -1) const; - virtual bool set(const char* field, const TVariant& v); - - TTS_textset(const char* query = ""); -}; - -class TIVA_item : public TObject -{ - int _row; - long _conto; - long _codiva; - long _codiva11; - real _imponibile; - real _imposta; -public: - int & row() { return _row;} - long & conto() { return _conto;} - long & codiva() { return _codiva;} - long & codiva11() { return _codiva11;} - real & imponibile() { return _imponibile;} - real & imposta() { return _imposta;} - TIVA_item(int row, long conto, long codiva, long codiva11) : _row(row), _conto(conto), _codiva(codiva), _codiva11(codiva11) {} - virtual ~TIVA_item() {} -}; - -/////////////////////////////////////////////////////////// -// TTS_sender -/////////////////////////////////////////////////////////// - -class TTS_sender : public TSkeleton_application -{ - TRiclassifica_cache* _tabelle; - TRecord_cache* _conti; - TAssoc_array _riclassifica; - TTS_textset* _tsfile; - TLog_report* _log; - bool _errors_logged; - bool _send_cg; - TString8 _dittamulti; - TDate _from; - TArray _recsets; - TAssoc_array _iva; - TAssoc_array _contiiva; - -protected: - bool new_rec(const char* t) { CHECK(t && *t, "Tipo non valido"); return _tsfile->new_rec(t) >= 0; } - void remove_last(); - void set(const char* field, const TVariant& var); - void set(const char* field, const int n) { set(field, TVariant((long)n)); } - void set(const char* field, const char* s) { set(field, TVariant(s)); } - void set(const char* field, const TDate& d) { set(field, TVariant(d)); } - void set(const char* field, const real& v) { set(field, TVariant(v)); } - - const TVariant& get(const char* field); - void add_mov(const TRecordset& mov); - void add_clifor(char tipocf, long codcf); - void add_header(const TRecordset& mov, const bool fullhead = true); - void add_datiiva(const TRecordset& mov); - void add_tot_fattura(const TRecordset& mov); - void add_conti_ricavo_costo(const TRecordset& mov); - void add_new_rec(const TRecordset& mov, const char tipocf, long codcf); - void add_diversi(const TRecordset& mov, const bool moviva); - void add_ratei_risconti(const TRecordset& mov); - void add_ulteriori(const TRecordset& mov); - const TString & scod2ricl(const char* tab, const TString& cod); - const TString & scod2ricl(const char* tab, const TVariant& cod); - const long cod2ricl(const char* tab, const TString& cod); - const long cod2ricl(const char* tab, const TVariant& cod); - const long bill2ricl(char & t, int gr, int co, long so, const bool header_cli = false); - - virtual TRecordset & movrecset(const TDate & from = eotime, const TDate & to = botime); - virtual TRecordset & rmovrecset(const TRecordset & mov); - virtual TRecordset & rivarecset(const TRecordset & mov); - virtual TRecordset & clirecset(const char tipocf, const long codcf); - virtual void get_citta_provincia(const TRecordset& cli, TString & dencom, TString & provcom, bool nascita = false); - virtual const char * decode_causale(const TRecordset& mov); - virtual bool test_swap(const TRecordset& mov); - -public: - void log(int sev, const char* msg); - - TString & dittamulti() { return _dittamulti;} - TAssoc_array & riclassifica() {return _riclassifica;} - - virtual void update_parameters(const TDate & d); - virtual void set_parameters(); - virtual bool create(); - virtual void main_loop(); - virtual bool destroy(); - TTS_sender() : _tabelle(NULL), _conti(NULL) {} -}; TTS_sender& app() { return (TTS_sender&)main_app(); } @@ -212,7 +89,7 @@ bool TTS_textset::destroy(TRecnotype r) bool ok; if (r >= 0) { - const TString& t = TAS400_recordset::rec_type(r); // Igora subtipo record! + const TString4 t = TAS400_recordset::rec_type(r); // Igora subtipo record! ok = TAS400_recordset::destroy(r); if (ok) @@ -571,15 +448,18 @@ TTS_mask::~TTS_mask() void TTS_sender::log(int sev, const char* msg) { - if (sev > 0) - { - TString m; - m << TR("Record") << ' ' << _tsfile->rec_type() << ": " << msg; - _log->log(sev, m); - _errors_logged = true; - } - else - _log->log(sev, msg); + if (_log != NULL) + { + if (sev > 0 && _tsfile != NULL) + { + TString m; + m << TR("Record") << ' ' << _tsfile->rec_type() << ": " << msg; + _log->log(sev, m); + _errors_logged = true; + } + else + _log->log(sev, msg); + } } void TTS_sender::set(const char* field, const TVariant& var) @@ -607,10 +487,8 @@ void TTS_sender::add_ratei_risconti(const TRecordset& mov) { } -void TTS_sender::add_new_rec(const TRecordset& mov, char tipocf, long codcf) +void TTS_sender::add_new_rec(const TRecordset& mov) { - if (codcf > 0 && get("TRF-RASO").as_string().blank()) - add_clifor(tipocf, codcf); set("TRF-80-SEGUENTE", "S"); if (new_rec("0")) { @@ -621,16 +499,31 @@ void TTS_sender::add_new_rec(const TRecordset& mov, char tipocf, long codcf) void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva) { - const bool dont_send_clifo = _riclassifica.is_key("TSNOHCLI"); + const bool vendite = mov.get(MOV_TIPO).as_string()[0] != 'F'; + long contoclifor = 0L; + char seznor = ' '; + + if (moviva) + { + if (test_swap(mov)) + seznor = vendite ? 'D' : 'A'; + else + seznor = vendite ? 'A' : 'D'; + } + + const bool dont_send_clifo = _riclassifica.is_key("TSNOHCLI"); TRecordset & rmov = rmovrecset(mov); - int i = 0 , j = 0; - bool added_rec = false, valid_rec = false, as400 = false; + int i = 0 , j = 0, k = 0; + bool added_rec = false, valid_rec = false; bool first_cli = true; TString80 field; TString16 key; + bool ok = rmov.move_first(); + const bool as400 = moviva && (rmov.get(RMV_ROWTYPE).as_string()[0] <= ' '); - for (bool ok = rmov.move_first(); ok; ok = rmov.move_next(), i++) - { + for (; ok; ok = rmov.move_next(), i++) + { + bool riga_ritenute = false; const int gr = rmov.get(RMV_GRUPPO).as_int(); const int co = rmov.get(RMV_CONTO).as_int(); const long so = rmov.get(RMV_SOTTOCONTO).as_int(); @@ -638,59 +531,74 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva) bool one_clifor =(dont_send_clifo && t > ' '); const long contoricl = bill2ricl(t, gr, co, so, one_clifor); bool add_rec = (j >= 80) || (dont_send_clifo && t > ' '); - if (moviva) { - const char tiporiga = rmov.get(RMV_ROWTYPE).as_string()[0]; - - switch (tiporiga) + if (as400) { - case 'T': - case 'I': - case 'D': - case 'N': - continue; - case 'F': - case 'S': - break; - default: - if (i == 0 && _send_cg && tiporiga <= ' ') - as400 = true; - if (!as400) + if (t > ' ' && first_cli) { - key.format("%08ld", contoricl); - if (_contiiva.is_key(key)) - continue; - if (_iva.is_key(key)) - { - const char sez = rmov.get(RMV_SEZIONE).as_string()[0]; - const bool vendite = mov.get(MOV_TIPO).as_string()[0] != 'F'; - - if (vendite) - { - if (sez == 'A') - continue; - } - else - { - if (sez == 'D') - continue; - } - } + first_cli = false; + contoclifor = contoricl; + continue; + } + key.format("%08ld", contoricl); + if (_contiiva.is_key(key)) + continue; + if (_contirit.is_key(key)) + riga_ritenute = true; + else + { + if (k < 8) + { + const real importo = rmov.get(RMV_IMPORTO).as_real(); + const char sez = rmov.get(RMV_SEZIONE).as_string()[0]; + TImporto i(sez, importo); + + i.normalize(seznor); + field.format("TRF-CONTORIC_%d", k); + set(field, contoricl); + field.format("TRF-IMP-RIC_%d", k); + set(field, i.valore()); + k++; + } + else + log(2, TR("Registrazione con più di 8 conti di costo/ricavo")); + continue; + } + } + else + { + const char tiporiga = rmov.get(RMV_ROWTYPE).as_string()[0]; + + switch (tiporiga) + { + case 'T': + first_cli = false; + contoclifor = contoricl; + case 'I': + case 'D': + case 'N': + continue; + case 'F': + case 'S': + riga_ritenute = true; + break; + default: + break; } - break; } } if (add_rec) { if (!first_cli) { - add_new_rec(mov, t, so); + add_new_rec(mov); j = 0; added_rec = true; valid_rec = false; } - first_cli = false; + if (dont_send_clifo && get("TRF-RASO").as_string().blank() && t > ' ' && so > 0 ) + add_clifor(t, so); } field.format("TRF-CONTO_%d", j); set(field, contoricl); @@ -699,8 +607,23 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva) field.format("TRF-DA_%d", j); set(field, rmov.get(RMV_SEZIONE)); j++; + if (riga_ritenute) + { + if (contoclifor > 0L) + { + field.format("TRF-CONTO_%d", j); + set(field, contoclifor); + field.format("TRF-IMPORTO_%d", j); + set(field, rmov.get(RMV_IMPORTO)); + field.format("TRF-DA_%d", j); + const TString4 sez = rmov.get(RMV_SEZIONE).as_string() == "D" ? "A" :"D"; + set(field, sez); + j++; + } + else + log(2, "Conto cliente non trovato per ritenute"); + } valid_rec = true; - } if (added_rec && !valid_rec) { @@ -711,14 +634,12 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva) void TTS_sender::add_conti_ricavo_costo(const TRecordset& mov) { - if (_send_cg) - { - TRecordset & rmov = rmovrecset(mov); + TRecordset & rmov = rmovrecset(mov); - rmov.move_first(); - if (rmov.get(RMV_ROWTYPE).as_string()[0] <= ' ') - return; - } + rmov.move_first(); + const char tiporiga = rmov.get(RMV_ROWTYPE).as_string()[0]; + if (tiporiga <= ' ') + return; TRecordset & riva = rivarecset(mov); TString codice = scod2ricl("TSREG", mov.get(MOV_REG)); @@ -736,14 +657,14 @@ void TTS_sender::add_conti_ricavo_costo(const TRecordset& mov) const int co = riva.get(RMI_CONTO).as_int(); const long so = riva.get(RMI_SOTTOCONTO).as_int(); char t = riva.get(RMI_TIPOC).as_string()[0]; - const long hcli = movrecset().get(MOV_CODCF).as_int(); + const long hcli = mov.get(MOV_CODCF).as_int(); const long contoricl = bill2ricl(t, gr, co, so, hcli == so); real imponibile = riva.get(RMI_IMPONIBILE).as_real() * fattore; if (corrispettivo) { - if (riva.get(RMI_IMPOSTA).as_real() == ZERO) + if (riva.get(RMI_IMPOSTA).is_zero()) { TCodiceIVA c(riva.get(RMI_CODIVA).as_string()); @@ -771,7 +692,7 @@ void TTS_sender::add_conti_ricavo_costo(const TRecordset& mov) TString80 field; if (_iva.items() > 8) - log(2, TR("Registrazione con piuà di 8 conti di costo/ricavo")); + log(2, TR("Registrazione con più di 8 conti di costo/ricavo")); FOR_EACH_ASSOC_OBJECT(_iva, o, k, it) @@ -802,15 +723,67 @@ bool TTS_sender::test_swap(const TRecordset& mov) return s; } +bool TTS_sender::swap_ritsoc(const TRecordset& mov) +{ + TRecordset & rmov = rmovrecset(mov); + bool ok = rmov.move_first(); + const char sez = rmov.get(RMV_SEZIONE).as_string()[0]; + char sezrit = sez; + + for (; ok; ok = rmov.move_next()) + { + const char tiporiga = rmov.get(RMV_ROWTYPE).as_string()[0]; + + if (tiporiga =='S') + { + sezrit = rmov.get(RMV_SEZIONE).as_string()[0]; + break; + } + } + + const bool s = sez != sezrit; + return s; +} + void TTS_sender::add_tot_fattura(const TRecordset& mov) { real totdoc = mov.get(MOV_TOTDOC).as_real(); + const real ritfis = mov.get(MOV_RITFIS).as_real(); + const real ritsoc = mov.get(MOV_RITSOC).as_real(); + if (ritfis != ZERO) + totdoc += ritfis; + if (ritsoc != ZERO) + { + if (swap_ritsoc(mov)) // Somma ritenute sociali con segno + totdoc -= ritsoc; + else + totdoc += ritsoc; + } if (test_swap(mov)) totdoc = -totdoc; set("TRF-TOT-FATT", totdoc); } +TMask * TTS_sender::get_mask() +{ + TTS_mask * m = new TTS_mask; + TDate to(TODAY); + + to.addmonth(-1); + to.set_end_month(); + if (to <= _from) + { + to = _from; + to.addmonth(1); + to.set_end_month(); + } + m->set(F_DATA_DA, _from); + m->set(F_DATA_AL, to); + + return m; +} + void TTS_sender::add_datiiva(const TRecordset& mov) { TRecordset & rmoviva = rivarecset(mov); @@ -937,16 +910,27 @@ void TTS_sender::get_citta_provincia(const TRecordset& cli, TString & dencom, TS { key << cli.get(CLI_STATOCF); key << '|' << cli.get(CLI_COMCF); + + if (key.len() < 5) + { + key = "|"; + key << cap2comune(cli.get(CLI_CAPCF).as_string(), cli.get(CLI_LOCCF).as_string()); + } } const TRectype& com = cache().get(LF_COMUNI, key); - - dencom.cut(0); - if (!nascita) - dencom << cli.get(CLI_LOCCF) << " "; - dencom << com.get(COM_DENCOM); - dencom.trim(); + dencom = com.get(COM_DENCOM); provcom = com.get(COM_PROVCOM); + + if (!nascita) + { + const TString& localita = cli.get(CLI_LOCCF).as_string(); + if (localita.full() && xvt_str_fuzzy_compare(localita, dencom) < 0.75) + { + dencom.insert(", "); + dencom.insert(localita); + } + } } const char * TTS_sender::decode_causale(const TRecordset& mov) @@ -961,7 +945,7 @@ void TTS_sender::add_clifor(char tipocf, long codcf) // dati clienti/fornitore if (codcf != 0) { - TRecordset & cli = clirecset(tipocf, codcf); + const TRecordset& cli = clirecset(tipocf, codcf); const char tipocf = cli.get(CLI_TIPOCF).as_string()[0]; TString80 indirizzo; @@ -1189,14 +1173,14 @@ const long TTS_sender::cod2ricl(const char* tab, const TVariant& cod) return cod2ricl(tab, cod.as_string()); } -void TTS_sender::update_parameters(const TDate & d) +void TTS_sender::update_parameters(const TMask & m, TRecordset & mov) { if (yesno_box(TR("Confermare il traferimento"))) { TConfig configtc(CONFIG_DITTA); - TRecordset & mov = movrecset(); +// TRecordset & mov = movrecset(); - configtc.set("TSULTINV", d); + configtc.set("TSULTINV", m.get_date(F_DATA_AL)); if (mov.items() > 0L) { @@ -1223,12 +1207,11 @@ void TTS_sender::update_parameters(const TDate & d) void TTS_sender::set_parameters() { - TConfig configtc(CONFIG_DITTA); + TConfig configtc(CONFIG_DITTA, "tc"); const TDate d(configtc.get("TSULTINV")); _from = d; _dittamulti = configtc.get("TSDitta"); - _send_cg = configtc.get_bool("TSSENDCG"); TAssoc_array& tab = configtc.list_variables(); @@ -1248,25 +1231,28 @@ void TTS_sender::set_parameters() } } } - bool go_on = true; + int i = 0, gr = 0; - for (int i = 0; go_on; i++) + for (i = 0, gr = configtc.get_int("TSGIVA", NULL, i); gr > 0; i++, gr = configtc.get_int("TSGIVA", NULL, i)) { - int gr = configtc.get_int("TSGIVA", NULL, i); - if (gr == 0) - go_on = false; - else - { - int co = configtc.get_int("TSCIVA", NULL, i); - long so = configtc.get_long("TSSIVA", NULL, i); - char t = ' '; + int co = configtc.get_int("TSCIVA", NULL, i); + long so = configtc.get_long("TSSIVA", NULL, i); + char t = ' '; - long contoricl = bill2ricl(t, gr, co, so); - TString16 key; key.format("%08ld", contoricl); - _contiiva.add(key, NULL); - } + long contoricl = bill2ricl(t, gr, co, so); + TString16 key; key.format("%08ld", contoricl); + _contiiva.add(key, NULL); } + for (i = 0, gr = configtc.get_int("TSGRIT", NULL, i); gr > 0; i++, gr = configtc.get_int("TSGRIT", NULL, i)) + { + int co = configtc.get_int("TSCRIT", NULL, i); + long so = configtc.get_long("TSSRIT", NULL, i); + char t = ' '; + long contoricl = bill2ricl(t, gr, co, so); + TString16 key; key.format("%08ld", contoricl); + _contirit.add(key, NULL); + } } bool TTS_sender::create() @@ -1284,9 +1270,11 @@ bool TTS_sender::destroy() return TSkeleton_application::destroy(); } -TRecordset & TTS_sender::movrecset(const TDate & from, const TDate & to) +TRecordset & TTS_sender::movrecset(const TMask & m) { - TRecordset * mov = (TRecordset *) _recsets.objptr(LF_MOV); + const TDate from = m.get_date(F_DATA_DA); + const TDate & to = m.get_date(F_DATA_AL); + TRecordset * mov = get_recset(LF_MOV); if (mov == NULL) { @@ -1295,8 +1283,7 @@ TRecordset & TTS_sender::movrecset(const TDate & from, const TDate & to) query << "\nFROM DATAREG=#DATA_DA"; query << "\nTO DATAREG=#DATA_AL"; - _recsets.add(::create_recordset(query), LF_MOV); - mov = (TRecordset *) _recsets.objptr(LF_MOV); + mov = set_recset(LF_MOV, ::create_recordset(query)); } if (from != eotime) mov->set_var("#DATA_DA", TVariant(from)); @@ -1307,13 +1294,10 @@ TRecordset & TTS_sender::movrecset(const TDate & from, const TDate & to) TRecordset & TTS_sender::rmovrecset(const TRecordset & mov) { - TRecordset * rmov = (TRecordset *) _recsets.objptr(LF_RMOV); + TRecordset * rmov = get_recset(LF_RMOV); if (rmov == NULL) - { - _recsets.add(::create_recordset("USE RMOV\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"), LF_RMOV); - rmov = (TRecordset *) _recsets.objptr(LF_RMOV); - } + rmov = set_recset(LF_RMOV, ::create_recordset("USE RMOV\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG")); const TVariant & numreg = mov.get(MOV_NUMREG); @@ -1324,13 +1308,10 @@ TRecordset & TTS_sender::rmovrecset(const TRecordset & mov) TRecordset & TTS_sender::rivarecset(const TRecordset & mov) { - TRecordset * rmoviva = (TRecordset *) _recsets.objptr(LF_RMOVIVA); + TRecordset * rmoviva = get_recset(LF_RMOVIVA); if (rmoviva == NULL) - { - _recsets.add(::create_recordset("USE RMOVIVA\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG"), LF_RMOVIVA); - rmoviva = (TRecordset *) _recsets.objptr(LF_RMOVIVA); - } + rmoviva = set_recset(LF_RMOVIVA, ::create_recordset("USE RMOVIVA\nFROM NUMREG=#NUMREG\nTO NUMREG=#NUMREG")); const TVariant & numreg = mov.get(MOV_NUMREG); @@ -1339,46 +1320,32 @@ TRecordset & TTS_sender::rivarecset(const TRecordset & mov) return *rmoviva; } -TRecordset & TTS_sender::clirecset(const char tipocf, const long codcf) +const TRecordset& TTS_sender::clirecset(const char tipocf, const long codcf) { - TRecordset * clifo = (TRecordset *) _recsets.objptr(LF_CLIFO); + TRecordset * clifo = get_recset(LF_CLIFO); if (clifo == NULL) - { - _recsets.add(::create_recordset("USE CLIFO\nFROM TIPOCF=#TIPOCF CODCF=#CODCF\nTO TIPOCF=#TIPOCF CODCF=#CODCF"), LF_CLIFO); - clifo = (TRecordset *) _recsets.objptr(LF_CLIFO); - } + clifo = set_recset(LF_CLIFO, ::create_recordset("USE CLIFO\nFROM TIPOCF=#TIPOCF CODCF=#CODCF\nTO TIPOCF=#TIPOCF CODCF=#CODCF")); TString4 w; w << tipocf; TVariant t(w); clifo->set_var("#TIPOCF", t); clifo->set_var("#CODCF", codcf); + clifo->move_first(); return *clifo; } void TTS_sender::main_loop() { - TTS_mask m; - TDate to(TODAY); - - to.addmonth(-1); - to.set_end_month(); - if (to <= _from) - { - to = _from; - to.addmonth(1); - to.set_end_month(); - } - m.set(F_DATA_DA, _from); - m.set(F_DATA_AL, to); - while (m.run() != K_QUIT) + TMask * m = get_mask(); + while (m->run() != K_QUIT) { const char* const title = TR("Invio a TeamSystem"); _tsfile = new TTS_textset; _log = new TLog_report(title); _errors_logged = false; - TRecordset & mov = movrecset(m.get_date(F_DATA_DA), m.get_date(F_DATA_AL)); + TRecordset & mov = movrecset(*m); TProgind pi(mov.items(), TR("Scansione movimenti"), true, true); for (bool ok = mov.move_first(); ok; ok = mov.move_next()) @@ -1403,16 +1370,19 @@ void TTS_sender::main_loop() } if (save) { - TFilename name = m.get(F_PATH); + TFilename name = m->get(F_PATH); - name.add(m.get(F_FILE)); - _tsfile->save_as(name); - update_parameters(m.get_date(F_DATA_AL)); + name.add(m->get(F_FILE)); + _tsfile->save_as(name); + update_parameters(*m, mov); } delete _log; + _log = NULL; delete _tsfile; + _tsfile = NULL; } + delete m; } int tc0700(int argc, char* argv[]) diff --git a/tc/tc0700.h b/tc/tc0700.h new file mode 100755 index 000000000..9287fdfa1 --- /dev/null +++ b/tc/tc0700.h @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////// +// TRiclassifica_cache +/////////////////////////////////////////////////////////// + +class TRiclassifica_cache : public TCache +{ + TLocalisamfile _multirel; +protected: + virtual TObject* key2obj(const char* key); +public: + const char * sdecode(const char* tab, const TString& cod); + long decode(const char* tab, const TString& cod); + TRiclassifica_cache() : _multirel(LF_MULTIREL) { _multirel.setkey(2);} +}; + +/////////////////////////////////////////////////////////// +// TTS_textset +/////////////////////////////////////////////////////////// + +class TTS_textset : public TAS400_recordset +{ + TAssoc_array _contatori; + +protected: + long add_count(const char* tipo, long n = 1); + +protected: + void add_field(const char* trc, const char* name = "Filler", int len = 0, char tipo = 'a', + int from = -1, const char* def = NULL); + +public: + virtual bool destroy(TRecnotype r); + virtual const TString& rec_type(TRecnotype r = -1) const; + virtual bool set(const char* field, const TVariant& v); + + TTS_textset(const char* query = ""); +}; + +class TIVA_item : public TObject +{ + int _row; + long _conto; + long _codiva; + long _codiva11; + real _imponibile; + real _imposta; +public: + int & row() { return _row;} + long & conto() { return _conto;} + long & codiva() { return _codiva;} + long & codiva11() { return _codiva11;} + real & imponibile() { return _imponibile;} + real & imposta() { return _imposta;} + TIVA_item(int row, long conto, long codiva, long codiva11) : _row(row), _conto(conto), _codiva(codiva), _codiva11(codiva11) {} + virtual ~TIVA_item() {} +}; + +/////////////////////////////////////////////////////////// +// TTS_sender +/////////////////////////////////////////////////////////// + +class TTS_sender : public TSkeleton_application +{ + TRiclassifica_cache* _tabelle; + TRecord_cache* _conti; + TAssoc_array _riclassifica; + TTS_textset* _tsfile; + TLog_report* _log; + bool _errors_logged; + TString8 _dittamulti; + TDate _from; + TArray _recsets; + TAssoc_array _iva; + TAssoc_array _contiiva; + TAssoc_array _contirit; + +protected: + TRecordset * get_recset(const int logicnum) const { return (TRecordset *) _recsets.objptr(logicnum);} + TRecordset * set_recset(const int logicnum, TRecordset * r) { _recsets.add(r, logicnum); return r;} + TArray & recsets() { return _recsets;} + bool new_rec(const char* t) { CHECK(t && *t, "Tipo non valido"); return _tsfile->new_rec(t) >= 0; } + void remove_last(); + void set(const char* field, const TVariant& var); + void set(const char* field, const int n) { set(field, TVariant((long)n)); } + void set(const char* field, const char* s) { set(field, TVariant(s)); } + void set(const char* field, const TDate& d) { set(field, TVariant(d)); } + void set(const char* field, const real& v) { set(field, TVariant(v)); } + + const TVariant& get(const char* field); + void add_mov(const TRecordset& mov); + void add_clifor(char tipocf, long codcf); + void add_header(const TRecordset& mov, const bool fullhead = true); + void add_datiiva(const TRecordset& mov); + void add_tot_fattura(const TRecordset& mov); + void add_conti_ricavo_costo(const TRecordset& mov); + void add_new_rec(const TRecordset& mov); + void add_diversi(const TRecordset& mov, const bool moviva); + void add_ratei_risconti(const TRecordset& mov); + void add_ulteriori(const TRecordset& mov); + const TString & scod2ricl(const char* tab, const TString& cod); + const TString & scod2ricl(const char* tab, const TVariant& cod); + const long cod2ricl(const char* tab, const TString& cod); + const long cod2ricl(const char* tab, const TVariant& cod); + const long bill2ricl(char & t, int gr, int co, long so, const bool header_cli = false); + + virtual TRecordset & movrecset(const TMask & m); + virtual TRecordset & rmovrecset(const TRecordset & mov); + virtual TRecordset & rivarecset(const TRecordset & mov); + virtual const TRecordset & clirecset(const char tipocf, const long codcf); + virtual void get_citta_provincia(const TRecordset& cli, TString & dencom, TString & provcom, bool nascita = false); + virtual const char * decode_causale(const TRecordset& mov); + virtual bool test_swap(const TRecordset& mov); + virtual bool swap_ritsoc(const TRecordset& mov); + virtual TMask * get_mask(); + +public: + void log(int sev, const char* msg); + + TString & dittamulti() { return _dittamulti;} + TAssoc_array & riclassifica() {return _riclassifica;} + + virtual void update_parameters(const TMask & m, TRecordset & mov); + virtual void set_parameters(); + virtual bool create(); + virtual void main_loop(); + virtual bool destroy(); + TTS_sender() : _tabelle(NULL), _conti(NULL), _tsfile(NULL), _log(NULL) {} +}; diff --git a/tc/tc0700.txt b/tc/tc0700.txt new file mode 100755 index 000000000..996d2ee7c --- /dev/null +++ b/tc/tc0700.txt @@ -0,0 +1,56 @@ +MOV_TIPO +MOV_NUMREG +MOV_REG +MOV_CODCF +MOV_TOTDOC +MOV_RITFIS +MOV_RITSOC +MOV_CODCAUS +MOV_DATAREG +MOV_DATADOC +MOV_NUMDOC +MOV_PROTIVA + +RMV_ROWTYPE +RMV_GRUPPO +RMV_CONTO +RMV_SOTTOCONTO +RMV_TIPOC +RMV_IMPORTO +RMV_SEZIONE + +RMI_GRUPPO +RMI_CONTO +RMI_SOTTOCONTO +RMI_TIPOC +RMI_IMPONIBILE +RMI_IMPOSTA +RMI_CODIVA +RMI_TIPODET +RMI_TIPOCR + +CLI_TIPOCF +CLI_CODCF +CLI_RAGSOC +CLI_STATONASC +CLI_COMNASC +CLI_STATOCF +CLI_COMCF +CLI_CAPCF +CLI_INDCF +CLI_CIVCF +CLI_LOCCF +CLI_TIPOPERS +CLI_COFI +CLI_PAIV +CLI_DATANASC +CLI_PTEL +CLI_TEL +CLI_PFAX +CLI_FAX +CLI_GRUPPORIC +CLI_CONTORIC +CLI_SOTTOCRIC +CLI_CODPAG +CLI_CODABI +CLI_CODCAB diff --git a/tc/tc0800.cpp b/tc/tc0800.cpp index 5e1342e6d..5f1fe7741 100755 --- a/tc/tc0800.cpp +++ b/tc/tc0800.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "tc0800a.h" @@ -10,12 +12,42 @@ //////////////////////////////////////////////////////////////////////// class TTS_ricl_msk : public TAutomask { - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly) { return true;} - + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + public: TTS_ricl_msk() : TAutomask("tc0800a") {} }; +bool TTS_ricl_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case F_CONTO: + { + TString16 key; + key.format("%d|%d", o.mask().get_int(F_GRUPPO), o.mask().get_int(F_CONTO)); + const TRectype & rec = cache().get(LF_PCON, key); + const char tsottoc = rec.get_char(PCN_TMCF); + + if (tsottoc <= ' ') + { + enable(F_SOTTOCONTO); + enable(F_DESC); + } + else + { + disable(F_SOTTOCONTO); + disable(F_DESC); + reset(F_SOTTOCONTO); + } + + } + break; + default: + break; + } + return true; +} class TTSRiclass_application : public TRelation_application @@ -118,7 +150,7 @@ void TTSRiclass_application::init_insert_mode(TMask& m) TEdit_field& e = (TEdit_field&)c; e.enable(); - if (e.browse() != NULL) + if (e.browse() != NULL && !e.browse()->cursor()->file().empty()) e.enable_check(); } } @@ -134,7 +166,7 @@ void TTSRiclass_application::init_modify_mode(TMask& m) TEdit_field& e = (TEdit_field&)c; e.enable(); - if (e.browse() != NULL) + if (e.browse() != NULL && !e.browse()->cursor()->file().empty()) e.enable_check(); } } @@ -145,7 +177,7 @@ void TTSRiclass_application::init_modify_mode(TMask& m) int TTSRiclass_application::rewrite(const TMask& m) { - int err = TRelation_application::write(m); + int err = TRelation_application::rewrite(m); if (err == NOERR) { @@ -176,6 +208,7 @@ bool TTSRiclass_application::user_create() TString title; _msk->get_caption(title); set_title(title); + return true; } diff --git a/tc/tcconf.h b/tc/tcconf.h index d3975432c..dee4d2011 100755 --- a/tc/tcconf.h +++ b/tc/tcconf.h @@ -13,6 +13,7 @@ #define F_NOHCLI 113 #define F_SENDCG 114 #define F_SHEET_IVA 115 +#define F_SHEET_RIT 116 #define SI_GRUPPO 101 #define SI_CONTO 102 diff --git a/ve/ve0100.cpp b/ve/ve0100.cpp index a8884df6d..3ad34615b 100755 --- a/ve/ve0100.cpp +++ b/ve/ve0100.cpp @@ -16,6 +16,11 @@ #include "../mg/anamag.h" #include "../mg/mglib.h" +TCursor& TMotore_application::get_filtered_cursor() const +{ + const TEdit_field& f = _msk->efield(F_NDOC); + return *f.browse()->cursor(); +} bool TMotore_application::save_and_new() const { TDocumento_mask & m = *_docmsk; diff --git a/ve/ve0100.h b/ve/ve0100.h index 3bc1440cd..21c65bb23 100755 --- a/ve/ve0100.h +++ b/ve/ve0100.h @@ -54,6 +54,7 @@ protected: virtual int rewrite( const TMask& m ); virtual void print(); virtual bool has_filtered_cursor() const { return true; } + virtual TCursor& get_filtered_cursor() const; virtual bool save_and_new() const; // Funzioni da associare ad ogni procedura int user_function( int index ); diff --git a/ve/ve1300.cpp b/ve/ve1300.cpp index 7d6299132..cff1ddae9 100755 --- a/ve/ve1300.cpp +++ b/ve/ve1300.cpp @@ -782,8 +782,7 @@ class TReport_doc_app : public TSkeleton_application int _anno; TString4 _codnum; - long _ndoc; - bool _archive; + long _ndoc, _codcf; protected: void add_data_filter(TString& query, bool from) const; @@ -792,8 +791,8 @@ protected: bool print_loop(const TString& query); void print_selection(); - void set_next_pdf(int a, const char* c, long n); - virtual bool get_next_pdf(int anno, long ditta, const char* codnum, long numdoc, TFilename& pdf) const; + void set_next_pdf(int an, const char* cn, long nd, long cf); + virtual bool get_next_pdf(int anno, long ditta, const char* codnum, long numdoc, long codcf, TFilename& pdf) const; virtual bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn, TString& subj, TString& text, TToken_string& attach, bool& ui) const ; @@ -803,23 +802,19 @@ public: virtual bool destroy(); }; -void TReport_doc_app::set_next_pdf(int a, const char* c, long n) +void TReport_doc_app::set_next_pdf(int an, const char* cn, long nd, long cf) { - _archive = n > 0L; - if (_archive) - { - _anno = a; - _codnum = c; - _ndoc = n; - } + _anno = an; + _codnum = cn; + _ndoc = nd; + _codcf = cf; } - -bool TReport_doc_app::get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, TFilename& pdf) const +bool TReport_doc_app::get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, long codcf, TFilename& pdf) const { bool ok = false; - if (_archive) - ok = TSkeleton_application::get_next_pdf(_anno, ditta, _codnum, _ndoc, pdf); + if (_anno > 0 && _codnum.full() && _ndoc > 0 && _codcf > 0) + ok = TSkeleton_application::get_next_pdf(_anno, ditta, _codnum, _ndoc, _codcf, pdf); return ok; } @@ -918,10 +913,15 @@ bool TReport_doc_app::print_loop(const TString& query) if (is_definitive) { const TString& codnum = doc.get(DOC_CODNUM).as_string(); - arc = cache().get("%NUM", codnum, "B6").full(); + if (arc) + { + set_next_pdf(doc.get(DOC_ANNO).as_int(), + doc.get(DOC_CODNUM).as_string(), + doc.get(DOC_NDOC).as_int(), + doc.get(DOC_CODCF).as_int()); + } } - set_next_pdf(doc.get(DOC_ANNO).as_int(), doc.get(DOC_CODNUM).as_string(), doc.get(DOC_NDOC).as_int()); const TString& tipodoc = doc.get(DOC_TIPODOC).as_string(); const TTipo_documento& tipo = _tipi_cache.tipo(tipodoc); @@ -995,7 +995,7 @@ bool TReport_doc_app::print_loop(const TString& query) if (book.pages() > 0) { - set_next_pdf(0, "", 0L); // Disabilita archiviazione PDF + set_next_pdf(0, "", 0L, 0L); // Disabilita archiviazione PDF book.print_or_preview(); } diff --git a/ve/ve6400.cpp b/ve/ve6400.cpp index 222f1f919..24482ac7c 100755 --- a/ve/ve6400.cpp +++ b/ve/ve6400.cpp @@ -1,19 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - #include "ve6400a.h" #include "velib.h" +#include +#include +#include +#include + +#include + /////////////////////////////////////////////////////////// // Maschera principale /////////////////////////////////////////////////////////// @@ -47,11 +41,12 @@ bool TScontrino_mask::on_field_event(TOperable_field& o, TField_event e, long jo { switch (o.dlg()) { - case DLG_SAVEREC: + case DLG_PRINT: if (e == fe_button) { if (send_data() && _ini_loaded) stop_run(K_AUTO_ENTER); + return false; } break; default: @@ -88,28 +83,27 @@ bool TScontrino_mask::save_profile() bool TScontrino_mask::load_ini() { - _ini_loaded = FALSE; + _ini_loaded = false; const TApplication& a = main_app(); const int argc = a.argc(); if (argc <= 2) - return FALSE; + return false; TSheet_field& sheet = sfield(F_SHEET); const TString& arg = a.argv(2); if ((arg[0] != '-' && arg[0] != '/') || (arg[1] != 'i' && arg[1] != 'I')) - return FALSE; + return false; _ini_name = arg.mid(2); if (_ini_name.blank() && argc > 3) _ini_name = a.argv(3); if (!_ini_name.exist()) - return FALSE; + return false; - TString16 para; - para.format("%d", LF_DOC); + TString8 para; para.format("%d", LF_DOC); TString tmp; TDocumento doc; @@ -128,7 +122,7 @@ bool TScontrino_mask::load_ini() } const TString& cofi = doc.clifor().get(CLI_COFI); - if (cofi.not_empty()) + if (cofi.full()) set(F_COFI, cofi); else { @@ -143,28 +137,33 @@ bool TScontrino_mask::load_ini() break; const TString& tiporiga = ini.get(RDOC_TIPORIGA); - TRiga_documento& rdoc = doc.new_row(tiporiga); - TAssoc_array& vars = ini.list_variables(); - FOR_EACH_ASSOC_STRING(vars, obj, key, str) + if (tiporiga.full()) { - if (*str == '"') + TRiga_documento& rdoc = doc.new_row(tiporiga); + TAssoc_array& vars = ini.list_variables(); + FOR_EACH_ASSOC_STRING(vars, obj, key, str) { - tmp = str; - tmp.strip("\""); - str = tmp; + if (*str == '"') + { + tmp = str; + tmp.strip("\""); + str = tmp; + } + rdoc.put(key, str); } - rdoc.put(key, str); - } - if (tiporiga.not_empty() && rdoc.is_articolo()) - { - TToken_string& row = sheet.row(-1); - row = rdoc.get(RDOC_CODARTMAG); - row.add(rdoc.get(RDOC_DESCR)); - row.add(rdoc.get(RDOC_QTA)); - row.add(rdoc.prezzo(TRUE, TRUE).string()); - row.add("1"); - } + if (rdoc.is_articolo()) + { + const TString80 codart = rdoc.get(RDOC_CODARTMAG); + + TToken_string& row = sheet.row(-1); // Crea un nuova riga + row = codart; // Codice articolo + row.add(rdoc.get(RDOC_DESCR)); // Descrizione riga + row.add(rdoc.get(RDOC_QTA)); // Quantita' + row.add(rdoc.prezzo(true, true).string()); // Prezzo lordo scontato + row.add(cache().get(LF_ANAMAG, codart, ANAMAG_REPARTO)); // Reparto + } + } } _ini_loaded = sheet.items() > 0; @@ -180,11 +179,11 @@ bool TScontrino_mask::save_ini(KEY k) ini.set("Result", k == K_ENTER ? "OK" : "CANCEL"); ini.set("Error", "0"); - const TRectype& eld = cache().get("%ELD", ini.get("Action")); - const TString& stato_finale = eld.get("S4"); - if (stato_finale.not_empty()) + const TString& eld = ini.get("Action"); + const TString& stato_finale = cache().get("%ELD", eld, "S4"); + if (stato_finale.full()) { - TString16 para; para.format("%d", LF_DOC); + TString4 para; para.format("%d", LF_DOC); ini.set(DOC_STATO, stato_finale, para); } } @@ -193,28 +192,36 @@ bool TScontrino_mask::save_ini(KEY k) bool TScontrino_mask::send_er400_data(bool extra) { -/* TSheet_field& sheet = sfield(F_SHEET); + TSheet_field& sheet = sfield(F_SHEET); const int rows = sheet.items(); if (rows <= 0) - return FALSE; + return false; - TMask m("Modalita' di pagamento", 1, 26, 8); + TMask m(TR("Modalita' di pagamento"), 1, 26, 8); m.add_radio(101, 0, "", 1, 0, 24, "CASH|TICK|ASS|CARD|CRT", - "Contanti|Buoni|Assegno|Carta di Credito|Credito"); - m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); + HR("Contanti|Buoni|Assegno|Carta di Credito|Credito")); + m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); if (m.run() != K_ENTER) - return FALSE; + return false; - const char* server = "Sidcomm95"; - const char* topic = server; // Ignoranza totale delle regole di buona programmazione DDE! - TDDE smart; - if (!smart.initiate(server, topic)) - return error_box("Impossibile stabilire una comunicazione DDE con %s", server); + const char* const server = "Sidcomm95"; + const char* const topic = server; // Ignoranza totale delle regole di buona programmazione DDE! + + const unsigned int conn = aga_dde_connect("localhost", server, topic); + if (conn == 0) + return error_box(FR("Impossibile stabilire una comunicazione DDE con %s"), server); TString80 cmd, tmp; + if (extra && !field(F_COFI).empty()) + { + cmd = "[CODF,"; + cmd << get(F_COFI) << ']'; + aga_dde_execute(conn, cmd); + } + const int text_len = extra ? 18 : 15; TParagraph_string para("", text_len); @@ -235,51 +242,50 @@ bool TScontrino_mask::send_er400_data(bool extra) cmd << para.get(0); real price; row.get(pos_prezzo, price); - cmd << ',' << price; + TString80 s = price.string(18, 2); + + s.trim(); + const int p = s.find(".00"); + if (p > 0) + { + s.cut(p); s << "00"; + } + + cmd << ',' << s; int rep; row.get(pos_rep, rep); if (rep <= 0 || rep > 25) rep = 1; cmd << ',' << rep; real qta; row.get(pos_qta, qta); - cmd << ',' << qta << ']'; + + s = qta.string(10, 5); s.trim(); + cmd << ',' << s << ']'; - smart.execute(cmd); + aga_dde_execute(conn, cmd); } if (extra) { - tmp = get(F_COFI); - if (tmp.not_empty()) + para = get(F_SALUTI); // ARRIVEDERCI E GRAZIE! + for (int i = 1; i <= 2; i++) { - cmd = "[CODF,"; - cmd << get(F_COFI) << ']'; - smart.execute(cmd); - } - - para = get(F_SALUTI); - if (!para.blank()) - { - for (int i = 1; i <= 2; i++) + tmp = para.get(); + if (tmp.full()) { - tmp = para.get(); tmp.replace(',', ' '); tmp.replace('[', '('); tmp.replace(']', ')'); - if (!tmp.blank()) - { - cmd.format("[TXT%d,%s]", i, (const char*)tmp); - smart.execute(cmd); - } + cmd.format("[TXT%d,%s]", i, (const char*)tmp); + aga_dde_execute(conn, cmd); } } } - cmd = "["; - cmd << m.get(101) << ']'; - smart.execute(cmd); + cmd.cut(0) << '[' << m.get(101) << ']'; + aga_dde_execute(conn, cmd); - smart.terminate();*/ + aga_dde_terminate(conn); - return TRUE; + return true; } @@ -288,7 +294,7 @@ bool TScontrino_mask::send_scr_data() TSheet_field& sheet = sfield(F_SHEET); const int rows = sheet.items(); if (rows <= 0) - return FALSE; + return false; ofstream o("input.scr"); @@ -319,17 +325,16 @@ bool TScontrino_mask::send_scr_data() row.get(pos_prezzo,prezzo); row.get(pos_qta,qta); real tot = qta * prezzo; - tot.round(0); - + tot.round(0); o << "plud,c,:" << descr << ",n" << grmerc << ",p" << tot.string("@@@@@@@@@@@") << ";"< + #define wxAgaClient wxDDEClient + #define wxAgaConnection wxDDEConnection +#else + // Forse inutile: forse gia' fatto da wxWidgets + #include + #define wxAgaClient wxTCPClient + #define wxAgaConnection wxTCPConnection +#endif + +static wxAgaClient* _net_client = NULL; +static unsigned long _net_conns = 0; + +unsigned long aga_dde_connect(const char* host, const char* service, const char* topic) +{ + if (_net_client == NULL) + { + _net_client = new wxAgaClient; + _net_conns = 0; + } + + wxConnectionBase* conn = _net_client->MakeConnection(host, service, topic); + if (conn != NULL) + _net_conns++; + + return (unsigned long)conn; +} + +bool aga_dde_execute(unsigned long connection, const char* msg) +{ + bool ok = false; + if (connection != 0) + { + wxAgaConnection* conn = (wxAgaConnection*)connection; + ok = conn->Execute((char*)msg, -1); + } + return ok; +} + +bool aga_dde_terminate(unsigned long connection) +{ + bool ok = false; + if (connection != 0 && _net_client != NULL) + { + wxAgaConnection* conn = (wxAgaConnection*)connection; + ok = conn->Disconnect(); + if (ok && _net_conns > 0) + { + _net_conns--; + if (_net_conns == 0) + { + delete _net_client; + _net_client = NULL; + } + } + } + return ok; +} diff --git a/xvaga/agasys.h b/xvaga/agasys.h index ad444788c..ac711d165 100755 --- a/xvaga/agasys.h +++ b/xvaga/agasys.h @@ -15,4 +15,8 @@ XVTDLL bool aga_unzip(const char* zipfile, const char* destdir); XVTDLL bool aga_zip(const char* zipmask, const char* zipfile); XVTDLL bool aga_zip_filelist(const char* filelist, const char* zipfile); +XVTDLL unsigned long aga_dde_connect(const char* host, const char* service, const char* topic); +XVTDLL bool aga_dde_execute(unsigned long connection, const char* command); +XVTDLL bool aga_dde_terminate(unsigned long connection); + #endif diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 24fdcfd88..1512683c8 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -3235,7 +3235,7 @@ long xvt_fsys_get_file_attr(const FILE_SPEC* fs, long attr) // File system /////////////////////////////////////////////////////////// -SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs) +SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) { SLIST list = xvt_slist_create(); @@ -5224,4 +5224,4 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom, w.SetStatusWidths(2, widths); return (WINDOW)&w; -} \ No newline at end of file +} diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 35d085b4c..b0a75ba3a 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -164,7 +164,7 @@ XVTDLL BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs); XVTDLL BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp); XVTDLL void xvt_fsys_get_default_dir(DIRECTORY *dirp); -XVTDLL SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs); +XVTDLL SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs); XVTDLL BOOLEAN xvt_fsys_parse_pathname (const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers); XVTDLL void xvt_fsys_restore_dir(); XVTDLL void xvt_fsys_save_dir();