diff --git a/ca/ca3700.cpp b/ca/ca3700.cpp index 282532817..5fb533563 100755 --- a/ca/ca3700.cpp +++ b/ca/ca3700.cpp @@ -9,6 +9,7 @@ #include "../cg/cglib01.h" #include "../ve/velib04.h" +#include "cdc.h" #include "commesse.h" #include "panapdc.h" #include "pconana.h" @@ -1590,7 +1591,7 @@ protected: void print_or_preview(bool pr); virtual void print() { print_or_preview(true); } virtual void preview() { print_or_preview(false); } - void esporta_csv(TMask& mask, TRecordset& rendy, const TString& codcms, const TString& cdc, const TString& codfase); + void esporta_csv(TRecordset& rendy, const int r); void incrementa(TToken_string& riga, const int col, const real& valore) const; public: @@ -1612,16 +1613,31 @@ void TPrint_rendiconto_ca::incrementa(TToken_string& riga, const int col, const } //metodo di alto livello per l'esportazione dei dati di totale in un file per excel -void TPrint_rendiconto_ca::esporta_csv(TMask& mask, TRecordset& rendy, - const TString& codcms, const TString& cdc, const TString& codfase) +void TPrint_rendiconto_ca::esporta_csv(TRecordset& rendy, const int r) { + TMask& mask = *_msk; + TSheet_field& sheet = mask.sfield(F_RIGHE); + TString codcms; ca_extract_sheet_field(sheet, r, LF_COMMESSE, codcms); + TString cdc; ca_extract_sheet_field(sheet, r, LF_CDC, cdc); + TString codfase; ca_extract_sheet_field(sheet, r, LF_FASI, codfase); + //crea una token string su cui mettere i valori dei record letti dal file .dbf TToken_string riga(512, '\t'); - riga.add(codcms); - riga.add(cache().get(LF_COMMESSE, codcms, COMMESSE_DESCRIZ)); - riga.add(cdc); - riga.add(codfase); + if (get_first_level().logic() == LF_COMMESSE) + { + riga.add(codcms); + riga.add(cache().get(LF_COMMESSE, codcms, COMMESSE_DESCRIZ)); + riga.add(cdc); + riga.add(codfase); + } + else + { + riga.add(cdc); + riga.add(cache().get(LF_CDC, cdc, CDC_DESCRIZ)); + riga.add(codcms); + riga.add(codfase); + } //recordset sul file .dbf, da scandire tutto uno per volta for (bool ok = rendy.move_first(); ok; ok = rendy.move_next()) @@ -1808,13 +1824,8 @@ void TPrint_rendiconto_ca::main_loop() //se stampa o anteprima.. if (key == K_ENTER) book.add(rep); - else - { - const TString codcms = row.get(0); - const TString cdc = row.get(); - const TString codfase = row.get(); - esporta_csv(mask, *rep.recordset(), codcms, cdc, codfase); - } + else //esportazione in excel + esporta_csv(*rep.recordset(), 0); } sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet } @@ -1827,13 +1838,8 @@ void TPrint_rendiconto_ca::main_loop() //se stampa o anteprima if (key == K_ENTER) book.add(rep); //aggiunge il report relativo alla cdc/cms corrente al book - else - { - const TString codcms = row->get(0); - const TString cdc = row->get(); - const TString codfase = row->get(); - esporta_csv(mask, *rep.recordset(), codcms, cdc, codfase); - } + else //esportazione in excel + esporta_csv(*rep.recordset(), r); } } //se stampa o anteprima @@ -1842,7 +1848,7 @@ void TPrint_rendiconto_ca::main_loop() if (mask.print_mode() == 'A') book.preview(); else - book.print(); //stampa il book dei report + book.print(); } } //while(true)... diff --git a/ca/calib01.cpp b/ca/calib01.cpp index 936b8c584..0c2f11e92 100755 --- a/ca/calib01.cpp +++ b/ca/calib01.cpp @@ -1979,3 +1979,39 @@ bool ca_implode_rows(const TRecord_array& input_rows, TRecord_array& compact_row return implosion_done; } + + +/////////////////////////////////////////////////////////////////////////////////////// +//metodi per ricavare informazioni sulla configurazione (usati per ora nel rendiconto) +/////////////////////////////////////////////////////////////////////////////////////// + +//metodo per ricavare la stringa dei codici dai campi dello sheet +bool ca_extract_sheet_field(const TSheet_field& sheet, const int row, const int logicnum, TString& codice) +{ + TMask& mask_sheet = sheet.sheet_mask(); //maschera di riga + codice.cut(0); + FOR_EACH_MASK_FIELD(mask_sheet, i, f) //giro sui campi della maschera di riga + { + const TFieldref* fr = f->field(); //campo corrente della maschera + if (fr != NULL && f->is_edit()) //deve essere un campo di tipo edit + { + TEdit_field& e = *(TEdit_field*)f; //visto che č di tipo edit puņ creare l'edit_field per farne la browse + if (e.browse() != NULL) + { + const TCursor& cur = *e.browse()->cursor(); + const int ln = cur.file().num(); //Allah! dal campo ricava il cursore sul file di numero ln + if (ln == logicnum && cur.key() == 1 && !e.empty()) + { + const TString& parte_codice = e.get(); + codice << parte_codice; + } + else + { + if (codice.full()) + break; + } + } + } + } + return codice.full(); +} diff --git a/ca/calib01.h b/ca/calib01.h index 85f6dd3dd..039c931fc 100755 --- a/ca/calib01.h +++ b/ca/calib01.h @@ -220,4 +220,9 @@ bool ca_can_merge_rows(const TRectype& compact_rec, const TRectype& rec); void ca_taglia_campo(TRectype& src, const char* campo_src, TRectype& dst, const char* campo_dst); void ca_copia_campo(const TRectype& src, const char* campo_src, TRectype& dst, const char* campo_dst); + +//metodi per ricavare informazioni sulla configurazione (usati per ora nel rendiconto) +//metodo per ricavare la stringa dei codici dai campi dello sheet +bool ca_extract_sheet_field(const TSheet_field& sheet, const int row, const int logicnum, TString& codice); + #endif