diff --git a/cm/cm1100.cpp b/cm/cm1100.cpp index 2a10fae27..88c9d25e6 100755 --- a/cm/cm1100.cpp +++ b/cm/cm1100.cpp @@ -41,10 +41,13 @@ bool TPag_per_cms_mask::on_field_event(TOperable_field& o, TField_event e, long // class dei dati da passare in stampa class TPag_per_cms_struct : public TSortable { + protected: virtual int compare(const TSortable& s) const; public: + static bool _ordina_forn; + int _tipo; long _codforn; TDate _datapag; @@ -60,23 +63,35 @@ public: TPag_per_cms_struct() : _tipo(0), _codforn(0), _nreg(0) { } }; +bool TPag_per_cms_struct::_ordina_forn = false; + int TPag_per_cms_struct::compare(const TSortable& s) const { const TPag_per_cms_struct& pcs = (const TPag_per_cms_struct&)s; - int cmp = _commessa.compare(pcs._commessa); - if (cmp == 0) + int cmp = 0; + if(_ordina_forn) { - cmp = _tipo - pcs._tipo; + if (_tipo == 0) + cmp = _codforn - pcs._codforn; + else + cmp = _conto.compare(pcs._conto); + + if (cmp == 0) + cmp = _nreg - pcs._nreg; + } + else + { + cmp = _commessa.compare(pcs._commessa); if (cmp == 0) { - switch (_tipo) //caso pagamento o costo non saldacontato + cmp = _tipo - pcs._tipo; + if (cmp == 0) { - case 0: - cmp = _nreg - pcs._nreg; - break; - default: - cmp = _conto.compare(pcs._conto); - break; + //caso pagamento o costo non saldacontato + if (_tipo == 0) + cmp = _nreg - pcs._nreg; + else + cmp = _conto.compare(pcs._conto); } } } @@ -104,6 +119,7 @@ protected: virtual bool validate(TForm_item &cf, TToken_string &s); const TString& prev_cms() const; + const long prev_forn() const; const TString& next_cms() const; int prev_type () const; const TPag_per_cms_struct& curr() const { return(TPag_per_cms_struct&)_righe[_curr_pag]; } @@ -125,6 +141,14 @@ const TString& TPag_per_cms_form::prev_cms() const return prev._commessa; } +const long TPag_per_cms_form::prev_forn() const +{ + if (_curr_pag <= 0) + return 0; + const TPag_per_cms_struct& prev = (const TPag_per_cms_struct&)_righe[_curr_pag-1]; + return prev._codforn; +} + const TString& TPag_per_cms_form::next_cms() const { if (_curr_pag >= _righe.last()) @@ -144,7 +168,7 @@ int TPag_per_cms_form::prev_type() const void TPag_per_cms_form::print_title (const char * title) { TPrint_section& last_head = section('H', last_page); - last_head.find_field(FR_CODCMS).set(title); + last_head.find_field(FR_HL_CODCMS).set(title); last_head.update(); for (word i = 0; i < last_head.height(); i++) printer().print(last_head.row(i)); @@ -159,7 +183,10 @@ void TPag_per_cms_form::azzera_totali() void TPag_per_cms_form::stampa_totali() { TPrintrow pr; - pr.put("@bTotali per commessa", 21); + if (TPag_per_cms_struct::_ordina_forn) + pr.put("@bTotali per fornitore", 21); + else + pr.put("@bTotali per commessa", 21); TCurrency tot; FOR_EACH_ASSOC_OBJECT(_tot_fatt, h, k, obj) @@ -170,17 +197,17 @@ void TPag_per_cms_form::stampa_totali() TString80 str; str = tot.string(true); str.right_just(15); - pr.put(str, 76); + pr.put(str, 83); str = _totpagcms.string(true); str.right_just(15); - pr.put(str, 93); + pr.put(str, 100); const TCurrency residuo = tot - _totpagcms; if (!residuo.is_zero()) { str = residuo.string(true); str.right_just(15); - pr.put(str, 109); + pr.put(str, 116); } printer().print(pr); @@ -205,8 +232,24 @@ bool TPag_per_cms_form::validate(TForm_item &cf, TToken_string &s) if (s == "_CODCMS") { - const TString& cms = curr()._commessa; - if (cms != prev_cms()) + bool cambio = false; + TString80 titolo; + if (TPag_per_cms_struct::_ordina_forn) + { + const long forn = curr()._codforn; + cambio = forn != prev_forn(); + TString16 key; + key.format("F|%ld", forn); + titolo = cache().get(LF_CLIFO, key, CLI_RAGSOC); + } + else + { + const TString& cms = curr()._commessa; + cambio = cms != prev_cms(); + titolo = cms; + } + + if (cambio) { if (_curr_pag > 0) { @@ -214,8 +257,8 @@ bool TPag_per_cms_form::validate(TForm_item &cf, TToken_string &s) if (_curr_pag < _righe.last()) //se sei all'ultimo movimento non aggiungere pagine vuote printer().formfeed(); } - if (cms.not_empty()) - print_title(cms); + if (titolo.not_empty()) + print_title(titolo); } else { @@ -280,8 +323,14 @@ bool TPag_per_cms_form::validate(TForm_item &cf, TToken_string &s) if (s == "_CODFORN") { - TString8 str; - str << curr()._codforn; + TString80 str; + if (TPag_per_cms_struct::_ordina_forn) + str << curr()._commessa; + else + { + if (curr()._codforn > 0) + str.format("%6ld", curr()._codforn); + } cf.set(str); return true; } @@ -325,11 +374,30 @@ bool TPag_per_cms_form::validate(TForm_item &cf, TToken_string &s) void TPag_per_cms_form::print(const TMask& m) { +//header odd del form (intestazione della pagina) TPrint_section& header = section('H', odd_page); - header.find_field(FR_DATAINI).set(m.get(F_DATAINI)); - header.find_field(FR_DATAFIN).set(m.get(F_DATAFIN)); - header.find_field(FR_DACDC).set(m.get(F_DACDC)); - header.find_field(FR_ACDC).set(m.get(F_ACDC)); + header.find_field(FR_HO_DATAINI).set(m.get(F_DATAINI)); + header.find_field(FR_HO_DATAFIN).set(m.get(F_DATAFIN)); + + header.find_field(FR_HO_DACODFOR).set(m.get(F_DACODFOR)); + header.find_field(FR_HO_DADESFOR).set(m.get(F_DADESFOR)); + header.find_field(FR_HO_ACODFOR).set(m.get(F_ACODFOR)); + header.find_field(FR_HO_ADESFOR).set(m.get(F_ADESFOR)); + + header.find_field(FR_HO_DACDC).set(m.get(F_DACDC)); + const TRectype& dacms = cache().get("CMS", m.get(F_DACDC)); + TString80 des = dacms.get("S0"); + header.find_field(FR_HO_DADESC).set(des); + header.find_field(FR_HO_ACDC).set(m.get(F_ACDC)); + const TRectype& acms = cache().get("CMS", m.get(F_ACDC)); + des = acms.get("S0"); + header.find_field(FR_HO_ADESC).set(des); + + if (TPag_per_cms_struct::_ordina_forn) + header.find_field(FR_HO_FORNCMS).set("Commessa"); + else + header.find_field(FR_HO_FORNCMS).set("Fornitore"); + _curr_pag = 0; azzera_totali(); //aggiunge una riga vuota (ppcs vuoto) per forzare il totale dell'ultima commessa @@ -366,7 +434,7 @@ protected: virtual bool create(); virtual bool destroy(); - bool cms_in_range(const TString& codcms) const; + bool cms_in_range(const TString& codcms, const TString& codfase) const; long find_movimento(const TRectype& riga_pag) const; void find_commesse(const long nreg, const TRectype& riga_pag); void find_commesse_cg(const long nreg); @@ -434,16 +502,26 @@ long TPag_per_cms::find_movimento(const TRectype& riga_pag) const return nreg; } -bool TPag_per_cms::cms_in_range(const TString& codcms) const +bool TPag_per_cms::cms_in_range(const TString& codcms, const TString& codfase) const { if (codcms.empty()) return false; - const TString& dalla = _mask->get(F_DACDC); - if (dalla.not_empty() && codcms < dalla) + const TString& dallac = _mask->get(F_DACDC); + if (dallac.not_empty() && codcms < dallac) return false; - const TString& alla = _mask->get(F_ACDC); - if (alla.not_empty() && codcms > alla) + const TString& allac = _mask->get(F_ACDC); + if (allac.not_empty() && codcms > allac) return false; +//la fase puo' essere vuota!! + if (codfase.empty()) + return true; + const TString& dallaf = _mask->get(F_DAFSC); + if (dallaf.not_empty() && codcms < dallaf) + return false; + const TString& allaf = _mask->get(F_AFSC); + if (allaf.not_empty() && codcms < allaf) + return false; + return true; } @@ -462,7 +540,8 @@ void TPag_per_cms::find_commesse(const long nreg, const TRectype& riga_pag) { const TRectype& rmoviva = pn.iva(i); const TString& codcms = rmoviva.get(RMI_CODCMS); - if (cms_in_range(codcms)) + const TString& codfase = rmoviva.get(RMI_FASCMS); + if (cms_in_range(codcms, codfase)) { real* imp = (real*)commesse.objptr(codcms); if (imp == NULL) @@ -524,7 +603,8 @@ void TPag_per_cms::find_commesse_cg(const long nreg) { const TRectype& rmov = pn.cg(i); const TString& codcms = rmov.get(RMV_CODCMS); - if (cms_in_range(codcms)) + const TString& codfase = rmov.get(RMV_FASCMS); + if (cms_in_range(codcms,codfase)) { const TBill conto(rmov); if (cerca_costo(conto)) @@ -575,25 +655,6 @@ void TPag_per_cms::lettura_conti(const char* paragrafo, TAssoc_array& assoc) assoc.add(val); } - -bool TPag_per_cms::create() -{ - _mask = new TPag_per_cms_mask; - _form = new TPag_per_cms_form(_righe); - - lettura_conti("Costi", _costi); //caricamento dei conti dei costi - lettura_conti("Pagamenti", _pagamenti); // "" pagamenti - - return TSkeleton_application::create(); -} - -bool TPag_per_cms::destroy() -{ - delete _mask; - delete _form; - return TRUE; -} - // Mettere in libreria al piu' presto!!!! typedef bool (*SCAN_FUNC)(const TRelation& rel, void* pJolly); @@ -645,7 +706,18 @@ bool TPag_per_cms::part_callback(const TRelation& rel, void* pJolly) void TPag_per_cms::scan_pags() { //costruzione filtro - TString filtro = "(TIPOC==\"F\")&&(TIPOPAG>=\"3\")"; //deve essere un pagamento a fornitore!!! + const long dacodfor = _mask->get_long(F_DACODFOR); + const long acodfor = _mask->get_long(F_ACODFOR); + TRectype darec(LF_PARTITE); + TRectype arec(LF_PARTITE); + darec.put(PART_TIPOCF, 'F'); + arec.put(PART_TIPOCF, 'F'); + if (dacodfor > 0) + darec.put(PART_SOTTOCONTO, dacodfor); + if (acodfor >= acodfor) + arec.put(PART_SOTTOCONTO, acodfor); + + TString filtro = "(TIPOPAG>=\"3\")"; //deve essere un pagamento a fornitore!!! const TDate dataini = _mask->get(F_DATAINI); const TDate datafin = _mask->get(F_DATAFIN); if (dataini.ok()) @@ -662,7 +734,7 @@ void TPag_per_cms::scan_pags() } //applica il filtro alla relazione TRelation rel(LF_PARTITE); - TCursor cur(&rel, filtro); + TCursor cur(&rel, filtro, 1, &darec, &arec); scan_cursor(cur, "Ricerca commesse...", part_callback, this); } @@ -739,6 +811,24 @@ void TPag_per_cms::crea_righe_stampa(TAssoc_array& assoc, const int tipo) } } +bool TPag_per_cms::create() +{ + _mask = new TPag_per_cms_mask; + _form = new TPag_per_cms_form(_righe); + + lettura_conti("Costi", _costi); //caricamento dei conti dei costi + lettura_conti("Pagamenti", _pagamenti); // "" pagamenti + + return TSkeleton_application::create(); +} + +bool TPag_per_cms::destroy() +{ + delete _mask; + delete _form; + return TRUE; +} + void TPag_per_cms::main_loop() { while (_mask->run() == K_ENTER) @@ -750,7 +840,8 @@ void TPag_per_cms::main_loop() case 2:_campodata = PART_DATAPAG;break; default:break; } - + + TPag_per_cms_struct::_ordina_forn = _mask->get_bool(F_ORDINAMENTO); _righe.destroy(); //azzera l'arrayone dei pagamenti scan_pags(); scan_movs(); diff --git a/cm/cm1100.h b/cm/cm1100.h index 691f862b7..c59864920 100755 --- a/cm/cm1100.h +++ b/cm/cm1100.h @@ -1,11 +1,21 @@ // campi del form cm1100a.frm -#define FR_DATAINI 11 -#define FR_DATAFIN 12 -#define FR_DACDC 13 -#define FR_ACDC 14 -#define FR_CODCMS 15 -#define FR_TIPORIGA 16 -#define FR_DESC 17 +#define FR_HO_DATAINI 11 +#define FR_HO_DATAFIN 12 +#define FR_HO_DACDC 13 +#define FR_HO_DADESC 14 +#define FR_HO_ACDC 15 +#define FR_HO_ADESC 16 +#define FR_HO_DACODFOR 17 +#define FR_HO_DADESFOR 18 +#define FR_HO_ACODFOR 19 +#define FR_HO_ADESFOR 20 +#define FR_HO_FORNCMS 21 + +#define FR_HL_CODCMS 22 + +#define FR_BO_TIPORIGA 31 +#define FR_BO_DESC 32 + diff --git a/cm/cm1100a.frm b/cm/cm1100a.frm index 54d4e4f86..a49460b14 100755 --- a/cm/cm1100a.frm +++ b/cm/cm1100a.frm @@ -4,18 +4,18 @@ SECTION GRAPHICS ODD LINEA -1 132 1 BEGIN - PROMPT 1 5 "@b" + PROMPT 1 6 "@b" END LINEA -1 132 1 BEGIN - PROMPT 1 7 "@b" + PROMPT 1 8 "@b" END END // intestazione generale stampa pagato per commessa -SECTION HEADER ODD 7 +SECTION HEADER ODD 8 NUMERO -1 BEGIN @@ -34,73 +34,109 @@ END STRINGA -1 BEGIN KEY "Intestazione stampa" - PROMPT 56 2 "@bPAGATO PER COMMESSA" + PROMPT 50 2 "@bPAGATO PER COMMESSA / FORNITORE" END -DATA FR_DATAINI +DATA FR_HO_DATAINI BEGIN KEY "Parametri stampa: data iniziale" PROMPT 1 3 "@bMovimenti dal " END -DATA FR_DATAFIN +DATA FR_HO_DATAFIN BEGIN KEY "Parametri stampa: data finale" PROMPT 40 3 "al " END -STRINGA FR_DACDC +STRINGA FR_HO_DACDC BEGIN KEY "da codice commessa" - PROMPT 1 4 "@bDalla commessa " + PROMPT 1 4 "@bDa comm. " END -STRINGA FR_ACDC +STRINGA FR_HO_DADESC 35 +BEGIN + KEY "da descr commessa" + PROMPT 30 4 "" +END + +STRINGA FR_HO_ACDC BEGIN KEY "a codice commessa" - PROMPT 40 4 "Alla commessa " + PROMPT 66 4 "A comm. " +END + +STRINGA FR_HO_ADESC 35 +BEGIN + KEY "a descr commessa" + PROMPT 93 4 "" +END + +STRINGA FR_HO_DACODFOR +BEGIN + KEY "da codice fornitore" + PROMPT 1 5 "@bDal forn. " +END + +STRINGA FR_HO_DADESFOR +BEGIN + KEY "da ragsoc" + PROMPT 17 5 "" +END + +STRINGA FR_HO_ACODFOR +BEGIN + KEY "a codice fornitore" + PROMPT 68 5 "Al forn. " +END + +STRINGA FR_HO_ADESFOR +BEGIN + KEY "a ragsoc" + PROMPT 84 5 "" END STRINGA -1 BEGIN KEY "numero registrazione" - PROMPT 1 6 "@bN. reg." + PROMPT 1 7 "@bN. reg." END STRINGA -1 BEGIN KEY "data pagamento" - PROMPT 10 6 "@bData pag." + PROMPT 10 7 "@bData pag." END STRINGA -1 BEGIN KEY "descrizione pagamento" - PROMPT 22 6 "@bDescrizione pagamento" + PROMPT 22 7 "@bDescrizione pagamento" END -STRINGA -1 +STRINGA FR_HO_FORNCMS BEGIN KEY "codice fornitore" - PROMPT 65 6 "@b Fornitore" + PROMPT 63 7 "@b" END STRINGA -1 BEGIN KEY "totale fattura" - PROMPT 78 6 "@bTotale fattura" + PROMPT 85 7 "@bTotale fattura" END STRINGA -1 BEGIN KEY "totale pagamento" - PROMPT 94 6 "@bTotale pagamento" + PROMPT 101 7 "@bTotale pagamento" END STRINGA -1 BEGIN KEY "totale residuo" - PROMPT 111 6 "@bTotale residuo" + PROMPT 118 7 "@bTotale residuo" END END // section header odd @@ -108,7 +144,7 @@ END // section header odd // riga con solo il codice commessa ed una riga vuota SECTION HEADER LAST 3 -STRINGA FR_CODCMS +STRINGA FR_HL_CODCMS BEGIN KEY "codice commessa" PROMPT 1 2 "@b" @@ -123,11 +159,11 @@ STRINGA -1 BEGIN KEY "tipo riga" PROMPT 1 1 "" - MESSAGE _TIPORIGA|COPY,FR_TIPORIGA + MESSAGE _TIPORIGA|COPY,FR_BO_TIPORIGA FLAGS "H" END -LISTA FR_TIPORIGA +LISTA FR_BO_TIPORIGA BEGIN KEY "lista tipo riga" PROMPT 1 1 "" @@ -185,17 +221,17 @@ BEGIN GROUP 2 END -STRINGA FR_DESC 45 +STRINGA FR_BO_DESC 40 BEGIN KEY "descrizione pagamento" PROMPT 22 1 "" MESSAGE _DESCRPAG END -NUMERO -1 6 +STRINGA -1 BEGIN - KEY "codice fornitore" - PROMPT 69 1 "" + KEY "codice fornitore/commessa" + PROMPT 63 1 "" MESSAGE _CODFORN GROUP 1 END @@ -203,7 +239,7 @@ END VALUTA -1 15 BEGIN KEY "totale fattura" - PROMPT 77 1 "" + PROMPT 84 1 "" MESSAGE _TOTDOC GROUP 1 END @@ -211,14 +247,14 @@ END VALUTA -1 15 BEGIN KEY "totale pagamento" - PROMPT 94 1 "" + PROMPT 101 1 "" MESSAGE _TOTPAG END VALUTA -1 15 BEGIN KEY "totale residuo" - PROMPT 110 1 "" + PROMPT 117 1 "" MESSAGE _TOTRES END diff --git a/cm/cm1100a.h b/cm/cm1100a.h index 5ff4ae267..9380b13bf 100755 --- a/cm/cm1100a.h +++ b/cm/cm1100a.h @@ -3,5 +3,12 @@ #define F_DATAINI 101 #define F_DATAFIN 102 #define F_DACDC 103 +#define F_DAFSC 104 #define F_ACDC 105 +#define F_AFSC 106 +#define F_ORDINAMENTO 107 +#define F_DACODFOR 108 +#define F_DADESFOR 109 +#define F_ACODFOR 110 +#define F_ADESFOR 111 diff --git a/cm/cm1100a.uml b/cm/cm1100a.uml index fcd9ab2b3..50559a207 100755 --- a/cm/cm1100a.uml +++ b/cm/cm1100a.uml @@ -4,13 +4,19 @@ TOOLBAR "" 0 -2 0 2 BUTTON DLG_PRINT 10 2 BEGIN - PROMPT -12 -1 "~Stampa" + PROMPT -13 -1 "~Stampa" MESSAGE EXIT,K_ENTER END +BUTTON DLG_ELABORA 10 2 +BEGIN + PROMPT -23 -1 "~Configura" + MESSAGE K_CFG +END + BUTTON DLG_QUIT 10 2 BEGIN - PROMPT -22 -1 "" + PROMPT -33 -1 "" END ENDPAGE @@ -43,14 +49,22 @@ BEGIN WARNING "La data finale deve essere successiva a quella iniziale" END -GROUPBOX DLG_NULL 76 4 +RADIOBUTTON F_ORDINAMENTO 1 40 BEGIN - PROMPT 1 8 "@bSelezione commesse" + PROMPT 1 7 "@bTipo ordinamento" + ITEM " |Commessa" + ITEM "X|Fornitore" + FLAGS "Z" +END + +GROUPBOX DLG_NULL 78 4 +BEGIN + PROMPT 1 10 "@bSelezione commesse" END STRING F_DACDC 20 BEGIN - PROMPT 2 9 "Da CDC/Commessa " + PROMPT 2 11 "Da CDC/Commessa " FLAGS "UZ" USE CMS INPUT CODTAB F_DACDC @@ -60,9 +74,21 @@ BEGIN CHECKTYPE SEARCH END +STRING F_DAFSC 10 +BEGIN + PROMPT 50 11 "Da fase " + FLAGS "UZ" + USE FSC + INPUT CODTAB F_DAFSC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DAFSC CODTAB + CHECKTYPE SEARCH +END + STRING F_ACDC 20 BEGIN - PROMPT 2 10 "A CDC/Commessa " + PROMPT 2 12 "A CDC/Commessa " FLAGS "UZ" COPY USE F_DACDC INPUT CODTAB F_ACDC @@ -71,6 +97,72 @@ BEGIN CHECKTYPE SEARCH END +STRING F_AFSC 10 +BEGIN + PROMPT 50 12 "A fase " + FLAGS "UZ" + COPY USE F_DAFSC + INPUT CODTAB F_AFSC + COPY DISPLAY F_DAFSC + OUTPUT F_AFSC CODTAB + CHECKTYPE SEARCH +END + +GROUPBOX DLG_NULL 78 4 +BEGIN + PROMPT 1 14 "@bSelezione fornitori" +END + +NUMBER F_DACODFOR 6 +BEGIN + PROMPT 2 15 "Da codice " + USE LF_CLIFO KEY 1 + FLAGS "U" + INPUT TIPOCF "F" + INPUT CODCF F_DACODFOR + DISPLAY "Codice " CODCF + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT F_DACODFOR CODCF + OUTPUT F_DADESFOR RAGSOC + CHECKTYPE NORMAL +END + +STRING F_DADESFOR 50 +BEGIN + PROMPT 23 15 "" + USE LF_CLIFO KEY 2 + INPUT TIPOCF "F" + INPUT RAGSOC F_DADESFOR + DISPLAY "Ragione sociale@50" RAGSOC + DISPLAY "Codice " CODCF + COPY OUTPUT F_DACODFOR + CHECKTYPE NORMAL +END + +NUMBER F_ACODFOR 6 +BEGIN + PROMPT 2 16 "A codice " + COPY USE F_DACODFOR + FLAGS "U" + INPUT TIPOCF "F" + INPUT CODCF F_ACODFOR + COPY DISPLAY F_DACODFOR + OUTPUT F_ACODFOR CODCF + OUTPUT F_ADESFOR RAGSOC + CHECKTYPE NORMAL +END + +STRING F_ADESFOR 50 +BEGIN + PROMPT 23 16 "" + COPY USE F_DADESFOR + INPUT TIPOCF "F" + INPUT RAGSOC F_ADESFOR + COPY DISPLAY F_DADESFOR + COPY OUTPUT F_ACODFOR + CHECKTYPE NORMAL +END + ENDPAGE ENDMASK