From 8e4d68a734a8d973f4626c9b412c29a227c10f87 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Sun, 10 Oct 2021 22:07:22 +0200 Subject: [PATCH] Patch level : 12.0 1086 Files correlati : ci1300ab.rep ci1300bb.rep ci1300a.rep ci1300a.msk ci1300b.rep ci1.exe Commento : Aggiunti report per beneficiario alla stampa ore per risorsa/attrezzatura aggiunto logo del beneficiario sintassi da mettere nel prescript del campo immagine : LOGO_BENEF #THIS ! L'Id dell'immagine deve essere LOGO+ --- src/ci/ci1300.cpp | 89 +++++++++++++++++++++++++++++++++------------ src/ci/ci1300a.h | 1 + src/ci/ci1300a.uml | 22 ++++++----- src/ci/ci1300ab.rep | 23 +++++++++--- src/ci/ci1300bb.rep | 10 ++--- src/ci/ci1350.cpp | 12 +++++- 6 files changed, 112 insertions(+), 45 deletions(-) diff --git a/src/ci/ci1300.cpp b/src/ci/ci1300.cpp index 2db410bd0..b5ac66688 100755 --- a/src/ci/ci1300.cpp +++ b/src/ci/ci1300.cpp @@ -11,6 +11,7 @@ #include "../ca/cfcms.h" #include "rilore.h" +#include "cilib.h" #include "ci1350.h" #include "ci1300a.h" @@ -34,7 +35,7 @@ protected: public: void set_codcf(long codcf) { _codcf = codcf; } void set_codtpl(const char *cod) { _codtpl = cod; } - TRil_ore_ris_report(const TString & tipostampa); + TRil_ore_ris_report(bool mensile, bool beneficiario); }; size_t TRil_ore_ris_report::get_usr_words(TString_array& words) const @@ -87,15 +88,15 @@ bool TRil_ore_ris_report::execute_usr_word(unsigned int opcode, TVariant_stack& return ok; } -TRil_ore_ris_report::TRil_ore_ris_report(const TString & tipostampa) : _codcf(0L) +TRil_ore_ris_report::TRil_ore_ris_report(bool mensile, bool beneficiario) : _codcf(0L) { TFilename report_name; - if (tipostampa[1] == 'M') + if (mensile) report_name = "ci1300a"; else report_name = "ci1300b"; - if (tipostampa[0] == 'B') + if (beneficiario) report_name << "b"; load(report_name); set_recordset(new TRil_ore_recordset); @@ -105,14 +106,17 @@ TRil_ore_ris_report::TRil_ore_ris_report(const TString & tipostampa) : _codcf(0L // Maschera /////////////////////////////////////////////////////////// -class TRil_ore_ris_mask : public TAutomask +class TRil_ore_ris_mask : public TSimpleAutomask { protected: - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + // virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); void elabora_risorsa(const TString& curr_risorsa, const int curr_mese, const bool ignore, TReport& rep) const; - const bool mensile() const { return get(F_TIPOSTAMPA)[1] == 'M';} - const bool per_beneficiario() const { return get(F_TIPOSTAMPA)[0] == 'B'; } + const TString & tipostampa() const { return get(F_TIPOSTAMPA); } + const bool mensile() const { return tipostampa() == "M";} + const bool per_beneficiario() const { return get_bool(F_BENEFICIARIO); } + const real proponi_costo(const char *codlist, const char * tipo, const char * codice, const char * tpora, int mese, int anno) const ; + public: void elabora() const; @@ -121,19 +125,48 @@ public: virtual ~TRil_ore_ris_mask() {} }; -TRil_ore_ris_mask::TRil_ore_ris_mask() : TAutomask("ci1300a") +TRil_ore_ris_mask::TRil_ore_ris_mask() : TSimpleAutomask("ci1300a") { } -bool TRil_ore_ris_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +/*bool TRil_ore_ris_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { return true; } +*/ +const real TRil_ore_ris_mask::proponi_costo(const char *codlist, const char * tipo, const char * codice, const char * tpora, int mese, int anno) const +{ + real r; + const TDate dal(1, mese, anno); + TRisoatt_key chiave(codlist, tipo[0], codice, dal, tpora); + const TRectype & rec = cache().get("&ROA", chiave); + + if (rec.empty()) + { + if (chiave.cod().full() && chiave.tpora().full()) + { + TModule_table tab("ROA"); + + tab.put("CODTAB", chiave); + const int err = tab.read(); + if (err != _isemptyfile) + { + chiave.overwrite("????????", 21, 8); + if (err != _iseof) + tab.prev(); + if (tab.get("CODTAB").match(chiave)) + r = tab.get_real("R1"); + } + } + } + else + r = rec.get_real("R1"); + return r; +} void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int curr_mese, const bool ignore, TReport& rep) const { const int tipo_ordinamento = get_int(F_ORDINAMENTO); - const TString4 tipo_stampa = get(F_TIPOSTAMPA); const int anno = get_int(F_ANNO); const int mese = mensile() ? curr_mese : 0; const bool calc_ore_lav = rep.field("F1.98") != NULL; @@ -207,13 +240,13 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c for (bool ok = rilore_recset.move_first(); ok; ok = rilore_recset.move_next()) { - const TString80 codcosto = rilore_recset.get(RILORE_CODCOSTO).as_string(); - TString80 codcms = rilore_recset.get(RILORE_CODCMS).as_string(); - const TString16 codfase = rilore_recset.get(RILORE_CODFASE).as_string(); + const TString80 codcosto = rilore_recset.get_string(RILORE_CODCOSTO); + TString80 codcms = rilore_recset.get_string(RILORE_CODCMS); + const TString16 codfase = rilore_recset.get_string(RILORE_CODFASE); //date limite qta ore sul record del file LF_RILORE - TDate ini_rilore = rilore_recset.get(RILORE_DADATA).as_date(); - TDate fine_rilore = rilore_recset.get(RILORE_ADATA).as_date(); + TDate ini_rilore = rilore_recset.get_date(RILORE_DADATA); + TDate fine_rilore = rilore_recset.get_date(RILORE_ADATA); //adatta le date alla commessa se quest'ultima è contenuta nell'intervallo (può essere più breve.. //..dell'intervallo selezionato, oppure sovrapporsi solo parzialmente) @@ -229,10 +262,10 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c if (giorni_lavorativi_rilore > 0) { - const real tot_ore = rilore_recset.get(RILORE_QTAORE).as_real(); + const real tot_ore = rilore_recset.get_real(RILORE_QTAORE); const real tot_ore_uso_risorsa_nel_periodo = tot_ore * giorni_lavorativi / giorni_lavorativi_rilore; - const TString8 tpora = rilore_recset.get(RILORE_TPORA).as_string(); + const TString8 tpora = rilore_recset.get_string(RILORE_TPORA); const TString8 tpassenza = cache().get("&ORE", tpora, "S2"); //crea la chiave per l'assoc_array @@ -297,7 +330,7 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c { if (giorni_lavorativi_rilore == 1 || ci_is_ferial_day(data)) { - const int index = tipo_stampa == 'M' ? data.day() : data.month(); + const int index = mensile() ? data.day() : data.month(); real prev = record->get(index); prev += ore_al_giorno; record->add(prev.string(), index); @@ -305,6 +338,17 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c tot += ore_al_giorno; record->add(tot.string(), 32); + real totcosto = record->get(34); + real costo = rilore_recset.get_real(RILORE_COSTO); + + if (costo == ZERO) + costo = proponi_costo(rilore_recset.get_string(RILORE_CODLIST), + rilore_recset.get_string(RILORE_TIPORA), + rilore_recset.get_string(RILORE_CODICE), + tpora, data.month(), data.year()); + totcosto += ore_al_giorno * costo; + record->add(totcosto.string(), 34); + int i = data - inizio_periodo + 1; if (tpassenza.full()) { @@ -372,14 +416,13 @@ void TRil_ore_ris_mask::elabora() const //book di stampa TReport_book book; //stampa mensile o annuale? - const TString4 tipostampa = get(F_TIPOSTAMPA); - TRil_ore_ris_report rep(tipostampa); + TRil_ore_ris_report rep(mensile(), per_beneficiario()); rep.set_codcf(get_long(F_CODFIN)); rep.set_codtpl(get(F_CODTPL)); int da_mese = 1; int a_mese = 1; - if (tipostampa[1] == 'M') + if (mensile()) { da_mese = get_int(F_DA_MESE); a_mese = get_int(F_A_MESE); @@ -395,7 +438,7 @@ void TRil_ore_ris_mask::elabora() const //giro su tutti i mesi; se stampa annuale o mese unico -> un giro solo for (int m = da_mese; m <= a_mese; m++) { - if (tipostampa[1] == 'M') + if (mensile()) format_report_month(get_int(F_ANNO), m, rep); //query sulla tabella interessata (risorse o attrezzature) diff --git a/src/ci/ci1300a.h b/src/ci/ci1300a.h index c65f7c080..e23c00e24 100755 --- a/src/ci/ci1300a.h +++ b/src/ci/ci1300a.h @@ -20,6 +20,7 @@ #define F_CODFIN 219 #define F_RAGFIN 220 #define F_RIGHE 221 +#define F_BENEFICIARIO 222 //campi riga sheet #define S_CODCMS 101 diff --git a/src/ci/ci1300a.uml b/src/ci/ci1300a.uml index 310c13094..45b55a81d 100755 --- a/src/ci/ci1300a.uml +++ b/src/ci/ci1300a.uml @@ -131,21 +131,25 @@ BEGIN PROMPT 1 6 "@bFiltri su anno / mese" END -LISTBOX F_TIPOSTAMPA 25 +LISTBOX F_TIPOSTAMPA 1 8 BEGIN PROMPT 2 7 "Tipo di stampa " - ITEM "AM|Mensile" - MESSAGE SHOW,F_DA_MESE|SHOW,F_A_MESE|CLEAR,4@ - ITEM "AA|Annuale" - MESSAGE HIDE,F_DA_MESE|HIDE,F_A_MESE|CLEAR,4@ - ITEM "BM|Per Beneficiario Mensile" - MESSAGE SHOW,F_DA_MESE|SHOW,F_A_MESE|ENABLE,4@ - ITEM "BA|Per Beneficiario Annuale" - MESSAGE HIDE,F_DA_MESE|HIDE,F_A_MESE|ENABLE,4@ + ITEM "M|Mensile" + MESSAGE SHOW,F_DA_MESE|SHOW,F_A_MESE + ITEM "A|Annuale" + MESSAGE HIDE,F_DA_MESE|HIDE,F_A_MESE FLAGS "Z" FIELD #TIPOSTAMPA END +BOOLEAN F_BENEFICIARIO +BEGIN + PROMPT 32 7 "Per Beneficiario" + MESSAGE FALSE CLEAR,4@ + MESSAGE TRUE ENABLE,4@ + FIELD #BENEFICIARIO +END + NUMBER F_ANNO 4 BEGIN PROMPT 2 8 "Anno " diff --git a/src/ci/ci1300ab.rep b/src/ci/ci1300ab.rep index a2220f8b1..62a007838 100644 --- a/src/ci/ci1300ab.rep +++ b/src/ci/ci1300ab.rep @@ -121,9 +121,23 @@ -