diff --git a/include/report.alx b/include/report.alx index 8bcb21cfe..01182d570 100755 --- a/include/report.alx +++ b/include/report.alx @@ -210,3 +210,7 @@ #SYSTEM.DATE @ \ Leggo la data #THIS ! \ Setto il campo corrente con la data ; +: MESSAGE_DITTA ( s1 -- ) + FIRM \ Campi della ditta corrente +; + diff --git a/include/report.cpp b/include/report.cpp index 099dd8987..040e01318 100755 --- a/include/report.cpp +++ b/include/report.cpp @@ -6,6 +6,10 @@ #include #include #include +#include +#include +#include +#include /////////////////////////////////////////////////////////// // TReport_font @@ -2325,7 +2329,7 @@ size_t TReport::get_usr_words(TString_array& words) const { "***", "DISABLE", "ENABLE", "GET_POS", "GET_SIZE", "HIDE", "ISAM_READ", "RUN_FORM", "SET_BACK_COLOR", "SET_FORE_COLOR", - "SET_POS", "SET_SIZE", "SHOW", "TABLE_READ", NULL + "SET_POS", "SET_SIZE", "SHOW", "TABLE_READ", "FIRM", NULL }; size_t i; for (i = 0; name[i] != NULL; i++) @@ -2579,6 +2583,151 @@ void TReport::msg_table_read(TVariant_stack& stack) } } +void TReport::msg_firm(TVariant_stack& stack) +{ + TReport_field& cf = *curr_field(); + TString in = stack.pop().as_string(); + const long codfirm = prefix().get_codditta(); + TString key; + + key.format("%ld", codfirm); + const TRectype & ditta = cache().get(LF_NDITTE, key); + if (in[0]!='!') + { + const int pos = in.find("."); + + if (pos < 0) + cf.set(ditta.get(in)); + else + if (pos > 0) + { + const TString file(in.left(pos - 1)); + + in = in.mid(pos + 1); + key = ditta.get(NDT_TIPOA); key << "|" << ditta.get(NDT_CODANAGR); + + const TRectype & anag = cache().get(LF_ANAG, key); + if (file == "ANAG" || file == "6") + cf.set(anag.get(in)); + else + if (file == "COM" || file == "13") + { + const bool is_fisc = anag.get(ANA_INDRF).not_empty(); + + key = anag.get(ANA_STATORES); key << "|" << is_fisc ? anag.get(ANA_COMRF) : anag.get(ANA_COMRES); + + const TRectype & comune = cache().get(LF_COMUNI, key); + cf.set(comune.get(in)); + } + else + if (file == "ULC" || file == "13") + { + key.format("%ld|1", codfirm); + + const TRectype & unloc = cache().get(LF_UNLOC, key); + cf.set(unloc.get(in)); + } + } + return; + } + in.ltrim(1); + if (in=="RAGSOC") + { + cf.set(ditta.get(NDT_RAGSOC)); + return; + } + if (in=="TEL") + { + TString valore; + + valore = ditta.get(NDT_PTEL); + valore << "-" << ditta.get(NDT_TEL); + cf.set(valore); + return; + } + if (in=="FAX") + { + TString valore; + + valore = ditta.get(NDT_PFAX); + valore << "-" << ditta.get(NDT_FAX); + cf.set(valore); + return; + } + + key = ditta.get(NDT_TIPOA); key << "|" << ditta.get(NDT_CODANAGR); + + const TRectype & anag = cache().get(LF_ANAG, key); + const bool is_fisc = anag.get(ANA_INDRF).not_empty(); + + if (in=="IND") + { + cf.set(anag.get(is_fisc ? ANA_INDRF : ANA_INDRES)); + return; + } + if (in=="NUM") + { + cf.set(anag.get(is_fisc ? ANA_CIVRF : ANA_CIVRES)); + return; + } + if (in=="CAP") + { + cf.set(anag.get(is_fisc ? ANA_CAPRF : ANA_CAPRES)); + return; + } + if (in=="IVA") + { + cf.set(anag.get("PAIV")); + return; + } + if (in=="CF") + { + cf.set(anag.get("COFI")); + return; + } + + key = anag.get(ANA_STATORES); key << "|" << is_fisc ? anag.get(ANA_COMRF) : anag.get(ANA_COMRES); + + const TRectype & comune = cache().get(LF_COMUNI, key); + + if (in=="COM") + { + cf.set(comune.get(COM_DENCOM)); + return; + } + if (in=="PROV") + { + cf.set(comune.get(COM_PROVCOM)); + return ; + } + key.format("%ld|1", codfirm); + + const TRectype & unloc = cache().get(LF_UNLOC, key); + + if (in=="REGSOC" || in=="REGIMP") + { + TString valore; + + valore = unloc.get(ULC_REGTRIB); + valore.insert(" ", 2); valore.insert(" ", 6); + valore.insert(" ", 11); valore.insert(" ", 21); + valore.insert("Reg.Imp. ", 0); + cf.set(valore); + return; + } + if (in=="CCIAA") + { + TString valore; + + valore = unloc.get(ULC_NUMCCIAA); + const TString & data = unloc.get(ULC_DATAICCIAA); + if (data.not_empty()) + valore << " del " << data; + cf.set(valore); + return; + } +} + bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack) { switch (opcode) @@ -2664,6 +2813,9 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack) case 14: // TABLE_READ msg_table_read(stack); break; + case 15: // FIRM + msg_firm(stack); + break; default: return false; } diff --git a/include/report.h b/include/report.h index 1ea83ff2a..cefcb4c88 100755 --- a/include/report.h +++ b/include/report.h @@ -462,6 +462,7 @@ protected: void do_isam_read_output(const TRectype& rec, TToken_string& out); void msg_isam_read(TVariant_stack& stack); void msg_table_read(TVariant_stack& stack); + void msg_firm(TVariant_stack& stack); void build_section_key(char type, int level, TString& key) const; short get_num_attr(const TXmlItem& item, const char* attr, short def = 0) const;