2009-09-25 13:53:33 +00:00
|
|
|
|
#include <applicat.h>
|
2008-10-28 15:03:16 +00:00
|
|
|
|
#include <automask.h>
|
2009-08-04 08:19:24 +00:00
|
|
|
|
#include <reputils.h>
|
|
|
|
|
#include <reprint.h>
|
2008-10-28 15:03:16 +00:00
|
|
|
|
#include <textset.h>
|
2009-03-11 14:11:30 +00:00
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
2009-07-28 07:50:30 +00:00
|
|
|
|
#include "lvlib.h"
|
2009-03-11 14:11:30 +00:00
|
|
|
|
#include "../ve/velib.h"
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-07-28 07:50:30 +00:00
|
|
|
|
#include "lvcondv.h"
|
|
|
|
|
#include "lvrcondv.h"
|
|
|
|
|
#include "lvrconsplan.h"
|
|
|
|
|
|
2009-03-12 12:15:09 +00:00
|
|
|
|
#include "lv2600a.h"
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
/////////////////////////////
|
|
|
|
|
//// TARTICOLI_KEY ////
|
|
|
|
|
/////////////////////////////
|
|
|
|
|
|
|
|
|
|
//classe TArticoli_key
|
|
|
|
|
class TArticoli_key: public TToken_string
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
const long codcf();
|
|
|
|
|
const char* codart();
|
|
|
|
|
const TDate data();
|
|
|
|
|
|
|
|
|
|
TArticoli_key(long codcf, TString& codart, TDate& data);
|
|
|
|
|
TArticoli_key(const char* key);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//CODCF: metodo che restituisce il codcf dalla TToken_string chiave degli articoli
|
|
|
|
|
const long TArticoli_key::codcf()
|
|
|
|
|
{
|
|
|
|
|
return get_int(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//CODART: metodo che restituisce il codart dalla TToken_string chiave degli articoli
|
|
|
|
|
const char* TArticoli_key::codart()
|
|
|
|
|
{
|
|
|
|
|
return get(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DATA: metodo che restituisce la data dalla TToken_string chiave degli articoli
|
|
|
|
|
const TDate TArticoli_key::data()
|
|
|
|
|
{
|
|
|
|
|
return (TDate)get(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metodi costruttori
|
|
|
|
|
TArticoli_key::TArticoli_key(long codcf, TString& codart, TDate& data)
|
|
|
|
|
{
|
|
|
|
|
add(codcf);
|
|
|
|
|
add(codart.trim());
|
|
|
|
|
add(data.date2ansi());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArticoli_key::TArticoli_key(const char* key):TToken_string(key)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////
|
|
|
|
|
//// TDOCUMENTI_KEY ////
|
|
|
|
|
//////////////////////////////
|
|
|
|
|
|
|
|
|
|
//classe TDocumenti_key
|
|
|
|
|
class TDocumenti_key: public TToken_string
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
const char* codnum();
|
|
|
|
|
const int anno();
|
|
|
|
|
const long ndoc();
|
|
|
|
|
const int idriga();
|
|
|
|
|
const long codcf();
|
|
|
|
|
const char* codart();
|
|
|
|
|
const TDate data();
|
|
|
|
|
|
|
|
|
|
TDocumenti_key(int anno, long ndoc, int idriga, long codcf, TString& codart, TDate& data);
|
|
|
|
|
TDocumenti_key(const char* key);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//CODNUM: metodo che restituisce il codnum dalla TToken_string chiave dei documenti
|
|
|
|
|
const char* TDocumenti_key::codnum()
|
|
|
|
|
{
|
|
|
|
|
return get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ANNO: metodo che restituisce l'anno dalla TToken_string chiave dei documenti
|
|
|
|
|
const int TDocumenti_key::anno()
|
|
|
|
|
{
|
|
|
|
|
return get_int(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NDOC: metodo che restituisce il numero documento dalla TToken_string chiave dei documenti
|
|
|
|
|
const long TDocumenti_key::ndoc()
|
|
|
|
|
{
|
|
|
|
|
return get_int(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//IDRIGA: metodo che restituisce l'idriga dalla TToken_string chiave dei documenti
|
|
|
|
|
const int TDocumenti_key::idriga()
|
|
|
|
|
{
|
|
|
|
|
return get_int(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//CODCF: metodo che restituisce il codcf dalla TToken_string chiave dei documenti
|
|
|
|
|
const long TDocumenti_key::codcf()
|
|
|
|
|
{
|
|
|
|
|
return get_int(4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//CODART: metodo che restituisce il codart dalla TToken_string chiave dei documenti
|
|
|
|
|
const char* TDocumenti_key::codart()
|
|
|
|
|
{
|
|
|
|
|
return get(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DATA: metodo che restituisce la data dalla TToken_string chiave dei documenti
|
|
|
|
|
const TDate TDocumenti_key::data()
|
|
|
|
|
{
|
|
|
|
|
return (TDate)get(6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metodi costruttori
|
|
|
|
|
TDocumenti_key::TDocumenti_key(int anno, long ndoc, int idriga, long codcf, TString& codart, TDate& data)
|
|
|
|
|
{
|
|
|
|
|
add(ini_get_string(CONFIG_DITTA, "lv", "NUM_RIT(0)"));
|
|
|
|
|
add(anno);
|
|
|
|
|
add(ndoc);
|
|
|
|
|
add(idriga);
|
|
|
|
|
add(codcf);
|
|
|
|
|
add(codart.trim());
|
|
|
|
|
add(data.date2ansi());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocumenti_key::TDocumenti_key(const char* key):TToken_string(key)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
//// TQUANTITA_CONATATE ////
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//classe TQuantita_contate
|
|
|
|
|
class TQuantita_contate: public TObject
|
|
|
|
|
{
|
|
|
|
|
long _numpezzi;
|
|
|
|
|
long _numrotti;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
const long get_pezzi() const;
|
|
|
|
|
const long get_rotti() const;
|
|
|
|
|
|
|
|
|
|
void set_pezzi(const long qta);
|
|
|
|
|
void set_rotti(const long qta);
|
|
|
|
|
|
|
|
|
|
void add_pezzi(const long qta);
|
|
|
|
|
void add_rotti(const long qta);
|
|
|
|
|
|
|
|
|
|
bool is_empty();
|
|
|
|
|
|
|
|
|
|
TQuantita_contate(long pezzi = 0, long rotti = 0);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//GET_PEZZI: metodo che restituisce il numero di pezzi contati
|
|
|
|
|
const long TQuantita_contate::get_pezzi() const
|
|
|
|
|
{
|
|
|
|
|
return _numpezzi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//GET_ROTTI: metodo che restituisce il numero di pezzi rotti contati
|
|
|
|
|
const long TQuantita_contate::get_rotti() const
|
|
|
|
|
{
|
|
|
|
|
return _numrotti;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SET_PEZZI: metodo che setta il numero di pezzi contati
|
|
|
|
|
void TQuantita_contate::set_pezzi(const long qta)
|
|
|
|
|
{
|
|
|
|
|
_numpezzi = qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SET_ROTTI: metodo che setta il numero di pezzi rotti contati
|
|
|
|
|
void TQuantita_contate::set_rotti(const long qta)
|
|
|
|
|
{
|
|
|
|
|
_numrotti = qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ADD_PEZZI: metodo che somma i pezzi contati alla quanti<74> che gi<67> esisteva
|
|
|
|
|
void TQuantita_contate::add_pezzi(const long qta)
|
|
|
|
|
{
|
|
|
|
|
_numpezzi += qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ADD_PEZZI: metodo che somma i pezzi rotti contati alla quanti<74> che gi<67> esisteva
|
|
|
|
|
void TQuantita_contate::add_rotti(const long qta)
|
|
|
|
|
{
|
|
|
|
|
_numrotti += qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//IS_EMPTY: metodo che resituisce true se entrambe le quantit<69> sono a zero
|
|
|
|
|
bool TQuantita_contate::is_empty()
|
|
|
|
|
{
|
|
|
|
|
return _numpezzi == 0 && _numrotti == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metodo costruttore
|
|
|
|
|
TQuantita_contate::TQuantita_contate(long pezzi, long rotti)
|
|
|
|
|
{
|
|
|
|
|
set_pezzi(pezzi);
|
|
|
|
|
set_rotti(rotti);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
//// TARTICOLI_CONTATI ////
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//classe TArticoli_contati
|
|
|
|
|
class TArticoli_contati: public TAssoc_array
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TQuantita_contate* quantita(long codcf, TString& codart, TDate& data, bool create = false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//QUANTITA: metodo che cerca nel TAssoc_array le quantit<69> contate in base ai parametri passati
|
|
|
|
|
//e lo crea in automatico se il parametro create vale "true"
|
|
|
|
|
TQuantita_contate* TArticoli_contati::quantita(long codcf, TString& codart, TDate& data, bool create)
|
|
|
|
|
{
|
|
|
|
|
TArticoli_key key(codcf, codart, data);
|
|
|
|
|
|
|
|
|
|
TQuantita_contate* qc = (TQuantita_contate*)objptr(key);
|
|
|
|
|
|
|
|
|
|
if(qc == NULL && create)
|
|
|
|
|
{
|
|
|
|
|
qc = new TQuantita_contate();
|
|
|
|
|
add(key, qc);
|
|
|
|
|
}
|
|
|
|
|
return qc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
/////////////////////////////////
|
|
|
|
|
//// TACQUISIZIONE_MSK ////
|
|
|
|
|
/////////////////////////////////
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//classe TAcquisizione_msk
|
2008-10-28 15:03:16 +00:00
|
|
|
|
class TAcquisizione_msk: public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o,TField_event e,long jolly);
|
|
|
|
|
public:
|
|
|
|
|
TAcquisizione_msk();
|
|
|
|
|
};
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//ON_FIELD_EVENT: metodo che gestisce gli eventi sui campi della maschera
|
2008-10-28 15:03:16 +00:00
|
|
|
|
bool TAcquisizione_msk::on_field_event(TOperable_field& f,TField_event e,long jolly)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//metodo costruttore che precarica i campi di interesse sulla maschera
|
2008-10-28 15:03:16 +00:00
|
|
|
|
TAcquisizione_msk::TAcquisizione_msk():TAutomask("lv2600a")
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
TConfig* configlv = new TConfig(CONFIG_DITTA, "lv");
|
|
|
|
|
|
|
|
|
|
const TString& path = configlv->get("PathContapezzi");
|
|
|
|
|
set(F_PATH, path);
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET_NAME);
|
|
|
|
|
for (int i = 0; ; i++)
|
|
|
|
|
{
|
|
|
|
|
TString nomefile = configlv->get("FileName", NULL, i);
|
|
|
|
|
if (nomefile.empty())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
TToken_string& row = sheet.row(-1);
|
|
|
|
|
row.add(nomefile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sheet.force_update();
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
///////////////////////////////////
|
|
|
|
|
//// TACQUISIZIONE_CACHE ////
|
|
|
|
|
///////////////////////////////////
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//classe TAcquisizione_cache
|
2009-03-18 15:23:56 +00:00
|
|
|
|
class TAcquisizione_cache : public TCache
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-03-16 16:30:01 +00:00
|
|
|
|
TString4 _codnum, _tipodoc, _stato;
|
2009-08-19 09:47:20 +00:00
|
|
|
|
long _ndoc;
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void discarding(const THash_object* obj);
|
|
|
|
|
virtual TObject* key2obj(const char* key);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TDocumento& doc(const TDate& gg, const long cc);
|
|
|
|
|
TAcquisizione_cache();
|
|
|
|
|
};
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//DISCARDING: metodo che salva un documento sul disco prima di eliminarlo dalla cache
|
2008-10-28 15:03:16 +00:00
|
|
|
|
void TAcquisizione_cache::discarding(const THash_object* obj)
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = (TDocumento&)obj->obj();
|
2009-03-18 15:23:56 +00:00
|
|
|
|
int err = doc.rewrite();
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//KEY2OBJ: metodo che sceglie il documento giusto da disco in modo da poterlo continuare, o lo crea se non c'<27>
|
2008-10-28 15:03:16 +00:00
|
|
|
|
TObject* TAcquisizione_cache::key2obj(const char* key)
|
|
|
|
|
{
|
|
|
|
|
TToken_string chiave(key);
|
2009-08-24 08:42:34 +00:00
|
|
|
|
TDate datadoc = chiave.get();
|
2009-07-23 15:24:26 +00:00
|
|
|
|
const TDate datagen(TODAY);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
TDate dadata = datadoc;
|
2009-07-28 07:50:30 +00:00
|
|
|
|
TDate adata = datagen;
|
2009-08-19 09:47:20 +00:00
|
|
|
|
adata.addmonth();
|
2009-03-16 16:30:01 +00:00
|
|
|
|
const long codcf = chiave.get_long();
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-08-19 09:47:20 +00:00
|
|
|
|
if(_ndoc == 0)
|
|
|
|
|
{
|
|
|
|
|
TString query2;
|
|
|
|
|
query2 << "USE DOC\n"
|
2009-08-20 10:56:21 +00:00
|
|
|
|
<< "FROM PROVV=\"D\" ANNO=" << datadoc.year() << " CODNUM=\"" << _codnum << "\"\n"
|
|
|
|
|
<< "TO PROVV=\"D\" ANNO=" << datadoc.year() << " CODNUM=\"" << _codnum << "\"";
|
2009-08-19 09:47:20 +00:00
|
|
|
|
TISAM_recordset sporco(query2);
|
|
|
|
|
sporco.move_last();
|
|
|
|
|
_ndoc = sporco.get(DOC_NDOC).as_int();
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-18 15:23:56 +00:00
|
|
|
|
TString query = "USE DOC KEY 2\n";
|
2009-08-20 10:56:21 +00:00
|
|
|
|
query << "SELECT (TIPODOC=\"" << _tipodoc << "\")&&(STATO=\"" << _stato <<"\")\n";
|
2009-03-18 15:23:56 +00:00
|
|
|
|
query << "FROM TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << datadoc.year() << " DATADOC=" << datadoc << " CODNUM=" << _codnum << "\n";
|
|
|
|
|
query << "TO TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << datadoc.year() << " DATADOC=" << datadoc << " CODNUM=" << _codnum << "\n";
|
2009-07-29 17:08:19 +00:00
|
|
|
|
TISAM_recordset rset(query);
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
TDocumento* doc = NULL;
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
if (rset.move_first())
|
|
|
|
|
doc = new TDocumento(rset.cursor()->curr());
|
2008-10-28 15:03:16 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-07-28 07:50:30 +00:00
|
|
|
|
TLaundry_contract cont(codcf, 0, datadoc);
|
|
|
|
|
const TString8 codcont = cont.get(LVCONDV_CODCONT);
|
|
|
|
|
|
|
|
|
|
TString query1 = "USE LVRCONSPLAN KEY 3\n";
|
2009-08-24 08:42:34 +00:00
|
|
|
|
query1 << "FROM CODCF=" << codcf << " CODCONT=" << codcont << " DTCONS=#DADATA\n";
|
|
|
|
|
query1 << "TO CODCF=" << codcf << " CODCONT=" << codcont << " DTCONS=#ADATA\n";
|
2009-07-28 07:50:30 +00:00
|
|
|
|
TISAM_recordset consegne(query1);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
consegne.set_var("#DADATA", ++dadata);
|
2009-08-24 08:42:34 +00:00
|
|
|
|
consegne.set_var("#ADATA", adata);
|
|
|
|
|
consegne.move_first();
|
2009-07-29 17:08:19 +00:00
|
|
|
|
const TDate dataprco = consegne.get(LVRCONSPLAN_DTCONS).as_date();
|
2009-07-28 07:50:30 +00:00
|
|
|
|
|
2009-08-19 09:47:20 +00:00
|
|
|
|
doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
doc->put(DOC_TIPODOC, _tipodoc);
|
|
|
|
|
doc->put(DOC_STATO, _stato);
|
|
|
|
|
doc->put(DOC_DATADOC, datadoc);
|
2009-03-18 15:23:56 +00:00
|
|
|
|
doc->put(DOC_TIPOCF, 'C');
|
2009-03-16 16:30:01 +00:00
|
|
|
|
doc->put(DOC_CODCF, codcf);
|
2009-07-28 07:50:30 +00:00
|
|
|
|
doc->put(DOC_CODCONT, codcont);
|
2009-08-10 14:13:34 +00:00
|
|
|
|
doc->put("DATACON", datadoc); //data conteggio
|
|
|
|
|
doc->put("DATAGEN", datagen); //data generazione del documento
|
2009-08-19 09:47:20 +00:00
|
|
|
|
doc->put("DATAPRCO", dataprco); //data prevista consegna
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
return doc;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//DOC: metodo che restituisce un puntatore ad un documento identificato dalla coppia data - cliente
|
2008-10-28 15:03:16 +00:00
|
|
|
|
TDocumento& TAcquisizione_cache::doc(const TDate& gg, const long cc)
|
|
|
|
|
{
|
|
|
|
|
TString16 key;
|
|
|
|
|
key << gg.date2ansi() << '|' << cc;
|
|
|
|
|
return *(TDocumento*)objptr(key);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//metodo costruttore di una cache di 17 elementi
|
2008-10-28 15:03:16 +00:00
|
|
|
|
TAcquisizione_cache::TAcquisizione_cache() : TCache(17)
|
|
|
|
|
{
|
2009-08-19 09:47:20 +00:00
|
|
|
|
_codnum = ini_get_string(CONFIG_DITTA, "lv", "NUM_RIT(0)");
|
|
|
|
|
_tipodoc = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_RIT(0)");
|
2009-08-20 09:14:10 +00:00
|
|
|
|
_stato = cache().get("%TIP", _tipodoc, "S2").left(1);
|
2009-08-19 09:47:20 +00:00
|
|
|
|
|
|
|
|
|
_ndoc = 0;
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
///////////////////////////////////
|
|
|
|
|
//// TCONFRONTO_CACHE ////
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//classe TConfronto_cache
|
|
|
|
|
class TConfronto_cache : public TCache
|
|
|
|
|
{
|
|
|
|
|
TString4 _codnum, _tipodoc, _stato;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void discarding(const THash_object* obj);
|
|
|
|
|
virtual TObject* key2obj(const char* key);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TDocumento& doc(const TDate& gg, const long cc);
|
|
|
|
|
TConfronto_cache();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//DISCARDING: metodo che salva un documento sul disco prima di eliminarlo dalla cache
|
|
|
|
|
void TConfronto_cache::discarding(const THash_object* obj)
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = (TDocumento&)obj->obj();
|
|
|
|
|
if (!doc.empty())
|
|
|
|
|
int err = doc.rewrite();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//KEY2OBJ: metodo che sceglie il documento giusto da disco in modo da poterlo continuare, o lo crea se non c'<27>
|
|
|
|
|
TObject* TConfronto_cache::key2obj(const char* key)
|
|
|
|
|
{
|
|
|
|
|
TToken_string chiave(key);
|
|
|
|
|
TDate datadoc = chiave.get();
|
|
|
|
|
const TDate datagen(TODAY);
|
|
|
|
|
TDate adata = datagen;
|
|
|
|
|
adata.addmonth();
|
|
|
|
|
const long codcf = chiave.get_long();
|
|
|
|
|
|
|
|
|
|
TString query = "USE DOC KEY 2\n";
|
|
|
|
|
query << "SELECT (TIPODOC=\"" << _tipodoc << "\")&&(STATO=\"" << _stato <<"\")\n";
|
|
|
|
|
query << "FROM TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << datadoc.year() << " DATADOC=" << datadoc << " CODNUM=" << _codnum << "\n";
|
|
|
|
|
query << "TO TIPOCF=C CODCF=" << codcf << " PROVV=D ANNO=" << datadoc.year() << " DATADOC=" << datadoc << " CODNUM=" << _codnum << "\n";
|
|
|
|
|
TISAM_recordset rset(query);
|
|
|
|
|
|
|
|
|
|
TDocumento* doc = NULL;
|
|
|
|
|
|
|
|
|
|
if (rset.move_first())
|
|
|
|
|
doc = new TDocumento(rset.cursor()->curr());
|
|
|
|
|
else
|
|
|
|
|
doc = new TDocumento();
|
|
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DOC: metodo che restituisce un puntatore ad un documento identificato dalla coppia data - cliente
|
|
|
|
|
TDocumento& TConfronto_cache::doc(const TDate& gg, const long cc)
|
|
|
|
|
{
|
|
|
|
|
TString16 key;
|
|
|
|
|
key << gg.date2ansi() << '|' << cc;
|
|
|
|
|
return *(TDocumento*)objptr(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metodo costruttore di una cache di 17 elementi
|
|
|
|
|
TConfronto_cache::TConfronto_cache() : TCache(17)
|
|
|
|
|
{
|
|
|
|
|
_codnum = ini_get_string(CONFIG_DITTA, "lv", "NUM_RIT(0)");
|
|
|
|
|
_tipodoc = ini_get_string(CONFIG_DITTA, "lv", "TIPODOC_RIT(0)");
|
|
|
|
|
_stato = cache().get("%TIP", _tipodoc, "S2").left(1);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
//// TACQUISIZIONE_LAVANDERIE_APP ////
|
|
|
|
|
////////////////////////////////////////////
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//classe TAcquisizione_lavanderie_app
|
2008-10-28 15:03:16 +00:00
|
|
|
|
class TAcquisizione_lavanderie_app : public TSkeleton_application
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
TAcquisizione_msk* _msk;
|
|
|
|
|
TString4 _auto;
|
|
|
|
|
TString4 _gr;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
2008-10-28 15:03:16 +00:00
|
|
|
|
protected:
|
2009-03-16 16:30:01 +00:00
|
|
|
|
virtual bool create();
|
|
|
|
|
virtual bool destroy();
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
bool elabora_file(const TString& file, TLog_report &rep, TArticoli_contati& articoli, int& nrighe, int& nrsalt);
|
|
|
|
|
void controlla_documenti(TLog_report& rep, TArticoli_contati& articoli, TAssoc_array& documenti);
|
|
|
|
|
void genera_documenti(TLog_report& rep, TAssoc_array& documenti);
|
|
|
|
|
void sposta_file(const TString& file);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool transfer();
|
|
|
|
|
virtual void main_loop();
|
2008-10-28 15:03:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//CREATE: metodo costruttore
|
|
|
|
|
bool TAcquisizione_lavanderie_app::create()
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-03-16 16:30:01 +00:00
|
|
|
|
_msk = new TAcquisizione_msk();
|
|
|
|
|
TSheet_field& sheet = _msk->sfield(F_SHEET_NAME);
|
|
|
|
|
sheet.set_auto_append();
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//se ho pi<70> di un parametro, allora lo sto lanciando da linea di comando, e ne devo tenere conto
|
2009-10-07 13:36:04 +00:00
|
|
|
|
if (argc() > 2)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
_auto = argv(2);
|
|
|
|
|
_auto = _auto.right(1);
|
|
|
|
|
|
|
|
|
|
_gr = argv(3);
|
|
|
|
|
_gr = _gr.right(1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_auto = "N";
|
|
|
|
|
_gr = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_gr == "S" || _gr.empty())
|
|
|
|
|
_msk->set(F_RICGIRI, "X");
|
|
|
|
|
else
|
|
|
|
|
_msk->set(F_RICGIRI, "");
|
|
|
|
|
|
2009-03-19 15:33:34 +00:00
|
|
|
|
open_files(LF_DOC, LF_RIGHEDOC);
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DESTROY: metodo distruttore
|
|
|
|
|
bool TAcquisizione_lavanderie_app::destroy()
|
2009-03-18 15:23:56 +00:00
|
|
|
|
{
|
|
|
|
|
delete _msk;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
return TApplication::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//ELABORA_FILE: metodo che effettivamente fa l'elaborazione del file
|
|
|
|
|
bool TAcquisizione_lavanderie_app::elabora_file(const TString& file, TLog_report& rep, TArticoli_contati& articoli, int& nrighe, int& nrsalt)
|
2009-03-16 16:30:01 +00:00
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//scandisco il file solo se esiste
|
|
|
|
|
TFilename strname = file;
|
|
|
|
|
if (!strname.exist())
|
|
|
|
|
{
|
|
|
|
|
TString str;
|
|
|
|
|
str << "ATTENZIONE: il file " << strname << " non esiste!";
|
|
|
|
|
warning_box(str);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
|
|
|
|
TScanner s(file);
|
|
|
|
|
while (s.ok())
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-03-16 16:30:01 +00:00
|
|
|
|
TString80 riga = s.line();
|
|
|
|
|
if (riga.blank())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
TDate datadoc;
|
2009-08-20 09:14:10 +00:00
|
|
|
|
long codcf = 0; TString8 codcf_str;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
TString80 codart;
|
|
|
|
|
long qta;
|
|
|
|
|
long rotti;
|
2009-03-19 14:28:46 +00:00
|
|
|
|
long ndoc = 0;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
TString16 tipo_conteggio;
|
|
|
|
|
TString80 operatore;
|
|
|
|
|
|
|
|
|
|
//controllo quale tracciato record devo seguire
|
|
|
|
|
if (riga.len() == 34) // -> MONTANARI
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
nrighe += 1;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//leggo i campi dalla riga del file
|
2009-03-19 14:28:46 +00:00
|
|
|
|
const int d = atoi(riga.mid(0,2));
|
|
|
|
|
const int m = atoi(riga.mid(2,2));
|
|
|
|
|
const int y = atoi(riga.mid(4,4));
|
|
|
|
|
if (d > 0 && d <= 31 && m > 0 && m <= 12 && y > 2000)
|
|
|
|
|
{
|
|
|
|
|
datadoc = TDate(d, m, y);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
if (datadoc < _msk->get_date(F_DADATA) || datadoc > _msk->get_date(F_ADATA))
|
|
|
|
|
{
|
|
|
|
|
nrsalt += 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
codcf_str = riga.mid(8,6); codcf = atol(codcf_str);
|
2009-03-19 14:28:46 +00:00
|
|
|
|
codart = riga.mid(14,8);
|
|
|
|
|
qta = atol(riga.mid(22,6));
|
|
|
|
|
rotti = atol(riga.mid(28,6));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
continue;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
else if (riga.len() == 121) // ->SKEMA
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//leggo i campi dalla riga del file
|
2009-03-19 15:33:34 +00:00
|
|
|
|
const int y = atoi(riga.mid(0,4));
|
|
|
|
|
const int m = atoi(riga.mid(4,2));
|
|
|
|
|
const int d = atoi(riga.mid(6,2));
|
|
|
|
|
if (d > 0 && d <= 31 && m > 0 && m <= 12 && y > 2000)
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
codcf_str = riga.mid(28,20); codcf = atol(codcf_str);
|
2009-03-19 15:33:34 +00:00
|
|
|
|
datadoc = TDate(d, m, y);
|
|
|
|
|
codart = riga.mid(8,20);
|
|
|
|
|
qta = atoi(riga.mid(48,11));
|
|
|
|
|
ndoc = atoi(riga.mid(59,11));
|
|
|
|
|
|
|
|
|
|
switch (atoi(riga.mid(70,11)))
|
|
|
|
|
{
|
|
|
|
|
case 1: tipo_conteggio = "Automatico"; break;
|
|
|
|
|
case 2: tipo_conteggio = "Manuale"; break;
|
|
|
|
|
case 3: tipo_conteggio = "Scarto"; break;
|
|
|
|
|
default: break;
|
2009-08-20 09:14:10 +00:00
|
|
|
|
}
|
|
|
|
|
operatore = riga.mid(81,40);
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
2009-03-19 15:33:34 +00:00
|
|
|
|
else
|
|
|
|
|
continue;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
TQuantita_contate* qc = articoli.quantita(codcf, codart.trim(), datadoc, true);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//se la chiave <20> gi<67> presente nel TAssoc_array, chiedi cosa fare delle quantit<69>
|
|
|
|
|
//altrimenti aggiungila con la rispettiva al TAssoc_array con la quantit<69> appena conteggiata
|
|
|
|
|
if (!qc->is_empty())
|
2009-03-16 16:30:01 +00:00
|
|
|
|
{
|
2009-08-21 08:22:55 +00:00
|
|
|
|
TString str;
|
2009-10-06 16:51:30 +00:00
|
|
|
|
str << "ATTENZIONE: <20> gi<67> presente un conteggio per il cliente " << codcf << " sull'articolo " << codart << "\n"
|
|
|
|
|
<< "Quantit<EFBFBD> conteggio attuale: " << qta << " Quantit<69> conteggio precedente: " << qc->get_pezzi() << "\n"
|
|
|
|
|
<< "Si desidera sommare le quantit<69>?\n"
|
|
|
|
|
<< "Premendo SI le quatit<69> verranno sommate;\n"
|
|
|
|
|
<< "Premendo NO il conteggio precedente verr<72> sostituito con quello attuale\n"
|
|
|
|
|
<< "Premendo ANNULLA verr<72> mantenuto il conteggio precedente";
|
2009-08-21 08:22:55 +00:00
|
|
|
|
KEY k = yesnocancel_box(str);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
2009-03-18 15:23:56 +00:00
|
|
|
|
switch (k)
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
case K_YES: qc->add_pezzi(qta); qc->add_rotti(rotti); break; //sommo le quantit<69>
|
|
|
|
|
case K_NO: qc->set_pezzi(qta); qc->set_rotti(rotti); break; //sostituisco le quantit<69>
|
|
|
|
|
default: break; //lascio tutto com'<27>
|
|
|
|
|
}
|
2009-03-18 15:23:56 +00:00
|
|
|
|
}
|
2009-08-19 09:47:20 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
qc->set_pezzi(qta);
|
|
|
|
|
qc->set_rotti(rotti);
|
2009-08-19 09:47:20 +00:00
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-08-04 08:19:24 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//CONTROLLA_DOCUMENTI: metodo che si occupa di controllare se i dati che sto inserendo in questo momento sono
|
|
|
|
|
//gi<67> stati inseriti in documenti precedenti, chiedendo cosa fare di volta in volta
|
|
|
|
|
void TAcquisizione_lavanderie_app::controlla_documenti(TLog_report& rep, TArticoli_contati& articoli, TAssoc_array& documenti)
|
|
|
|
|
{
|
|
|
|
|
TConfronto_cache ca;
|
|
|
|
|
bool found = false;
|
|
|
|
|
FOR_EACH_ASSOC_OBJECT(articoli, obj, key, itm)
|
|
|
|
|
{
|
|
|
|
|
TArticoli_key keyart(key);
|
|
|
|
|
const TQuantita_contate* qc = (TQuantita_contate*)itm;
|
|
|
|
|
|
|
|
|
|
//recupero i dati dalla chiave del TAssoc_array degli articoli
|
|
|
|
|
int codcf = keyart.codcf();
|
|
|
|
|
TString80 codart = keyart.codart();
|
|
|
|
|
TDate datadoc = keyart.data();
|
|
|
|
|
|
|
|
|
|
//recupero i dati dal contenuto del TAssoc_array degli articoli
|
|
|
|
|
TQuantita_contate* quantita = new TQuantita_contate(0, 0);
|
|
|
|
|
quantita->set_pezzi(qc->get_pezzi());
|
|
|
|
|
quantita->set_rotti(qc->get_rotti());
|
|
|
|
|
|
|
|
|
|
TDocumento& doc = ca.doc(datadoc, codcf);
|
|
|
|
|
if (doc.empty())
|
|
|
|
|
{
|
|
|
|
|
//preparo la chiave per il TAssoc_array dei documenti
|
|
|
|
|
TDocumenti_key keydoc(datadoc.year(), 0, 0, codcf, codart, datadoc);
|
|
|
|
|
|
|
|
|
|
//aggiungo la riga corrispondente
|
|
|
|
|
documenti.add(keydoc, quantita);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
else
|
2009-03-16 16:30:01 +00:00
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
int idriga;
|
|
|
|
|
for (idriga = 1; idriga <= doc.rows(); idriga++)
|
2008-10-28 15:03:16 +00:00
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//cerco se esiste gi<67> una riga sul documento selezionato per quell'articolo
|
|
|
|
|
TRiga_documento& rdoc = doc[idriga];
|
|
|
|
|
TString80 codart_doc = rdoc.get(RDOC_CODART); codart_doc.trim();
|
|
|
|
|
|
|
|
|
|
if (codart_doc == codart)
|
|
|
|
|
{
|
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
|
|
TString str;
|
|
|
|
|
str << "ATTENZIONE: <20> gi<67> presente un buono di ritiro per il cliente " << codcf << " sull'articolo " << codart << "\n"
|
|
|
|
|
<< "Quantit<EFBFBD> conteggio: " << quantita->get_pezzi() << " Quantit<69> buono di ritiro: " << rdoc.get_int(RDOC_QTAGG1) << "\n"
|
|
|
|
|
<< "Si desidera sommare le quantit<69>?\n"
|
|
|
|
|
<< "Premendo SI le quatit<69> verranno sommate;"
|
|
|
|
|
<< "Premendo NO la quantit<69> sul buono verr<72> sostitiuita con quella conteggiata;"
|
|
|
|
|
<< "Premendo ANNULLA il buono non verr<72> modificato";
|
|
|
|
|
KEY k = yesnocancel_box(str);
|
|
|
|
|
|
|
|
|
|
switch (k)
|
|
|
|
|
{
|
|
|
|
|
case K_YES: quantita->add_pezzi(rdoc.get_int(RDOC_QTAGG1)); quantita->add_rotti(rdoc.get_int(RDOC_QTA)); break; //sommo le quantit<69>
|
|
|
|
|
case K_NO: break; //sostituisco le quantit<69>
|
|
|
|
|
default: quantita->set_pezzi(rdoc.get_int(RDOC_QTAGG1)); quantita->set_rotti(rdoc.get_int(RDOC_QTA)); break; //lascio tutto com'<27>
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
idriga = 0;
|
|
|
|
|
//preparo la chiave per il TAssoc_array dei documenti
|
|
|
|
|
TDocumenti_key keydoc(datadoc.year(), doc.get_long(DOC_NDOC), idriga, codcf, codart, datadoc);
|
|
|
|
|
|
|
|
|
|
documenti.add(keydoc, quantita);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
ca.destroy();
|
|
|
|
|
}
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//metodo che effettivamente genera i buoni di ritiro, se l'utente ha confermato la sua intenzione a crearli
|
|
|
|
|
void TAcquisizione_lavanderie_app::genera_documenti(TLog_report& rep, TAssoc_array& documenti)
|
|
|
|
|
{
|
|
|
|
|
TAcquisizione_cache ca;
|
|
|
|
|
|
|
|
|
|
const bool giri = _msk->get_bool(F_RICGIRI);
|
|
|
|
|
FOR_EACH_ASSOC_OBJECT(documenti, obj, key, itm)
|
|
|
|
|
{
|
|
|
|
|
TDocumenti_key keydoc(key);
|
|
|
|
|
const TString4 codnum = keydoc.codnum();
|
|
|
|
|
const int anno = keydoc.anno();
|
|
|
|
|
const int ndoc = keydoc.ndoc();
|
|
|
|
|
const int idriga = keydoc.idriga();
|
|
|
|
|
const int codcf = keydoc.codcf();
|
|
|
|
|
const TString80 codart = keydoc.codart();
|
|
|
|
|
const TDate datadoc = keydoc.data();
|
|
|
|
|
|
|
|
|
|
TQuantita_contate* qc = (TQuantita_contate*)itm;
|
|
|
|
|
const long qtacon = qc->get_pezzi();;
|
|
|
|
|
const long qtarotti = qc->get_rotti();
|
|
|
|
|
|
|
|
|
|
TLaundry_contract cont(codcf, 0, datadoc);
|
|
|
|
|
const TString8 codcont = cont.get(LVCONDV_CODCONT);
|
|
|
|
|
|
|
|
|
|
TDate oggi(TODAY);
|
|
|
|
|
|
|
|
|
|
TDocumento& doc = ca.doc(datadoc, codcf);
|
|
|
|
|
if (!giri)
|
|
|
|
|
doc.put("DATAPRCO", oggi);
|
|
|
|
|
|
|
|
|
|
if (doc.rows() > 0 && (idriga > 0 && idriga <= doc.rows()))
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento& rdoc = doc[idriga];
|
|
|
|
|
rdoc.put(RDOC_QTAGG1, qtacon);
|
|
|
|
|
rdoc.put(RDOC_QTA, qtarotti);
|
|
|
|
|
}
|
|
|
|
|
else
|
2009-03-16 16:30:01 +00:00
|
|
|
|
{
|
2009-03-18 15:23:56 +00:00
|
|
|
|
const TRectype& anamag = cache().get(LF_ANAMAG, codart);
|
|
|
|
|
|
|
|
|
|
TRiga_documento& rdoc = doc.new_row("22");
|
|
|
|
|
rdoc.put(RDOC_CODART, codart);
|
|
|
|
|
rdoc.put(RDOC_DESCR, anamag.get(ANAMAG_DESCR));
|
|
|
|
|
rdoc.put(RDOC_CODARTMAG, codart);
|
|
|
|
|
rdoc.put(RDOC_CHECKED, 'X');
|
2009-07-28 07:50:30 +00:00
|
|
|
|
rdoc.put(RDOC_CODAGG1, ini_get_string(CONFIG_DITTA, "lv", "CAUSLAV"));
|
2009-10-06 16:51:30 +00:00
|
|
|
|
rdoc.put(RDOC_QTAGG1, qtacon);
|
|
|
|
|
rdoc.put(RDOC_QTA, qtarotti);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
2009-07-28 08:07:39 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
if (!doc.get_date("DATAPRCO").ok() && giri)
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("Il documento ") << doc.get(DOC_NDOC) << TR(" del ") << doc.get(DOC_DATADOC)
|
|
|
|
|
<< TR(" del cliente ") << codcf << TR(" non ha data di prevista consegna.");
|
|
|
|
|
rep.log(1,msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-28 08:07:39 +00:00
|
|
|
|
|
2009-03-19 15:33:34 +00:00
|
|
|
|
if (ca.empty())
|
|
|
|
|
{
|
|
|
|
|
warning_box(TR("ATTENZIONE: il file importato non ha generato nessun documento; controllare che il tracciato record sia coerente"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
else
|
2009-03-19 15:33:34 +00:00
|
|
|
|
ca.destroy();
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SPOSTA_FILE: metodo che sposta cambiando nome i file elaborati durante la generazione dei buoni
|
|
|
|
|
void TAcquisizione_lavanderie_app::sposta_file(const TString& file)
|
|
|
|
|
{
|
|
|
|
|
TFilename fileori = file;
|
|
|
|
|
TFilename path = fileori.path();
|
|
|
|
|
path.add("elaborati");
|
|
|
|
|
make_dir(path);
|
|
|
|
|
|
|
|
|
|
TString strname;
|
|
|
|
|
strname.format("%06d_%06d_%s", TDate(TODAY).date2ansi(), daytime(), (const char*)fileori.name());
|
|
|
|
|
TFilename filedest = path;
|
|
|
|
|
filedest.add(strname);
|
|
|
|
|
|
|
|
|
|
if (fcopy(fileori, filedest))
|
|
|
|
|
fileori.fremove();
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TRANSFER: metodo che scorre i campi nome e, se sono pieni, richiama il metodo
|
|
|
|
|
//ELABORA_FILE(), che effettivamente fa l'elaborazione
|
|
|
|
|
bool TAcquisizione_lavanderie_app::transfer()
|
|
|
|
|
{
|
|
|
|
|
//prendo il path dalla maschera
|
|
|
|
|
const TString& path = _msk->get(F_PATH);
|
|
|
|
|
TSheet_field& sheet = _msk->sfield(F_SHEET_NAME);
|
|
|
|
|
TFilename file;
|
2009-08-19 09:47:20 +00:00
|
|
|
|
|
|
|
|
|
TLog_report logrep("Aquisizione da contapezzi");
|
|
|
|
|
logrep.kill_duplicates(true);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
TArticoli_contati articoli;
|
|
|
|
|
TAssoc_array documenti;
|
|
|
|
|
int nrighe = 0;
|
|
|
|
|
int nrsalt = 0;
|
2009-08-04 08:19:24 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
//per ogni riga dello sheet, leggo il suo contenuto, se contiene dei caratteri jolly
|
|
|
|
|
//preparo la lista dei file che soddisfano la maschera in quella directory e li elaboro
|
|
|
|
|
//tutti, altrimenti elaboro esattamente il file che <20> scritto sullo sheet
|
2009-10-06 16:51:30 +00:00
|
|
|
|
bool elaborato = false;
|
2009-03-16 16:30:01 +00:00
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r1, row1)
|
|
|
|
|
{
|
|
|
|
|
if(row1->full())
|
|
|
|
|
{
|
2009-03-19 14:28:46 +00:00
|
|
|
|
if (row1->find('/') >= 0 || row1->find('\\') >= 0)
|
|
|
|
|
file = *row1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
file = path;
|
|
|
|
|
file.add(*row1);
|
|
|
|
|
}
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
|
|
|
|
if (file.find('*') >= 0 || file.find('?') >= 0)
|
|
|
|
|
{
|
2009-03-19 14:28:46 +00:00
|
|
|
|
TString_array lista_file;
|
|
|
|
|
list_files(file, lista_file);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
|
2009-07-28 08:07:39 +00:00
|
|
|
|
FOR_EACH_ARRAY_ROW(lista_file, r2, row2)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
elaborato = elabora_file(*row2, logrep, articoli, nrighe, nrsalt);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-10-06 16:51:30 +00:00
|
|
|
|
elaborato = elabora_file(file, logrep, articoli, nrighe, nrsalt);
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
if(elaborato)
|
|
|
|
|
{
|
|
|
|
|
controlla_documenti(logrep, articoli, documenti);
|
|
|
|
|
TString str;
|
|
|
|
|
str << "Sono stati ricevuti " << nrighe << " record, di cui " << nrighe - nrsalt << " sono stati elaborati correttamente"
|
|
|
|
|
<< " e " << nrsalt << " ignorati.\nSi desidera procedere con la generazione dei buoni di ritiro?";
|
|
|
|
|
if (yesno_box(str))
|
|
|
|
|
{
|
|
|
|
|
genera_documenti(logrep, documenti);
|
|
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r1, row1)
|
|
|
|
|
{
|
|
|
|
|
if(row1->full())
|
|
|
|
|
{
|
|
|
|
|
if (row1->find('/') >= 0 || row1->find('\\') >= 0)
|
|
|
|
|
file = *row1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
file = path;
|
|
|
|
|
file.add(*row1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file.find('*') >= 0 || file.find('?') >= 0)
|
|
|
|
|
{
|
|
|
|
|
TString_array lista_file;
|
|
|
|
|
list_files(file, lista_file);
|
|
|
|
|
|
|
|
|
|
FOR_EACH_ARRAY_ROW(lista_file, r2, row2)
|
|
|
|
|
sposta_file(*row2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sposta_file(file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TReport_book buc;
|
|
|
|
|
buc.add(logrep);
|
|
|
|
|
if (buc.pages() > 0)
|
|
|
|
|
buc.preview();
|
|
|
|
|
else
|
|
|
|
|
message_box(TR("Generazione terminata"));
|
|
|
|
|
}
|
2009-08-04 08:19:24 +00:00
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TAcquisizione_lavanderie_app::main_loop()
|
|
|
|
|
{
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//lo lancio in automatico da linea di comando
|
|
|
|
|
if (_auto == "A")
|
|
|
|
|
_msk->send_key(K_SPACE, DLG_OK);
|
2009-03-16 16:30:01 +00:00
|
|
|
|
while (_msk->run() == K_ENTER)
|
|
|
|
|
transfer();
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int lv2600(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
TAcquisizione_lavanderie_app a;
|
|
|
|
|
a.run (argc, argv, "Acquisizione bolle di rientro/ritiro");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|