diff --git a/ci/ci0300.cpp b/ci/ci0300.cpp index d998d3a61..9dc8d65ef 100755 --- a/ci/ci0300.cpp +++ b/ci/ci0300.cpp @@ -8,55 +8,12 @@ #include "ci0.h" #include "cilib.h" #include "ci0300.h" +#include "../ve/velib.h" /////////////////////////////////////////////////////////// // TConfigurazioneIndustriale_mask /////////////////////////////////////////////////////////// -void TConfigurazioneIndustriale_mask::add_element(TToken_string& t, long selrow) -{ - if (selrow<-1) - return; - - if (selrow>items()-1) - selrow = -1; - - rows_array().add(t,selrow); - force_update(); - -} - -void TConfigurazioneIndustriale_mask::add_element(long selrow) -{ - if (selrow<-1) - return; - - if (selrow>items()-1) - selrow = -1; - - sheet().insert(selrow, true, true); - force_update(); - -} - -void TConfigurazioneIndustriale_mask::delete_element(long selrow) -{ - TToken_string t(40); - - if (items()<1) - return; - - if (selrow<0) - return; - - if (selrow>items()-1) - return; - - rows_array().destroy(selrow); - force_update(); - -} - void TConfigurazioneIndustriale_mask::moveup_element(long selrow) { if (items()<=1) @@ -68,7 +25,9 @@ void TConfigurazioneIndustriale_mask::moveup_element(long selrow) if (selrow>items()-1) return; - rows_array().swap(selrow,selrow-1); + rows_array().swap(selrow,selrow - 1); + sheet().check_row(selrow - 1); + sheet().check_row(selrow); sheet().force_update(); sheet().select(selrow-1); @@ -86,6 +45,8 @@ void TConfigurazioneIndustriale_mask::movedown_element(long selrow) return; rows_array().swap(selrow,selrow+1); + sheet().check_row(selrow); + sheet().check_row(selrow + 1); sheet().force_update(); sheet().select(selrow+1); @@ -101,6 +62,37 @@ bool TConfigurazioneIndustriale_mask::on_field_event(TOperable_field& o, TField_ case F_MOVEDN: movedown_element(sheet().selected()); break; + case FR_TIPODOC: + if (e == fe_modify) + { + TCodice_numerazione cod_num(o.mask().get(FR_NUM)); + const TString& tipo = o.get(); + int last = cod_num.ntipi_doc(); + + for (int i = 0; i < last; i++ ) + { + const TString16 curtipo(cod_num.tipo_doc(i)); + if (curtipo == tipo) + return true; + } + return o.error_box( "Tipo non valido per la numerazione selezionata!" ); + } + + case FR_COLL: + if (e == fe_modify && !o.mask().is_running()) + { + TMask & row_mask = o.mask(); + + row_mask.set(FR_NUM, ""); + row_mask.set(FR_TIPODOC, ""); + row_mask.set(FR_STATO, ""); + row_mask.set(FR_VAR, ""); + row_mask.set(FR_MODCOLL, ""); + const int row = sheet().selected(); + sheet().update_row(row); + sheet().check_row(row); + sheet().force_update(row); + } default: break; } @@ -158,15 +150,21 @@ void TConfigurazioneIndustriale_app::file_to_sheet() while (configfile.exist("Descr",item)) { - TToken_string t; + TToken_string & t = mask().sheet().row(item); t.add(configfile.get("Filter", NULL,item, "F01")); t.add(configfile.get("Descr", NULL,item, "Fatture")); t.add(configfile.get("InsertRemain", NULL,item, "")); t.add(configfile.get("ModifyRemain", NULL,item, "")); - mask().add_element(t); + t.add(configfile.get("DocColl", NULL, item, "")); + t.add(configfile.get("NumColl", NULL, item, "")); + t.add(configfile.get("TipoColl", NULL, item, "")); + t.add(configfile.get("StatoColl", NULL, item, "")); + t.add(configfile.get("ModColl", NULL, item, "")); + t.add(configfile.get("Var", NULL, item, "")); + mask().sheet().check_row(item); item++; } - + mask().sheet().force_update(); } void TConfigurazioneIndustriale_app::sheet_to_file() @@ -191,6 +189,12 @@ void TConfigurazioneIndustriale_app::sheet_to_file() configfile.set("Descr", currdesc, NULL, true, i); configfile.set("InsertRemain", mask().row(i).get(2), NULL, true, i); configfile.set("ModifyRemain", mask().row(i).get(3), NULL, true, i); + configfile.set("DocColl", mask().row(i).get(4), NULL, true, i); + configfile.set("NumColl", mask().row(i).get(5), NULL, true, i); + configfile.set("TipoColl", mask().row(i).get(6), NULL, true, i); + configfile.set("StatoColl", mask().row(i).get(7), NULL, true, i); + configfile.set("ModColl", mask().row(i).get(8), NULL, true, i); + configfile.set("Var", mask().row(i).get(9), NULL, true, i); totlen+=currdesc.len(); } diff --git a/ci/ci0300.h b/ci/ci0300.h index 8509efa33..4d0967385 100755 --- a/ci/ci0300.h +++ b/ci/ci0300.h @@ -13,9 +13,6 @@ protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); public: - void add_element(TToken_string& t, long selrow = -1); - void add_element(long selrow = -1); - void delete_element(long selrow); void moveup_element(long selrow); void movedown_element(long selrow); diff --git a/ci/ci0300a.h b/ci/ci0300a.h index 9a803f71e..662422905 100755 --- a/ci/ci0300a.h +++ b/ci/ci0300a.h @@ -1,6 +1,22 @@ // DEFINIZIONE CAMPI MASCHERE PER LA CONFIGURAZIONE di CI // campi maschera ci0300a.uml -#define F_SHEET 151 -#define F_MOVEUP 152 -#define F_MOVEDN 153 +#define F_SHEET 151 +#define F_MOVEUP 152 +#define F_MOVEDN 153 + + +#define FR_FILTRO 101 +#define FR_DES 102 +#define FR_INS 103 +#define FR_MOD 104 +#define FR_COLL 105 +#define FR_NUM 106 +#define FR_TIPODOC 107 +#define FR_STATO 108 +#define FR_MODCOLL 109 +#define FR_VAR 110 + +#define FR_DESNUM 201 +#define FR_DESTIPODOC 202 +#define FR_DESSTA 203 diff --git a/ci/ci0300a.uml b/ci/ci0300a.uml index e4eb1e8a9..5f7f9f021 100755 --- a/ci/ci0300a.uml +++ b/ci/ci0300a.uml @@ -18,13 +18,19 @@ ENDPAGE PAGE "Configurazione" -1 -1 78 23 -SPREADSHEET F_SHEET 74 16 +SPREADSHEET F_SHEET -1 16 BEGIN PROMPT 3 1 "" - ITEM "Filtro@4" + ITEM "Filtro" ITEM "Descrizione@30" - ITEM "Rimani in\nInserimento@14" - ITEM "Rimani in\nModifica@14" + ITEM "Rimani in\ninserimento@11" + ITEM "Rimani in\nmodifica@9" + ITEM "Documento\ncollegato@9" + ITEM "Numerazione" + ITEM "Tipo\nDocumento" + ITEM "Stato" + ITEM "Modifica documento\ncollegato@18" + ITEM "Campi modificati@50" END BUTTON F_MOVEUP 2 2 @@ -43,35 +49,133 @@ ENDPAGE ENDMASK -PAGE "Tipologia Documento" -1 -1 50 8 +PAGE "Tipologia Documento" -1 -1 78 13 -STRING 101 4 +STRING FR_FILTRO 4 BEGIN PROMPT 1 1 "Filtro " USE %NUM - INPUT CODTAB 101 + INPUT CODTAB FR_FILTRO DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 - OUTPUT 101 CODTAB - OUTPUT 102 S0 + OUTPUT FR_FILTRO CODTAB + OUTPUT FR_DES S0 CHECKTYPE NORMAL FLAG "UPA" END -STRING 102 30 +STRING FR_DES 30 BEGIN PROMPT 1 2 "Descrizione " END -BOOLEAN 103 +BOOLEAN FR_INS BEGIN PROMPT 1 3 "Rimani in inserimento" END -BOOLEAN 104 +BOOLEAN FR_MOD BEGIN - PROMPT 1 4 "Rimani in inserimento" + PROMPT 1 4 "Rimani in modifica" +END + +BOOLEAN FR_COLL +BEGIN + PROMPT 1 5 "Documento collegato" + MESSAGE FALSE CLEAR,1@ + MESSAGE TRUE ENABLE,1@ +END + +BOOLEAN FR_MODCOLL +BEGIN + PROMPT 23 5 "Modifica interattiva del documento collegato" + GROUP 1 +END + +STRING FR_NUM 4 +BEGIN + PROMPT 1 6 "Numerazione " + USE %NUM + INPUT CODTAB FR_NUM + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT FR_NUM CODTAB + OUTPUT FR_DESNUM S0 + CHECKTYPE REQUIRED + FLAG "UPA" + GROUP 1 +END + +STRING FR_DESNUM 50 +BEGIN + PROMPT 23 6 "" + HELP "Descrizione numerazione" + USE %NUM KEY 2 + INPUT S0 FR_DESNUM + DISPLAY "Descrizione@50" S0 + DISPLAY "Codice" CODTAB + COPY OUTPUT FR_NUM + GROUP 1 +END + +STRING FR_TIPODOC 4 +BEGIN + PROMPT 1 7 "Tipo " + HELP "Codice tipo documento" + USE %TIP + INPUT CODTAB FR_TIPODOC + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT FR_TIPODOC CODTAB + OUTPUT FR_DESTIPODOC S0 + CHECKTYPE REQUIRED + FLAG "UP" + GROUP 1 +END + +STRING FR_DESTIPODOC 50 +BEGIN + PROMPT 23 7 "" + HELP "Descrizione tipo documento" + USE %TIP KEY 2 + INPUT S0 FR_DESTIPODOC + DISPLAY "Descrizione@50" S0 + DISPLAY "Codice" CODTAB + COPY OUTPUT FR_TIPODOC + GROUP 1 +END + +STRING FR_STATO 1 +BEGIN + PROMPT 1 8 "Stato " + USE %STD + CHECKTYPE REQUIRED + INPUT CODTAB FR_STATO + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT FR_STATO CODTAB + OUTPUT FR_DESSTA S0 + FLAG "U" + GROUP 1 +END + +STRING FR_DESSTA 50 +BEGIN + PROMPT 23 8 "" + HELP "Descrizione tipo documento" + USE %STD KEY 2 + INPUT S0 FR_DESSTA + DISPLAY "Descrizione@40" S0 + DISPLAY "Codice" CODTAB + COPY OUTPUT FR_STATO + GROUP 1 +END + +ZOOM FR_VAR 50 +BEGIN + PROMPT 1 9 "Campi variati " + GROUP 1 END BUTTON DLG_CANCEL 10 2 diff --git a/ci/ci0400.cpp b/ci/ci0400.cpp index a227efbe2..b9e60806e 100755 --- a/ci/ci0400.cpp +++ b/ci/ci0400.cpp @@ -33,11 +33,18 @@ void TImmissioneDocumenti_app::init_tabs() while (items == 0 || configfile.exist("Descr",items)) { - pagenames.add(configfile.get("Descr", NULL,items, "Fatture")); - m.filters().add(configfile.get("Filter", NULL,items, "F01")); + pagenames.add(configfile.get("Descr", NULL, items, "Fatture")); + m.filters().add(configfile.get("Filter", NULL, items, "F01")); m.insert().set(items, configfile.get_bool("InsertRemain", NULL, items)); m.modify().set(items, configfile.get_bool("ModifyRemain", NULL, items)); - m.activate_almanac(F_AL01 + items, items, TDate(TODAY)); + m.doc_coll().set(items, configfile.get_bool("DocColl", NULL, items)); + m.num_coll().add(configfile.get("NumColl", NULL, items), items); + m.tipo_coll().add(configfile.get("TipoColl", NULL, items), items); + m.stato_coll().add(configfile.get("StatoColl", NULL, items), items); + m.var_coll().add(configfile.get("Var", NULL, items), items); + m.mod_coll().set(items, configfile.get_bool("ModColl", NULL, items)); + m.activate_almanac(F_AL01 + items, items, TDate(TODAY)); + items++; } m.disable_page(items); @@ -87,6 +94,9 @@ void TImmissioneDocumenti_app::init_flags() bool TImmissioneDocumenti_app::create() { + open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR, + LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, LF_MOV, LF_STOMAG, + LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0); _mask = new TImmissioneDocumenti_mask(); init_tabs(); @@ -218,8 +228,7 @@ void TImmissioneDocumenti_mask::open_day_mask(TDate date) void TImmissioneDocumenti_mask::call_ve0(int exitval, TRelation& relation, TDate& date, const TString& codnum, const TString& doctype, byte currpage) { TFilename tempfile; - tempfile.tempdir(); - tempfile.add("ci.ini"); + tempfile.temp("", "ini"); { TConfig configfile(tempfile); @@ -228,7 +237,7 @@ void TImmissioneDocumenti_mask::call_ve0(int exitval, TRelation& relation, TDate { case K_ENTER: configfile.set("Action", "Modify", "Transaction"); - if (_modify[currpage]) + if (modify()[currpage]) configfile.set("Mode", "R", "Transaction"); configfile.set("NDOC", relation.lfile().get(DOC_NDOC), "33"); break; @@ -238,7 +247,7 @@ void TImmissioneDocumenti_mask::call_ve0(int exitval, TRelation& relation, TDate break; case K_INS: configfile.set("Action", "Insert", "Transaction"); - if (_insert[currpage]) + if (insert()[currpage]) configfile.set("Mode", "R", "Transaction"); configfile.set("DATADOC", date.string(), "33"); break; @@ -259,6 +268,105 @@ void TImmissioneDocumenti_mask::call_ve0(int exitval, TRelation& relation, TDate TExternal_app ve(commandline); ve.run(); + if (doc_coll()[currpage]) + { + TDocumento doc; + TLocalisamfile documenti(LF_DOC); + long recno; + long ndoc_coll = 0L; + bool new_doc = false; + + { + TConfig configfile(tempfile); + + recno = configfile.get_long("Record", "Transaction"); + if (recno > 0L) + { + doc.head().readat(documenti, recno); + doc.read(); + + + const TString16 num_coll(num_coll().row(currpage)); + const TString16 tipo_coll(tipo_coll().row(currpage)); + const TString16 stato_coll(stato_coll().row(currpage)); + const long ndoc = doc.get_long(DOC_NDOC); + + TLocalisamfile rdoc(LF_RIGHEDOC); + rdoc.setkey(4); + rdoc.put(RDOC_DAPROVV, "D"); + rdoc.put(RDOC_DAANNO, date.year()); + rdoc.put(RDOC_DACODNUM, codnum); + rdoc.put(RDOC_DANDOC, ndoc); + + new_doc = rdoc.read(_isgteq) != NOERR; + + if (!new_doc) + { + bool new_doc = (rdoc.get(RDOC_DAPROVV) != "D"); + + new_doc |= (rdoc.get_int(RDOC_DAANNO) != date.year()); + new_doc |= (rdoc.get(RDOC_DACODNUM) != codnum); + new_doc |= (rdoc.get_long(RDOC_DANDOC) != ndoc); + + if (!new_doc) + ndoc_coll = rdoc.get_long(RDOC_NDOC); + } + + configfile.set(DOC_CODNUM, num_coll, "33"); + configfile.set(DOC_TIPODOC, tipo_coll, "33"); + + if (exitval == K_DEL) + configfile.set("Action", "Delete", "Transaction"); + else + { + TDocumento doc_coll('D', date.year(), num_coll, ndoc_coll); + + configfile.set("Action", "Modify", "Transaction"); + configfile.set("Mode", "", "Transaction"); + configfile.set_paragraph("33"); + configfile.remove("STATO"); // creato dalla transazione precedente ??? + + if (new_doc) + { + TToken_string var(var_coll().row(currpage), ' '); + + doc_coll.copy_contents(doc); + + for (const char * field = var.get(0); field && *field; field = var.get()) + doc_coll.zero(field); + doc_coll.put(DOC_STATO, stato_coll); + doc_coll.write(); + ndoc_coll = doc_coll.get_long(DOC_NDOC); + } + else + { + TString_array vals; + TToken_string var(var_coll().row(currpage), ' '); + const char * field; + + var.add(DOC_STATO); + for (field = var.get(0); field && *field; field = var.get()) + vals.add(doc_coll.get(field)); + + doc_coll.copy_contents(doc); + + int i = 0; + + for (field = var.get(0); field && *field; field = var.get()) + doc_coll.put(field, vals.row(i++)); + doc_coll.rewrite(); + + if (!mod_coll()[currpage]) + ndoc_coll = 0L; + } + } + configfile.set(DOC_NDOC, ndoc_coll, "33"); + } + } + if (ndoc_coll > 0L) + ve.run(); + } + remove_file(tempfile); } diff --git a/ci/ci0400.h b/ci/ci0400.h index 366ebbedc..1f922f8a1 100755 --- a/ci/ci0400.h +++ b/ci/ci0400.h @@ -12,7 +12,12 @@ class TImmissioneDocumenti_mask : public TAlmanac_mask TBit_array _ordered; TBit_array _insert; TBit_array _modify; - + TBit_array _doccoll; + TBit_array _modcoll; + TString_array _numcoll; + TString_array _tipocoll; + TString_array _statocoll; + TString_array _varcoll; protected: @@ -26,11 +31,23 @@ public: const TString_array & filters() const { return _filters;} const TArray & flags() const { return _flags;} const TBit_array & ordered() const { return _ordered;} + const TBit_array & doc_coll() const { return _doccoll;} + const TBit_array & mod_coll() const { return _modcoll;} + const TString_array & num_coll() const { return _numcoll;} + const TString_array & tipo_coll() const { return _tipocoll;} + const TString_array & stato_coll() const { return _statocoll;} + const TString_array & var_coll() const { return _varcoll;} TString_array & filters() { return _filters;} TArray & flags() { return _flags;} TBit_array & ordered() { return _ordered;} TBit_array & insert() { return _insert;} TBit_array & modify() { return _modify;} + TBit_array & doc_coll() { return _doccoll;} + TBit_array & mod_coll() { return _modcoll;} + TString_array & num_coll() { return _numcoll;} + TString_array & tipo_coll() { return _tipocoll;} + TString_array & stato_coll() { return _statocoll;} + TString_array & var_coll() { return _varcoll;} public: // apertura del foglio interno di gestione dei documenti diff --git a/ci/ci1200b.rep b/ci/ci1200b.rep index ed1721c9e..334627e98 100755 --- a/ci/ci1200b.rep +++ b/ci/ci1200b.rep @@ -176,7 +176,7 @@ MESSAGE EMPTY SHOW,20|HIDE,10 - USE RDOC KEY 2 SELECT (((CODNUM=#S_CODNUM)||(CODNUM='MNI')||(CODNUM='DFNI')||(CODNUM='FCI'))STR(CODCMS=#S_CMS)NUM(ANSI(33.DATADOC)E;=ANSI(#S_DATEFROM))NUM(ANSI(33.DATADOC)C;=#S_DATETO)(33.CODCFE;=#DACF)(33.CODCFC;=#ACF)) + USE RDOC KEY 2 BY 20.RAGSOC 33.NDOC 33.DATADOC NRIGA JOIN DOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC JOIN CLIFO TO DOC INTO CODCF=CODCF TIPOCF=TIPOCF diff --git a/ci/ci1200c.rep b/ci/ci1200c.rep index 00d5230a1..bf87ba98d 100755 --- a/ci/ci1200c.rep +++ b/ci/ci1200c.rep @@ -162,7 +162,7 @@ - USE RDOC KEY 2 SELECT ((CODNUM=#S_CODNUM)NUM(ANSI(33.DATADOC)E;=ANSI(#S_DATEFROM))NUM(ANSI(33.DATADOC)C;=#S_DATETO)) + USE RDOC KEY 2 BY 33.TIPODOC CODART CODCMS 33.DATADOC JOIN DOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC JOIN COMMESSE INTO CODCMS=CODCMS diff --git a/ci/ci1200d.rep b/ci/ci1200d.rep index 536eae74e..86f75ea4b 100755 --- a/ci/ci1200d.rep +++ b/ci/ci1200d.rep @@ -164,7 +164,7 @@ - USE RDOC KEY 2 SELECT ((CODNUM=#S_CODNUM)NUM(ANSI(33.DATADOC)E;=ANSI(#S_DATEFROM))NUM(ANSI(33.DATADOC)C;=#S_DATETO)) + USE RDOC KEY 2 BY 20.RAGSOC 33.TIPODOC 34.CODCMS 33.DATADOC JOIN DOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC JOIN CLIFO TO DOC INTO CODCF=CODCF TIPOCF=TIPOCF diff --git a/ci/ci1200e.rep b/ci/ci1200e.rep index 34e000b73..f9e3d15db 100755 --- a/ci/ci1200e.rep +++ b/ci/ci1200e.rep @@ -122,7 +122,7 @@ - USE RDOC KEY 2 SELECT (((CODNUM=#S_CODNUM)||(CODNUM='MNI')||(CODNUM='DFNI')||(CODNUM='FCI'))STR(CODCMSE;=#S_CMSFROM)STR(CODCMSC;=#S_CMSTO)NUM(ANSI(33.DATADOC)E;=ANSI(#S_DATEFROM))NUM(ANSI(33.DATADOC)C;=#S_DATETO)(33.TIPODOC!='')) + USE RDOC KEY 2 BY CODCMS 33.TIPODOC[2,4] JOIN DOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC JOIN COMMESSE INTO CODCMS=CODCMS diff --git a/ci/ci1200f.rep b/ci/ci1200f.rep index c02e815b9..6b751100b 100755 --- a/ci/ci1200f.rep +++ b/ci/ci1200f.rep @@ -192,7 +192,7 @@ - USE RDOC KEY 2 SELECT (((CODNUM=#S_CODNUM)||(CODNUM="MNI"))STR(CODCMSE;=#S_CMSFROM)STR(CODCMSC;=#S_CMSTO)NUM(ANSI(33.DATADOC)E;=ANSI(#S_DATEFROM))NUM(ANSI(33.DATADOC)C;=#S_DATETO)) + USE RDOC KEY 2 BY 33.CODCMS 33.TIPODOC CODART JOIN DOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC JOIN COMMESSE INTO CODCMS=CODCMS diff --git a/ci/ci1200g.rep b/ci/ci1200g.rep index 8ef5a1734..0c81d2832 100755 --- a/ci/ci1200g.rep +++ b/ci/ci1200g.rep @@ -191,7 +191,7 @@ - USE DOC KEY 3 SELECT ((CODNUM=#S_CODNUM)STR(CODCMSE;=#S_CMSFROM)STR(CODCMSC;=#S_CMSTO)) + USE DOC KEY 3 BY CODCMS TIPODOC JOIN RDOC INTO CODNUM=CODNUM ANNO=ANNO PROVV=PROVV NDOC=NDOC FROM DATADOC=#S_DATEFROM