diff --git a/src/cg/cg0200.cpp b/src/cg/cg0200.cpp index c0e7ad05d..00f534f34 100755 --- a/src/cg/cg0200.cpp +++ b/src/cg/cg0200.cpp @@ -254,17 +254,31 @@ HIDDEN bool almeno_cf_o_pi(TMask_field& f) { const bool occas = m.get_bool(F_OCCASIONALE); const int alleg = m.get_int(F_ALLEG); + if (!occas && (alleg == 0 || alleg == 6 || alleg == 7)) // ... e non sono occasionale { const TEdit_field& cofi = m.efield(F_COFI); - if (cofi.empty()) // Dal 2007 serve il codice fiscale - ok = cofi.yesno_box(TR("Codice fiscale assente per residente in Italia : lo accetto ugualmente ?")); - // Se NON sono privato (alleg != 6), serve partita IVA + const bool only_one_paiv = ini_get_bool(CONFIG_DITTA, "cg", "OnlyOnePaIV"); + + if (cofi.empty()) // Dal 2007 serve il codice fiscale + { + if (only_one_paiv && !supervisor()) + return cofi.error_box(TR("Codice fiscale assente per residente in Italia")); + else + ok = cofi.yesno_box(TR("Codice fiscale assente per residente in Italia : lo accetto ugualmente ?")); + } if (ok) { const TEdit_field& paiv = m.efield(F_PAIV); - if (alleg != 6 && paiv.empty()) - ok = paiv.yesno_box(TR("Partita IVA assente per non privato : la accetto ugualmente ?")); + + // Se NON sono privato (alleg != 6), serve partita IVA + if (alleg != 6 && paiv.empty()) + { + if (only_one_paiv && !supervisor()) + return paiv.error_box(TR("Partita IVA assente per non privato")); + else + ok = paiv.yesno_box(TR("Partita IVA assente per non privato : la accetto ugualmente ?")); + } } } } @@ -1028,7 +1042,7 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query) break; if (i == 0) indsp_sheet().reset(); - + riga.cut(0); riga.add(ini.get(IND_RAGSOC)); riga.add(ini.get(IND_INDIR)); @@ -1050,7 +1064,7 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query) riga.add(com.get(COM_DENCOM)); riga.add(ini.get(IND_INDIR2)); riga.add(ini.get(IND_CODIND)); - + indsp_sheet().row(i)=riga; // Load the sheets of CODINDDOC, CODINDSP, CODINDEFF. @@ -1270,6 +1284,7 @@ void TClifo_application::reset_sheet() TClifo_application& a = app(); + a.field_sheet(F_CODINDDOC).destroy(); a.field_sheet(F_CODINDDOC).add(nulla); a.field_sheet(F_CODINDSP).destroy(); @@ -1335,7 +1350,7 @@ void TClifo_application::common_f(const TMask& m) indsp_pack(); TArray& rows=indsp_sheet().rows_array(); int n_items = rows.items(); - + for (int i = 0; i < n_items; i++) { TToken_string& row=(TToken_string&)rows[i]; @@ -1467,6 +1482,7 @@ void TClifo_application::indsp_sheet_rebuilder() for (int i = 0; i < n; i++) { TToken_string& riga= righe.row(i); + rigav.format("%d", i+1); rigav.add(riga.get(0)); rigav.add(riga.get()); @@ -1556,7 +1572,6 @@ bool TClifo_application::user_create() // initvar e arrmask open_files(LF_CLIFO, LF_CFVEN, LF_INDSP, LF_TAB, LF_TABCOM, LF_MOV, LF_ANAG, LF_ANAGFIS, LF_PCON, LF_COMUNI, LF_TABMOD, LF_CFPRI, 0); _has_cg = has_module(CGAUT, CHK_DONGLE); - _rel = new TClifoVI; //gestisce i campi salvati sulla tabella di modulo lv020 (lvclifo) _rel->add("&LV020" ,"CODTAB==" CLI_TIPOCF "+" CLI_CODCF, 1, LF_CLIFO, LVAUT); diff --git a/src/cg/cg1300l.h b/src/cg/cg1300l.h index 029a99a9b..c88e33fa4 100755 --- a/src/cg/cg1300l.h +++ b/src/cg/cg1300l.h @@ -1,6 +1,6 @@ #define F_TIPO 201 #define F_CLIFO 202 -#define F_COFI 203 +#define F_SORT 203 #define F_RESET 204 #define S_DIRTY 101 @@ -10,4 +10,6 @@ #define S_PAIV 105 #define S_COFI 106 #define S_ALLEG 107 -#define S_ERROR 108 +#define S_CODALLEG 108 +#define S_TIPOPERS 109 +#define S_ERROR 110 diff --git a/src/cg/cg1300l.uml b/src/cg/cg1300l.uml index 38030ddc7..b9b3bc7e7 100755 --- a/src/cg/cg1300l.uml +++ b/src/cg/cg1300l.uml @@ -27,9 +27,12 @@ BEGIN FLAGS "Z" END -BOOLEAN F_COFI +LISTBOX F_SORT 1 14 BEGIN - PROMPT 31 1 "Controllo Codice Fiscale" + PROMPT 31 1 "Ordinamento " + ITEM "1|Partita IVA" + ITEM "2|Codice fiscale" + ITEM "3|Codice" END SPREADSHEET F_CLIFO 0 -1 @@ -42,6 +45,8 @@ BEGIN ITEM "Partita IVA" ITEM "Codice Fiscale@16" ITEM "Allegato@28" + ITEM "Codice allegato" + ITEM "Tipo persona" ITEM "Problema riscontrato@50" END @@ -105,9 +110,21 @@ BEGIN ITEM "G|Gruppo IVA" END +NUMBER S_CODALLEG 7 +BEGIN + PROMPT 1 7 "Codice allegato" +END + +LISTBOX S_TIPOPERS 1 9 +BEGIN + PROMPT 1 8 "Allegato " + ITEM "F|Fisica" + ITEM "1|Giuridica" +END + MEMO S_ERROR 50 3 BEGIN - PROMPT 1 7 "Problema riscontrato" + PROMPT 1 9 "Problema riscontrato" FLAGS "D" END diff --git a/src/cg/cg1309.cpp b/src/cg/cg1309.cpp index 929eac013..fdfc0e3e7 100755 --- a/src/cg/cg1309.cpp +++ b/src/cg/cg1309.cpp @@ -31,10 +31,43 @@ public: TCheck_PIVA_mask() : TAutomask("cg1300l"), _last_row(0) {} }; +int sort(TSheet_field & s, int r1, int r2) +{ + const int key = s.mask().get_int(F_SORT); + + switch (key) + { + case 1: + { + const TString & p1 = s.get_str_row_cell(r1, S_PAIV); + const TString & p2 = s.get_str_row_cell(r2, S_PAIV); + + return strcmp(p1, p2); + } + break; + case 2: + { + const TString & c1 = s.get_str_row_cell(r1, S_COFI); + const TString & c2 = s.get_str_row_cell(r2, S_COFI); + + return strcmp(c1, c2); + } + break; + case 3: + { + long c1 = s.get_long_row_cell(r1, S_CODCF); + long c2 = s.get_long_row_cell(r2, S_CODCF); + + return c1 - c2; + } + break; + } + return 0; +} + // Carica lo sheet in base alle impostazioni correnti (F_CLIFO, F_COFI) void TCheck_PIVA_mask::load_sheet() { - const bool check_cofi = get_bool(F_COFI); TSheet_field& s = sfield(F_CLIFO); // Elenco di tutti i clienti (o fornitori) TISAM_recordset clifo("USE CLIFO\nFROM TIPOCF=#TIPO\nTO TIPOCF=#TIPO"); @@ -129,12 +162,15 @@ void TCheck_PIVA_mask::load_sheet() alleg = "0"; s.set_row_cell(S_ALLEG, alleg, r); s.set_row_cell(S_SOSPESO, clifo.get(CLI_SOSPESO).as_bool(), r); + s.set_row_cell(S_CODALLEG, clifo.get(CLI_CODALLEG).as_int(), r); + s.set_row_cell(S_TIPOPERS, clifo.get(CLI_TIPOPERS).as_string(), r); msg.trim(); s.set_row_cell(S_ERROR, msg, r); } } } } + s.sort(sort); s.force_update(); _row = s.items() > 0 ? s.row(0) : EMPTY_STRING; _last_row = 0; @@ -207,9 +243,14 @@ bool TCheck_PIVA_mask::on_field_event(TOperable_field& o, TField_event e, long j if (e == fe_init || e == fe_modify) update_sheet(); break; - case F_COFI: - if (e == fe_modify) - update_sheet(); + case F_SORT: + if (e == fe_modify) + { + TSheet_field& s = sfield(F_CLIFO); + + s.sort(sort); + s.force_update(); + } break; case F_RESET: if (e == fe_button)