campo-sirio/ci/ci0400.cpp
brugno f15009b25f Patch level :
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@12995 c028cbd2-c16b-5b4b-a496-9718f37d4682
2005-04-22 11:18:23 +00:00

233 lines
4.9 KiB
C++
Executable File

#include <applicat.h>
#include <automask.h>
#include <execp.h>
#include <relation.h>
#include <sheet.h>
#include <utility.h>
#include <doc.h>
#include "ci0.h"
#include "cilib.h"
#include "ci0400.h"
#include "ci0400a.h"
///////////////////////////////////////////////////////////
// TImmissioneDocumenti_app
///////////////////////////////////////////////////////////
// Inizializzazioni
void TImmissioneDocumenti_app::init_tabs()
{
TToken_string pagenames;
int items;
_tabs.destroy();
_filters.destroy();
pagenames = "";
TConfig configfile("ci0400.ini");
configfile.list_paragraphs(_tabs);
items = _tabs.items();
const short id = F_AL01;
for (int i = 0; i < items; i++)
{
pagenames.add(_tabs.row(i));
_filters.add(configfile.get("Filtro",_tabs.row(i)));
_mask->activate_almanac(id + i, i, TDate(TODAY));
}
_mask->set_caption(pagenames);
_mask->disable_page(items);
}
void TImmissioneDocumenti_app::init_flags()
{
int items;
TDate currdate;
TDate currstart;
TString filter;
filter << "ANNO==\"" << _year << "\"";
TRelation relation(LF_DOC);
TSorted_cursor cursor(&relation, "ANNO", filter);
items =cursor.items();
for (cursor=0;cursor.pos()<items;++cursor)
{
currdate = relation.lfile().get_date(DOC_DATADOC);
_flags.set(currdate-_newyearsday, 1);
}
}
// Overrides
bool TImmissioneDocumenti_app::create()
{
_mask = new TImmissioneDocumenti_mask();
init_tabs();
init_flags();
return TSkeleton_application::create();
}
bool TImmissioneDocumenti_app::destroy()
{
delete _mask;
return TSkeleton_application::destroy();
}
void TImmissioneDocumenti_app::main_loop()
{
while (_mask->run() == K_ENTER)
{
TDate selday = _mask->selected_day();
int currpage = _mask->curr_page();
// _mask->open_inner_sheet(selday,_filters.row(currpage));
}
}
// Chiamate dalla maschera
void TImmissioneDocumenti_app::change_year(int newyear, bool init_flg)
{
_year = newyear;
_newyearsday.set_day(1);
_newyearsday.set_month(1);
_newyearsday.set_year(_year);
if (init_flg) init_flags();
}
bool TImmissioneDocumenti_app::has_documents(TDate& day)
{
return ((_flags)[day-_newyearsday]);
}
///////////////////////////////////////////////////////////
// TImmissioneDocumenti_mask
///////////////////////////////////////////////////////////
// Routines Proprietarie
void TImmissioneDocumenti_mask::open_inner_sheet(TDate date, TString doctype)
{
int exitval;
TString filter;
filter << "(ANSI(DATADOC)==\"" << date.string(ANSI) << "\")";
filter << "&&";
filter << "(CODNUM==\"" << doctype << "\")";
TRelation relation(LF_DOC);
relation.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF");
TCursor cursor(&relation, filter);
TCursor_sheet sheet(&cursor,
"ANNO|CODNUM|TIPODOC|NUMDOCRIF|STATO|DATADOCRIF|NDOC|20->RAGSOC",
TR("Selezione documenti"),
HR("Anno|Num.|Tipo|Docum.Rif.|Stato|Data@10|Documento|Ragione Sociale@50"),
0x10||0x02||0x04);
exitval = sheet.run();
switch(exitval)
{
case K_ENTER:
case K_DEL:
case K_INS:
call_ve0(exitval, relation, date, doctype);
break;
case K_ESC:
break;
default:
break;
}
}
void TImmissioneDocumenti_mask::call_ve0(int exitval, TRelation& relation, TDate& date, TString& doctype)
{
TFilename tempfile;
tempfile.tempdir();
tempfile.add("cicallsve0.ini");
{
TConfig configfile(tempfile);
switch(exitval)
{
case K_ENTER:
configfile.set("Action", "Modify", "main");
configfile.set("CODNUM", doctype, "33");
configfile.set("NDOC", relation.lfile().get(DOC_NDOC), "33");
break;
case K_DEL:
configfile.set("Action", "Delete", "main");
configfile.set("CODNUM", doctype, "33");
configfile.set("NDOC", relation.lfile().get(DOC_NDOC), "33");
break;
case K_INS:
configfile.set("Action", "Insert", "main");
configfile.set("NDOC", date.string(), "33");
break;
default:
break;
}
configfile.set("PROVV", "D", "33");
configfile.set("ANNO", curr_almanac().selected_year(), "33");
configfile.set("CODNUM", doctype, "33");
}
TString commandline;
commandline.format("ve0 -0 /i%s",tempfile);
TExternal_app ve(commandline);
ve.run();
remove_file(tempfile);
}
// Richiami all'applicazione
void TImmissioneDocumenti_mask::change_year(int newyear)
{
immissione_documenti_app().change_year(newyear);
}
bool TImmissioneDocumenti_mask::is_date_void(TDate& cdate)
{
return !(immissione_documenti_app().has_documents(cdate));
}
///////////////////////////////////////////////////////////
// Mains
///////////////////////////////////////////////////////////
int ci0300(int argc, char* argv[])
{
TImmissioneDocumenti_app a ;
a.run(argc, argv, TR("Immissione Documenti"));
return 0;
}
int ci0400(int argc, char* argv[])
{
TImmissioneDocumenti_app a ;
a.run(argc, argv, TR("Immissione Documenti"));
return 0;
}