From 1df7e5164394450d6cd413e59ac310fc64cb042c Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Dec 2001 15:15:54 +0000 Subject: [PATCH] Patch level : no patch (per roberto Files correlati : si0.exe Ricompilazione Demo : [ ] Commento : Liste pagamenti per Sipag bisogna fare i form (Clienti->Documenti->Righe documento) e evenutalmente aggiornare i filtri nel programma. chiamata si0 -1 (si0200a si0200b si0200c si0200d) git-svn-id: svn://10.65.10.50/trunk@9969 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- si/si0200.cpp | 1598 ++++-------------------------------------------- si/si0200a.h | 24 +- si/si0200a.uml | 441 +++++++------ 3 files changed, 358 insertions(+), 1705 deletions(-) diff --git a/si/si0200.cpp b/si/si0200.cpp index 7276cb78c..443e7cf84 100755 --- a/si/si0200.cpp +++ b/si/si0200.cpp @@ -6,35 +6,26 @@ #include #include #include -#include #include #include #include +#include +#include #include #include +#include "../ve/velib.h" -#include "..\ve\velib.h" -#include "..\ve\sconti.h" -#include "si0200.h" - -#define LISTADOC "listadoc" -#define FAKETOTFLD 9999 - -// Queste classi (TDocisamfile e TRDocisamfile) servono nel costruttore di TDocumento_form -// in modo da sostituire i file della relazione, ovvero LF_DOC e LF_RIGHEDOC. -// Facendo in questo modo ogni get() del record, viene reindirizzata alla get() dei -// TVariable_recfield, in modo da utilizzare nel form le istruzioni FIELD anche per i campi -// virtuali. +#include "si0200a.h" class TDocisamfile : public TLocalisamfile { - TDocumentoEsteso *_doc; + TDocumento _doc; public: - virtual TRectype& curr() const { return (TRectype&) *_doc; } + virtual TRectype& curr() const { return (TRectype&) _doc; } virtual int readat(TRecnotype nrec, word lockop = _nolock); - TDocisamfile(TDocumentoEsteso* doc) : TLocalisamfile(LF_DOC) { _doc = doc;} + TDocisamfile() : TLocalisamfile(LF_DOC) {} virtual ~TDocisamfile() {}; }; @@ -42,1501 +33,158 @@ int TDocisamfile::readat(TRecnotype nrec, word lockop) { int err = TBaseisamfile::readat(nrec, _nolock); if (err == NOERR) - { - err = _doc->read(curr()); - if (err == NOERR) - { - _doc->summary_reset(TRUE); // forza il ricalcolo perche' trattasi di documento diverso - _doc->summary_filter(1); - } - } + err = _doc.read(TBaseisamfile::curr()); return err; } -class TRDocisamfile : public TLocalisamfile +class TListe_form : public TForm { - TDocumento *_doc; - bool _normal_next; - int _row; +// @access Protected Member protected: - TDocumento& doc() const { return *_doc;} -public: - void set_normal_next(const bool b = TRUE) { _normal_next = TRUE; } - virtual int next(word lockop = _nolock) { return _normal_next ? TLocalisamfile::next(lockop) : NOERR; } - virtual TRectype& curr() const ; - void set_row(int r) { _row = r;} - TRDocisamfile(TDocumento* doc) : TLocalisamfile(LF_RIGHEDOC) { _doc = doc; _row = 1; _normal_next = FALSE;} - virtual ~TRDocisamfile() {}; +public: + virtual bool validate(TForm_item& fld, TToken_string& val); + TListe_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") : TForm(form, code, editlevel, desc) {} + virtual ~TListe_form() {} }; - -TRectype& TRDocisamfile::curr() const -{ - TRectype& rr = ((_row > 0 && _row <= _doc->rows()) ? (TRectype&) doc()[_row] : TLocalisamfile::curr()); - return rr; -} -//////////////////////////////////////////////////////////////////////////// -// classe TDocumento_form customizzata dalla Form per i documenti -//////////////////////////////////////////////////////////////////////////// - -class TDocumento_form : public TForm -{ - static TDocumento_form* _form; - TDocisamfile* _docfile; - TRDocisamfile* _rdocfile; - TSorted_cursor * _sorted_cur; // Valido solo per i form di lista documenti - TRelation &_firmrel; // relazione di gestione dei dati della ditta corrente - TString _module; // codice del modulo di carta associato a questo al form - - TString_array _exclude_array_t; // array di tipi riga da escludere dalla stampa - TString_array _exclude_array_a; // array di articoli da escludere dalla stampa - TDocumentoEsteso * _doc; // Documento da stampare - TAssoc_array _doc_totals; // Assocarray per codice numerazione contenente i totali nel caso di stampa lista documenti - bool _valid, _cli_loaded; // flag che indica se il form e' valido | se l'oggetto cliente è già stato caricato - TString_array _group_decimals; // Array di TToken_string per ogni gruppo definito in GENERAL. - // Il primo elelemento della token_string conterra' il numero del gruppo - // il secondo il n.ro di decimali per importi in lire ed il terzo il n.ro - // di decimali per gli importi in valuta - // I gruppi sono cosi' predefiniti: - // PRI_DECIMALS corrisponde al gruppo 29 - // QTA_DECIMALS corrisponde al gruppo 30 - // IMP_DECIMALS corrisponde al gruppo 31 - // Altri gruppi definiti dall'utente saranno cosi' sintatticamente impostati: - // NEW_GROUP - // Dove e' il numero del gruppo - // e' il numero di decimali per i documenti in lire - // e' il numero di decimali per i documenti in valuta - // ATTENZIONE: e' importante che i nomi dei gruppi utilizzati per modificare le pictures non siano usati per - // per altri messaggi. Inoltre un TForm_item che appartiene ad un gruppo di modifica picture - // non puo' appartenere ad un altro gruppo dello stesso tipo, ad esempio i gruppi 29 e 30 contemporaneamente. - // Puo' pero' appartenere anche ad altri gruppi che non siano utilizzati per lo scopo qui definito -protected: - virtual void extended_parse_general(TScanner &); // gestione dei parametri estesi nella sezione general - virtual bool validate(TForm_item &, TToken_string &); // gestione dei messaggi estesi nei campi - bool print_on_body(int r); // Trascrive la riga 'r' del documento sul body. Ritorna TRUE se va stampata, FALSE se va saltata - - void print_header(TPrinter& p); // Stampa la testata - void print_footer(TPrinter& p); // Stampa la pedata - - static void doc_header_handler(TPrinter& p); - static void doc_footer_handler(TPrinter& p); - -public: - void edit_picture(TForm_item & f, const int dec); - void modify_pictures(); - virtual TCursor* cursor() const { return _sorted_cur ? _sorted_cur : TForm::cursor(); } - void hide_sections(); - bool is_faketotfld(); - void print_documento(); - bool valid() { return _valid; } - bool doc_arrange(); - int ncopie() { return _doc->tipo().ncopie(); } - const TString &get_module_code() { return _module; } // ritorna il codice del modulo di carta - TString_array & exclude_list_t() { return _exclude_array_t; } - TString_array & exclude_list_a() { return _exclude_array_a; } - TDocumentoEsteso& doc() { return *_doc; } - TDocumento_form(TRectype&/*TDocumentoEsteso **/ doc, TRelation& rel, const bool definitiva, const bool interattivo); - TDocumento_form(const char* form, TRelation& rel); - virtual ~TDocumento_form(); -}; - -TDocumento_form* TDocumento_form::_form = NULL; - -TDocumento_form::TDocumento_form(TRectype&/*TDocumentoEsteso**/ doc, TRelation& rel, const bool definitiva, const bool interattivo): TForm(), _firmrel(rel), _valid(FALSE), _sorted_cur(NULL) -{ - _form = this; - - TString codnum(doc.get(DOC_CODNUM)); - TString numdoc(doc.get(DOC_NDOC)); - TString tipodoc(doc.get(DOC_TIPODOC)); - TString nomeform; - - const TRectype rec = cache().get("%TIP", tipodoc); - if (!rec.empty()) - { // se non ci sono errori procede con la stampa - nomeform= rec.get("S5"); // legge il nome del form di stampa - TFilename test(nomeform); test.ext("frm"); - if (!test.exist()) - { - error_box("Nome form di stampa '%s' non valido per il tipo documento %s ", (const char*)nomeform, (const char*)tipodoc); - return; - } - } - else - { - error_box("Tipo di documento non valido: '%s'", (const char*)tipodoc); - return; - } - _valid = TRUE; - - - read(nomeform); - _cli_loaded= FALSE; - _doc = new TDocumentoEsteso(doc); // istanzia TDocumentoEsteso - _docfile = new TDocisamfile(_doc); - _rdocfile = new TRDocisamfile(_doc); - relation()->replace(_docfile,0); - relation()->replace(_rdocfile,1); - if (_doc->physical_rows() > 0) - relation()->update(); - modify_pictures(); - dec_parm p; - const int items = _group_decimals.items(); - for (int i = 0; i< items; i++) - { - TToken_string& t = _group_decimals.row(i); - int gruppo = t.get_int(0); - switch (gruppo) - { - case GROUP_QTA : p.qta_lit = t.get_int(1);p.qta_val = t.get_int(2); - break; - // add other groups here - default: - break; - } - } - _doc->set_decimals(p); - - // Inizializza lo sfondo delle pagine normali - set_background(3, TRUE); - - TPrinter& pr = printer(); - - pr.setheaderhandler(doc_header_handler); - TPrint_section& head = section('H'); - pr.headerlen(head.height()); - - pr.setfooterhandler(doc_footer_handler); - const TPrint_section& foot = section('F'); - pr.footerlen(foot.height()); -} - -// costruttore per stampa lista documenti (uso convenzionale dei forms) -TDocumento_form::TDocumento_form(const char* form, TRelation& rel): TForm(form), _firmrel(rel), _valid(FALSE) -{ - _cli_loaded= FALSE; - _doc = new TDocumentoEsteso; - _docfile = new TDocisamfile(_doc); - _rdocfile = new TRDocisamfile(_doc); - _rdocfile->set_normal_next(); - relation()->replace(_docfile,0); - relation()->replace(_rdocfile,1); - _sorted_cur = new TSorted_cursor(relation(), "PROVV|ANNO|CODNUM|STATO|DATADOC|NDOC"); -} - -TDocumento_form::~TDocumento_form() -{ - - // Membri di cui NON va fatta la delete: - // _docfile : perche' viene fatta dal distruttore di TRelation - // _rdocfile : perche' viene fatta dal distruttore di TRelation - if (_doc) delete _doc; - if (_sorted_cur) delete _sorted_cur; -} - -void TDocumento_form::hide_sections() -{ - // Scorre tutte le sezioni e nasconde gli items - const char s[3] = { 'B', 'G', 'H' }; - for (int sn = 0; sn < 3 ; sn++) - { - const char sc = s[sn]; - for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1)) - { - TPrint_section* sec = exist(sc, pt); - if (sec == NULL) - continue; - TForm_item* f; - for(word i = 0; i < sec->fields(); i++) - { - f = &(sec->field(i)); - f->hide(); - } - } - } -} - -bool TDocumento_form::is_faketotfld() -{ - TPrint_section* fl = exist('F',last_page); - if (fl != NULL) - { - TForm_item* f; - for(word i = 0; i < fl->fields(); i++) - { - f = &(fl->field(i)); - if (f->id() == FAKETOTFLD) - return TRUE; - } - } - return FALSE; -} - -bool TDocumento_form::doc_arrange() -{ - TPrinter& pr = printer(); - - if (char_to_pos() != '\0' || (ipx()+ipy()+fpx()) != 0) - { - if (offset_x() != 0 || offset_y() != 0) - { - error_box("Non e' possibile settare contemporaneamente gli offset" - " e i parametri di posizionamento del modulo %s.", (const char*)name()); - return FALSE; - } - else - if (pr.printtype() == winprinter) - _form->arrange_form(); - } - else - pr.set_offset(_form->offset_y(), _form->offset_x()); - return TRUE; -} - -void TDocumento_form::print_documento() -{ - TPrinter& pr = printer(); - - // stampa tutte le righe - TPrint_section& body = section('B'); - TPrint_section& foot = section('F'); - TPrint_section* sect = exist('B', last_page); - TString last_section; - - const int righe = _doc->rows(); - bool one_row_printed = FALSE; - - set_last_page(FALSE); // E' importante settare questo flag, per evitare "Falli di Piede" eheh :-) - for (int r=1; r<=righe; r++) - { - _rdocfile->set_row(r); - cursor()->next_match(LF_RIGHEDOC); - - if (!print_on_body(r)) continue; - - if (sect) - { - sect->update(); - const TString& curr_section = sect->field(0).get(); - if (r == 1 || curr_section != last_section) - { - last_section = curr_section; - const word h = sect->height(); - for (word j = 0; j < h; j++) - pr.print(sect->row(j)); - } - } - - const word h = body.height(); - for (word j = 0; j < h; j++) - pr.print(body.row(j)); - - if (!one_row_printed) - one_row_printed = TRUE; - - if ((*_doc)[r].tipo().formfeed()) - pr.formfeed(); - } - - if (!one_row_printed) - { - // Riga fasulla... per stampare l'intestazione obbligatoriamente, - // anche in caso che non vi siano righe nel documento o che siano tutte escluse - TPrintrow r; - pr.print(r); - } - - if (_doc->tipo().add_conai() && _doc->clifor().vendite().get_bool("CONAIASS")) - { - TRiga_documento last_row(_doc); - TConfig c(CONFIG_DITTA); - - last_row = _rdocfile->curr(); - _rdocfile->zero(); - TString80 desc(c.get("DESCCONAIASS")); - if (desc.empty()) - desc = "Contributo CONAI assolto"; - _rdocfile->put(RDOC_DESCR, desc); - body.update(); - const word h = body.height(); - if (pr.rows_left() <= h+1) // salto pagina - pr.formfeed(); - - for (word j = 0; j < h; j++) - pr.print(body.row(j)); - - _rdocfile->curr() = last_row; - } - - TPrint_section* last_foot = exist('F', last_page, FALSE); - if (last_foot != NULL) - { - const word lfh = last_foot->height(); - const word left = pr.rows_left() + pr.footersize(); - if (lfh > left) // Se l'ultimo footer e' troppo grande ... - pr.formfeed(); // Stampa il footer normale - pr.footerlen(lfh); // Fondamentale! - } - set_last_page(TRUE); - pr.formfeed(); // Stampa l'ultimo footer - - // Rimette ad 1 il numero della pagina - pr.setcurrentpage(1); -} - -void TDocumento_form::print_header(TPrinter& pr) -{ - TPrint_section& head = section('H'); - - head.update(); - - const word r = head.height()-1; - - for (word j = 0; j <= r; j++) - pr.setheaderline(j, head.row(j)); +bool TListe_form::validate(TForm_item& fld, TToken_string& val) +{ + return TForm::validate(fld, val); } -void TDocumento_form::print_footer(TPrinter& pr) -{ - const bool p = _form->page(pr)>0; - TPrint_section& foot = section('F',p ? odd_page : last_page); - - foot.update(); - word r = foot.height(); - - for (word j = 0; j < r; j++) - pr.setfooterline(j, foot.row(j)); - -} - -void TDocumento_form::doc_header_handler(TPrinter& pr) -{ - pr.resetheader(); - _form->print_header(pr); -} - -void TDocumento_form::doc_footer_handler(TPrinter& pr) -{ - pr.resetfooter(); - _form->print_footer(pr); -} - -void TDocumento_form::edit_picture(TForm_item & fi, const int dec) -{ - const TString old_picture = fi.picture(); - TString new_picture(20); - const int comma_pos = old_picture.find(','); - const int stop_pos = old_picture.find('.'); - char migliaia_char = '.'; - - if (comma_pos > 0 && stop_pos > 0) - { - if (stop_pos > comma_pos) - migliaia_char = ','; - } - - if (old_picture.empty()) // picture di default - { - new_picture = "."; // in lire - if (dec > 0) new_picture << dec; // in valuta - } - else - { - if (dec == 0) return; // 0 non cambia la picture - - new_picture = old_picture; - - // Resetta la picture: toglie eventuali decimali gia' presenti... - const int pos = new_picture.rfind(migliaia_char == '.' ? ',' : '.'); - if (pos >= 0) - new_picture.cut(pos); - - // Se si decide di metterne... altrimenti ndec -1 lascia la picture senza decimali - if (dec > 0) - { - TString16 dec_to_add; - for (int i = 0; i < dec; i++) - dec_to_add << "@"; // aggiunge tanti "@" quanti sono i decimali voluti - if (migliaia_char == ',') - new_picture << "."; // se ha trovato la virgola come separatore di migliaia significa che deve aggiungere il punto decimale - else - new_picture << ","; // altrimenti aggiunge la solita virgola - new_picture << dec_to_add; // infine aggiunge i decimali richiesti - } - } - const int w = old_picture.len(); // se la picture eccede la dimensione della picture, toglie i caratteri piu' a sx - int exceed = w - new_picture.len(); - if (exceed<0 && w>0) - { - exceed=::abs(exceed); - new_picture = new_picture.mid(exceed,new_picture.len()-exceed); - if (new_picture[0] == migliaia_char) - new_picture.ltrim(1); - } - fi.set_picture(new_picture); // setta la nuova picture -} - -void TDocumento_form::modify_pictures() -{ - const bool valuta = _doc->in_valuta(); - const char sechar[4] = { 'B', 'F', 'G', 'H' }; - for (int sn = 0; sn < 4 ; sn++) - { - const char sc = sechar[sn]; - for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1)) - { - TPrint_section* sec = exist(sc, pt); - if (sec != NULL) - for (word i = 0; i < sec->fields() ; i++) - { - TForm_item& fi = sec->field(i); - if (fi.in_group(GROUP_PRICES)) - edit_picture(fi, _doc->decimals(TRUE)); - else - if (fi.in_group(GROUP_IMPORTI)) - edit_picture(fi, _doc->decimals()); - else - { - const int items = _group_decimals.items(); // numero di gruppi definiti - for (int j = 0; j < items; j++) - { - TToken_string& r = _group_decimals.row(j); - const int group = r.get_int(0); - if (fi.in_group(group)) // trova se appartiene al gruppo, modifica la picture - { - edit_picture(fi,valuta ? r.get_int(2) : r.get_int(1)); - break; // considera solo il primo gruppo trovato - } - } - } - } - } - } -} - -bool TDocumento_form::print_on_body(int r) -{ - TPrint_section& body = section('B'); - TRiga_documento& riga = doc()[r]; - const TString & tiporiga = riga.get(RDOC_TIPORIGA); - bool ok = _exclude_array_t.find(tiporiga) < 0; - - if (ok) - { - const TString & codart = riga.get(RDOC_CODART); - ok = _exclude_array_a.find(codart) < 0; - } - - if (ok) - body.update(); // Crea la vera riga di stampa, eventuali allineamenti avverranno nella validate(), come al solito. - - return ok; -} - -void TDocumento_form::extended_parse_general(TScanner &scanner) -{ - // se viene riconosciuto il token per l'impostazione del modulo legge il codice... - if (scanner.key() == "MO") _module= scanner.string(); - - // Legge i decimali necessari per gli arrotondamenti (il primo per gli importi in lire, l'altro per quelli in valuta) -// if (scanner.key() == "PR") -// { -// TToken_string t; -// t.add(GROUP_PRICES);t.add(scanner.integer());t.add(scanner.integer()); -// _group_decimals.add(t); -// } - - // Stessa cosa per le quantita' - if (scanner.key() == "QT") - { - TToken_string t; - t.add(GROUP_QTA);t.add(scanner.integer());t.add(scanner.integer()); - _group_decimals.add(t); - } - - // Stessa cosa per gli importi in genere -// if (scanner.key() == "IM") -// { -// TToken_string t; -// t.add(GROUP_IMPORTI);t.add(scanner.integer());t.add(scanner.integer()); -// _group_decimals.add(t); -// } - - if (scanner.key() == "NE") - { - TToken_string t; - t.add(scanner.integer());t.add(scanner.integer());t.add(scanner.integer()); - _group_decimals.add(t); - } - - // Esclude certi tipi riga e codici articolo - if (scanner.key() == "EX") - { - TToken_string s(scanner.string(),','); - const char * i = s.get(); - if (i) - { - if (*i) - _exclude_array_t.add(i); - i = s.get(); - if (i && *i) - _exclude_array_a.add(i); - } - } -} - -bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) -{ - const TString code(s.get(0)); // prende il primo parametro, il codice del messaggio - TString valore; - - if (code== "_DITTA") - { - // lettura dei dati della ditta - // sintassi: _DITTA,{|} - // dove: è un riferimento alla relazione di gestione dei dati della ditta (es. 113@->DENCOM è la denominazione del comune di residenza della ditta) - // è uno delle macro seguenti: - // !RAGSOC ragione sociale - // !IND indirizzo (fiscale se c'è, oppure di residenza) - // !NUM numero civico (fiscale se c'è, oppure di residenza) - // !CAP CAP (fiscale se c'è, oppure di residenza) - // !COM comune (fiscale se c'è, oppure di residenza) - // !PROV provincia (fiscale se c'è, oppure di residenza) - // !IVA partita iva - // !CF codice fiscale - // !TEL numero di telefono (con prefisso) - // !FAX numero di fax (con prefisso) - // !REGSOC numero di registrazione presso il Tribunale - // !CCIAA numero di registrazione presso la camera di commercio - // nota: la relazione della ditta è così strutturata: - // %NDITTE (9) Dati ditte - // + %ANAGR (6) Anagrafica generale (indirizzo, ecc.) - // + %COMUNI (113@) Comune di residenza - // + %COMUNI (213@) Comune di residenza fiscale - TString in(s.get()); - - if (in[0]!='!') - { - cf.set(_firmrel.curr().get(in)); - return TRUE; - } - else - { - in.ltrim(1); - bool _fisc= _firmrel.lfile(6).get("INDRF").not_empty(); - if (in=="RAGSOC") - { - cf.set(_firmrel.lfile().get("RAGSOC")); - return TRUE; - } - if (in=="IND") - { - if (_fisc) - cf.set(_firmrel.lfile(6).get("INDRF")); - else - cf.set(_firmrel.lfile(6).get("INDRES")); - return TRUE; - } - if (in=="NUM") - { - if (_fisc) - cf.set(_firmrel.lfile(6).get("CIVRF")); - else - cf.set(_firmrel.lfile(6).get("CIVRES")); - return TRUE; - } - if (in=="CAP") - { - if (_fisc) - cf.set(_firmrel.lfile(6).get("CAPRF")); - else - cf.set(_firmrel.lfile(6).get("CAPRES")); - return TRUE; - } - if (in=="COM") - { - if (_fisc) - cf.set(_firmrel.lfile(-213).get("DENCOM")); - else - cf.set(_firmrel.lfile(-113).get("DENCOM")); - return TRUE; - } - if (in=="PROV") - { - if (_fisc) - cf.set(_firmrel.lfile(-213).get("PROVCOM")); - else - cf.set(_firmrel.lfile(-113).get("PROVCOM")); - return TRUE; - } - if (in=="IVA") - { - cf.set(_firmrel.lfile(6).get("PAIV")); - return TRUE; - } - if (in=="CF") - { - cf.set(_firmrel.lfile(6).get("COFI")); - return TRUE; - } - if (in=="TEL") - { - valore = _firmrel.lfile().get("PTEL"); - valore << "/" << _firmrel.lfile().get("TEL"); - cf.set(valore); - return TRUE; - } - if (in=="FAX") - { - valore = _firmrel.lfile().get("PFAX"); - valore << "/" << _firmrel.lfile().get("FAX"); - cf.set(valore); - return TRUE; - } - if (in=="REGSOC") - { - valore = _firmrel[LF_UNLOC].get("REGIMP"); - valore.insert(" ", 2); valore.insert(" ", 6); - valore.insert(" ", 11); valore.insert(" ", 21); - valore.insert("Reg.Imp. ", 0); - cf.set(valore); - return TRUE; - } - if (in=="CCIAA") - { - valore = _firmrel[LF_UNLOC].get("NUMCCIAA"); - const TString & data = _firmrel[LF_UNLOC].get("DATAICCIAA"); - if (data.not_empty()) - valore << " del " << data; - cf.set(valore); - return TRUE; - } - } - } // fine _DITTA - - if (code== "_CLIENTE") - { - // lettura dei dati del cliente - // sintassi: _CLIENTE,{|} - // dove: è un riferimento alla relazione di gestione dei dati del cliente - // è uno delle macro seguenti: - // !RAGSOC ragione sociale - // !CAP Codice Avviamento Postale (viene implementato un messaggio perche' sugli occasionali ha un nome campo diverso!!) - // !IND indirizzo - // !NUM numero civico - // !INDNUM indirizzo + numero civico - // !COM comune - // !PROV provincia - // !TEL primo numero di telefono (con prefisso) - // !TEL2 secondo numero di telefono (con prefisso) - // !TEL3 terzo numero di telefono (con prefisso) - // !FAX numero di fax (con prefisso) - // !COM-> accede ai campi del comune di residenza cliente - // !COMN-> accede ai campi del comune di nascita del cliente - TCli_for & cli_for = _doc->clifor(); - TOccasionale & cli_occ = _doc->occas(); - const bool occasionale = cli_for.occasionale(); - TString in(s.get()); // prende la macro o il fieldref - if (in[0] != '!') - { - // Controlla l'esistenza dei campi... - if (occasionale && cli_occ.exist(in)) - valore = cli_occ.get(in); - - if (!occasionale && cli_for.exist(in)) - valore = cli_for.get(in); - - cf.set(valore); - return TRUE; - } - in.ltrim(1); - if (in=="INDNUM") - { - valore = occasionale ? cli_occ.get(OCC_INDIR) : cli_for.get(CLI_INDCF); - valore << " " ; - valore << (occasionale ? cli_occ.get(OCC_CIV) : cli_for.get(CLI_CIVCF)); - cf.set(valore); - return TRUE; - } - if (in.find("COM") == 0) - { - const bool nascita = in[3] == 'N'; - const int p = in.find("->"); - if (p > 0) - in.ltrim(p + 2); - TLocalisamfile com(LF_COMUNI); - if (nascita) - { - com.put("STATO", occasionale ? cli_occ.get(OCC_STATONASC) : cli_for.get(CLI_STATONASC)); - com.put("COM", occasionale ? cli_occ.get(OCC_COMNASC) : cli_for.get(CLI_COMNASC)); - } - else - { - com.put("STATO", occasionale ? cli_occ.get(OCC_STATO): cli_for.get(CLI_STATOCF)); - com.put("COM", occasionale ? cli_occ.get(OCC_COM): cli_for.get(CLI_COMCF)); - } - if (com.read() == NOERR) - cf.set(com.get(in)); - return TRUE; - } - if (in.find("CAP") == 0) - { - valore = occasionale ? cli_occ.get(OCC_CAP) : cli_for.get(CLI_CAPCF); - cf.set(valore); - return TRUE; - } - if (in.find("TEL") == 0) - { - if (!occasionale) - { - if (in.len() == 3) - in << "1"; - const TString num(cli_for.get(in)); - in.insert("P"); - valore = cli_for.get(in); - valore << "/" << num; - } - cf.set(valore); - return TRUE; - } - if (in=="FAX") - { - if (!occasionale) - { - valore = cli_for.get("PFAX"); - valore << "/" << cli_for.get("FAX"); - } - cf.set(valore); - return TRUE; - } - if (in=="RAGSOC") - { - valore = occasionale ? cli_occ.get(in) : cli_for.get(in); - valore.strip_d_spaces(); - cf.set(valore); - return TRUE; - } - } // fine _CLIENTE - - if (code == "_DESCRIGA") - { - // Messaggio per reperire la descrizione estesa sulle righe del documento - TLocalisamfile &rdoc= (cursor())->file(LF_RIGHEDOC); - TString descrizione = rdoc.get("DESCR"); - const bool desclunga = rdoc.get_bool("DESCLUNGA"); - if (desclunga) - { - const TString & dest = rdoc.get("DESCEST"); - - descrizione << dest; - } - int nfields = s.items(); - for (int j = 1; j < nfields; j++) - { - const TString & fld = s.get(j); - TForm_item & f = cf.find_field(fld); - const TString & val = f.get(); - if (val.not_empty()) - descrizione << " " << val; - } - cf.set(descrizione); - TParagraph_string p(descrizione, cf.width()); - const int h = cf.height(); - for (int i=0; p.get() != NULL && i < h; i++); -// cf.put_paragraph(descrizione); - // Setta l'altezza effettiva del body, per evitare sprechi di righe - cf.section().set_height(p.empty() ? 1 : i); - return TRUE; - } - - if (code== "_RIEPILOGOIVA") - { - // tabella riepilogo aliquote iva e relative imposte - // sintassi: _RIEPILOGOIVA,,, - // dove: è uno dei seguenti: - // 1 = codici IVA a regime normale - // 2 = codici IVA da ventilare - // 4 = codici IVA esenti - // 8 = codici IVA non imponibili - // 16 = codici IVA non soggetti - // oppure la combinazione di uno o piu' di essi: - // 12 = 4+8, 19 = 1+2+16, 29 = 1+4+8+16 ecc... - // dove: è uno dei seguenti: - // COD colonna dei codici - // IMP colonna degli imponibili - // IVA colonna delle imposte - // ALI colonna delle aliquote - // DES colonna delle descrizioni (stampata solo se il regime IVA non e' normale) - // dove: è uno dei seguenti: - // 0 indica di non leggere il successivo codice IVA nella tabella riepilogativa - // 1 indica di leggere il successivo codice IVA nella tabella riepilogativa - - if (s.items() == 4) - { - byte selector = byte(atoi(s.get())); // il primo parametro e' il selettore del tipo di codice - if (selector != 0) - { - _doc->summary_filter(selector); - - TString16 what = s.get(); // cosa deve stampare ? - TString value(_doc->summary_get(what)); // Piglia il valore dalla riga selezionata sulla tabellina - - what = s.get(); - const bool next = what == "1"; // deve cambiare elemento ? - if (next) _doc->summary_set_next(); - - cf.set(value); - } - } - else - error_box("Numero di parametri non corretto in _RIEPILOGOIVA"); - return TRUE; - } // fine _RIEPILOGOIVA - - if (code == "_TOTIMPONIBILI") - { - // sintassi: _TOTIMPONIBILI, - // dove: funge da filtro per la somma degli imponibili - // se selettore vale 0 restituisce il tot. imponibili con le spese - // vedi _RIEPILOGOIVA per la spiegazione dei filtri selettivi - byte sel = atoi(s.get()); - real x = sel == 0 ? _doc->imponibile(TRUE) : _doc->tot_imponibili(sel); - - cf.set(x.string()); - return (TRUE); - } // fine _TOTIMPONIBILI - - if (code== "_SCADENZE") - { - // messaggio per stampare le scadenze - // sintassi: _SCADENZE,, - // dove e' uno dei seguenti: - // DATA : stampa la data di scadenza - // IMPORTO : stampa l'importo in scadenza - // dove vale 0 o 1 se indica di rendere corrente la prossima scadenza - if (s.items() == 3) - { - TString what(s.get()); - TString value(_doc->scadenze_get(what)); - - what = s.get(); - const bool next = what == "1"; - if (next) _doc->scadenze_set_next(); - cf.set(value); - } - return TRUE; - } - - if (code == "_EDITPICTURE") - { - const int flds2set = s.items() -1; -// TString16 val(cursor()->file(LF_DOC).get(DOC_CODVAL)); -// const bool valuta = val.not_empty() && val != "LIT"; - const int ndec = _doc->decimals(); - for (int i = 1; i<=flds2set; i++) - { - const short fld = s.get_int(i); - edit_picture(cf.section().find_field(fld), ndec); - } - } - - if (code == "_SEPARATOR") // Riempitore - { - TString sep; - sep.fill('-',s.get_int(1)); - cf.set(sep); - - return TRUE; - } - - if (code == "_WEEK" || code == "_YEAR") - { - const TString16 which(s.get()); - TString16 data; - if (which == "DATACONS") - { - TLocalisamfile & rdoc= (cursor())->file(LF_RIGHEDOC); - data = rdoc.get(which); - } - if (data.empty()) - data = _doc->get(which); - TDate d(data); - const char * c = s.get(); - bool complete = c != NULL && *c != '\0'; - int week; - int year; - d.get_week_year(week, year, complete); - if (code == "_WEEK") - cf.set(data.format("%d", week)); - else - cf.set(data.format("%d", year)); - } - - if (code == "_LISTADOC") // Messaggio per riepilogo lista documenti - { - const TString16 what(s.get(1)); - TString16 which(s.get(2)); - if (what == "STORE") - { - if (which[0] == '#') - which.ltrim(1); // Toglie il # - const TString16 codnum(cf.section().find_field(atoi(which)).get()); - const real r(cf.get()); - - real* v = (real*)_doc_totals.objptr(codnum); - if (v == NULL) - { - v = new real(ZERO); - _doc_totals.add(codnum, v); - } - if (_doc->is_nota_credito()) - *v -= r; - else - *v += r; - } else - if (what == "ADDTOT") - { - const real r = cf.get(); - if (!r.is_zero()) - { - TForm_item& tot = cf.find_field(which); - real v = tot.get(); - if (_doc->is_nota_credito()) - v -= r; - else - v += r; - tot.set(v.string()); - } - } - else - { - TString_array k; - _doc_totals.get_keys(k); - const int index = atoi(which)-1; - if (index < k.items()) - { - TString16 codnum(k.row(index)); - if (what == "CODICE") - cf.set(codnum); - else - if (what == "TOTALE") - { - real& r = (real&) _doc_totals[codnum]; - cf.set(r.string()); - } - } - } - } - - return TForm::validate(cf, s); // se il codice del messaggio non è identificato viene passato alla funzione standard -} - -////////////////////////////////////////////////////////////////////////////////////////////// -// classe TStampaDoc_application customizzata dalla TApplication per l'applicazione principale -////////////////////////////////////////////////////////////////////////////////////////////// - - -enum behaviour -{ - skip, - go, - cancel -}; - -// Chiavi di ordinamento LF_DOC: -// Chiave 1: ordinamento per Provvisorio + Anno + Codice numerazione + Numero documento -// Chiave 3: ordinamento per Data documento + Provvisorio + Anno + Codice numerazione + Numero documento - -#define BY_NUM_KEY 1 -#define BY_DATE_KEY 3 - - -class TStampaDoc_application: public TSkeleton_application -{ - TString _codnum; // codice di numerazione - char _provv; // stampa documenti provvisiori o definitivi (D o P) - int _anno; // anno della documentazione - int _key; // chiave per scorrere i documenti (1 o 3, vedi sopra) - int _ncopie; // numero di copie per ogni documento - long _dalnum, _alnum; // estremi di numerazione dei documenti - TDate _dadata, _adata; // estremi di data dei documenti - bool _definitiva; // flag che indica se la stampa è definitiva o no - TRelation *_firmrel; // puntatore alla relazione che gestisce i dati della ditta corrente - TDocumento_form *_form; // puntatore al form di stampa - TMask * _selection_mask; - TArray_sheet *_clifo_sheet; // Array sheet per la selezione cli/fo - TAssoc_array _clifo_sel; // Assoc array con solo i cli/fo selezionati. Facilita il filtro... - +class TListe_application: public TSkeleton_application +{ + TMask * _select_mask; + TListe_form * _form; + TFilename _formname; + protected: virtual bool create(); virtual bool destroy(); + char tipo_lista() const { return _formname[6]; } + void set_limits(); virtual void main_loop(); - bool select(void); - virtual void on_firm_change(void); - void set_filter(); - static bool date2num_handler(TMask_field& f, KEY key); - static bool range_handler(TMask_field& f, KEY key); - static bool tipocf_handler (TMask_field& f, KEY k); - static bool fr_cod_handler (TMask_field& f, KEY k); - static bool to_cod_handler (TMask_field& f, KEY k); - static bool select_button (TMask_field& f, KEY k); - static bool reset_button (TMask_field& f, KEY k); - static bool filter_clifo(const TRelation* r); - long select_cod_range(long from, long to); - void reset_choices(TMask& m); - void set_choice_limits(TMask& m); - void build_clifo_list(const char c='C'); public: - TDocumento_form& form() { return *_form; } - void print_selected(); - TStampaDoc_application() : _key(BY_NUM_KEY) {}; - virtual ~TStampaDoc_application() {}; + TListe_application() : _select_mask(NULL), _form(NULL) {}; + virtual ~TListe_application() {}; }; -inline TStampaDoc_application& app() { return (TStampaDoc_application&) main_app(); } +inline TListe_application& app() { return (TListe_application&) main_app(); } -void TStampaDoc_application::print_selected() -{ - TRelation rel(LF_DOC); - rel.add(LF_RIGHEDOC,"CODNUM==CODNUM|ANNO==ANNO|PROVV==PROVV|NDOC==NDOC"); - TCursor cur(&rel); - cur.setkey(_key); - TLocalisamfile& doc = cur.file(); - TRectype darec(LF_DOC),arec(LF_DOC); // Estremi filtro - TString modulo_prec; - const bool order_by_num = _key == BY_NUM_KEY; - - TPrinter& pr = printer(); - pr.open(); - - TProgind* pi = pr.printtype() != screenvis ? - new TProgind(cur.items(),"Stampa documenti in corso...",FALSE,TRUE) : - NULL; - _form = new TDocumento_form(LISTADOC,*_firmrel); - const int hh = 6; - const int fl = printer().formlen(); - int rows[4]; - rows[0] = hh-2; - rows[1] = hh; - rows[2] = fl; - rows[3] = 0; - _form->cursor()->setkey(_key); - darec.put(DOC_DATADOC, _dadata); - darec.put(DOC_PROVV, _provv); - darec.put(DOC_ANNO, _anno); - arec = darec; - arec.put(DOC_DATADOC, _adata); - _form->cursor()->setregion(darec,arec); - - const bool dettaglio = _selection_mask->get_bool(F_DETTAGLIO); - _form->find_field('B', odd_page, "H_RIGHE").enable(dettaglio); // Visualizza i dettagli righe se richiesto - _form->find_field('B', odd_page, "RIGHE").enable(dettaglio); - - set_filter(); - if (_form->cursor()->items()) - _form->print(); - delete _form; - - if (pi != NULL) delete pi; - printer().close(); -} - -void TStampaDoc_application::set_filter() -{ - TCursor* cur = _form->cursor(); - TString filtro,e1,e2,sw; - - // Compone la lista dei clienti/forntitori selezionati - _clifo_sel.destroy(); - TString16 key; - const long items = _clifo_sheet->items(); - for (long i = 0L; ichecked(i)) - { - key.format("%06ld", _clifo_sheet->row(i).get_long(1)); // Formatta il codice - _clifo_sel.add(key, NULL); - } - // NB: se _clifo_sel non contiene nulla, non viene effettuato alcun filtro su CLI/FO (non setta la funzione!!) - filtro.format("TIPOCF==\"%c\"", _selection_mask->get(F_TIPOCF)[0]); - - const int selval = _selection_mask->get_int(F_SELVAL); - const TString16 val = _selection_mask->get(F_VALUTA); - const int ndec = TCurrency::get_firm_dec(); - - _form->edit_picture(_form->find_field('F',last_page, 6), ndec); // pictures per totali finali - _form->edit_picture(_form->find_field('F',last_page, 8), ndec); - _form->edit_picture(_form->find_field('F',last_page, 10), ndec); - _form->edit_picture(_form->find_field('F',last_page, 12), ndec); - _form->edit_picture(_form->find_field('F',last_page, 16), ndec); - _form->edit_picture(_form->find_field('F',last_page, 17), ndec); - if (selval == 1) //In Lire - { - const TString16 firm_val(TCurrency::get_firm_val()); - const bool not_empty = firm_val.not_empty(); - - filtro << "&&"; - if (not_empty) - filtro << "((CODVAL==\"" << firm_val << "\")||"; - filtro << "(CODVAL==\"\")"; - if (not_empty) - filtro << ")"; - } - else - if (selval == 2) // nella valuta specificata - filtro << "&&(CODVAL==\"" << val << "\")"; - else - _form->find_field('B',odd_page,35).set("1"); // Cosi' effettua i totali generali in lire ????? - - // Compone l'espressione filtro... - // prende tutte le righe dello spreasheet che non sono totalmente vuote: - // (CODNUM=="xxx"&&(STATO=="x"||STATO=="y"||STATO=="z"...)) ---> questo per una singola riga... - // se vi sono piu' righe, lo si ripete aggiungendo prima un bellissimo "||" - bool put_parentheses = FALSE; - TSheet_field& sf = (TSheet_field&)_selection_mask->field(F_SHEETNUMS); - const int rows = sf.items(); - for (int j=0; jsetfilter(filtro); - cur->set_filterfunction(_clifo_sheet->checked() > 0 ? filter_clifo : NULL); -} - -//////////////////////////////////////////////////////////////// -// Handlers della maschera -//////////////////////////////////////////////////////////////// -long TStampaDoc_application::select_cod_range(long from, long to) -{ - if (to == 0l) to = 999999L; - - for (int i = 0; i < _clifo_sheet->items(); i++) - { - TToken_string& c = _clifo_sheet->row(i); - - const long cod = c.get_long(1); - if (cod >= from && cod <= to) - _clifo_sheet->check(i); - else - _clifo_sheet->uncheck(i); - } - - return _clifo_sheet->checked(); -} - -void TStampaDoc_application::build_clifo_list(const char c) -{ - TLocalisamfile clifo(LF_CLIFO); - _clifo_sheet->destroy(); // Distrugge la lista - TToken_string tt; - - TRecfield tipocf(clifo.curr(), CLI_TIPOCF); - clifo.zero(); - clifo.put(CLI_TIPOCF, c); - - for (clifo.read(_isgteq); !clifo.eof(); clifo.next()) // Compila la lista!! - { - if (((const char*)tipocf)[0] != c) - break; - tt = ""; - tt.add(" "); - tt.add(clifo.get(CLI_CODCF)); - tt.add(clifo.get(CLI_RAGSOC)); - _clifo_sheet->add(tt); - } -} - -bool TStampaDoc_application::tipocf_handler(TMask_field& f, KEY key) -{ - if (f.to_check(key) && key == K_TAB) - { - app().begin_wait(); - app().reset_choices(f.mask()); - app().build_clifo_list(f.get()[0]); - app().end_wait(); - } - return TRUE; -} - -bool TStampaDoc_application::fr_cod_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask(); - if (key == K_F9) - { - TMask& m = f.mask(); - TArray_sheet* sh = app()._clifo_sheet; - - sh->disable_check(); - sh->disable(DLG_USER); - if (sh->run() == K_ENTER) - { - app().select_cod_range(sh->row(sh->selected()).get_long(1), m.get_long(F_CODTO)); - app().set_choice_limits(m); - } - sh->enable(DLG_USER); - } - else if (key == K_TAB && f.focusdirty()) - { - const long l = app().select_cod_range(m.get_long(F_CODFR), m.get_long(F_CODTO)); - app().set_choice_limits(m); - m.set(F_SELECTED, l); - } - return TRUE; -} - -bool TStampaDoc_application::to_cod_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask(); - if (key == K_F9) - { - TArray_sheet* sh = app()._clifo_sheet; - TMask& m = f.mask(); - - sh->disable_check(); - sh->disable(DLG_USER); - if (sh->run() == K_ENTER) - { - app().select_cod_range(m.get_long(F_CODFR),sh->row(sh->selected()).get_long(1)); - app().set_choice_limits(m); - } - sh->enable(DLG_USER); - } - if (key == K_TAB && f.focusdirty()) - { - const long l = app().select_cod_range(m.get_long(F_CODFR), - m.get_long(F_CODTO)); - app().set_choice_limits(m); - m.set(F_SELECTED, l); - } - return TRUE; -} - -bool TStampaDoc_application::select_button(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - app()._clifo_sheet->enable_check(); - if (app()._clifo_sheet->run() == K_ENTER) - app().set_choice_limits(f.mask()); - } - return TRUE; -} - -void TStampaDoc_application::reset_choices(TMask& m) -{ - m.reset(F_SELECTED); - m.reset(F_CODFR); - m.reset(F_CODTO); - _clifo_sheet->check(-1, FALSE); -} - -bool TStampaDoc_application::reset_button(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - app().reset_choices(f.mask()); - return TRUE; -} - -void TStampaDoc_application::set_choice_limits(TMask& m) -{ - long first = -1l, last = -1l; - for (int i = 0; i < _clifo_sheet->items(); i++) - { - if (_clifo_sheet->checked(i)) - { - const long cf = _clifo_sheet->row(i).get_long(1); - if (first == -1l) - first = cf; - if (last < cf) - last = cf; - } - } - if (first != -1) - m.set(F_CODFR, first); - if (last != -1) - m.set(F_CODTO, last); - m.set(F_SELECTED, _clifo_sheet->checked()); -} - -bool TStampaDoc_application::date2num_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask(); - if (key == K_TAB && f.focusdirty()) - { - short dlg = f.dlg(); - TLocalisamfile doc(LF_DOC); - doc.setkey(3); - TString codnum1(m.get(F_CODNUM)),codnum2; - TString anno1(m.get(F_ANNO)),anno2; - TString provv1(m.get(F_PROVV)),provv2; - TDate data1(m.get_date(dlg)),data2; - long numdoc; - doc.zero(); - doc.put("CODNUM", codnum1); - doc.put("ANNO", anno1); - doc.put("PROVV", provv1); - doc.put("DATADOC", data1); - if (doc.read(_isgteq) == NOERR) - { - codnum2 = doc.get("CODNUM"); - anno2 = doc.get("ANNO"); - provv2 = doc.get("PROVV"); - data2 = doc.get_date("DATADOC"); - if (codnum1 == codnum2 && anno1 == anno2 && provv1 == provv2 && data1 == data2) - { - numdoc = doc.get_long("NDOC"); - m.set(dlg == F_DA_DATADOC ? F_DA_NDOC : F_A_NDOC, numdoc); - } - } - } - return TRUE; -} - -bool TStampaDoc_application::range_handler(TMask_field& f, KEY key) -{ - bool rt = TRUE; - TMask& m = f.mask(); - if (key == K_TAB && f.focusdirty()) - { - const long lim_sup = atol(f.get()); - const long lim_inf = m.get_long(F_DA_NDOC); - if (lim_sup < lim_inf) - { - f.error_box("Il limite superiore deve essere maggiore del limite inferiore"); - rt = FALSE; - } - } - return rt; -} - -//////////////////////////////////////////////////////////////// -// Filtro per cli/fo sul cursore della lista documenti -//////////////////////////////////////////////////////////////// -bool TStampaDoc_application::filter_clifo(const TRelation* r) -{ - const long codcf = r->lfile().get_long(CLI_CODCF); - TString16 key; - key.format("%06ld", codcf); - - return app()._clifo_sel.is_key(key); -} - -//////////////////////////////////////////////////////////////// -// Funzioni rimanenti -//////////////////////////////////////////////////////////////// - -bool TStampaDoc_application::create() -{ - _firmrel= new TRelation(LF_NDITTE); // istanziamento e impostazione della relazione di gestione della ditta corrente - _firmrel->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR"); - _firmrel->add(LF_UNLOC,"CODDITTA=CODDITTA"); // si posiziona sulla prima unita' locale della ditta - _firmrel->add(LF_COMUNI, "COM=STATORES+COMRES", 1, LF_ANAG, 100+LF_COMUNI); - _firmrel->add(LF_COMUNI, "COM=STATORES+COMRF", 1, LF_ANAG, 200+LF_COMUNI); - open_files(LF_TABCOM, LF_TAB, LF_OCCAS, LF_CLIFO, LF_INDSP, LF_CFVEN, LF_MOVMAG, LF_RMOVMAG, LF_CONDV, LF_ANAMAG , LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CAUSALI, 0); - const int argc = TApplication::argc(); - - on_firm_change(); - _selection_mask = new TMask("si0200a"); - _clifo_sheet = new TArray_sheet(3, 3, -3, -3, "Selezione Clienti/Fornitori", - "@1|Codice@6R|Descrizione@50"); - build_clifo_list(); // Costruisce l'array sheet dei clienti (si parte!!) - - _selection_mask->set_handler(F_TIPOCF, tipocf_handler); - _selection_mask->set_handler(F_CODFR, fr_cod_handler); - _selection_mask->set_handler(F_CODTO, to_cod_handler); - _selection_mask->set_handler(BUT_SEL, select_button); - _selection_mask->set_handler(BUT_ANN, reset_button); +bool TListe_application::create() +{ + if (argc() < 3) + return error_box("manca il nome del form di stampa"); + open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, + LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, + LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0); + _formname == argv(2); + _select_mask = new TMask("ve0200a"); + _form = new TListe_form(_formname); + return TSkeleton_application::create(); } -bool TStampaDoc_application::destroy() +void TListe_application::set_limits() +{ + TCursor * c = _form->cursor(); + TRelation * r = c->relation(); + TString16 tipo(_select_mask->get(F_TIPOCF)); + TString16 cli_fr(_select_mask->get(F_CODFR)); + TString16 cli_to(_select_mask->get(F_CODTO)); + TRectype from(LF_CLIFO); + from.put("TIPOCF", tipo); + TRectype to(from); + + if (cli_fr.empty() && cli_to.empty()) + { + TString16 rag_fr(_select_mask->get(F_RAGSOCFR)); + if (rag_fr.not_empty()) + from.put("RAGSOC", rag_fr); + TString16 rag_to(_select_mask->get(F_RAGSOCTO)); + if (rag_to.not_empty()) + to.put("RAGSOC", rag_to); + r->lfile().setkey(2); + + } + else + { + TString16 cli_fr(_select_mask->get(F_CODFR)); + if (cli_fr.not_empty()) + from.put("CODCF", cli_fr); + TString16 rag_to(_select_mask->get(F_CODTO)); + if (rag_to.not_empty()) + to.put("CODCF", cli_to); + r->lfile().setkey(1); + + } + c->setregion(from, to); + TString filter; + + filter << format("((33->ANNO == %d)", _select_mask->get_int(F_ANNO)); + filter << format("&& (33->PROVV == %c)", _select_mask->get(F_PROVV)[0]); + TSheet_field & s = _select_mask->sfield(F_SHEETNUMS); + const int rows = s.items(); + + for (int i = 0; i < rows; i++) + { + TString numfilter("&& ("); + TToken_string r = s.row(i); + + numfilter << format("33->CODNUM == %s", (const char *)r.get(0)); + + for (int j = 0; j < 6; j++) + { + const int stato = r.get_int(); + + if (stato > 0) + numfilter << format("&& (33->STATO == %d)", stato); + } + if (numfilter.not_empty()) + filter << numfilter; + } + TDate data_fr(_select_mask->get(F_DA_DATADOC)); + if (data_fr.ok()) + filter << format("&& (33->DATADOC >= %s)", (const char *) data_fr.string(ANSI)); + TDate data_to(_select_mask->get(F_A_DATADOC)); + if (data_to.ok()) + filter << format("&& (33->DATADOC >= %s)", (const char *) data_to.string(ANSI)); + TDate art_fr(_select_mask->get(F_DA_DATADOC)); + if (art_fr.ok()) + filter << format("&& (34->CODARTMAG >= %s)", (const char *) art_fr); + TDate art_to(_select_mask->get(F_A_DATADOC)); + if (art_to.ok()) + filter << format("&& (34->CODARTMAG >= %s)", (const char *) art_to); + filter << ")"; + + c->setfilter(filter, TRUE); +} + +bool TListe_application::destroy() { - delete _firmrel; // distruzione della relazione di gestione della ditta corrente - delete _selection_mask; - delete _clifo_sheet; + delete _select_mask; + delete _form; return TApplication::destroy(); } -void TStampaDoc_application::on_firm_change() +void TListe_application::main_loop() { - TLocalisamfile &firmfile= _firmrel->lfile(); - firmfile.put("CODDITTA", get_firm()); - _firmrel->read(); -} - -bool TStampaDoc_application::select() -{ - TMask& m = * _selection_mask; - - m.reset(); - reset_choices(m); - if (m.run() == K_ENTER) - { - _anno= m.get_int(F_ANNO); - _provv= m.get(F_PROVV)[0]; - _dadata = m.get_date(F_DA_DATADOC); - if (!_dadata.ok()) - _dadata = TDate(1,1,_anno); - _adata = m.get_date(F_A_DATADOC); - if (!_adata.ok()) - _adata = TDate(31,12,_anno); - _key = BY_NUM_KEY; - - return TRUE; + while (_select_mask->run()) + { + set_limits(); + _form->print(); } - else - return FALSE; -} - -void TStampaDoc_application::main_loop() -{ - while (select()) - print_selected(); } // Do all the work! int si0200(int argc, char* argv[]) { - TStampaDoc_application a; + TListe_application a; a.run(argc, argv, "Lista documenti"); return (0); } diff --git a/si/si0200a.h b/si/si0200a.h index 621dc7e15..03e3ab13b 100755 --- a/si/si0200a.h +++ b/si/si0200a.h @@ -1,6 +1,20 @@ -// trasferimento dati a CT Bologna -// definizione campi per maschera di selezione +#define F_CODNUM 101 +#define F_ANNO 102 +#define F_PROVV 103 +#define F_DA_NDOC 106 +#define F_A_NDOC 107 -//#define F_TRASFERIMENTO 101 // trasferimento totale o parziale -#define F_DATAINI 101 // data inizio modifiche per trasferimento parziale -#define F_FILENAME 102 // nome del file dove scaricare i dati +#define F_DA_DATADOC 108 +#define F_A_DATADOC 109 + +#define F_TIPOCF 110 +#define F_CODFR 111 +#define F_CODTO 112 +#define F_RAGSOCFR 113 +#define F_RAGSOCTO 114 +#define F_SERVFR 115 +#define F_SERVTO 116 + +#define F_SHEETNUMS 201 + +#define GROUP_IMPORTI 31 \ No newline at end of file diff --git a/si/si0200a.uml b/si/si0200a.uml index a93f710b4..6d9f70669 100755 --- a/si/si0200a.uml +++ b/si/si0200a.uml @@ -1,237 +1,228 @@ -TO "" 0 -3 0 2 -ST 30 70 50 -BE -PR 2 -3 "Profilo " -PSELECT -GR 1 -EN -BU 24 10 2 -BE -PR -12 -1 "~Stampa" -ME EXIT,13 -EN -BU 2 10 2 -BE -PR -22 -1 "" -EN -EN +#include "si0200a.h" + +TOOLBAR "" 0 -3 0 2 +STRING DLG_PROFILE 70 50 +BEGIN + PR 2 -3 "Profilo " + PSELECT + GR 1 +END + +BUTTON DLG_PRINT 10 2 +BEGIN + PROMPT -12 -1 "~Stampa" + MESSAGE EXIT,K_ENTER +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -22 -1 "" +END +ENDPAGE PA "Stampe Pagamenti" -1 2 80 20 -NU 102 4 0 -BE -PR 2 1 "Anno " -FLAG "P" -CH REQUIRED -EN -LI 103 12 -BE -PR 25 1 "Tipo numerazione " -IT "D|Definitiva" -IT "P|Provvisoria" -FLAG "P" -EN -SPREADSHEET 201 78 4 -BE -PR 1 2 "" -IT "Cod. num." -IT "Stato 1" -IT "Stato 2" -IT "Stato 3" -IT "Stato 4" -IT "Stato 5" -IT "Stato 6" -EN +NUMBER F_ANNO 4 0 +BEGIN + PROMPT 2 1 "Anno " + FLAG "P" + CHECKTYPE REQUIRED +END -LI 110 1 9 -BE -PR 2 7 "Tipo " -IT "C|Clienti" -IT "F|Fornitori" -EN +LIST F_PROVV 12 +BEGIN + PROMPT 25 1 "Tipo numerazione " + ITEM "D|Definitiva" + ITEM "P|Provvisoria" + FLAG "P" +END -NU 111 6 -BE -PR 68 8 "" -FL "B" -EN -NU 112 6 -BE -PR 68 9 "" -FL "B" -EN +SPREADSHEET F_SHEETNUMS 55 8 +BEGIN + PROMPT 1 2 "" + ITEM "Cod. num." + ITEM "Stato 1" + ITEM "Stato 2" + ITEM "Stato 3" + ITEM "Stato 4" + ITEM "Stato 5" + ITEM "Stato 6" +END -ST 119 50 50 -BE -PR 2 8 "Dal Cliente " -US 20 KE 2 -IN TIPOCF 110 -IN RAGSOC 119 -DI "Ragione Sociale@50" RAGSOC -DI "Codice " CODCF -OU 111 CODCF -OU 119 RAGSOC -EN -ST 120 50 50 -BE -PR 2 9 "Al Cliente " -US 20 KE 2 -IN TIPOCF 110 -IN RAGSOC 120 -DI "Ragione Sociale@50" RAGSOC -DI "Codice " CODCF -OU 112 CODCF -OU 120 RAGSOC -EN -ST 121 20 -BE -PR 2 10 "Dal Servizio " -US 47 KE 1 -IN CODART 121 -DI "Codice " CODART -DI "Descrizione@50" DESCR -OU 121 CODART -EN -ST 122 20 -BE -PR 2 11 "Al Servizio " -US 47 KE 1 -IN CODART 122 -DI "Codice " CODART -DI "Descrizione@50" DESCR -OU 122 CODART -EN +LIST F_TIPOCF 1 9 +BEGIN + PROMPT 2 10 "Tipo " + ITEM "C|Clienti" + ITEM "F|Fornitori" +END -DA 108 -BE -PR 2 12 "Dalla Data " -EN -DA 109 -BE -PR 27 12 "Alla Data " -EN +STRING F_RAGSOCFR 50 +BEGIN + PROMPT 2 11 "Dal Cliente " + USE LF_CLIFO KEY 2 + INPUT TIPOCF F_TIPOCF SELECT + INPUT RAGSOC F_RAGSOCFR + DISPLAY "Ragione Sociale@50" RAGSOC + DISPLAY "Codice " CODCF + OUTPUT F_RAGSOCFR RAGSOC + OUTPUT F_CODFR CODCF +END +NUMBER F_CODFR 6 +BEGIN + PROMPT 68 11 "Da codice " + USE LF_CLIFO + INPUT TIPOCF F_TIPOCF SELECT + INPUT CODCF F_CODFR + DISPLAY "Codice " CODCF + DISPLAY "Ragione Sociale@50" RAGSOC + COPY OUTPUT F_RAGSOCFR +END -ST 113 5 +STRING F_RAGSOCTO 50 BE -PR 25 16 "Scelte n. " -FL "DR" -EN + PROMPT 2 12 "Al Cliente " + USE LF_CLIFO KEY 2 + INPUT TIPOCF F_TIPOCF SELECT + INPUT RAGSOC F_RAGSOCTO + DISPLAY "Ragione Sociale@50" RAGSOC + DISPLAY "Codice " CODCF + OUTPUT F_RAGSOCTO RAGSOC + OUTPUT F_CODTO CODCF +END -BU 114 10 2 -BE -PR 45 16 "~Selezione" -PI 115 -EN -BU 115 10 -BE -PR 45 18 "A~zzera" -EN -RA 116 20 -BE -PR 2 15 "Stampa documenti" -IT "1|Valuta ditta" -ME CLEAR,117 -IT "2|In valuta" -ME ENABLE,117 -IT "3|Tutti" -ME CLEAR,117 -EN -ST 117 3 -BE -PR 25 17 "Cod. val. " -FL "U" -US %VAL -IN CODTAB 117 -DI "Codice" CODTAB -DI "Descrizione@50" S0 -OU 117 CODTAB -CH REQUIRED -EN -BO 118 -BE -PR 25 18 "Dettaglio righe" -EN -EN +NUMBER F_CODTO 6 +BEGIN + PROMPT 68 12 "A codice " + USE LF_CLIFO + INPUT TIPOCF F_TIPOCF SELECT + INPUT CODCF F_CODTO + DISPLAY "Codice " CODCF + DISPLAY "Ragione Sociale@50" RAGSOC + COPY OUTPUT F_RAGSOCTO +END + +STRING F_SERVFR 20 +BEGIN + PROMPT 2 13 "Dal Servizio " + USE 47 + INPUT CODART F_SERVFR + DISPLAY "Codice " CODART + DISPLAY "Descrizione@50" DESCR + OUTPUT F_SERVFR CODART +END + +STRING F_SERVTO 20 +BEGIN + PR 2 14 "Al Servizio " + USE 47 + INPUT CODART F_SERVTO + DISPLAY "Codice " CODART + DISPLAY "Descrizione@50" DESCR + OUTPUT F_SERVTO CODART +END + +DATE F_DA_DATADOC +BEGIN + PROMPT 2 15 "Dalla Data " +END + +DATE F_A_DATADOC +BEGIN + PROMPT 27 15 "Alla Data " +END + +ENDPAGE ENDMASK -PA "" -1 -1 75 10 -ST 101 4 -BE -PR 1 1 "Codice numerazione " -FLAG "U" -US %NUM -IN CODTAB 101 -DI "Cod. Num." CODTAB -DI "Descrizione@50" S0 -OU 101 CODTAB -CH NORMAL -EN -ST 102 1 -BE -PR 1 3 "Stato 1 " -US %STD -IN CODTAB 102 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 102 CODTAB -CH NORMAL -EN -ST 103 1 -BE -PR 1 4 "Stato 2 " -US %STD -IN CODTAB 103 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 103 CODTAB -CH NORMAL -EN -ST 104 1 -BE -PR 1 5 "Stato 3 " -US %STD -IN CODTAB 104 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 104 CODTAB -CH NORMAL -EN -ST 105 1 -BE -PR 1 6 "Stato 4 " -US %STD -IN CODTAB 105 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 105 CODTAB -CH NORMAL -EN -ST 106 1 -BE -PR 1 7 "Stato 5 " -US %STD -IN CODTAB 106 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 106 CODTAB -CH NORMAL -EN -ST 107 1 -BE -PR 1 8 "Stato 6 " -US %STD -IN CODTAB 107 -DI "Stato" CODTAB -DI "Descrizione@50" S0 -OU 107 CODTAB -CH NORMAL -EN -BU 1 9 2 -BE -PR -12 -1 "" -EN -BU 2 9 2 -BE -PR -22 -1 "" -EN -EN + +PAGE "" -1 -1 75 10 + +STRING 101 4 +BEGIN + PROMPT 1 1 "Codice numerazione " + FLAG "U" + USE %NUM + INPUT CODTAB 101 + DISPLAY "Cod. Num." CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 101 CODTAB + CHECKTYPE NORMAL +END + +STRING 102 1 +BEGIN + PROMPT 1 3 "Stato 1 " + USE %STD + INPUT CODTAB 102 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 102 CODTAB + CHECKTYPE NORMAL +END + +STRING 103 1 +BEGIN + PROMPT 1 4 "Stato 2 " + USE %STD + INPUT CODTAB 103 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 103 CODTAB + CHECKTYPE NORMAL +END + +STRING 104 1 +BEGIN + PROMPT 1 5 "Stato 3 " + USE %STD + INPUT CODTAB 104 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 104 CODTAB + CHECKTYPE NORMAL +END + +STRING 105 1 +BEGIN + PROMPT 1 6 "Stato 4 " + USE %STD + INPUT CODTAB 105 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 105 CODTAB + CHECKTYPE NORMAL +END + +STRING 106 1 +BEGIN + PROMPT 1 7 "Stato 5 " + USE %STD + INPUT CODTAB 106 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 106 CODTAB + CHECKTYPE NORMAL +END + +STRING 107 1 +BEGIN + PROMPT 1 8 "Stato 6 " + USE %STD + INPUT CODTAB 107 + DISPLAY "Stato" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT 107 CODTAB + CHECKTYPE NORMAL +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_CANCEL 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE ENDMASK