From 9ab71b0f71905f10263547bb0273259320b9e281 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Fri, 8 Oct 2021 22:45:18 +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 | 161 +++++++++++++++---- src/ci/ci1300a.h | 8 +- src/ci/ci1300a.rep | 2 +- src/ci/ci1300a.uml | 77 +++++++-- src/ci/ci1300ab.rep | 375 ++++++++++++++++++++++++++++++++++++++++++++ src/ci/ci1300b.rep | 2 +- src/ci/ci1300bb.rep | 246 +++++++++++++++++++++++++++++ src/ci/ci1350.cpp | 4 +- src/ci/ci1350.h | 2 +- 9 files changed, 827 insertions(+), 50 deletions(-) create mode 100644 src/ci/ci1300ab.rep create mode 100644 src/ci/ci1300bb.rep diff --git a/src/ci/ci1300.cpp b/src/ci/ci1300.cpp index e5e9060a9..2c9fd8546 100755 --- a/src/ci/ci1300.cpp +++ b/src/ci/ci1300.cpp @@ -8,6 +8,7 @@ #include "../ca/calib01.h" #include "../ca/commesse.h" +#include "../ca/cfcms.h" #include "rilore.h" #include "ci1350.h" @@ -20,24 +21,86 @@ class TRil_ore_ris_report : public TReport { + unsigned int _first_msg; + unsigned int _golem_opcode; + long _codcf; + TString _codtpl; + protected: virtual bool use_mask() { return false; } + virtual size_t get_usr_words(TString_array& words) const; + virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack); public: - TRil_ore_ris_report(const char tipostampa); + 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::TRil_ore_ris_report(const char tipostampa) +size_t TRil_ore_ris_report::get_usr_words(TString_array& words) const { - if (tipostampa == 'M') - load("ci1300a"); - else - load("ci1300b"); + TReport::get_usr_words(words); - TRil_ore_recordset* recset = new TRil_ore_recordset; - set_recordset(recset); + const char* const name[] = + { + "LOGO_BENEF", NULL + }; + + ((TRil_ore_ris_report*)this)->_first_msg = words.items(); // Calcola il primo numero disponibile + ((TRil_ore_ris_report*)this)->_golem_opcode = words.find("GOLEM"); + + size_t i; + + for (i = 0; name[i] != NULL; i++) + words.add(name[i]); + return i; } + +bool TRil_ore_ris_report::execute_usr_word(unsigned int opcode, TVariant_stack& stack) +{ + bool ok = true; + if (opcode >= _first_msg) + { + opcode -= _first_msg; + switch (opcode) + { + case 0: + { + TToken_string key("C"); + TString id("LOGO"); + + id << _codtpl; + stack.push(id); + key.add(_codcf); + stack.push(key); + stack.push(CLI_OGGETTI); + stack.push(LF_CLIFO); + execute_usr_word(21, stack); + } + break; + default: ok = false; + break; + } + } + else + ok = TReport::execute_usr_word(opcode, stack); + return ok; +} + +TRil_ore_ris_report::TRil_ore_ris_report(const TString & tipostampa) : _codcf(0L) +{ + TFilename report_name; + + if (tipostampa[1] == 'M') + report_name = "ci1300a"; + else + report_name = "ci1300b"; + if (tipostampa[0] == 'B') + report_name << "b"; + load(report_name); + set_recordset(new TRil_ore_recordset); +} + /////////////////////////////////////////////////////////// // Maschera /////////////////////////////////////////////////////////// @@ -45,9 +108,11 @@ TRil_ore_ris_report::TRil_ore_ris_report(const char tipostampa) class TRil_ore_ris_mask : public TAutomask { 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; + 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'; } public: void elabora() const; @@ -68,14 +133,14 @@ bool TRil_ore_ris_mask::on_field_event(TOperable_field& o, TField_event e, long 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 char tipo_stampa = get(F_TIPOSTAMPA)[0]; + const TString4 tipo_stampa = get(F_TIPOSTAMPA); const int anno = get_int(F_ANNO); - const int mese = tipo_stampa == 'M' ? curr_mese : 0; + const int mese = mensile() ? curr_mese : 0; const bool calc_ore_lav = rep.field("F1.98") != NULL; //date del periodo TDate inizio_periodo, fine_periodo; - ci_inizio_fine_periodo(tipo_stampa, anno, mese, inizio_periodo, fine_periodo); + ci_inizio_fine_periodo(mensile(), anno, mese, inizio_periodo, fine_periodo); //creare un assoc_array con chiave TToken_string cms-sede-fase(1) o sede-cms-fase(2) in base ai parametri.. //..indicati sulla maschera @@ -96,7 +161,6 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c tpass.add("PH", i); } - const TVariant tiporisorsa = get(F_RISOATT); //query sul file delle ore in chiave 3: TIPO+TIPORA+CODICE+.....frega niente altro @@ -120,10 +184,18 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c } //aggiunta Adolfica: lista di commesse da considerare separatamente pił commessa borraccione.. //..con tutte le altre + TSheet_field& lista = sfield(F_RIGHE); rilore_recset.set_list(lista.rows_array(), ignore); + TString tipo_commessa_beneficiario; + long codfin = 0L; + if (per_beneficiario()) + { + tipo_commessa_beneficiario = get(F_CODTPL); + codfin = get_long(F_CODFIN); + } //un giro con le ore a 'P'reventivo, uno con quelle a 'C'onsuntivo for (int i = 0; i < 2; i++) { @@ -136,7 +208,7 @@ 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(); - const TString80 codcms = rilore_recset.get(RILORE_CODCMS).as_string(); + TString80 codcms = rilore_recset.get(RILORE_CODCMS).as_string(); const TString16 codfase = rilore_recset.get(RILORE_CODFASE).as_string(); //date limite qta ore sul record del file LF_RILORE @@ -165,22 +237,44 @@ void TRil_ore_ris_mask::elabora_risorsa(const TString& curr_risorsa, const int c //crea la chiave per l'assoc_array TToken_string key; + if (ignore) key = OTHER_ACTIVITIES; else { - switch(tipo_ordinamento) - { - case 1: key.add(codcms); break; - case 2: key.add(codcms); key.add(codcosto); break; - case 3: key.add(codcms); key.add(codfase); break; - case 4: key.add(codcms); key.add(codcosto); key.add(codfase); break; - case 5: key.add(codcosto); break; - case 6: key.add(codcosto); key.add(codcms); break; - case 7: key.add(codcosto); key.add(codfase); break; - case 8: key.add(codcosto); key.add(codcms); key.add(codfase); break; - default: break; - } + if (per_beneficiario() && codcms.full()) + { + const TString & codtipo = cache().get(LF_COMMESSE, codcms, COMMESSE_CODTIPO); + bool altre = true; + + if (codtipo == tipo_commessa_beneficiario) + { + TToken_string key_fin(codcms); + + key_fin.add("C"); + key_fin.add(1); + if (atol(cache().get(LF_CFCMS, key_fin, CFCMS_CODCF)) == codfin) + altre = false; + } + if (altre) + key = OTHER_ACTIVITIES; + } + + if (key != OTHER_ACTIVITIES) + { + switch (tipo_ordinamento) + { + case 1: key.add(codcms); break; + case 2: key.add(codcms); key.add(codcosto); break; + case 3: key.add(codcms); key.add(codfase); break; + case 4: key.add(codcms); key.add(codcosto); key.add(codfase); break; + case 5: key.add(codcosto); break; + case 6: key.add(codcosto); key.add(codcms); break; + case 7: key.add(codcosto); key.add(codfase); break; + case 8: key.add(codcosto); key.add(codcms); key.add(codfase); break; + default: break; + } + } } //se la chiave non esiste gią nell'assoc_array allora crea l'elemento TToken_string* record = (TToken_string*)righe.objptr(key); @@ -278,12 +372,14 @@ void TRil_ore_ris_mask::elabora() const //book di stampa TReport_book book; //stampa mensile o annuale? - const char tipostampa = get(F_TIPOSTAMPA)[0]; + const TString4 tipostampa = get(F_TIPOSTAMPA); TRil_ore_ris_report rep(tipostampa); + rep.set_codcf(get_long(F_CODFIN)); + rep.set_codtpl(get(F_CODTPL)); int da_mese = 1; int a_mese = 1; - if (tipostampa == 'M') + if (tipostampa[1] == 'M') { da_mese = get_int(F_DA_MESE); a_mese = get_int(F_A_MESE); @@ -299,7 +395,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 == 'M') + if (tipostampa[1] == 'M') format_report_month(get_int(F_ANNO), m, rep); //query sulla tabella interessata (risorse o attrezzature) @@ -362,9 +458,8 @@ void TRil_ore_ris_mask::elabora() const rep.set_recordset(recset); for (int ignore = ignore_start; ignore <= ignore_end; ignore++) - { elabora_risorsa(curr_risorsa, m, ignore!=0, rep); - } //for (int ignore = ignore_start.. + //stampa un report per risorsa book.add(rep); } ////for (bool ok = recset_ris_att.move_first()... diff --git a/src/ci/ci1300a.h b/src/ci/ci1300a.h index 3ef81e499..c65f7c080 100755 --- a/src/ci/ci1300a.h +++ b/src/ci/ci1300a.h @@ -14,10 +14,12 @@ #define F_A_MESE 213 #define F_ORDINAMENTO 214 #define F_SHOW_FASI 215 - #define F_STAMPADATA 216 - -#define F_RIGHE 220 +#define F_CODTPL 217 +#define F_DESTPL 218 +#define F_CODFIN 219 +#define F_RAGFIN 220 +#define F_RIGHE 221 //campi riga sheet #define S_CODCMS 101 diff --git a/src/ci/ci1300a.rep b/src/ci/ci1300a.rep index bc220e9a0..99fff3c51 100755 --- a/src/ci/ci1300a.rep +++ b/src/ci/ci1300a.rep @@ -1,6 +1,6 @@ - Rilevazione ore mensili per Risorsa - Attrezzatura + Rilevazione ore mensili per Risorsa - Attrezzatura mensile