Files correlati : Ricompilazione Demo : [ ] Commento :aggiunta stampa bilancio di commessa riassuntivo di ogni fase (crpa request) git-svn-id: svn://10.65.10.50/trunk@15578 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			210 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			210 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
 | 
						|
#include "ca3.h"
 | 
						|
#include "ca3883.h"
 | 
						|
#include "ca3883a.h"
 | 
						|
#include "calib01.h"
 | 
						|
#include "calib02.h"
 | 
						|
#include "pconana.h"
 | 
						|
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	MASCHERA
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TPrint_stima_ricavi_mask : public TAnal_report_mask
 | 
						|
{
 | 
						|
protected:
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
	const TString& get_report_class() const; 
 | 
						|
  bool test_compatible_report();
 | 
						|
	
 | 
						|
public:
 | 
						|
  TPrint_stima_ricavi_mask();
 | 
						|
  virtual ~TPrint_stima_ricavi_mask() {}
 | 
						|
};
 | 
						|
 | 
						|
const TString& TPrint_stima_ricavi_mask::get_report_class() const
 | 
						|
{
 | 
						|
  TString& classe = get_tmp_string();
 | 
						|
  classe = "ca3900a";
 | 
						|
  return classe;
 | 
						|
}
 | 
						|
 | 
						|
bool TPrint_stima_ricavi_mask::test_compatible_report()
 | 
						|
{
 | 
						|
	const TString& cls = get_report_class();
 | 
						|
  const TString& name = get(F_REPORT);
 | 
						|
  bool ok = name.not_empty();
 | 
						|
  if (ok)
 | 
						|
  {
 | 
						|
    TReport rep; 
 | 
						|
    ok = rep.load(name);
 | 
						|
    if (ok)
 | 
						|
    {
 | 
						|
      const TString& classe = rep.get_class();
 | 
						|
      ok = classe == cls;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  if (!ok)
 | 
						|
  {
 | 
						|
    set(F_REPORT, cls);
 | 
						|
		TFilename path = cls;
 | 
						|
    path.ext("rep");
 | 
						|
    ok = path.custom_path();
 | 
						|
  }
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
bool TPrint_stima_ricavi_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{
 | 
						|
  switch (o.dlg())
 | 
						|
  {
 | 
						|
  case F_REPORT:
 | 
						|
    if (e == fe_button)
 | 
						|
    {
 | 
						|
      const TString8 lib = get_report_class();
 | 
						|
      TFilename path = o.get();
 | 
						|
      if (select_custom_file(path, "rep", lib))
 | 
						|
      {
 | 
						|
        path = path.name();
 | 
						|
        path.ext("");
 | 
						|
        o.set(path);
 | 
						|
      }
 | 
						|
    } else
 | 
						|
    if (e == fe_close)
 | 
						|
    {
 | 
						|
      if (!test_compatible_report())
 | 
						|
        return error_box(TR("Impossibile trovare un report compatibile"));
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  default: 
 | 
						|
		break;
 | 
						|
  }
 | 
						|
	return TAnal_report_mask::on_field_event(o, e, jolly);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
TPrint_stima_ricavi_mask::TPrint_stima_ricavi_mask()
 | 
						|
								:TAnal_report_mask("ca3900")
 | 
						|
{
 | 
						|
	TConfig& cfg = ca_config();
 | 
						|
	const bool use_pdcc = cfg.get_bool("UsePdcc");
 | 
						|
 | 
						|
  const TMultilevel_code_info& pconana_info = ca_multilevel_code_info(LF_PCONANA);
 | 
						|
  const int pconana_levels = pconana_info.levels();
 | 
						|
  
 | 
						|
  int prefix = cfg.get_int("PdcPrefix");
 | 
						|
  if (prefix >= pconana_levels)
 | 
						|
    prefix = pconana_levels-1;
 | 
						|
 | 
						|
	  // Controllo se voglio (e posso) usare il conto analitico come prefisso di quello contabile
 | 
						|
  if (use_pdcc && prefix > 0)
 | 
						|
  {
 | 
						|
    const TMultilevel_code_info& info = ca_multilevel_code_info(LF_PCONANA);
 | 
						|
    const int levels = info.levels();
 | 
						|
    if (levels >= 2 && prefix < levels && esistono_riclassificazioni())
 | 
						|
    {
 | 
						|
    	ca_create_fields(*this, 0, LF_PCONANA, 1, 13, F_PRE1, F_PREDES1, 0x0, PCONANA_CODCONTO);
 | 
						|
 | 
						|
      // Nascondi i campi che non fanno parte del prefisso
 | 
						|
	    for (int i = 0; i < levels; i++)
 | 
						|
	    {
 | 
						|
        if (i < prefix)
 | 
						|
        {
 | 
						|
          field(F_PRE1 + i).check_type(CHECK_REQUIRED);
 | 
						|
          field(F_PRE1 + i).set_group(6);
 | 
						|
          field(F_PREDES1 + i).set_group(6);
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
          field(F_PRE1 + i).hide();
 | 
						|
          field(F_PREDES1 + i).hide();
 | 
						|
        }
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
	
 | 
						|
	// setta gli handlers a tutti i campi generati della maschera;senza questa chiamata la on_field_event
 | 
						|
	// non puo' funzionare sui campi generati!!!
 | 
						|
	set_handlers();
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////////
 | 
						|
//	RECORDSET 
 | 
						|
///////////////////////////////////////////////////////////////
 | 
						|
class TPrint_stima_ricavi_recordset : public TPrint_saldana_recordset
 | 
						|
{
 | 
						|
 | 
						|
public:
 | 
						|
  TPrint_stima_ricavi_recordset() : TPrint_saldana_recordset(9) {}
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	REPORT
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TPrint_stima_ricavi_rep : public TAnal_report
 | 
						|
{
 | 
						|
 | 
						|
protected:
 | 
						|
	virtual bool set_recordset();
 | 
						|
	virtual bool get_usr_val(const TString& name, TVariant& var) const;
 | 
						|
 | 
						|
public:
 | 
						|
	void set_filter(const TPrint_stima_ricavi_mask& msk);
 | 
						|
};
 | 
						|
 | 
						|
bool TPrint_stima_ricavi_rep::get_usr_val(const TString& name, TVariant& var) const
 | 
						|
{
 | 
						|
	return TAnal_report::get_usr_val(name, var);
 | 
						|
}
 | 
						|
 | 
						|
bool TPrint_stima_ricavi_rep::set_recordset()
 | 
						|
{
 | 
						|
  TPrint_stima_ricavi_recordset* rs = new TPrint_stima_ricavi_recordset();
 | 
						|
  return TAnal_report::set_recordset(rs);
 | 
						|
}
 | 
						|
 | 
						|
void TPrint_stima_ricavi_rep::set_filter(const TPrint_stima_ricavi_mask& msk)
 | 
						|
{
 | 
						|
	TPrint_stima_ricavi_recordset* recset = new TPrint_stima_ricavi_recordset(); 
 | 
						|
 | 
						|
  recset->set_filter(msk, "");
 | 
						|
	TAnal_report::set_recordset(recset);
 | 
						|
}
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	APPLICAZIONE
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TPrint_stima_ricavi : public TSkeleton_application
 | 
						|
{
 | 
						|
public:
 | 
						|
  virtual void main_loop();
 | 
						|
};
 | 
						|
 | 
						|
void TPrint_stima_ricavi::main_loop()
 | 
						|
{
 | 
						|
  TPrint_stima_ricavi_mask mask;
 | 
						|
  while (mask.run() == K_ENTER)
 | 
						|
  {
 | 
						|
		//report e book dei report
 | 
						|
		TReport_book book;
 | 
						|
		TString path = mask.get(F_REPORT);
 | 
						|
		if (path.empty())
 | 
						|
			path = "ca3900a";
 | 
						|
		TPrint_stima_ricavi_rep rep;
 | 
						|
		rep.load(path);
 | 
						|
 | 
						|
		rep.set_filter(mask);	
 | 
						|
		book.add(rep);
 | 
						|
		book.print_or_preview();
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
int ca3900(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TPrint_stima_ricavi a;
 | 
						|
  a.run(argc, argv, TR("Stampa stima ricavi di competenza"));
 | 
						|
  return 0;
 | 
						|
}
 |