This commit was manufactured by cvs2svn to create branch 'R_10_00'.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21591 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9a75a96188
commit
5f7397c6c0
210
ps/ps0330200.cpp
Executable file
210
ps/ps0330200.cpp
Executable file
@ -0,0 +1,210 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <dongle.h>
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "../mg/anamag.h"
|
||||
#include "../mg/codcorr.h"
|
||||
|
||||
#include "ps0330200a.h"
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// MASCHERA
|
||||
///////////////////////////////////////////////
|
||||
class TDisp_by_ftp_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
TDisp_by_ftp_mask();
|
||||
};
|
||||
|
||||
TDisp_by_ftp_mask::TDisp_by_ftp_mask() : TAutomask("ps0330200a")
|
||||
{
|
||||
}
|
||||
|
||||
bool TDisp_by_ftp_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
/*switch(o.dlg())
|
||||
{
|
||||
default:
|
||||
break;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// RECORDSET
|
||||
///////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// APPLICAZIONE
|
||||
///////////////////////////////////////////////
|
||||
class TDisp_by_ftp : public TSkeleton_application
|
||||
{
|
||||
TDisp_by_ftp_mask* _mask;
|
||||
|
||||
protected:
|
||||
virtual bool check_autorization() const {return false;}
|
||||
virtual const char * extra_modules() const {return "ve";}
|
||||
virtual bool create();
|
||||
virtual void main_loop();
|
||||
|
||||
const TString& find_ean(const TString& codart);
|
||||
|
||||
public:
|
||||
void elabora();
|
||||
|
||||
};
|
||||
|
||||
//ritorna il codice EAN13 dell'articolo in input; in caso di codici multipli ritorna l'ultimo...
|
||||
//..dovrebbe essere il più nuovo...forse...
|
||||
const TString& TDisp_by_ftp::find_ean(const TString& codart)
|
||||
{
|
||||
TString ean_query;
|
||||
ean_query << "USE CODCORR";
|
||||
ean_query << "\nSELECT (TIPO==1)";
|
||||
ean_query << "\nFROM CODART=#CODART";
|
||||
ean_query << "\nTO CODART=#CODART";
|
||||
TISAM_recordset ean_recset(ean_query);
|
||||
ean_recset.set_var("#CODART", codart);
|
||||
const bool ok = ean_recset.move_first();
|
||||
|
||||
TString& ean_code = get_tmp_string();
|
||||
if (ok)
|
||||
ean_code = ean_recset.get(CODCORR_CODARTALT).as_string();
|
||||
|
||||
return ean_code;
|
||||
}
|
||||
|
||||
void TDisp_by_ftp::elabora()
|
||||
{
|
||||
//preparazione file .txt che verrà completato in locale con i dati estratti e poi spedito alla..
|
||||
//..directory ftp specificata
|
||||
TFilename file_txt;
|
||||
file_txt.tempdir();
|
||||
file_txt.add(_mask->get(F_FILENAME));
|
||||
file_txt.ext(".txt");
|
||||
ofstream file_output(file_txt);
|
||||
|
||||
//crea il recordset da esportare
|
||||
//esporta dati dalle giacenze di magazzino, l'anagrafica articolo, l'unità di misura
|
||||
TString query;
|
||||
query << "USE 109";
|
||||
query << "\nBY ANAMAG.CODART";
|
||||
query << "\nJOIN ANAMAG INTO CODART==CODART";
|
||||
query << "\nJOIN UMART INTO CODART=CODART NRIGA=1";
|
||||
query << "\nFROM ANNOES=#ANNO";
|
||||
query << "\nTO ANNOES=#ANNO";
|
||||
|
||||
TISAM_recordset recset(query);
|
||||
|
||||
const TDate today(TODAY);
|
||||
const long anno = 2009; //today.year();
|
||||
recset.set_var("#ANNO", anno);
|
||||
|
||||
const long items = recset.items();
|
||||
|
||||
TProgind pi(items, "Elaborazione in corso...", true, true);
|
||||
|
||||
TToken_string record;
|
||||
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
record.cut(0);
|
||||
|
||||
const TString80 codart = recset.get("ANAMAG.CODART").as_string();
|
||||
record.add(codart); //codart
|
||||
|
||||
TString descr = recset.get("ANAMAG.DESCR").as_string();
|
||||
descr << " " << recset.get("ANAMAG.DESCRAGG").as_string();
|
||||
descr.left(100);
|
||||
record.add(descr); //descr
|
||||
|
||||
record.add(""); //co. prodotto produttore
|
||||
|
||||
const real giac = recset.get("GIAC").as_real();
|
||||
const long int_giac = giac.integer();
|
||||
record.add(int_giac); //quantita' disponibile
|
||||
|
||||
record.add(""); //qta in arrivo (integer)
|
||||
record.add(""); //data arrivo prevista (gg/mm/aaaa)
|
||||
|
||||
const real prezzo = recset.get("UMART.PREZZO").as_real(); //prezzo (con ',' separatore decimale; se vogliono '.' .> string())
|
||||
record.add(prezzo.stringa());
|
||||
|
||||
record.add(""); //prezzo al pubblico
|
||||
|
||||
TString16 str_data = today.string();
|
||||
str_data.replace('-', '/');
|
||||
record.add(today.string()); //data creazione
|
||||
|
||||
const TString& grmerc = recset.get("ANAMAG.GRMERC").as_string();
|
||||
record.add(grmerc); //gruppo merceologco
|
||||
const TString& grmerc_descr = cache().get("GMC", codart, "S0");
|
||||
record.add(grmerc_descr); //descrizione grmerc
|
||||
|
||||
const TString& marca = codart.left(3);
|
||||
record.add(marca); //marca
|
||||
const TString& descr_marca = cache().get(LF_ANAMAG, marca, ANAMAG_DESCR);
|
||||
record.add(descr_marca); //descrizione marca
|
||||
|
||||
record.add(""); //stato del prodotto (1 carattere: Nuovo,In esurimento, Fine serie, Obsoleto)
|
||||
|
||||
record.add(codart); //codart per l'EAN
|
||||
const TString& ean_code = find_ean(codart);
|
||||
record.add(ean_code); //descrizione per l'EAN
|
||||
|
||||
//crittura del record sull'ofstream
|
||||
file_output << record << endl;
|
||||
}
|
||||
|
||||
//chiusura dell'ofstream
|
||||
file_output.close();
|
||||
|
||||
//spostamento del file locale nella directory di destinazione
|
||||
TFilename dst_file = _mask->get(F_FTP_PATH);
|
||||
dst_file.add(file_txt.name());
|
||||
const int err = xvt_fsys_fcopy(file_txt, dst_file);
|
||||
|
||||
}
|
||||
|
||||
bool TDisp_by_ftp::create()
|
||||
{
|
||||
//se non ha VE non può proseguire
|
||||
if (!has_module(VEAUT))
|
||||
return error_box(TR("Modulo non autorizzato"));
|
||||
Tdninst dninst;
|
||||
if (!dninst.can_I_run(true))
|
||||
return error_box(TR("Programma non autorizzato!"));
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
void TDisp_by_ftp::main_loop()
|
||||
{
|
||||
_mask = new TDisp_by_ftp_mask;
|
||||
if (_mask->run() != K_QUIT)
|
||||
elabora();
|
||||
|
||||
delete _mask;
|
||||
_mask = NULL;
|
||||
}
|
||||
|
||||
|
||||
int ps0330200 (int argc, char **argv)
|
||||
{
|
||||
TDisp_by_ftp a;
|
||||
a.run(argc,argv, TR("Esportazione disponibilita'"));
|
||||
return true;
|
||||
}
|
4
ps/ps0330200a.h
Executable file
4
ps/ps0330200a.h
Executable file
@ -0,0 +1,4 @@
|
||||
#define F_FILENAME 201
|
||||
#define F_FTP_PATH 202
|
||||
|
||||
|
48
ps/ps0330200a.uml
Executable file
48
ps/ps0330200a.uml
Executable file
@ -0,0 +1,48 @@
|
||||
#include "ps0330200a.h"
|
||||
|
||||
PAGE "Esportazione disponibilita' via FTP" -1 -1 78 6
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 1 0 "Nome del file txt da esportare (SENZA estensione '.txt' !)"
|
||||
END
|
||||
|
||||
STRING F_FILENAME 32
|
||||
BEGIN
|
||||
PROMPT 1 1 ""
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 1 3 "Indirizzo ftp di destinazione (scritto come ftp://utente:password@sito)"
|
||||
END
|
||||
|
||||
STRING F_FTP_PATH 255 75
|
||||
BEGIN
|
||||
PROMPT 1 4 ""
|
||||
FLAGS "M"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING DLG_PROFILE 50
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Profilo "
|
||||
PSELECT
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "" 0 0 0 2
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "~Mmmuuu!"
|
||||
PICTURE TOOL_PACK2MAG
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user