Patch level : 12.0 1101
Files correlati : ca3.exe ca3100.uml ca3100a.rep ca3100b.rep ca3200.uml ca3200a.rep ca3200b.rep ca3300.uml ca3300a.rep ca3300b.rep ca3300c.rep ca3300d.rep ca3600.uml ca3600a.rep ca3700.uml ca3700a.rep ca3700b.rep ca3800.uml ca3800a.rep ca3800as.rep ca3800b.rep ca3800bs.rep ca3800c.rep ca3800cs.rep ca3883.cpp ca3900.uml ca3900a.rep Commento : modificato il meccanismo per lanciare le stampe in batch. Sintassi: ca3 -7 -b <nome del file che contiene i valori dell maschera> (-T) <tipo di output <P>rint|<E>xport|E<X>cel|PD<F>|<T>esto|<D>Base|<V>isualizza> (-O) <nome del file di output (-F) <codice ditta> (-S) <separatore per excel) Esempio: ca3 -7 -b select.sav X c:\out\rend esporta il rendiconto di commessa usando i parametri salvati in select.sav nel file c:\out\rend.xls
This commit is contained in:
parent
652b308a1b
commit
54e9fa5217
@ -873,6 +873,35 @@ bool TApplication::get_next_mail(TToken_string& to, TToken_string& cc, TToken_st
|
||||
return ok;
|
||||
}
|
||||
|
||||
char TApplication::get_arg(int & narg, TString & arg)
|
||||
{
|
||||
char arg_type = '\0';
|
||||
int nargs = argc();
|
||||
|
||||
arg = argv(nargs);
|
||||
if (arg.starts_with("-u"))
|
||||
nargs--;
|
||||
if (narg < argc())
|
||||
{
|
||||
arg = argv(narg);
|
||||
if (arg[0] == '-')
|
||||
{
|
||||
arg_type = UPCASE(arg[1]);
|
||||
arg =arg.mid(2);
|
||||
arg.trim();
|
||||
if (arg.blank())
|
||||
{
|
||||
arg = argv(++narg);
|
||||
arg.trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
arg_type = ' ';
|
||||
narg++;
|
||||
}
|
||||
return arg_type;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// The Skeleton application!
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -158,7 +158,7 @@ public:
|
||||
// @cmember Ritorna l'array di parametri da passare all'applicazione
|
||||
const char** argv() const
|
||||
{ return _argv_; }
|
||||
// @cmember Ritroan il parametro <p i>-esimo da passare all'applicazione
|
||||
// @cmember Ritorna il parametro <p i>-esimo da passare all'applicazione
|
||||
const char* argv(int i) const { return _argv_[i]; }
|
||||
// @cmember Ritorna il numero di paramentri da passare all'applicazione
|
||||
int argc() const
|
||||
@ -196,6 +196,7 @@ public:
|
||||
virtual bool task_win_shown() const { return true; }
|
||||
// @cmember imposta la riduzione a icona della finestra principale
|
||||
virtual bool task_win_iconized() const { return false; }
|
||||
char get_arg(int & narg, TString & arg);
|
||||
|
||||
// @cmember Costruttore
|
||||
TApplication();
|
||||
|
@ -1,9 +1,13 @@
|
||||
#if defined(EXPORT) || defined(EXPORT_EXCEL) || defined(EXPORT_PDF) || defined(EXPORT_DBF) || defined(EXPORT_TEXT) || defined(ALL_EXPORT)
|
||||
STRING DLG_OUTPUT 255 64
|
||||
STRING DLG_OUTPUTD 255 50
|
||||
BEGIN
|
||||
PROMPT 1 -3 "Output "
|
||||
DSELECT
|
||||
END
|
||||
STRING DLG_OUTPUTF 60 18
|
||||
BEGIN
|
||||
PROMPT 62 -3 "\"
|
||||
END
|
||||
#endif
|
||||
|
||||
STRING DLG_REPORT 256 66
|
||||
|
@ -55,8 +55,9 @@
|
||||
#define DLG_EXPORT_PDF 51 /* TAG del bottone Esporta un pdf */
|
||||
#define DLG_EXPORT_DBF 52 /* TAG del bottone Esporta in dbf */
|
||||
#define DLG_EXPORT_TEXT 53 /* TAG del bottone Esporta un testo */
|
||||
#define DLG_OUTPUT 54 /* TAG del campo <output> */
|
||||
#define DLG_REPORT 55 /* TAG del campo <report> */
|
||||
#define DLG_OUTPUTD 54 /* TAG del campo <output> direttorio*/
|
||||
#define DLG_OUTPUTF 55 /* TAG del campo <output> file*/
|
||||
#define DLG_REPORT 56 /* TAG del campo <report> */
|
||||
|
||||
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */
|
||||
|
||||
|
@ -2496,7 +2496,7 @@ TTree_field& TMask::add_tree (
|
||||
return *f;
|
||||
}
|
||||
|
||||
TGroup_field& TMask::add_groupbox (
|
||||
TGroup_field& TMask::add_groupbox(
|
||||
short id, // @parm Numero identificatore del campo da aggiungere
|
||||
int page, // @parm Pagina nel quale aggiungere il campo
|
||||
const char* prompt, // @parm Prompt del campo
|
||||
@ -2542,14 +2542,14 @@ bool TMask::save(const TFilename & fname, // @parm nome del file, se vuoto usa _
|
||||
FILE* f = fopen(_workfile, append ? "a" : "w");
|
||||
|
||||
if (f == nullptr)
|
||||
return yesnofatal_box("Non posso aprire %s ", (const char*) _workfile);
|
||||
return yesnofatal_box("Non posso aprire %s ", (const char*)_workfile);
|
||||
|
||||
const int max = fields();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TMask_field& c = fld(i);
|
||||
if (c.is_editable())
|
||||
fprintf(f, "%d|%s\n", c.dlg(), (const char*)c.get());
|
||||
fprintf(f, "%d|%s\n", c.dlg(), c.automagic()|| c.is_firm() ? "" : (const char*)c.get());
|
||||
}
|
||||
fprintf(f, "[EOM]\n");
|
||||
fclose(f);
|
||||
@ -2591,7 +2591,20 @@ bool TMask::load(const TFilename & fname, // @parm nome del file, se vuoto usa _
|
||||
{
|
||||
t.rtrim();
|
||||
const int pos = id2pos(t.get_int(0));
|
||||
if (pos >= 0) fld(pos).set(t.get());
|
||||
const TString val = t.get();
|
||||
|
||||
if (pos >= 0)
|
||||
{
|
||||
TMask_field& c = fld(pos);
|
||||
|
||||
if (c.is_kind_of(CLASS_DATE_FIELD) && (c.automagic() || val == "%o" || val == "%O"))
|
||||
c.set(today);
|
||||
else
|
||||
if (c.is_kind_of(CLASS_EDIT_FIELD) && (c.is_firm() || val == "%f" || val == "%F"))
|
||||
c.set(prefix().get_codditta());
|
||||
else
|
||||
c.set(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
_lastpos = ftell(f);
|
||||
|
@ -98,33 +98,89 @@ TTrec * TReport_application::get_dbase_recdesc(TReport & rep, const TAutomask &
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
// @cmember Ciclo principale
|
||||
void TReport_application::main_loop()
|
||||
{
|
||||
TAutomask & m = get_mask();
|
||||
KEY k;
|
||||
bool has_rs = main_app().has_module(RSAUT, CHK_DONGLE);
|
||||
TString arg = argv(2);
|
||||
int narg = 2;
|
||||
const long old_firm = get_firm();
|
||||
bool restore_firm = false;
|
||||
TString arg;
|
||||
char arg_type = get_arg(narg, arg);
|
||||
TFilename name;
|
||||
|
||||
arg.trim();
|
||||
|
||||
if (arg.starts_with("-b"))
|
||||
if (arg_type == 'B')
|
||||
{
|
||||
TFilename fname = arg.mid(2);
|
||||
TFilename fname = arg;
|
||||
char sep = '\t';
|
||||
|
||||
if(fname.exist())
|
||||
if (fname.exist())
|
||||
{
|
||||
m.load(fname);
|
||||
|
||||
TReport & rep = get_report(m);
|
||||
TReport_book b(title());
|
||||
export_type type = _export_printer;
|
||||
TFilename name = argv(4);
|
||||
|
||||
m.load(fname, true);
|
||||
while ((arg_type = get_arg(narg, arg)) != '\0')
|
||||
{
|
||||
switch (arg_type)
|
||||
{
|
||||
case 'F' :
|
||||
if (atol(arg) != old_firm)
|
||||
{
|
||||
restore_firm = true;
|
||||
set_firm(atol(arg));
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
name = arg;
|
||||
break;
|
||||
case 'S':
|
||||
sep = arg[0];
|
||||
break;
|
||||
case 'T':
|
||||
k = 20000 + UPCASE(arg[0]);
|
||||
break;
|
||||
case ' ':
|
||||
default:
|
||||
if (atol(arg) != 0)
|
||||
{
|
||||
if (atol(arg) != old_firm)
|
||||
{
|
||||
restore_firm = true;
|
||||
set_firm(atol(arg));
|
||||
}
|
||||
}
|
||||
else
|
||||
if (arg.len() == 1)
|
||||
k = 20000 + UPCASE(arg[0]);
|
||||
else
|
||||
name = arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ask_filename = name.blank();
|
||||
|
||||
if (name.blank() || name.starts_with("-u"))
|
||||
if (name.blank())
|
||||
name = get_output_filename(m, rep);
|
||||
k = 20000 + UPCASE(argv(3)[0]);
|
||||
else
|
||||
{
|
||||
if (!dexist(name.path()))
|
||||
if (!make_dir(name.path()))
|
||||
{
|
||||
error_box(FR("Non posso creare %s uso il direttorio temporaneo"), (const char *)name.path());
|
||||
|
||||
const TString fname = name.name();
|
||||
name.cut(0);
|
||||
name.tempdir();
|
||||
name.add(fname);
|
||||
}
|
||||
}
|
||||
|
||||
switch (k)
|
||||
{
|
||||
case K_PRINT:
|
||||
@ -151,6 +207,7 @@ void TReport_application::main_loop()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
execute_print(b, m, rep, type);
|
||||
switch (k)
|
||||
{
|
||||
@ -162,7 +219,7 @@ void TReport_application::main_loop()
|
||||
esporta(b, m, rep);
|
||||
break;
|
||||
case K_EXCEL:
|
||||
b.export_excel(name);
|
||||
b.export_excel(name, false, false, false, sep);
|
||||
break;
|
||||
case K_PDF:
|
||||
b.export_pdf(name);
|
||||
@ -180,6 +237,8 @@ void TReport_application::main_loop()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (restore_firm)
|
||||
set_firm(old_firm);
|
||||
}
|
||||
|
||||
else
|
||||
@ -194,8 +253,11 @@ void TReport_application::main_loop()
|
||||
m.enable(DLG_EXPORT_DBF, has_rs);
|
||||
if (m.exist(DLG_EXPORT_TEXT))
|
||||
m.enable(DLG_EXPORT_TEXT, has_rs);
|
||||
if (m.exist(DLG_OUTPUT))
|
||||
m.show(DLG_OUTPUT, has_rs);
|
||||
if (m.exist(DLG_OUTPUTD))
|
||||
{
|
||||
m.show(DLG_OUTPUTD, has_rs);
|
||||
m.show(DLG_OUTPUTF, has_rs);
|
||||
}
|
||||
while ((k = m.run()) != K_QUIT)
|
||||
{
|
||||
TReport & rep = get_report(m);
|
||||
@ -261,16 +323,27 @@ void TReport_application::main_loop()
|
||||
|
||||
const char * TReport_application::get_output_filename(const TAutomask & mask, const TReport & rep)
|
||||
{
|
||||
TFilename output = get_mask().get(output_id());
|
||||
TFilename output = get_mask().get(outputdir_id());
|
||||
TString fname = get_mask().get(outputfile_id());
|
||||
|
||||
if (output.blank())
|
||||
output.tempdir();
|
||||
output.add(output_name(mask, rep));
|
||||
|
||||
TString & t = get_tmp_string(20);
|
||||
if (!dexist(output))
|
||||
if (!make_dir(output))
|
||||
{
|
||||
error_box(FR("Non posso creare %s uso il direttorio temporaneo"), (const char *)output);
|
||||
output.cut(0);
|
||||
output.tempdir();
|
||||
}
|
||||
if (fname.blank())
|
||||
{
|
||||
TString t(20);
|
||||
|
||||
fname = output_name(mask, rep);
|
||||
_strtime_s(t.get_buffer(), t.size());
|
||||
t.strip(":");
|
||||
output << '_' << today.date2ansi() << '_' << t;
|
||||
fname << '_' << today.date2ansi() << '_' << t;
|
||||
}
|
||||
output.add(fname);
|
||||
return get_tmp_string() = output;
|
||||
}
|
@ -52,12 +52,13 @@ protected: // TApplication
|
||||
virtual void execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type = _export_printer);
|
||||
|
||||
public:
|
||||
virtual short output_id() const { return DLG_OUTPUT; }
|
||||
virtual short outputdir_id() const { return DLG_OUTPUTD; }
|
||||
virtual short outputfile_id() const { return DLG_OUTPUTF; }
|
||||
virtual short report_id() const { return DLG_REPORT; }
|
||||
const char * report_name(const TAutomask & mask) const { return mask.get(report_id()); }
|
||||
virtual void print(TReport_book & book, TAutomask & mask, TReport & rep) { book.print_or_preview(); }
|
||||
virtual void esporta(TReport_book & book, TAutomask & mask, TReport & rep) { book.esporta();}
|
||||
virtual void export_excel(TFilename & name, TReport_book & book, TAutomask & mask, TReport & rep) { book.export_excel(name, false, true); }
|
||||
virtual void export_excel(TFilename & name, TReport_book & book, TAutomask & mask, TReport & rep, char sep = '\t') { book.export_excel(name, false, true, false, sep); }
|
||||
virtual void export_pdf(TFilename & name, TReport_book & book, TAutomask & mask, TReport & rep) { book.export_pdf(name, false, true); }
|
||||
virtual void export_text(TFilename & name, TReport_book & book, TAutomask & mask, TReport & rep) { book.export_text(name, 0, false, true); }
|
||||
virtual void export_dbase(TFilename & name, TReport_book & book, TAutomask & mask, TReport & rep) { book.export_dbase(name, get_dbase_recdesc(rep, mask), false, true); }
|
||||
|
@ -1269,6 +1269,7 @@ void TReport_field::copy(const TReport_field& rf)
|
||||
_halign = rf._halign; _valign = rf._valign;
|
||||
_picture = rf._picture; _field = rf._field;
|
||||
_hidden = rf.hidden();
|
||||
_hidden_default = rf._hidden_default;
|
||||
_deactivated = rf.deactivated();
|
||||
_hide_zeroes = rf._hide_zeroes;
|
||||
_field = rf._field; _alt_field = rf._alt_field;
|
||||
@ -1359,6 +1360,7 @@ bool TReport_field::load_field()
|
||||
}
|
||||
_draw_rct = _rct;
|
||||
_draw_hidden = _hidden;
|
||||
_hidden_default = _hidden;
|
||||
_draw_deactivated = _deactivated;
|
||||
|
||||
return ok;
|
||||
@ -2021,7 +2023,7 @@ TReport_field::TReport_field(TReport_section* sec)
|
||||
_border(0), _halign('L'), _valign('T'), _dynamic_height(false),
|
||||
_font(NULL), _print_font(NULL),
|
||||
_hidden(false), _deactivated(false), _hide_zeroes(false), _selected(false),
|
||||
_draw_hidden(false), _draw_deactivated(false)
|
||||
_hidden_default(false), _draw_hidden(false), _draw_deactivated(false)
|
||||
{ }
|
||||
|
||||
TReport_field::TReport_field(const TReport_field& rf)
|
||||
@ -2990,6 +2992,28 @@ void TReport::reset_export_sections()
|
||||
|
||||
sect->show(section_shown);
|
||||
}
|
||||
|
||||
TToken_string disabled_fields(get_excel_disabled_field());
|
||||
|
||||
FOR_EACH_STR_TOKEN(disabled_fields, fld_id)
|
||||
{
|
||||
if (fld_id[2] == '.')
|
||||
{
|
||||
TReport_section * sect = find_section(fld_id[0], atoi(fld_id.mid(1, 1)));
|
||||
|
||||
if (sect != nullptr)
|
||||
{
|
||||
const int id = atoi(fld_id.mid(3));
|
||||
TReport_field * fld = sect->find_field(id);
|
||||
|
||||
if (fld != nullptr)
|
||||
{
|
||||
const bool on = fld->shown_default();
|
||||
fld->show(on);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
set_dbase_fixed_fields(false);
|
||||
}
|
||||
|
||||
@ -3006,6 +3030,25 @@ void TReport::set_export4excel()
|
||||
|
||||
sect->show(on);
|
||||
}
|
||||
|
||||
TToken_string disabled_fields(get_excel_disabled_field());
|
||||
|
||||
FOR_EACH_STR_TOKEN(disabled_fields, fld_id)
|
||||
{
|
||||
if (fld_id[2] == '.')
|
||||
{
|
||||
TReport_section * sect = find_section(fld_id[0], atoi(fld_id.mid(1, 1)));
|
||||
|
||||
if (sect != nullptr)
|
||||
{
|
||||
const int id = atoi(fld_id.mid(3));
|
||||
TReport_field * fld = sect->find_field(id);
|
||||
|
||||
if (fld != nullptr)
|
||||
fld->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TReport::set_export4dbase()
|
||||
|
@ -361,7 +361,7 @@ class TReport_field : public TSortable
|
||||
TBit_array _modules;
|
||||
|
||||
TReport_font *_font, *_print_font;
|
||||
bool _hidden, _deactivated, _hide_zeroes, _selected;
|
||||
bool _hidden, _deactivated, _hide_zeroes, _selected, _hidden_default;
|
||||
|
||||
TReport_rct _draw_rct; // In centesimi
|
||||
bool _draw_hidden, _draw_deactivated;
|
||||
@ -430,6 +430,8 @@ public:
|
||||
|
||||
bool hidden() const { return _hidden; }
|
||||
bool shown() const { return !hidden(); }
|
||||
bool hidden_default() const { return _hidden_default; }
|
||||
bool shown_default() const { return !hidden_default(); }
|
||||
void show(bool on) { _hidden = !on; }
|
||||
void hide() { show(false); }
|
||||
bool deactivated() const { return _deactivated; }
|
||||
@ -599,6 +601,7 @@ public:
|
||||
int find_max_level(char type) const;
|
||||
|
||||
virtual const char * get_excel_header_section() { return "H0"; }
|
||||
virtual const char * get_excel_disabled_field() { return ""; }
|
||||
virtual void set_dbase_fixed_fields(bool on = true) {}
|
||||
void reset_export_sections();
|
||||
void set_export_sections(export_type type);
|
||||
|
@ -1861,7 +1861,7 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go
|
||||
return false;
|
||||
|
||||
TFilename temp;
|
||||
TToken_string line(8192, '\t');
|
||||
TToken_string line(8192, ';');
|
||||
TString ext = fname.ext(); ext.lower();
|
||||
|
||||
if (ext.blank())
|
||||
@ -1890,7 +1890,7 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go
|
||||
remove_files(f, false);
|
||||
}
|
||||
temp.temp("exp", "xls");
|
||||
export_excel(temp, signature);
|
||||
export_excel(temp, signature, false, false, ';');
|
||||
|
||||
TExternisamfile dbf(fname, *desc);
|
||||
ifstream ifstream(temp);
|
||||
@ -1944,7 +1944,7 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TBook::export_excel(TFilename& fname, bool signature, bool goto_url, bool ask_filename)
|
||||
bool TBook::export_excel(TFilename& fname, bool signature, bool goto_url, bool ask_filename, char sep)
|
||||
{
|
||||
ask_filename |= fname.blank();
|
||||
if (ask_filename && !ask_export_filename(fname))
|
||||
@ -2039,10 +2039,12 @@ bool TBook::export_excel(TFilename& fname, bool signature, bool goto_url, bool a
|
||||
TToken_string* line = (TToken_string*)page.objptr(row);
|
||||
if (line == NULL)
|
||||
{
|
||||
line = new TToken_string(256,'\t');
|
||||
line = new TToken_string(256,sep);
|
||||
page.add(line, row);
|
||||
}
|
||||
reformat_excel(str);
|
||||
if (str.find(sep) >= 0)
|
||||
str <<'"' << str << '"';
|
||||
line->add(str, idx);// come mai ?? pos);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// esporta il book in un file dbf il tracciato record passato viene disallocato
|
||||
virtual bool export_dbase(TFilename& fname, TTrec * desc = nullptr, bool signature = false, bool goto_url = false, bool ask_filename = false);
|
||||
virtual bool export_excel(TFilename& fname, bool signature = false, bool goto_url = false, bool ask_filename = false);
|
||||
virtual bool export_excel(TFilename& fname, bool signature = false, bool goto_url = false, bool ask_filename = false, char sep = '\t');
|
||||
virtual bool export_pdf(TFilename& fname, bool signature = false, bool goto_url = false, bool ask_filename = false);
|
||||
virtual bool export_text(TFilename& fname, int size = 0, bool signature = false, bool goto_url = false, bool ask_filename = false);
|
||||
virtual bool send_mail(TFilename& fname, bool signature = false);
|
||||
|
@ -15,7 +15,7 @@ TScanner::TScanner(const char* filename)
|
||||
|
||||
if (fail())
|
||||
{
|
||||
DIRECTORY dir; xvt_fsys_get_default_dir(&dir);
|
||||
DIRECTORY dir; xvt_fsys_get_curr_dir(&dir);
|
||||
TFilename curdir; xvt_fsys_convert_dir_to_str(&dir, curdir.get_buffer(), curdir.size());
|
||||
|
||||
TString msg;
|
||||
|
@ -194,6 +194,12 @@ bool dexist(
|
||||
return file && *file && xvt_fsys_dir_exists(file) != 0;
|
||||
}
|
||||
|
||||
bool is_dir(
|
||||
const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza
|
||||
{
|
||||
return file && *file && xvt_fsys_file_attr(file, XVT_FILE_ATTR_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
long fsize(const char* name)
|
||||
{
|
||||
return (name && *name) ? xvt_fsys_file_attr(name, XVT_FILE_ATTR_SIZE) : 0L;
|
||||
|
@ -60,6 +60,7 @@ bool fmove(const char* orig, const char* dest, bool append = false, bool advance
|
||||
bool fexist(const char* file);
|
||||
long fsize(const char* file);
|
||||
bool dexist(const char* file);
|
||||
bool is_dir(const char* file);
|
||||
void log_message(const char* fmt, ...);
|
||||
|
||||
const time_t atime(const char* file); // access time
|
||||
|
Loading…
x
Reference in New Issue
Block a user