2ea3151c0d
Files correlati : lv1 lv1300a.msk Ricompilazione Demo : [ ] Commento : Aggiunta la stampa degli inventari git-svn-id: svn://10.65.10.50/trunk@20400 c028cbd2-c16b-5b4b-a496-9718f37d4682
181 lines
5.2 KiB
C++
Executable File
181 lines
5.2 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <execp.h>
|
||
#include <relation.h>
|
||
#include <reprint.h>
|
||
|
||
#include "lv1300a.h"
|
||
#include "../ve/velib.h"
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TStampa_inv_msk
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TStampa_inv_msk: public TAutomask
|
||
{
|
||
protected:
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
public:
|
||
TStampa_inv_msk();
|
||
};
|
||
|
||
TStampa_inv_msk::TStampa_inv_msk() : TAutomask("lv1300a")
|
||
{
|
||
const TString& codnum = ini_get_string(CONFIG_DITTA, "lv", "NUM_INV");
|
||
set(F_CODNUM, codnum);
|
||
set(F_DESNUM, cache().get("%NUM", codnum, "S0"));
|
||
|
||
const TString& tipdoc = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_INV");
|
||
set(F_TIPODOC, tipdoc);
|
||
set(F_DESTIPODOC, cache().get("%TIP", tipdoc, "S0"));
|
||
}
|
||
|
||
bool TStampa_inv_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{ return true; }
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TStampa_inv_set
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TStampa_inv_set : public TISAM_recordset
|
||
{
|
||
protected:
|
||
static bool status_filter(const TRelation* rel);
|
||
virtual void set_custom_filter(TCursor& cursor) const;
|
||
|
||
public:
|
||
TStampa_inv_set(const TMask& mask);
|
||
};
|
||
|
||
// Accetta solo i documenti stampabili in definitivo
|
||
bool TStampa_inv_set::status_filter(const TRelation* rel)
|
||
{
|
||
const TRectype& doc = rel->curr();
|
||
const char stato_attuale = doc.get_char(DOC_STATO);
|
||
if (stato_attuale <= ' ')
|
||
return true;
|
||
|
||
const TTipo_documento& tipo = cached_tipodoc(doc.get(DOC_TIPODOC));
|
||
if (stato_attuale == tipo.stato_finale_stampa())
|
||
return false;
|
||
|
||
const TString& stati_stampa = tipo.stati_iniziali_stampa();
|
||
return stati_stampa.blank() || stati_stampa.find(stato_attuale) >= 0;
|
||
}
|
||
|
||
void TStampa_inv_set::set_custom_filter(TCursor& cursor) const
|
||
{
|
||
cursor.set_filterfunction(status_filter);
|
||
}
|
||
|
||
TStampa_inv_set::TStampa_inv_set(const TMask& mask) : TISAM_recordset("USE DOC")
|
||
{
|
||
const TDate data_from = mask.get_date(F_DADATA);
|
||
|
||
TString query = "USE DOC \n";
|
||
|
||
switch(mask.get_int(F_STAMPAPER))
|
||
{
|
||
case 0:
|
||
query << "JOIN %STD INTO CODTAB==STATO\n"
|
||
<< "FROM PROVV=\"D\" ANNO=" << data_from.year() << " CODNUM=\"" << mask.get(F_CODNUM) << "\" NDOC=" << mask.get_int(F_DANDOC) << "\n"
|
||
<< "TO PROVV=\"D\" ANNO=" << data_from.year() << " CODNUM=\"" << mask.get(F_CODNUM) << "\" NDOC=" << mask.get_int(F_ANDOC) << "\n";
|
||
break;
|
||
case 1:
|
||
query << "SELECT (BETWEEN(DATADOC,#DADATA,#ADATA))\n"
|
||
<< "JOIN %STD INTO CODTAB==STATO\n"
|
||
<< "FROM PROVV=\"D\" ANNO=" << data_from.year() << " CODNUM=\"" << mask.get(F_CODNUM) << "\"\n"
|
||
<< "TO PROVV=\"D\" ANNO=" << data_from.year() << " CODNUM=\"" << mask.get(F_CODNUM) << "\"\n";
|
||
default: break;
|
||
}
|
||
|
||
set(query);
|
||
//inserire parametri filtri se <20> il caso
|
||
if(mask.get_int(F_STAMPAPER) == 1)
|
||
{
|
||
set_var("#DADATA", mask.get_date(F_DADATA));
|
||
set_var("#ADATA", mask.get_date(F_ADATA));
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TStampa_inv_app
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TStampa_inv_app: public TSkeleton_application
|
||
{
|
||
protected:
|
||
virtual void main_loop();
|
||
void elabora(const TMask& mask, const char action) const;
|
||
};
|
||
|
||
void TStampa_inv_app::elabora(const TMask& mask, const char action) const
|
||
{
|
||
TStampa_inv_set inventari(mask);
|
||
|
||
TCursor* c = inventari.cursor();
|
||
TCursor_sheet sht(c, " |NDOC|DATADOC|4->S0[1,25]", TR("Selezione Documenti"),
|
||
HR("@1|Numero\nDoc.@7|Data\nDoc.@10|Stato"));
|
||
sht.check(-1);
|
||
if (sht.run() && sht.one_checked())
|
||
{
|
||
TFilename tmp;
|
||
tmp.temp("", "ini");
|
||
|
||
// Ensure that the ofstream is well closed before ve1 call
|
||
if (tmp.full()) // dummy test
|
||
{
|
||
const TDate data_from = mask.get_date(F_DADATA);
|
||
const TString& cod_num = mask.get(F_CODNUM);
|
||
TString16 chiavedoc; // Parte della chiave comune a tutti i documenti
|
||
chiavedoc << "D|" << data_from.year() << "|" << cod_num << "|";
|
||
|
||
ofstream outf(tmp);
|
||
outf << "[Transaction]" << endl; // Transaction header
|
||
outf << "Action=" << action << endl; // 'S'tampa o 'A'nteprima
|
||
outf << "Mode=D" << endl; // Definitive (always?)
|
||
outf << "NoPrintDlg=X" << endl; // Dont' prompt the user with the print dialog
|
||
outf << endl;
|
||
outf << "[33]" << endl; // Transaction body
|
||
long nx = 0; // Document counter
|
||
FOR_EACH_CHECKED_ROW(sht, i, row)
|
||
{
|
||
outf << "Doc(" << (nx++) << ")=";
|
||
outf << chiavedoc << row->get(1) << endl;
|
||
}
|
||
}
|
||
|
||
if (tmp.exist())
|
||
{
|
||
TString cmdline; cmdline << "ve1 -2 -i" << tmp;
|
||
TExternal_app app(cmdline);
|
||
app.run();
|
||
tmp.fremove();
|
||
}
|
||
}
|
||
}
|
||
|
||
void TStampa_inv_app::main_loop()
|
||
{
|
||
TStampa_inv_msk m;
|
||
bool running = true;
|
||
while (running)
|
||
{
|
||
const KEY k = m.run();
|
||
switch (k)
|
||
{
|
||
case K_ENTER: elabora(m, 'S'); break; // 'S'tampa
|
||
case 'A' : elabora(m, 'A'); break; // 'A'nteprima
|
||
case 'P' : elabora(m, 'P'); break; // 'P'df
|
||
default : running = false; break; // quit
|
||
}
|
||
}
|
||
}
|
||
|
||
int lv1300(int argc, char* argv[])
|
||
{
|
||
TStampa_inv_app app;
|
||
app.run(argc, argv, TR("Stampa Inventario"));
|
||
return 0;
|
||
}
|