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>
|
2009-11-13 10:26:47 +00:00
|
|
|
|
#include <urldefid.h>
|
2009-03-11 14:11:30 +00:00
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
2009-07-28 07:50:30 +00:00
|
|
|
|
#include "lvlib.h"
|
2010-03-12 15:24:44 +00:00
|
|
|
|
|
|
|
|
|
#include "../mg/clifogiac.h"
|
2009-03-11 14:11:30 +00:00
|
|
|
|
#include "../ve/velib.h"
|
2008-10-28 15:03:16 +00:00
|
|
|
|
|
2009-12-15 15:38:34 +00:00
|
|
|
|
#include "clifo.h"
|
2009-12-02 11:52:12 +00:00
|
|
|
|
#include "cfven.h"
|
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
|
|
|
|
|
{
|
2009-12-22 08:52:32 +00:00
|
|
|
|
real _numpezzi;
|
|
|
|
|
real _numrotti;
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2009-12-22 08:52:32 +00:00
|
|
|
|
const real get_pezzi() const;
|
|
|
|
|
const real get_rotti() const;
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void set_pezzi(const real qta);
|
|
|
|
|
void set_rotti(const real qta);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void add_pezzi(const real qta);
|
|
|
|
|
void add_rotti(const real qta);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
bool is_empty();
|
|
|
|
|
|
2009-12-22 08:52:32 +00:00
|
|
|
|
TQuantita_contate(real pezzi = ZERO, real = ZERO);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//GET_PEZZI: metodo che restituisce il numero di pezzi contati
|
2009-12-22 08:52:32 +00:00
|
|
|
|
const real TQuantita_contate::get_pezzi() const
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
return _numpezzi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//GET_ROTTI: metodo che restituisce il numero di pezzi rotti contati
|
2009-12-22 08:52:32 +00:00
|
|
|
|
const real TQuantita_contate::get_rotti() const
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
return _numrotti;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SET_PEZZI: metodo che setta il numero di pezzi contati
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void TQuantita_contate::set_pezzi(const real qta)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
_numpezzi = qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SET_ROTTI: metodo che setta il numero di pezzi rotti contati
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void TQuantita_contate::set_rotti(const real qta)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
_numrotti = qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ADD_PEZZI: metodo che somma i pezzi contati alla quanti<74> che gi<67> esisteva
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void TQuantita_contate::add_pezzi(const real qta)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
_numpezzi += qta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ADD_PEZZI: metodo che somma i pezzi rotti contati alla quanti<74> che gi<67> esisteva
|
2009-12-22 08:52:32 +00:00
|
|
|
|
void TQuantita_contate::add_rotti(const real qta)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
_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
|
2009-12-22 08:52:32 +00:00
|
|
|
|
TQuantita_contate::TQuantita_contate(real pezzi, real rotti)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
|
|
|
|
set_pezzi(pezzi);
|
|
|
|
|
set_rotti(rotti);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-13 11:03:54 +00:00
|
|
|
|
/////////////////////////////////
|
2009-10-06 16:51:30 +00:00
|
|
|
|
//// TARTICOLI_CONTATI ////
|
2009-10-13 11:03:54 +00:00
|
|
|
|
/////////////////////////////////
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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-13 11:03:54 +00:00
|
|
|
|
TConfig configlv(CONFIG_DITTA, "lv");
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
2009-10-13 11:03:54 +00:00
|
|
|
|
const TString& path = configlv.get("PathContapezzi");
|
2009-10-06 16:51:30 +00:00
|
|
|
|
set(F_PATH, path);
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET_NAME);
|
|
|
|
|
for (int i = 0; ; i++)
|
|
|
|
|
{
|
2009-10-13 11:03:54 +00:00
|
|
|
|
TString nomefile = configlv.get("FileName", NULL, i);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
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-12-15 15:38:34 +00:00
|
|
|
|
TToken_string orderkey;
|
|
|
|
|
orderkey.add(RDOC_CODART);
|
|
|
|
|
doc.sort_rows(orderkey);
|
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);
|
2009-11-26 14:22:31 +00:00
|
|
|
|
if(sporco.move_last())
|
|
|
|
|
_ndoc = sporco.get(DOC_NDOC).as_int();
|
2009-08-19 09:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
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-12-02 11:52:12 +00:00
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add('C');
|
|
|
|
|
key.add(codcf);
|
|
|
|
|
const int codindsp = atoi(cache().get(LF_CFVEN, key, CFV_CODINDSP));
|
|
|
|
|
TLaundry_contract cont(codcf, codindsp, datadoc);
|
2009-07-28 07:50:30 +00:00
|
|
|
|
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-12-15 11:25:03 +00:00
|
|
|
|
const int coditi = consegne.get(LVRCONSPLAN_CODITI).as_int();
|
2010-03-05 10:00:43 +00:00
|
|
|
|
TString8 codaut = consegne.get(LVRCONSPLAN_CODAUT).as_string().right(5); codaut.trim();
|
2009-12-15 11:25:03 +00:00
|
|
|
|
|
|
|
|
|
//recupero i dati di interesse dal cliente
|
|
|
|
|
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
|
|
|
|
const TString4 codpag = clifo.get(CLI_CODPAG);
|
|
|
|
|
const long codabi = clifo.get_long(CLI_CODABI);
|
|
|
|
|
const long codcab = clifo.get_long(CLI_CODCAB);
|
|
|
|
|
const TString80 iban = clifo.get(CLI_IBAN);
|
2009-07-28 07:50:30 +00:00
|
|
|
|
|
2009-11-05 09:32:42 +00:00
|
|
|
|
//reupero la cuasale di magazzino di testata
|
|
|
|
|
const TString16 causmag = cache().get("%TIP", _tipodoc, "S9");
|
|
|
|
|
|
2009-12-15 11:25:03 +00:00
|
|
|
|
//recupero i dati di interesse dal file CFVEN
|
|
|
|
|
const TRectype& cfven = cache().get(LF_CFVEN, key);
|
|
|
|
|
const long codabipr = cfven.get_long(CFV_CODABIPR);
|
|
|
|
|
const long codcabpr = cfven.get_long(CFV_CODCABPR);
|
|
|
|
|
const bool ragdoc = cfven.get_bool(CFV_RAGGDOC);
|
|
|
|
|
const TString8 codag1 = cfven.get(CFV_CODAG1);
|
|
|
|
|
const TString4 codmez = cfven.get(CFV_CODSPMEZZO);
|
|
|
|
|
const TString4 codporto = cfven.get(CFV_CODPORTO);
|
|
|
|
|
const TString4 codnote1 = cfven.get(CFV_CODNOTESP1);
|
|
|
|
|
const TString4 codnote2 = cfven.get(CFV_CODNOTESP2);
|
|
|
|
|
const TString4 codnote = cfven.get(CFV_CODNOTE);
|
|
|
|
|
const TString8 codvet1 = cfven.get(CFV_CODVETT1);
|
|
|
|
|
const TString8 codvet2 = cfven.get(CFV_CODVETT2);
|
|
|
|
|
const TString8 codvet3 = cfven.get(CFV_CODVETT3);
|
|
|
|
|
const real speseinc = cfven.get_real(CFV_PERCSPINC);
|
|
|
|
|
const TString4 catven = cfven.get(CFV_CATVEN);
|
|
|
|
|
const bool addbolli = cfven.get_bool(CFV_ADDBOLLI);
|
|
|
|
|
const TString8 codlist = cfven.get(CFV_CODLIST);
|
|
|
|
|
const TString4 codzona = cfven.get(CFV_CODZONA);
|
|
|
|
|
|
2010-03-05 10:00:43 +00:00
|
|
|
|
if(codaut.empty())
|
|
|
|
|
codaut = cfven.get(CFV_CODAG);
|
|
|
|
|
|
2009-12-15 11:25:03 +00:00
|
|
|
|
//gestione sconto
|
|
|
|
|
TString sconto;
|
|
|
|
|
|
|
|
|
|
const char tpgest = ini_get_string(CONFIG_DITTA, "ve", "GESSCO")[0];
|
|
|
|
|
switch(tpgest)
|
|
|
|
|
{
|
2009-12-29 12:58:19 +00:00
|
|
|
|
case 'P': sconto = cfven.get(CFV_SCONTO); break; //Percentuale su anagrafica cliente
|
2009-12-15 11:25:03 +00:00
|
|
|
|
case 'T': sconto = cache().get("%SCC", cfven.get(CFV_CODSCC), "S1"); break; //Gestione tabella sconti
|
|
|
|
|
case 'A': //Gestione archivio sconti
|
|
|
|
|
{
|
|
|
|
|
TConfig ditta(CONFIG_DITTA, "ve");
|
|
|
|
|
|
|
|
|
|
TLocalisamfile sconti(LF_SCONTI);
|
|
|
|
|
sconti.put("TIPO", "I");
|
|
|
|
|
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 1))
|
|
|
|
|
sconti.put("CODCAT", cfven.get(CFV_CATVEN));
|
|
|
|
|
|
|
|
|
|
TString16 cod;
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 2))
|
|
|
|
|
cod.format("%-2s", (const char*)cfven.get(CFV_CODSCC));
|
|
|
|
|
else
|
|
|
|
|
cod = " ";
|
|
|
|
|
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 3))
|
|
|
|
|
{
|
|
|
|
|
TString8 tmp;
|
|
|
|
|
tmp.format("%-2s", (const char*)cfven.get(CFV_CODZONA));
|
|
|
|
|
cod << tmp;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cod << " ";
|
|
|
|
|
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 4))
|
|
|
|
|
cod << clifo.get(CLI_CODPAG);
|
|
|
|
|
|
|
|
|
|
sconti.put("CODART", cod);
|
|
|
|
|
|
|
|
|
|
if (sconti.read() == NOERR)
|
|
|
|
|
sconto = sconti.get("SCONTO");
|
|
|
|
|
}
|
|
|
|
|
case 'N': //sconto non gestito
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cont.get(LVCONDV_CODNUM).empty())
|
|
|
|
|
{
|
|
|
|
|
doc = new TDocumento('D', datadoc.year(), _codnum, ++_ndoc);
|
|
|
|
|
doc->put(DOC_TIPODOC, _tipodoc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
doc = new TDocumento('D', datadoc.year(), cont.get(LVCONDV_CODNUM), ++_ndoc);
|
|
|
|
|
doc->put(DOC_TIPODOC, cont.get(LVCONDV_TPDOC));
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
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-12-19 15:33:40 +00:00
|
|
|
|
if(codindsp > 0)
|
|
|
|
|
doc->put(DOC_CODINDSP, codindsp);
|
2009-11-05 09:32:42 +00:00
|
|
|
|
doc->put(DOC_CODPAG, codpag);
|
|
|
|
|
doc->put(DOC_CAUSMAG, causmag);
|
2009-12-15 11:25:03 +00:00
|
|
|
|
doc->put(DOC_CODABIA, codabi);
|
|
|
|
|
doc->put(DOC_CODCABA, codcab);
|
|
|
|
|
doc->put(DOC_IBAN, iban);
|
|
|
|
|
doc->put(DOC_CODABIP, codabipr);
|
|
|
|
|
doc->put(DOC_CODCABP, codcabpr);
|
|
|
|
|
doc->put(DOC_CODAG, codaut);
|
|
|
|
|
doc->put(DOC_CODAGVIS, codag1);
|
|
|
|
|
doc->put(DOC_CODSPMEZZO, codmez);
|
|
|
|
|
doc->put(DOC_ZONA, codzona);
|
|
|
|
|
doc->put(DOC_CODPORTO, codporto);
|
|
|
|
|
doc->put(DOC_CODNOTESP1, codnote1);
|
|
|
|
|
doc->put(DOC_CODNOTESP2, codnote2);
|
|
|
|
|
doc->put(DOC_CODNOTE, codnote);
|
|
|
|
|
doc->put(DOC_CODVETT1, codvet1);
|
|
|
|
|
doc->put(DOC_CODVETT2, codvet2);
|
|
|
|
|
doc->put(DOC_CODVETT3, codvet3);
|
|
|
|
|
doc->put(DOC_CATVEN, catven);
|
|
|
|
|
doc->put(DOC_CODLIST, codlist);
|
|
|
|
|
doc->put(DOC_CAUSMAG, causmag);
|
|
|
|
|
doc->put(DOC_PERCSPINC, speseinc);
|
|
|
|
|
doc->put(DOC_ADDBOLLI, addbolli);
|
|
|
|
|
doc->put(DOC_SCONTOPERC, sconto);
|
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
|
2009-12-15 11:25:03 +00:00
|
|
|
|
doc->put("CODITI", coditi); //codice itinerario
|
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
|
2009-11-09 16:49:56 +00:00
|
|
|
|
TFilename strname = file;
|
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-12-15 15:38:34 +00:00
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add('C');
|
|
|
|
|
key.add(codcf);
|
|
|
|
|
const int codindsp = atoi(cache().get(LF_CFVEN, key, CFV_CODINDSP));
|
|
|
|
|
TLaundry_contract cont(codcf, codindsp, datadoc);
|
|
|
|
|
const TRectype& rcont = cont.row(codart.trim());
|
|
|
|
|
|
|
|
|
|
if(rcont.empty())
|
|
|
|
|
{
|
|
|
|
|
TString str;
|
|
|
|
|
str << "L'articolo " << codart << " non <20> previsto nel contratto del cliente " << codcf;
|
|
|
|
|
warning_box(str);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 15:24:44 +00:00
|
|
|
|
TLocalisamfile magcli(LF_CLIFOGIAC);
|
|
|
|
|
magcli.put(CLIFOGIAC_ANNOES, datadoc.year());
|
|
|
|
|
magcli.put(CLIFOGIAC_TIPOCF, 'C');
|
|
|
|
|
magcli.put(CLIFOGIAC_CODCF, codcf);
|
|
|
|
|
magcli.put(CLIFOGIAC_INDSPED, cont.get_int(LVCONDV_CODINDSP));
|
|
|
|
|
magcli.put(CLIFOGIAC_CODART, codart);
|
|
|
|
|
magcli.put(CLIFOGIAC_NRIGA, 1);
|
|
|
|
|
//leggo il record corrispondente
|
|
|
|
|
if(magcli.read())
|
|
|
|
|
{
|
|
|
|
|
const real dotod = magcli.get_real(CLIFOGIAC_DOTOD);
|
|
|
|
|
|
|
|
|
|
if(qta > dotod)
|
|
|
|
|
{
|
|
|
|
|
TString str;
|
|
|
|
|
str << "Attenzione! Il cliente " << codcf << " per l'articolo " << codart << " ha una dotazione di "
|
|
|
|
|
<< dotod << " pezzi, e ne sono stati ritirati " << qta << " (" << qta - dotod << " in pi<70>).";
|
|
|
|
|
warning_box(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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"
|
2009-11-13 10:26:47 +00:00
|
|
|
|
<< "(SI -> Somma NO -> Ignora Conteggio ANNULLA -> Sosituisci il conteggio precedente)\n";
|
|
|
|
|
|
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>
|
2009-11-13 10:26:47 +00:00
|
|
|
|
case K_NO: break; //lascio tutto com'<27>
|
|
|
|
|
default: qc->set_pezzi(qta); qc->set_rotti(rotti); break; //sostituisco le quantit<69>
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
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
|
2009-12-22 08:52:32 +00:00
|
|
|
|
TQuantita_contate* quantita = new TQuantita_contate(ZERO, ZERO);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
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"
|
2009-11-13 10:26:47 +00:00
|
|
|
|
<< "(SI -> Somma NO -> Ignora Conteggio ANNULLA -> Modifica Buono)\n";
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
KEY k = yesnocancel_box(str);
|
|
|
|
|
|
|
|
|
|
switch (k)
|
|
|
|
|
{
|
2010-01-19 14:44:52 +00:00
|
|
|
|
case K_YES: quantita->add_pezzi(rdoc.get_real(RDOC_QTAGG1)); quantita->add_rotti(rdoc.get_real(RDOC_QTAGG2)); break; //sommo le quantit<69>
|
|
|
|
|
case K_NO: quantita->set_pezzi(rdoc.get_real(RDOC_QTAGG1)); quantita->set_rotti(rdoc.get_real(RDOC_QTAGG2)); break; //lascio tutto com'<27>
|
2009-11-13 10:26:47 +00:00
|
|
|
|
default: break; //sostituisco le quantit<69>
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
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;
|
2009-12-22 08:52:32 +00:00
|
|
|
|
const real qtacon = qc->get_pezzi();
|
|
|
|
|
const real qtarotti = qc->get_rotti();
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
2009-12-02 11:52:12 +00:00
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add('C');
|
|
|
|
|
key.add(codcf);
|
|
|
|
|
const int codindsp = atoi(cache().get(LF_CFVEN, key, CFV_CODINDSP));
|
|
|
|
|
TLaundry_contract cont(codcf, codindsp, datadoc);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
const TString8 codcont = cont.get(LVCONDV_CODCONT);
|
2010-01-28 17:12:23 +00:00
|
|
|
|
const TRectype rcont = cont.row(codart);
|
2010-02-16 11:29:48 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
TDate oggi(TODAY);
|
|
|
|
|
|
|
|
|
|
TDocumento& doc = ca.doc(datadoc, codcf);
|
|
|
|
|
if (!giri)
|
|
|
|
|
doc.put("DATAPRCO", oggi);
|
|
|
|
|
|
2010-02-16 11:29:48 +00:00
|
|
|
|
const TDate dtcons = doc.get_date("DATAPRCO");
|
|
|
|
|
|
2010-02-18 07:51:39 +00:00
|
|
|
|
const TString4 causale = rcont.get(LVRCONDV_CAUSLAV).full() ? rcont.get(LVRCONDV_CAUSLAV) : ini_get_string(CONFIG_DITTA, "lv", "CAUSLAV");
|
2010-02-16 11:29:48 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
if (doc.rows() > 0 && (idriga > 0 && idriga <= doc.rows()))
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento& rdoc = doc[idriga];
|
|
|
|
|
rdoc.put(RDOC_QTAGG1, qtacon);
|
2010-01-19 14:44:52 +00:00
|
|
|
|
rdoc.put(RDOC_QTAGG2, qtarotti);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-03-16 16:30:01 +00:00
|
|
|
|
{
|
2009-11-05 09:32:42 +00:00
|
|
|
|
const TRectype& anamag = cache().get(LF_ANAMAG, codart);
|
2009-03-18 15:23:56 +00:00
|
|
|
|
|
|
|
|
|
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');
|
2010-01-28 17:12:23 +00:00
|
|
|
|
rdoc.put(RDOC_CODAGG1, causale);
|
2009-10-06 16:51:30 +00:00
|
|
|
|
rdoc.put(RDOC_QTAGG1, qtacon);
|
2010-01-19 14:44:52 +00:00
|
|
|
|
rdoc.put(RDOC_QTAGG2, qtarotti);
|
2009-11-05 09:32:42 +00:00
|
|
|
|
rdoc.put(RDOC_CODIVA, anamag.get(ANAMAG_CODIVA));
|
2010-01-28 17:12:23 +00:00
|
|
|
|
|
2010-03-12 15:24:44 +00:00
|
|
|
|
//scrivo il magazzino
|
2010-01-28 17:12:23 +00:00
|
|
|
|
const TCausale_lavanderie cau(causale);
|
|
|
|
|
TCausale_magazzino rit(cau.causale_ritiro());
|
|
|
|
|
TCausale_magazzino con(cau.causale_consegna());
|
|
|
|
|
|
|
|
|
|
TString8 magazzino;
|
2010-03-09 14:10:29 +00:00
|
|
|
|
TString8 magazzinoc;
|
2010-01-28 17:12:23 +00:00
|
|
|
|
|
|
|
|
|
if(rit.get("S10").full())
|
2010-03-09 14:10:29 +00:00
|
|
|
|
magazzino = rit.get("S10").mid(0,5);
|
2010-01-28 17:12:23 +00:00
|
|
|
|
else
|
2010-03-09 14:10:29 +00:00
|
|
|
|
magazzino << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGN");
|
2010-01-28 17:12:23 +00:00
|
|
|
|
|
|
|
|
|
if(con.get("S10").full())
|
2010-03-09 14:10:29 +00:00
|
|
|
|
magazzinoc = con.get("S10").mid(0,5);
|
2010-01-28 17:12:23 +00:00
|
|
|
|
else
|
|
|
|
|
magazzinoc << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGC");
|
|
|
|
|
|
|
|
|
|
rdoc.put(RDOC_CODMAG, magazzino);
|
|
|
|
|
rdoc.put(RDOC_CODMAGC, magazzinoc);
|
|
|
|
|
|
|
|
|
|
//scrivo l'unit<69> di misura
|
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add(codart);
|
|
|
|
|
key.add(1);
|
|
|
|
|
const TRectype& umart = cache().get(LF_UMART, key);
|
|
|
|
|
rdoc.put(RDOC_UMQTA, umart.get(UMART_UM));
|
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);
|
|
|
|
|
|
2009-11-13 10:26:47 +00:00
|
|
|
|
//se la ciopia <20> andata a buon fine, creo un file .old vuoto e cancello il file .dat
|
2009-10-06 16:51:30 +00:00
|
|
|
|
if (fcopy(fileori, filedest))
|
2009-11-13 10:26:47 +00:00
|
|
|
|
{
|
|
|
|
|
TFilename fileold;
|
|
|
|
|
fileold = fileori.path();
|
|
|
|
|
|
|
|
|
|
TString strn = fileori.name_only();
|
|
|
|
|
strn << ".old";
|
|
|
|
|
|
|
|
|
|
fileold.add(strn);
|
|
|
|
|
|
|
|
|
|
fclose(fopen(fileold, "w"));
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
fileori.fremove();
|
2009-11-13 10:26:47 +00:00
|
|
|
|
}
|
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-11-26 14:22:31 +00:00
|
|
|
|
bool esiste = 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-11-09 16:49:56 +00:00
|
|
|
|
{
|
|
|
|
|
TFilename strname = *row2;
|
|
|
|
|
if (strname.exist())
|
|
|
|
|
{
|
|
|
|
|
esiste = true;
|
|
|
|
|
elaborato = elabora_file(*row2, logrep, articoli, nrighe, nrsalt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 16:30:01 +00:00
|
|
|
|
}
|
2009-11-09 16:49:56 +00:00
|
|
|
|
else if(file.exist())
|
|
|
|
|
{
|
|
|
|
|
esiste = true;
|
2009-10-06 16:51:30 +00:00
|
|
|
|
elaborato = elabora_file(file, logrep, articoli, nrighe, nrsalt);
|
2009-11-09 16:49:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!esiste)
|
|
|
|
|
{
|
|
|
|
|
TString str;
|
|
|
|
|
str << "ATTENZIONE: non <20> stato trovato nessun file da elaborare";
|
|
|
|
|
warning_box(str);
|
|
|
|
|
}
|
2008-10-28 15:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
if(elaborato)
|
|
|
|
|
{
|
|
|
|
|
controlla_documenti(logrep, articoli, documenti);
|
2009-11-10 10:40:39 +00:00
|
|
|
|
|
2009-11-26 14:22:31 +00:00
|
|
|
|
bool genera = true;
|
|
|
|
|
|
|
|
|
|
if (_auto == "A")
|
|
|
|
|
{
|
|
|
|
|
if (nrsalt > 0)
|
|
|
|
|
{
|
|
|
|
|
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 = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2009-11-13 10:26:47 +00:00
|
|
|
|
{
|
|
|
|
|
TString str;
|
2009-11-26 14:22:31 +00:00
|
|
|
|
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?";
|
2009-11-13 10:26:47 +00:00
|
|
|
|
|
2009-11-26 14:22:31 +00:00
|
|
|
|
if (!yesno_box(str))
|
|
|
|
|
genera = false;
|
2009-11-13 10:26:47 +00:00
|
|
|
|
}
|
2009-11-10 10:40:39 +00:00
|
|
|
|
|
2009-11-13 10:26:47 +00:00
|
|
|
|
if (nrsalt == 0 || genera)
|
2009-10-06 16:51:30 +00:00
|
|
|
|
{
|
2009-11-13 10:26:47 +00:00
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
genera_documenti(logrep, documenti);
|
|
|
|
|
|
2009-11-13 10:26:47 +00:00
|
|
|
|
//diagnostica
|
2009-11-16 16:57:29 +00:00
|
|
|
|
TAssoc_array buoni;
|
|
|
|
|
FOR_EACH_ASSOC_OBJECT(documenti, obj, key, itm)
|
|
|
|
|
{
|
|
|
|
|
TDocumenti_key tmp = (TDocumenti_key)key;
|
|
|
|
|
TDoc_key kdoc(tmp.anno(), tmp.codnum(), tmp.ndoc());
|
|
|
|
|
|
|
|
|
|
if (!buoni.is_key(kdoc))
|
|
|
|
|
buoni.add(kdoc, kdoc);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-13 10:26:47 +00:00
|
|
|
|
TString str;
|
2009-11-16 16:57:29 +00:00
|
|
|
|
if (buoni.items() > 1)
|
|
|
|
|
str << "Sono stati generati " << buoni.items() << " buoni di ritiro.";
|
2009-11-13 10:26:47 +00:00
|
|
|
|
else
|
2009-11-16 16:57:29 +00:00
|
|
|
|
str << "E' stato generato " << buoni.items() << " buono di ritiro.";
|
2009-11-13 10:26:47 +00:00
|
|
|
|
|
|
|
|
|
message_box(str);
|
|
|
|
|
|
2009-10-06 16:51:30 +00:00
|
|
|
|
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)
|
2009-11-09 16:49:56 +00:00
|
|
|
|
{
|
|
|
|
|
TFilename strname(*row2);
|
|
|
|
|
if (strname.exist())
|
|
|
|
|
sposta_file(*row2);
|
|
|
|
|
}
|
2009-10-06 16:51:30 +00:00
|
|
|
|
}
|
2009-11-09 16:49:56 +00:00
|
|
|
|
else if (file.exist())
|
2009-10-06 16:51:30 +00:00
|
|
|
|
sposta_file(file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 14:22:31 +00:00
|
|
|
|
if (_auto != "A")
|
2009-11-09 16:49:56 +00:00
|
|
|
|
{
|
|
|
|
|
TReport_book buc;
|
|
|
|
|
buc.add(logrep);
|
|
|
|
|
if (buc.pages() > 0)
|
|
|
|
|
buc.preview();
|
2009-11-26 14:22:31 +00:00
|
|
|
|
|
|
|
|
|
if (genera)
|
|
|
|
|
message_box(TR("Generazione terminata"));
|
2009-11-09 16:49:56 +00:00
|
|
|
|
else
|
2009-11-26 14:22:31 +00:00
|
|
|
|
message_box(TR("Generazione interrotta"));
|
2009-11-09 16:49:56 +00:00
|
|
|
|
}
|
2009-11-26 14:22:31 +00:00
|
|
|
|
_msk->send_key(K_SPACE, DLG_QUIT);
|
2009-10-06 16:51:30 +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;
|
|
|
|
|
}
|