diff --git a/ps/ps0830.cpp b/ps/ps0830.cpp index 3e950388f..a07e2e724 100755 --- a/ps/ps0830.cpp +++ b/ps/ps0830.cpp @@ -7,14 +7,11 @@ int main(int argc, char** argv) const int op = argc < 2 ? 0 : argv[1][1]-'0'; switch (op) { - case 0: - ps0830100(argc,argv); // esportazione listino Baiseina - break; - default: - ps0830100(argc,argv); - break; + case 0: + default: + ps0830100(argc,argv); // esportazione listino Baiseina + break; } - exit(0); return 0; } diff --git a/ps/ps0830100.cpp b/ps/ps0830100.cpp index 6e598d2d0..2b89e80f5 100755 --- a/ps/ps0830100.cpp +++ b/ps/ps0830100.cpp @@ -15,7 +15,6 @@ #include "ps0830.h" #include "ps0830100.h" - ///////////////////////////////////////////////////////////// // Recordset esporta_listino ///////////////////////////////////////////////////////////// @@ -24,6 +23,8 @@ class TEsporta_listino_recordset : public TCSV_recordset { protected: virtual const TToken_string& sheet_head() const; + virtual unsigned int columns() const { return 6; } + public: virtual bool set(unsigned int fld, const TVariant& var); TEsporta_listino_recordset(); @@ -32,25 +33,27 @@ public: const TToken_string& TEsporta_listino_recordset::sheet_head() const { TToken_string& head = get_tmp_string(); - head = "COD_EAN@20|PREZZO@10|CASSA@5|DESCRIZIONE@13|SCPERC@5|SCMON@5|CODOFF@5"; + head = HR("Codice EAN@13|Prezzo@10R|Cassa@5|Descrizione@13|Sc.per.@5|Sc.mon.@5|Cod.Off.@5"); return head; } bool TEsporta_listino_recordset::set(unsigned int column, const TVariant& var) { - TString str; - if (var.is_date()) - { - if (!var.is_empty()) + if (!var.is_empty()) + { + TString80 str; + if (var.is_date()) { const TDate data = var.as_date(); - str.format("%04d-%02d-%02d", data.year(), data.month(), data.day()); + str = data.string(full,'-', full, full, amg_date); } - } - else - str << var; - str.replace('|', '/'); - return TCSV_recordset::set(column, TVariant(str)); + else + str << var; + str.replace('|', '/'); + return TCSV_recordset::set(column, TVariant(str)); + } + + return TCSV_recordset::set(column, var); } TEsporta_listino_recordset::TEsporta_listino_recordset() @@ -66,12 +69,12 @@ class TEsporta_listino_mask : public TAutomask { private: void serialize(bool bSave); + void esporta_listino(const bool anteprima); protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); public: - void esporta_listino(const bool anteprima); TEsporta_listino_mask(); ~TEsporta_listino_mask(); }; @@ -109,27 +112,26 @@ bool TEsporta_listino_mask::on_field_event(TOperable_field& f, TField_event e, l { switch (f.dlg()) { - case DLG_ELABORA: + case DLG_OK: if (e == fe_button) - { esporta_listino(false); - } break; - case DLG_PRINT: + case DLG_PREVIEW: if (e == fe_button) - { esporta_listino(true); - } break; - case DLG_QUIT: - if (e == fe_button) + case F_PATH: + if (e == fe_init || e == fe_modify) { + TFilename file = f.get(); + file.add("aggiorna.bat"); + enable(DLG_OK, file.exist()); } break; default: break; } - return TRUE; + return true; } void TEsporta_listino_mask::esporta_listino(const bool anteprima) @@ -140,37 +142,39 @@ void TEsporta_listino_mask::esporta_listino(const bool anteprima) query << "SELECT (CATVEN=\"DE\") && (RCONDV.PREZZO>\"0\") && (CODCORR.CODARTALT!=\"\")\n"; query << "JOIN CODCORR INTO CODART==CODRIGA NRIGA=1\n"; query << "JOIN ANAMAG INTO CODART==CODRIGA\n"; - query << "ORDER BY CODCORR.CODARTALT, ANAMAG.REPARTO[2,3], RCONDV.CODRIGA"; TISAM_recordset listino(query); TEsporta_listino_recordset csv; const int items = listino.items(); - TProgind pi(items, "Estrazione listino...", true, true); + TProgind pi(items, TR("Estrazione listino..."), true, true); for (bool ok = listino.move_first(); ok; ok = listino.move_next()) { if (!pi.addstatus(1)) break; - csv.new_rec(""); - csv.set(0, listino.get("CODCORR.CODARTALT")); - real prezzo = listino.get(RCONDV_PREZZO).as_real(); - prezzo.round(2); - prezzo = prezzo*100; - csv.set(1, TVariant(prezzo)); - csv.set(2, listino.get("ANAMAG.REPARTO[2,3]")); - csv.set(3, listino.get("ANAMAG.DESCR[1,12]")); - csv.set(4, "0"); - csv.set(5, "0"); - csv.set(6, "0"); + + real prezzo = listino.get(RCONDV_PREZZO).as_real(); + if (prezzo > ZERO) + { + csv.new_rec(""); + csv.set(0, listino.get("CODCORR.CODARTALT")); + prezzo = prezzo*CENTO; + prezzo.round(); + csv.set(1, TVariant(prezzo)); + csv.set(2, listino.get("ANAMAG.REPARTO[2,3]")); + csv.set(3, listino.get("ANAMAG.DESCR[1,12]")); + csv.set(4, "0"); + csv.set(5, "0"); + csv.set(6, "0"); + } } //for(move_first().. + csv.sort(); + if (anteprima) { - //TRecordset_sheet sheet(csv, TR("Elenco di controllo")); - //sheet.run(); - - csv.save_as("ps0830100.xls", fmt_silk); - xvt_sys_goto_url("ps0830100.xls", "open"); + TRecordset_sheet sheet(csv, TR("Elenco di controllo")); + sheet.run(); } else { @@ -178,16 +182,16 @@ void TEsporta_listino_mask::esporta_listino(const bool anteprima) file.add(get(F_NAME)); csv.save_as(file, fmt_text); - if (yesno_box("Generazione listino terminata. Procedo con l'invio?")) + if (yesno_box(TR("Generazione listino terminata.\nProcedere con l'invio?"))) { - TFilename appname = "aggiorna.bat"; - if (appname.exist()) + file = get(F_PATH); file.add("aggiorna.bat"); + if (file.exist()) { - TExternal_app a("aggiorna.bat"); - a.run(false,false); + TExternal_app a(file); + a.run(false,false,false); } else - message_box("Impossibile procedere con l'invio, non esiste l'applicazione aggiorna.bat"); + error_box(TR("Impossibile procedere con l'invio,\nnon esiste l'applicazione %s"), (const char*)file); } } } @@ -200,10 +204,8 @@ void TEsporta_listino_mask::esporta_listino(const bool anteprima) class TEsporta_listino_app : public TSkeleton_application { - protected: - virtual bool check_autorization() const {return false;} - virtual const char * extra_modules() const {return "ve";} + virtual const char* extra_modules() const { return "ve"; } virtual void main_loop(); }; diff --git a/ps/ps0830100.uml b/ps/ps0830100.uml index 4b3d8df15..6ab25b09e 100755 --- a/ps/ps0830100.uml +++ b/ps/ps0830100.uml @@ -1,8 +1,8 @@ #include "ps0830100.h" -PAGE "Esportazione listino" -1 -1 80 14 +PAGE "Esportazione listino" -1 -1 78 8 -GROUPBOX DLG_NULL 76 3 +GROUPBOX DLG_NULL 75 3 BEGIN PROMPT 2 1 "@bDitta corrente" END @@ -23,7 +23,7 @@ BEGIN FLAGS "D" END -GROUPBOX DLG_NULL 76 4 +GROUPBOX DLG_NULL 75 4 BEGIN PROMPT 2 4 "Esportazione" END @@ -46,21 +46,19 @@ BEGIN FIELD NAME END -BUTTON DLG_PRINT 9 2 -BEGIN - PROMPT -13 -1 "~Anteprima" -END - -BUTTON DLG_ELABORA 9 2 -BEGIN - PROMPT -23 -1 "~Esporta" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -33 -1 "" -END - ENDPAGE +TOOLBAR "topbar" 0 0 0 2 + +BUTTON DLG_PREVIEW 9 2 +BEGIN + PROMPT -13 -1 "~Anteprima" + PICTURE TOOL_PREVIEW +END + +#include + +ENDPAGE + ENDMASK +