1994-09-16 10:13:08 +00:00
|
|
|
#include <confapp.h>
|
|
|
|
#include <lffiles.h>
|
|
|
|
#include <files.h>
|
1994-10-12 17:59:25 +00:00
|
|
|
#include <isam.h>
|
1994-11-18 11:40:45 +00:00
|
|
|
#include <tabutil.h>
|
|
|
|
#include <attiv.h>
|
1994-09-16 10:13:08 +00:00
|
|
|
#include "cg5100a.h"
|
|
|
|
|
|
|
|
class CG51_App : public TConfig_application
|
|
|
|
{
|
1994-11-18 11:40:45 +00:00
|
|
|
bool _change_pcon;
|
1994-10-12 17:59:25 +00:00
|
|
|
TString16 _val;
|
1994-11-18 11:40:45 +00:00
|
|
|
TArray _atts;
|
1994-10-14 18:46:45 +00:00
|
|
|
|
|
|
|
void swap_file(int logicnum, bool tocom);
|
1994-11-18 11:40:45 +00:00
|
|
|
void check_registers(int year);
|
|
|
|
|
1994-09-16 10:13:08 +00:00
|
|
|
public:
|
|
|
|
virtual bool preprocess_config (TMask& mask, TConfig& config);
|
|
|
|
virtual bool postprocess_config (TMask& mask, TConfig& config);
|
|
|
|
virtual bool postprocess_config_changed(const char* par, const char* var,
|
|
|
|
const char* oldv, const char* newv);
|
|
|
|
|
1994-11-18 11:40:45 +00:00
|
|
|
virtual bool user_create();
|
1994-10-12 17:59:25 +00:00
|
|
|
virtual bool user_destroy();
|
1994-09-16 10:13:08 +00:00
|
|
|
CG51_App() : TConfig_application(CONFIG_DITTA) {}
|
|
|
|
virtual ~CG51_App() {}
|
|
|
|
};
|
1994-10-14 18:46:45 +00:00
|
|
|
|
1994-11-18 11:40:45 +00:00
|
|
|
bool CG51_App::user_create()
|
|
|
|
{
|
|
|
|
_change_pcon = FALSE;
|
|
|
|
|
|
|
|
TLocalisamfile attiv(LF_ATTIV);
|
|
|
|
attiv.zero();
|
|
|
|
|
|
|
|
attiv.put(ATT_CODDITTA, get_firm());
|
|
|
|
TRectype r(attiv.curr());
|
|
|
|
|
|
|
|
for(attiv.read(_isgteq); attiv.status() == NOERR && attiv.curr() == r;
|
|
|
|
attiv.next())
|
|
|
|
// istanzia array _atts on le attivita' della ditta corrente
|
|
|
|
_atts.add(new TString(attiv.get(ATT_CODATT)));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CG51_App::check_registers(int year)
|
|
|
|
{
|
|
|
|
// controlla che per ogni data attivita' esistano almeno un registro
|
|
|
|
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
|
|
|
TTable reg("REG");
|
|
|
|
TRecfield reg_year(reg.curr(), "CODTAB", 0,3);
|
|
|
|
|
|
|
|
const byte R_ACQ = 0x01;
|
|
|
|
const byte R_VEN = 0x02;
|
|
|
|
const byte R_ALL = R_ACQ | R_VEN;
|
|
|
|
|
|
|
|
bool is_giornale = FALSE;
|
|
|
|
|
|
|
|
byte flags = 0x00;
|
|
|
|
|
|
|
|
for (int i = 0; i < _atts.items(); i++)
|
|
|
|
{
|
|
|
|
TString& att = (TString&)_atts[i];
|
|
|
|
for (reg.first(); !reg.eof(); reg.next())
|
|
|
|
{
|
|
|
|
if (atoi(reg_year) == year && reg.get_int("I0") == 5)
|
|
|
|
{
|
|
|
|
is_giornale = TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (atoi(reg_year) != year || att != reg.get("S8"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (reg.get_int("I0"))
|
|
|
|
{
|
|
|
|
case 1: // vendite
|
|
|
|
flags |= R_VEN;
|
|
|
|
break;
|
|
|
|
case 2: // acquisti
|
|
|
|
flags |= R_ACQ;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (flags == R_ALL && is_giornale) break;
|
|
|
|
}
|
|
|
|
if (flags < R_ALL)
|
|
|
|
{
|
|
|
|
TString wrn("I seguenti registri non esistono per l'attivita' ");
|
|
|
|
wrn << att << "(" << year << "):";
|
|
|
|
if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite";
|
|
|
|
if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti";
|
|
|
|
warning_box(wrn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// libro giornale non si controlla per attivita'
|
|
|
|
if(!is_giornale)
|
|
|
|
warning_box("Non esiste probabilmente nessun "
|
|
|
|
"libro giornale per l'anno %d", year);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1994-10-14 18:46:45 +00:00
|
|
|
void CG51_App::swap_file(int logicnum, bool tocom)
|
1994-10-12 17:59:25 +00:00
|
|
|
{
|
|
|
|
TDir dir;
|
|
|
|
TString file(16);
|
|
|
|
|
1994-10-14 18:46:45 +00:00
|
|
|
dir.get(logicnum, _lock, _nordir, _sysdirop);
|
|
|
|
file = dir.name();
|
|
|
|
file[0] = tocom ? '%' : '$';
|
|
|
|
dir.set(file, dir.eod(), dir.flags(), dir.des(), dir.expr());
|
|
|
|
dir.put(logicnum, _nordir, _sysdirop);
|
|
|
|
dir.get(logicnum, _lock, (tocom ? _comdir :_nordir), _sysdirop);
|
|
|
|
if (tocom)
|
1994-10-12 17:59:25 +00:00
|
|
|
{
|
|
|
|
file = dir.name();
|
1994-10-14 18:46:45 +00:00
|
|
|
file[0] = '%';
|
1994-10-12 17:59:25 +00:00
|
|
|
dir.set(file, dir.eod(), dir.flags(), dir.des(), dir.expr());
|
1994-10-14 18:46:45 +00:00
|
|
|
dir.put(logicnum, _comdir, _sysdirop);
|
|
|
|
}
|
|
|
|
if (dir.eox() == 0L)
|
|
|
|
{
|
|
|
|
TSystemisamfile s(logicnum);
|
|
|
|
s.build(10L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CG51_App::user_destroy()
|
|
|
|
{
|
|
|
|
if (_change_pcon)
|
|
|
|
{
|
|
|
|
swap_file(LF_PCON, _val[0] == 'X');
|
|
|
|
swap_file(LF_CAUSALI, _val[0] == 'X');
|
|
|
|
swap_file(LF_RCAUSALI, _val[0] == 'X');
|
1994-10-12 17:59:25 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
1994-09-16 10:13:08 +00:00
|
|
|
|
|
|
|
bool CG51_App::preprocess_config (TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
// these are disabled in normal applications
|
1994-10-12 17:59:25 +00:00
|
|
|
TLocalisamfile mov(LF_MOV);
|
|
|
|
const bool movempty = mov.empty();
|
|
|
|
mask.enable(CHK_ANCFCM, movempty);
|
|
|
|
mask.enable(CHK_PCTCCM, movempty);
|
1994-09-16 10:13:08 +00:00
|
|
|
disable_menu_item(M_FILE_NEW);
|
|
|
|
disable_menu_item(M_FILE_REVERT);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CG51_App::postprocess_config(TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
enable_menu_item(M_FILE_NEW);
|
|
|
|
enable_menu_item(M_FILE_REVERT);
|
1994-11-22 16:12:37 +00:00
|
|
|
check_registers(mask.get_int(FLD_ANLIIV));
|
1994-09-16 10:13:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CG51_App::postprocess_config_changed(const char* par, const char* var,
|
|
|
|
const char* oldv, const char* newv)
|
|
|
|
{
|
|
|
|
TString v(var);
|
|
|
|
|
|
|
|
if (v == "AnCfCm")
|
|
|
|
{
|
1994-10-12 17:59:25 +00:00
|
|
|
if (yesno_box("Confermi il cambiamento dell'anagrafica clienti/fornitori"))
|
1994-10-14 18:46:45 +00:00
|
|
|
swap_file(LF_CLIFO, *newv == 'X');
|
1994-10-12 17:59:25 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
1994-09-16 10:13:08 +00:00
|
|
|
}
|
|
|
|
else if (v == "PcTcCm")
|
|
|
|
{
|
1994-10-12 17:59:25 +00:00
|
|
|
if (yesno_box("Confermi il cambiamento del piano conti/causali"))
|
|
|
|
{
|
|
|
|
_change_pcon = TRUE;
|
|
|
|
_val = newv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
1994-09-16 10:13:08 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cg5100 (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
CG51_App appc;
|
|
|
|
appc.run(argc, argv, "Parametri Ditta");
|
|
|
|
return 0;
|
|
|
|
}
|