fc92b4e2c8
Files correlati : Ricompilazione Demo : [ ] Commento :PERSONALIZZAZIONE SAILOG git-svn-id: svn://10.65.10.50/trunk@18545 c028cbd2-c16b-5b4b-a496-9718f37d4682
536 lines
16 KiB
C++
Executable File
536 lines
16 KiB
C++
Executable File
#include <Textset.h>
|
|
#include <Applicat.h>
|
|
#include <Automask.h>
|
|
#include <Reprint.h>
|
|
#include <currency.h>
|
|
#include "pd5317.h"
|
|
#include "pd5317100.h"
|
|
|
|
//Stampa Listino Carrelli
|
|
//lvietri
|
|
|
|
class TCarrelli_recordset: public TCSV_recordset
|
|
{
|
|
public:
|
|
TCarrelli_recordset(): TCSV_recordset("CSV(\"\t\")") {}
|
|
};
|
|
|
|
//DEFINIZIONE DELLA STRUTTURA
|
|
struct TStruttura_carrelli: public TObject
|
|
{
|
|
const TString _articolo;
|
|
TString _user1;
|
|
TString _user2;
|
|
TString _user3;
|
|
TString _user4;
|
|
TString _user5;
|
|
TString _user6;
|
|
TString _user7;
|
|
TString _user8;
|
|
TString _user9;
|
|
TString _user10;
|
|
TString _user11;
|
|
TString _user12;
|
|
TString _user13;
|
|
TString _user14;
|
|
TDate _data_doc;
|
|
TCurrency _importob;
|
|
TDate _data_gara;
|
|
TCurrency _prezzoAcq;
|
|
TString _descr_conto;
|
|
TString _modello;
|
|
TCurrency _noleggio;
|
|
TCurrency _manutenzione;
|
|
TString _venduto_a;
|
|
TCurrency _prezzo_vend;
|
|
TCurrency _prezzo_p1;
|
|
TCurrency _prezzo_autom;
|
|
TCurrency _prezzo_recup;
|
|
|
|
TStruttura_carrelli():_articolo(""),_user1 (""),_user2 (""),
|
|
_user3 (""),_user4 (""),_user5 (""),
|
|
_user6 (""),_user7 (""),_user8 (""),
|
|
_user9 (""),_user10(""),_user11(""),
|
|
_user12(""),_user13(""),_user14(""),
|
|
_data_doc(""),_data_gara(""),_modello(""),
|
|
_venduto_a("") {}
|
|
|
|
TStruttura_carrelli(TString articolo,TString user[],TDate dataDoc,
|
|
TCurrency importob, TDate data_gara, TCurrency prezzoAcq,TString descrAcq,
|
|
TString modello,TCurrency noleggio,TCurrency manutenzione, TString venduto_a,
|
|
TCurrency prezzoVend,TCurrency prezzo_p1, TCurrency prezzo_autom,
|
|
TCurrency prezzo_recup):
|
|
_articolo(articolo),_user1 (user[0 ]),_user2 (user[1 ]),_user3 (user[2 ]),
|
|
_user4 (user[3 ]),_user5 (user[4 ]),_user6 (user[5 ]),_user7 (user[6 ]),
|
|
_user8 (user[7 ]),_user9 (user[8 ]),_user10(user[9 ]),_user11(user[10]),
|
|
_user12(user[11]),_user13(user[12]),_user14(user[13]),_data_doc(dataDoc),
|
|
_importob(importob),_data_gara(data_gara) ,_prezzoAcq(prezzoAcq),
|
|
_descr_conto(descrAcq), _modello(modello),_noleggio(noleggio),
|
|
_manutenzione(manutenzione),_venduto_a(venduto_a), _prezzo_vend(prezzoVend),
|
|
_prezzo_p1(prezzo_p1), _prezzo_autom(prezzo_autom),_prezzo_recup(prezzo_recup)
|
|
{}
|
|
};
|
|
|
|
class TCarrelli_mask: public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
public:
|
|
TCarrelli_mask():TAutomask("pd5317100"){}
|
|
};
|
|
|
|
bool TCarrelli_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
class TCarrelli_report : public TReport
|
|
{
|
|
protected:
|
|
virtual bool use_mask() { return false; }
|
|
};
|
|
|
|
class TCarrelli_app: public TSkeleton_application
|
|
{
|
|
protected:
|
|
virtual void main_loop();
|
|
void elabora(const TMask& mask) const;
|
|
TString get_query(int tipo, TString venduto) const;
|
|
TString get_query_saldana(TString codice) const;
|
|
TString get_query_saldana(TString codice, TString operatore) const;
|
|
const char * TCarrelli_app::extra_modules() const;
|
|
};
|
|
|
|
const char * TCarrelli_app::extra_modules() const { return "mg"; }
|
|
|
|
TString TCarrelli_app::get_query_saldana(TString codice) const
|
|
{
|
|
return get_query_saldana(codice,"==");
|
|
}
|
|
|
|
TString TCarrelli_app::get_query_saldana(TString codice, TString operatore) const
|
|
{
|
|
//Stringhe x composizione query
|
|
TString query, select, between;
|
|
|
|
select << "USE SALDANA KEY 2\n";
|
|
select << "SELECT ((CONTO" << operatore<< "'" << codice << "')&&";
|
|
between << "(BETWEEN(COMMESSA,#COMM,#COMM)))";
|
|
|
|
query << select << between;
|
|
|
|
return query;
|
|
}
|
|
|
|
TString TCarrelli_app::get_query(int tipo,TString venduto) const
|
|
{
|
|
//Stringhe x composizione query
|
|
TString query, select, between, join, order_by;
|
|
|
|
if(tipo==0)//query su analitica\articoli\commesse
|
|
{
|
|
TString operConto = "!=";
|
|
if(venduto=="X")
|
|
{
|
|
operConto = "==";
|
|
}
|
|
select << "USE SALDANA KEY 2\n";
|
|
select << "SELECT ((CONTO" << operConto << "'004076000003')&&";
|
|
between << "(ANAMAG.CODART!='')&&";
|
|
between << "(BETWEEN(COMMESSA,#FROM,#TO)))\n";
|
|
order_by<< "BY COMMESSA\n";
|
|
join << "JOIN ANAMAG TO SALDANA INTO CODART==COMMESSA \n";
|
|
join << "JOIN COMMESSE TO SALDANA INTO CODCMS==COMMESSA \n";
|
|
}
|
|
else if(tipo==1)//query su articolo\doc.
|
|
{
|
|
select << "USE DOC KEY 3\n";
|
|
select << "SELECT ((TIPODOC='B01')&&";
|
|
between << "(BETWEEN(CODCMS,#COMM,#COMM)))\n";
|
|
join << "JOIN CLIFO TO DOC INTO TIPOCF==TIPOCF CODCF==CODCF\n";
|
|
join << "JOIN INDSPED TO DOC INTO TIPOCF==TIPOCF CODCF==CODCF CODIND==CODINDSP\n";
|
|
join << "JOIN COMUNI TO CLIFO INTO COM==COMCF \n";
|
|
}
|
|
else if(tipo==2)//query su saldana ACQUISTO DA
|
|
{
|
|
select << "USE SALDANA KEY 2\n";
|
|
select << "SELECT (((CONTO ?='003081*')||(CONTO =='003071000002'))&&";
|
|
between << "(BETWEEN(COMMESSA,#COMM,#COMM)))";
|
|
}
|
|
else if(tipo==3)//query su piano dei conti.
|
|
{
|
|
select << "USE PCON KEY 1\n";
|
|
select << "SELECT ((GRUPPO=#GRUPPO1)&&(CONTO=#CONTO1)&&(SOTTOCONTO=#SOTTOCONTO1))";
|
|
}
|
|
else if(tipo==4)//query su multirel per sapere se cespite
|
|
{
|
|
select << "USE MULTIREL KEY 2\n";
|
|
select << "SELECT ((COD =='CEMAT')&&";
|
|
between << "(BETWEEN(SECOND,#COMM,#COMM)))";
|
|
}
|
|
|
|
query << select << between << order_by << join;
|
|
|
|
return query;
|
|
}
|
|
|
|
class TRiepCarrelli: public TArray
|
|
{
|
|
public:
|
|
void add(TString articolo, TString user[], TDate dataDoc,
|
|
TCurrency importob, TDate data_gara, TCurrency prezzoAcq,TString descrAcq,
|
|
TString modello,TCurrency noleggio,TCurrency manutenzione,
|
|
TString venduto_a, TCurrency prezzoVend,
|
|
TCurrency prezzo_p1, TCurrency prezzo_autom,
|
|
TCurrency prezzo_recup);
|
|
|
|
TRiepCarrelli():TArray(){}
|
|
};
|
|
|
|
|
|
void TRiepCarrelli::add(TString articolo,TString user[],TDate dataDoc,
|
|
TCurrency importob, TDate data_gara,
|
|
TCurrency prezzoAcq,TString descrAcq,
|
|
TString modello,TCurrency noleggio,TCurrency manutenzione,
|
|
TString venduto_a, TCurrency prezzoVend,
|
|
TCurrency prezzo_p1, TCurrency prezzo_autom,
|
|
TCurrency prezzo_recup)
|
|
{
|
|
TStruttura_carrelli* struttura = new TStruttura_carrelli(
|
|
articolo,user,dataDoc,importob,data_gara,
|
|
prezzoAcq,descrAcq,modello, noleggio, manutenzione,
|
|
venduto_a,prezzoVend,prezzo_p1,prezzo_autom, prezzo_recup);
|
|
|
|
TArray::add(struttura);
|
|
}
|
|
|
|
//metodo principale di elaborazione
|
|
void TCarrelli_app:: elabora(const TMask& mask)const
|
|
{
|
|
TString venduto = mask.get(F_VENDUTO);
|
|
|
|
TISAM_recordset riep(get_query(0,venduto));
|
|
|
|
//inserire parametri filtri
|
|
riep.set_var("#FROM",TVariant(mask.get(F_COD_CMS)));//
|
|
riep.set_var("#TO",TVariant(mask.get(F_COD_CMS_TO)));//
|
|
riep.set_var("#F_VEN",TVariant(mask.get(F_VENDUTO)));//
|
|
riep.set_var("#F_CAR",TVariant(mask.get(F_CARICO)));//
|
|
|
|
TRiepCarrelli riepilogo;
|
|
|
|
//inizializzazione variabili da utilizzare nella
|
|
//struttura
|
|
TString articolo;
|
|
TString user[14];
|
|
TString campo;
|
|
TString ragsoc;
|
|
TString indir;
|
|
TDate dataDoc;
|
|
TCurrency importob;
|
|
TCurrency prezzoAcq;
|
|
TDate data_gara;
|
|
TString descr_conto;
|
|
TString conto;
|
|
TString prov;
|
|
TString modello;
|
|
int gruppo1;
|
|
int conto1;
|
|
int sottoGruppo1;
|
|
TString venduto_a;
|
|
TCurrency prezzoVend;
|
|
TCurrency prezzo_p1;
|
|
TCurrency noleggio;
|
|
TCurrency manutenzione;
|
|
TCurrency prezzo_autom;
|
|
TCurrency prezzo_recup;
|
|
TString commessa;
|
|
TString commessaOld;
|
|
|
|
for(bool ok = riep.move_first();ok;ok=riep.move_next())
|
|
{
|
|
commessa = riep.get("SALDANA.COMMESSA").as_string();
|
|
articolo = riep.get("ANAMAG.CODART").as_string();//A
|
|
|
|
if(commessa==commessaOld ||
|
|
commessa.empty() ||
|
|
articolo.empty())
|
|
{
|
|
continue;
|
|
}
|
|
commessaOld=commessa;
|
|
|
|
int numUser = 1;
|
|
//if(articolo.not_empty())
|
|
{
|
|
for(int a = 0; a<14; a++) //da B a N
|
|
{
|
|
campo = "ANAMAG.USER";
|
|
campo << numUser;
|
|
user[a] = riep.get(campo).as_string();
|
|
numUser++;
|
|
}
|
|
|
|
ragsoc = "";//M
|
|
indir = "";//N
|
|
dataDoc= "";//O
|
|
|
|
TISAM_recordset bolle(get_query(1,""));
|
|
bolle.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = bolle.move_last();ok2;ok2=bolle.move_next())
|
|
{
|
|
ragsoc = bolle.get("CLIFO.RAGSOC").as_string();
|
|
indir = bolle.get("INDSPED.LOCALITA").as_string();
|
|
dataDoc= bolle.get("DATADOC").as_date();
|
|
|
|
if(indir.empty())
|
|
{
|
|
indir = bolle.get("COMUNI.DENCOM").as_string();
|
|
prov = bolle.get("COMUNI.PROVCOM").as_string();
|
|
indir.trim() << "(" << prov.trim() << ")";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if(ragsoc.not_empty())
|
|
{
|
|
user[11] = ragsoc;
|
|
user[12] = indir ;
|
|
}
|
|
|
|
importob = riep.get("COMMESSE.IMPORTOB").as_real();//P
|
|
data_gara = riep.get("COMMESSE.DATAGARA").as_string();//Q
|
|
modello = riep.get("COMMESSE.DESCRIZ").as_string();//T
|
|
|
|
prezzoAcq.set_price(0);//R
|
|
conto="";
|
|
descr_conto="";//S
|
|
TISAM_recordset saldana(get_query(2,""));
|
|
saldana.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok3 = saldana.move_first();ok3;ok3=saldana.move_next())
|
|
{
|
|
prezzoAcq = prezzoAcq + saldana.get("SALDANA.SALDO").as_real();
|
|
conto = saldana.get("SALDANA.CONTO").as_string();
|
|
}
|
|
|
|
if(conto.not_empty())
|
|
{
|
|
gruppo1 = atoi(conto.sub(0,3));
|
|
conto1 = atoi(conto.sub(3,6));
|
|
sottoGruppo1 = atoi(conto.sub(6));
|
|
|
|
TISAM_recordset pconto(get_query(3,""));
|
|
pconto.set_var("#GRUPPO1",TVariant(long (gruppo1)));//
|
|
pconto.set_var("#CONTO1",TVariant(long (conto1)));//
|
|
pconto.set_var("#SOTTOCONTO1",TVariant(long (sottoGruppo1)));//
|
|
for(bool ok3 = pconto.move_first();ok3;ok3=pconto.move_next())
|
|
{
|
|
descr_conto = pconto.get("PCON.DESCR").as_string();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//NOLEGGIO
|
|
noleggio.set_price(0);//U
|
|
TISAM_recordset noleg(get_query_saldana("004076000004"));
|
|
noleg.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = noleg.move_first();ok2;ok2=noleg.move_next())
|
|
{
|
|
noleggio = noleggio + noleg.get("SALDANA.SALDO").as_real();
|
|
}
|
|
|
|
//MANUTENZIONE
|
|
manutenzione.set_price(0);//U
|
|
TISAM_recordset manut(get_query_saldana("003071000003"));
|
|
manut.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = manut.move_first();ok2;ok2=manut.move_next())
|
|
{
|
|
manutenzione = manutenzione + manut.get("SALDANA.SALDO").as_real();
|
|
}
|
|
|
|
/*
|
|
Scaletta per il recupero del venduto:
|
|
1) user1 prelevato da anamag
|
|
2) se esiste su SALDANA con il conto 004 076 000003(Venduto)
|
|
3) controllo su multirel se si tratta di un cespite
|
|
4) se esiste su SALDANA con il conto 003 071 000002 (acquistato)
|
|
5) se esiste su SALDANA con il conto 003 081 000043
|
|
sino al 003 081 999999 (leasing)
|
|
*/
|
|
venduto_a = user[0];//W
|
|
prezzoVend.set_price(0);//X
|
|
if(venduto_a.empty())
|
|
{
|
|
//VENDUTO
|
|
TISAM_recordset saldana(get_query_saldana("004076000003"));
|
|
saldana.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = saldana.move_last();ok2;ok2=saldana.move_next())
|
|
{
|
|
venduto_a = "VENDUTO";
|
|
prezzoVend = prezzoVend + saldana.get("SALDANA.SALDO").as_real();
|
|
}
|
|
|
|
if(venduto_a.empty())
|
|
{
|
|
//CESPITE
|
|
TISAM_recordset cespite(get_query(4,""));
|
|
cespite.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = cespite.move_last();ok2;ok2=cespite.move_next())
|
|
{
|
|
venduto_a = "CESPITE";
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(venduto_a.empty())
|
|
{
|
|
//ACQUISTATO
|
|
TISAM_recordset acquistato(get_query_saldana("003071000002"));
|
|
acquistato.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = acquistato.move_last();ok2;ok2=acquistato.move_next())
|
|
{
|
|
venduto_a = "ACQUISTATO";
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(venduto_a.empty())
|
|
{
|
|
//LEASING
|
|
TISAM_recordset leasing(get_query_saldana("?=","003081*"));
|
|
leasing.set_var("#COMM",TVariant(articolo));
|
|
for(bool ok2 = leasing.move_last();ok2;ok2=leasing.move_next())
|
|
{
|
|
venduto_a = "LEASING";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
prezzo_p1 = (prezzoAcq + manutenzione)*1.10;//Y
|
|
prezzo_autom = prezzo_p1 * 1.1 * 1.2;//Z
|
|
|
|
prezzo_recup = noleggio - prezzoVend - prezzo_p1;//AB
|
|
|
|
riepilogo.add(articolo,user,dataDoc,importob,data_gara,
|
|
prezzoAcq,descr_conto,modello,
|
|
noleggio,manutenzione,venduto_a,prezzoVend,
|
|
prezzo_p1, prezzo_autom,prezzo_recup);
|
|
|
|
}
|
|
}
|
|
|
|
//gestione report
|
|
TCarrelli_report rep;
|
|
bool stampa = rep.load("pd5317100");
|
|
TCarrelli_recordset* riep_set = new TCarrelli_recordset();
|
|
rep.set_recordset(riep_set);
|
|
|
|
//scandisce clienti e tiene buoni solo quelli valorizzati
|
|
FOR_EACH_ARRAY_ITEM(riepilogo,c,obj)
|
|
{
|
|
TStruttura_carrelli& s = *(TStruttura_carrelli*) obj;
|
|
|
|
riep_set->new_rec();
|
|
int colonna = 0;
|
|
riep_set->set(colonna,TVariant(TVariant(s._articolo)));//A
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user1)));//B
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user2)));//C
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user3)));//D
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user4)));//E
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user5)));//F
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user6)));//G
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user7)));//H
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user8)));//I
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user9)));//J
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user10)));//K
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user11)));//L
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user12)));//M
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user13)));//N
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._data_doc)));//O
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant((s._importob).string()));//P
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._data_gara)));//Q
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._prezzoAcq).string())));//R
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._descr_conto)));//S
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._modello)));//T
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._noleggio).string())));//U
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._manutenzione).string())));//V
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._venduto_a)));//W
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._prezzo_vend).string())));//X
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._prezzo_p1).string())));//Y
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._prezzo_autom).string())));//Z
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant(s._user14)));//AA
|
|
colonna++;
|
|
riep_set->set(colonna,TVariant(TVariant((s._prezzo_recup).string())));//AB
|
|
colonna++;
|
|
}
|
|
|
|
//Crea file che contiene il recordset
|
|
//riep_set->save_as("c:\\riepilogoBolla.txt");
|
|
|
|
//Se il report esiste..
|
|
if(stampa)
|
|
{
|
|
//carica tutte le variabili del report.
|
|
rep.mask2report(mask);
|
|
|
|
TReport_book b;
|
|
bool ok = b.add(rep);// Richiede parametri di stampa in base alla maschera omonima
|
|
if (ok)
|
|
{
|
|
//Se esiste almeno 1 pagina
|
|
if (b.pages() > 0)
|
|
b.print_or_preview(); // Stampa effettivamente
|
|
else
|
|
warning_box (TR("Nessun record estratto per i parametri inseriti"));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void TCarrelli_app::main_loop()
|
|
{
|
|
TCarrelli_mask mask;
|
|
|
|
//Setto come check iniziale il venduto a Si
|
|
mask.set("#F_VEN","X");
|
|
|
|
while(mask.run()==K_ENTER)
|
|
{
|
|
elabora(mask);
|
|
}
|
|
}
|
|
|
|
int pd5317100(int argc, char* argv[])
|
|
{
|
|
TCarrelli_app app;
|
|
app.run(argc, argv, TR("Stampa Listino Carrelli"));
|
|
return 0;
|
|
} |