Patch level : 12.00 nopatch
Files correlati : Commento : Ricerca dei report per descrizione
This commit is contained in:
		
							parent
							
								
									4b95782d3d
								
							
						
					
					
						commit
						b1387820bf
					
				| @ -1682,9 +1682,12 @@ bool TProfile_select::check(CheckTime ct) | ||||
| // TReport_select
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| TReport_select::TReport_select(TEdit_field* ef, const char* classe) | ||||
| : TBrowse_button(ef), _classe(classe) | ||||
| { } | ||||
| TReport_select::TReport_select(TEdit_field* ef, const char* classe, const char *type) | ||||
| 	: TBrowse_button(ef), _classe(classe), _type(type), _required(false) | ||||
| { | ||||
| 	if ( _type.blank()) | ||||
| 		_type = "D"; | ||||
| } | ||||
| 
 | ||||
| void TReport_select::parse_input(TScanner& scanner) | ||||
| { | ||||
| @ -1698,40 +1701,36 @@ void TReport_select::parse_output(TScanner& scanner) | ||||
|            | ||||
| KEY TReport_select::run() | ||||
| { | ||||
|   TFilename path = field().get(); | ||||
|   TFilename repdescr = field().get_window_data(); | ||||
| 
 | ||||
|   if (select_custom_file(path, "rep", _classe)) | ||||
|   { | ||||
| 		path = path.name(); | ||||
|     path.ext(""); | ||||
|     field().set(path); | ||||
|   } | ||||
| 
 | ||||
|   return path.not_empty() ? K_ENTER : K_ESC; | ||||
|   if (select_custom_file(repdescr, "rep", _type, _classe)) | ||||
|     field().set(repdescr); | ||||
|   return repdescr.full() ? K_ENTER : K_ESC; | ||||
| } | ||||
| 
 | ||||
| bool TReport_select::check(CheckTime ct) | ||||
| { | ||||
|   TFilename name = field().get(); | ||||
| 	 | ||||
| 	TFilename name; | ||||
| 
 | ||||
| 	if (ct == STARTING_CHECK || ct == RUNNING_CHECK || ct == FINAL_CHECK) | ||||
| 	{ | ||||
| 		TString_array reps; | ||||
| 		const TString & repdescr = field().get_window_data(); | ||||
| 
 | ||||
| 		list_custom_files("rep", _classe, reps); | ||||
| 		if (name.empty()) | ||||
| 
 | ||||
| 		list_custom_files("rep", _classe, reps, _type); | ||||
| 
 | ||||
| 		if (repdescr.empty()) | ||||
| 		{ | ||||
| 
 | ||||
| 			if (reps.items() > 0) | ||||
| 				field().set(((TToken_string &)reps[0]).get(0)); | ||||
| 				field().set_window_data(((TToken_string &)reps[0]).get(0)); | ||||
| 			else | ||||
| 				field().set(""); | ||||
| 				field().set_window_data(""); | ||||
| 		} | ||||
| 		if (ct == RUNNING_CHECK || ct == FINAL_CHECK) | ||||
| 		{ | ||||
| 			const TString & repname = field().get(); | ||||
| 
 | ||||
| 			if (repname.blank() && ct == FINAL_CHECK) | ||||
| 			if (repdescr.blank() && ct == FINAL_CHECK) | ||||
| 				return field().error_box(TR("Il report deve essere specificato")); | ||||
| 			if (_classe.full()) | ||||
| 			{ | ||||
| @ -1741,12 +1740,15 @@ bool TReport_select::check(CheckTime ct) | ||||
| 				{ | ||||
| 					TToken_string * row = (TToken_string *)obj; | ||||
| 
 | ||||
| 					found = (repname == row->get(0)); | ||||
| 					found = (repdescr == row->get(0)); | ||||
| 					if (found) | ||||
| 					{ | ||||
| 						name = row->get(descr_type() ? 1 : 0); | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
| 				if (!found) | ||||
| 					return field().error_box(FR("Il report %s non è compatibile"), (const char *)repname); | ||||
| 					return field().error_box(FR("Il report %s non è compatibile"), (const char *)repdescr); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @ -1760,13 +1762,38 @@ void TReport_select::set_report_class(const char * classe) | ||||
| 	TString_array reps; | ||||
| 
 | ||||
| 	_classe = classe; | ||||
| 	list_custom_files("rep", _classe, reps); | ||||
| 	list_custom_files("rep", _classe, reps, _type); | ||||
| 	if (reps.items()) | ||||
| 		field().set(reps[0].get()); | ||||
| 	else | ||||
| 		field().set(""); | ||||
| } | ||||
| 
 | ||||
| const TString & TReport_select::get_path(const char * name) | ||||
| { | ||||
| 	TString repdescr = name; | ||||
| 	bool found = false; | ||||
| 	TFilename path; | ||||
| 	TString_array reps; | ||||
| 
 | ||||
| 	list_custom_files("rep", _classe, reps, _type); | ||||
| 	FOR_EACH_ARRAY_ITEM(reps, r, obj) | ||||
| 	{ | ||||
| 		TToken_string * row = (TToken_string *)obj; | ||||
| 
 | ||||
| 		found = (repdescr == row->get(0)); | ||||
| 		if (found) | ||||
| 		{ | ||||
| 			path = row->get(0); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	if (cod_type() && !required() && path.blank()) | ||||
| 		path = name; | ||||
| 
 | ||||
| 	return get_tmp_string() = path; | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| //   TFuzzy_browse
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
|  | ||||
| @ -384,8 +384,9 @@ public: | ||||
| 
 | ||||
| class TReport_select : public TBrowse_button | ||||
| { | ||||
|   TString _classe; | ||||
| 
 | ||||
| 	TString _classe; | ||||
| 	TString4 _type; | ||||
| 	bool _required; | ||||
| 
 | ||||
| public: | ||||
|   // @cmember Controlla la sintassi della input del campo e ne setta i membri
 | ||||
| @ -404,8 +405,13 @@ public: | ||||
| 
 | ||||
| 	void set_report_class(const char * classe); | ||||
| 	const TString & get_report_class() const { return _classe; } | ||||
| 	const TString & get_path(const char * name); | ||||
| 	bool descr_type() const { return _type == "D"; } | ||||
| 	bool cod_type() const { return _type == "C"; } | ||||
| 	void set_required(bool on = true) { _required = on; } | ||||
| 	bool required() const { return _required; } | ||||
| 
 | ||||
|   TReport_select(TEdit_field* ef, const char* classe); | ||||
| 	TReport_select(TEdit_field* ef, const char* classe, const char * type); | ||||
|   virtual ~TReport_select() { } | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -404,7 +404,14 @@ void TMask_field::construct(TScanner& scanner, WINDOW parent) | ||||
| 
 | ||||
|   while(scanner.popkey() != "EN")       // END of control
 | ||||
|     parse_item(scanner); | ||||
| 	if (this->is_kind_of(CLASS_EDIT_FIELD)) | ||||
| 	{ | ||||
| 		TEdit_field & e = (TEdit_field &)*this; | ||||
| 		TReport_select * rs = e.reportsel(); | ||||
| 
 | ||||
| 		if (rs != nullptr) | ||||
| 			rs->set_required(e.check_type() == CHECK_REQUIRED); | ||||
| 	} | ||||
| 	if (is_edit()) | ||||
| 	{ | ||||
| 		TBrowse* b = ((TEdit_field*)this)->browse(); | ||||
| @ -1941,6 +1948,13 @@ void TEditable_field::set_field(const TString& fr) | ||||
| // Legge il valore attuale del campo in formato RAW
 | ||||
| const TString& TEditable_field::get() const | ||||
| { | ||||
| 	if (is_kind_of(CLASS_EDIT_FIELD)) | ||||
| 	{ | ||||
| 		TReport_select * b = ((TEdit_field *)this)->reportsel(); | ||||
| 
 | ||||
| 		if (b != nullptr) | ||||
| 			return b->get_path(_str); | ||||
| 	} | ||||
|   return _str; | ||||
| } | ||||
| 
 | ||||
| @ -2203,7 +2217,7 @@ const TBrowse* TEdit_field::parse_browse(TScanner& scanner) const | ||||
|   return b; | ||||
| } | ||||
| 
 | ||||
| bool TEdit_field::set_selector(char s, const TString& str) | ||||
| bool TEdit_field::set_selector(char s, const TString& str, const TString & type) | ||||
| { | ||||
| #ifdef DBG     | ||||
|   if (_browse)  | ||||
| @ -2216,7 +2230,7 @@ bool TEdit_field::set_selector(char s, const TString& str) | ||||
|     case 'D': _browse = new TDir_select(this); break; | ||||
|     case 'F': _browse = new TFile_select(this, str); break; | ||||
|     case 'P': _browse = new TProfile_select(this); set_default("NONE"); break; | ||||
|     case 'R': _browse = new TReport_select(this, str); break; | ||||
|     case 'R':	_browse = new TReport_select(this, str, type); break; | ||||
|     default: break; | ||||
|     } | ||||
| 
 | ||||
| @ -2429,17 +2443,26 @@ bool TEdit_field::parse_item(TScanner& scanner) | ||||
| 
 | ||||
|   if (scanner.key() == "DS")            // DSELECT
 | ||||
|   { | ||||
|     return set_selector('D', EMPTY_STRING); | ||||
|     return set_selector('D'); | ||||
|   } | ||||
| 
 | ||||
|   if (scanner.key() == "PS")            // PSELECT
 | ||||
|   { | ||||
|     return set_selector('P', EMPTY_STRING); | ||||
|     return set_selector('P'); | ||||
|   } | ||||
| 
 | ||||
|   if (scanner.key() == "RS")            // RSELECT
 | ||||
|   { | ||||
|     return set_selector('R', scanner.string()); | ||||
| 		TString classe = scanner.string(); | ||||
| 		TString type = scanner.line(); | ||||
| 		 | ||||
| 		type.upper(); | ||||
| 		if (type != "D" &&  type != "C") | ||||
| 		{ | ||||
| 			scanner.push(); | ||||
| 			type.cut(0); | ||||
| 		} | ||||
|     return set_selector('R', classe, type); | ||||
|   } | ||||
| 
 | ||||
|   if (scanner.key() == "IT")            // ITEM
 | ||||
| @ -2675,6 +2698,7 @@ void TEdit_field::autoselect(bool on) | ||||
| TString& TEdit_field::get_window_data() | ||||
| { | ||||
|   _str = win2raw(_ctl->caption()); | ||||
| 
 | ||||
|   return _str; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -872,9 +872,6 @@ protected: | ||||
| 
 | ||||
|   // @cmember Ritorna <p data> formattato secondo i flags settati del campo
 | ||||
|   virtual const char* reformat(const char* data) const; | ||||
| 
 | ||||
|   // @cmember Scrive il valore del campo direttamente sulla finestra del controllo
 | ||||
|   virtual void set_window_data(const char* data); | ||||
|    | ||||
|   // @cmember Mostra un messaggio di errore di default per il campo
 | ||||
|   bool default_error_box() const; | ||||
| @ -884,6 +881,9 @@ protected: | ||||
| 
 | ||||
|   // @access Public Member
 | ||||
| public: | ||||
| 	// @cmember Scrive il valore del campo direttamente sulla finestra del controllo
 | ||||
| 	virtual void set_window_data(const char* data); | ||||
| 
 | ||||
|   // @cmember Setta il flag read-only
 | ||||
| 	virtual void set_read_only(bool r); | ||||
| 
 | ||||
| @ -906,7 +906,7 @@ public: | ||||
|   // @cmember Imposta la ricerca del campo 
 | ||||
|   virtual void set_query_button(TBrowse_button* ); | ||||
|    | ||||
|   bool set_selector(char s, const TString& str); | ||||
|   bool set_selector(char s, const TString& str = EMPTY_STRING, const TString & type = EMPTY_STRING); | ||||
| 
 | ||||
|   // @cmember Ritorna true se il campo e' di tipo edit
 | ||||
|   virtual bool is_edit() const { return true; } | ||||
|  | ||||
| @ -1012,7 +1012,7 @@ static bool get_xml_child(const TString& line, const char* tag, TString& value) | ||||
|   return false; | ||||
| } | ||||
| 
 | ||||
| bool list_custom_files(const char* ext, const char* classe, TString_array& files) | ||||
| bool list_custom_files(const char* ext, const char* classe, TString_array& files, const char * type) | ||||
| { | ||||
|   TString_array lista; | ||||
|   TFilename path; | ||||
| @ -1061,10 +1061,20 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files | ||||
|       if (ok) | ||||
|       { | ||||
|         get_xml_child(stringona, "description", desc); | ||||
| 
 | ||||
|         TToken_string* riga = new TToken_string; | ||||
|         riga->add(*row); | ||||
| 
 | ||||
| 				if (type[0] == 'D') | ||||
| 				{ | ||||
| 					riga->add(desc); | ||||
| 					riga->add(*row); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					riga->add(*row); | ||||
| 					riga->add(desc); | ||||
| 				} | ||||
|         riga->add(acqua); | ||||
|         riga->add(desc);  | ||||
|         riga->add(path.find("custom") > 0 ? "X" : ""); | ||||
|         files.add(riga); | ||||
|       } | ||||
| @ -1073,20 +1083,21 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files | ||||
|   return !files.empty(); | ||||
| } | ||||
| 
 | ||||
| bool select_custom_file(TFilename& path, const char* ext, const char* library) | ||||
| bool select_custom_file(TFilename& descr, const char* ext, const char* type, const char* library) | ||||
| { | ||||
|   TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@16|Classe@8|Descrizione@50|Custom")); | ||||
| 	const TString header = type[0] == 'D' ? HR("Descrizione@50|Nome@16|Classe@8|Custom") : HR("Nome@16|Descrizione@50|Classe@8|Custom"); | ||||
|   TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), header); | ||||
|   TString_array& files = sheet.rows_array(); | ||||
|   TFilename first = path.name(); first.ext(""); // Riga su cui posizionarsi
 | ||||
|   bool ok = list_custom_files(ext, library, files); | ||||
|  // TFilename first = path.name(); first.ext(""); // Riga su cui posizionarsi
 | ||||
|   bool ok = list_custom_files(ext, library, files, type); | ||||
| 
 | ||||
|   if (ok) | ||||
|   { | ||||
|     if (first.full()) // Cerco la prima riga da selezionare se possibile
 | ||||
|     if (descr.full()) // Cerco la prima riga da selezionare se possibile
 | ||||
|     { | ||||
|       FOR_EACH_ARRAY_ROW(files, i, row) | ||||
|       { | ||||
|         if (first.compare(row->get(0), -1, true) == 0) // Ho trovato la selezione corrente
 | ||||
|         if (descr.compare(row->get(0), -1, true) == 0) // Ho trovato la selezione corrente
 | ||||
|         { | ||||
|           sheet.select(i); | ||||
|           break; | ||||
| @ -1096,11 +1107,7 @@ bool select_custom_file(TFilename& path, const char* ext, const char* library) | ||||
| 
 | ||||
|     ok = sheet.run() == K_ENTER; | ||||
|     if (ok) | ||||
|     { | ||||
|       path = sheet.row(-1).get(0); | ||||
|       path.ext(ext); | ||||
|       ok = path.custom_path(); | ||||
|   } | ||||
|       descr = sheet.row(-1).get(0); //
 | ||||
|   } | ||||
| 
 | ||||
|   return ok; | ||||
|  | ||||
| @ -199,8 +199,8 @@ public: | ||||
| // Utility
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| bool list_custom_files(const char* ext, const char* library, TString_array& files); | ||||
| bool select_custom_file(TFilename& path, const char* ext, const char* classe = NULL); | ||||
| bool list_custom_files(const char* ext, const char* library, TString_array& files, const char * type); | ||||
| bool select_custom_file(TFilename& descr, const char* exte, const char* type, const char* classe = NULL); | ||||
| const TString& logic2table(int logic_num); | ||||
| int table2logic(const TString& name); | ||||
| TRecordset* create_recordset(const TString& sql); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user