Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento : programma per stampa rilevazione ore mensili: qualcosa stampa git-svn-id: svn://10.65.10.50/branches/R_10_00@21649 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									bd0fabfd1e
								
							
						
					
					
						commit
						54ff580f71
					
				
							
								
								
									
										202
									
								
								ci/ci1300.cpp
									
									
									
									
									
								
							
							
						
						
									
										202
									
								
								ci/ci1300.cpp
									
									
									
									
									
								
							| @ -13,6 +13,35 @@ | ||||
| #include "rilore.h" | ||||
| #include "ci1300a.h" | ||||
| 
 | ||||
| #define _last_column 32; | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Recordset
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| class TRil_ore_recordset : public TCSV_recordset | ||||
| { | ||||
| public: | ||||
|   TRil_ore_recordset(); | ||||
| }; | ||||
| 
 | ||||
| TRil_ore_recordset::TRil_ore_recordset() | ||||
| : TCSV_recordset("CSV(\"|\")") | ||||
| { | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Report
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| class TRil_ore_report : public TReport | ||||
| { | ||||
| protected: | ||||
|   virtual bool use_mask() { return false; } | ||||
| 
 | ||||
| public: | ||||
|   TRil_ore_report() { load("ci1300a"); } | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Maschera
 | ||||
| @ -22,6 +51,8 @@ class TRil_ore_mask : public TAutomask | ||||
| { | ||||
| protected: | ||||
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); | ||||
| 
 | ||||
|   bool is_ferial_day(const TDate& data) const; | ||||
|   long calcola_giorni_lavorativi(const TDate& dataini, const TDate& datafine) const; | ||||
|   long calcola_giorni_lavorativi_cms(const TDate& ini_cms, const TDate& fine_cms,  | ||||
|                                      const TDate& dataini, const TDate& datafine, | ||||
| @ -44,6 +75,13 @@ bool TRil_ore_mask::on_field_event(TOperable_field& o, TField_event e, long joll | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| bool TRil_ore_mask::is_ferial_day(const TDate& data) const | ||||
| { | ||||
|   return data.wday() < 6 && !data.is_holiday(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| long TRil_ore_mask::calcola_giorni_lavorativi(const TDate& dataini, const TDate& datafine) const | ||||
| { | ||||
|   long num_giorni_lav = datafine - dataini + 1; | ||||
| @ -52,13 +90,14 @@ long TRil_ore_mask::calcola_giorni_lavorativi(const TDate& dataini, const TDate& | ||||
|   { | ||||
|     for (TDate data = dataini; data <= datafine; ++data) | ||||
|     { | ||||
|       if (data.is_holiday()) | ||||
|       if (!is_ferial_day(data)) | ||||
|         num_giorni_lav--; | ||||
|     } | ||||
|   } | ||||
|   return num_giorni_lav; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| long TRil_ore_mask::calcola_giorni_lavorativi_cms(const TDate& ini_cms, const TDate& fine_cms,  | ||||
|                                                   const TDate& dataini, const TDate& datafine, | ||||
|                                                   TDate& inizio_lav, TDate& fine_lav) const | ||||
| @ -115,23 +154,24 @@ void TRil_ore_mask::elabora_risorsa(const TString& curr_risorsa, TReport& rep) c | ||||
| 
 | ||||
|     const long rilore_recset_items = rilore_recset.items(); | ||||
| 
 | ||||
|     TString msg; | ||||
|     msg << "Scansione " << curr_risorsa << ".."; | ||||
| 
 | ||||
|     for (bool ok = rilore_recset.move_first(); ok; ok = rilore_recset.move_next()) | ||||
|     { | ||||
|       const TString& codcosto = rilore_recset.get(RILORE_CODCOSTO).as_string(); | ||||
|       const TString& codcms = rilore_recset.get(RILORE_CODCMS).as_string(); | ||||
|       const TString& codfase = rilore_recset.get(RILORE_CODFASE).as_string(); | ||||
|       const TString80 codcosto = rilore_recset.get(RILORE_CODCOSTO).as_string(); | ||||
|       const TString80 codcms = rilore_recset.get(RILORE_CODCMS).as_string(); | ||||
|       const TString16 codfase = rilore_recset.get(RILORE_CODFASE).as_string(); | ||||
| 
 | ||||
|       //panegirico allucinante per riproporzionare le ore in base al mese, alla commessa, alle feste ecc. in modo da..
 | ||||
|       //..ottenere alla fine il numero di giorni lavorativi buoni per la commessa nel mese scelto
 | ||||
|       //date limite commessa
 | ||||
|       const TRectype& rec_cms = cache().get(LF_COMMESSE, codcms); | ||||
|       TDate ini_cms, fine_cms; | ||||
|       const int durata_cms = ca_durata_commessa(rec_cms, ini_cms, fine_cms); | ||||
| 
 | ||||
|       //date limite qta ore sul record del file LF_RILORE
 | ||||
|       TDate dataini = rilore_recset.get(RILORE_DADATA).as_date(); | ||||
|       TDate datafine = rilore_recset.get(RILORE_ADATA).as_date(); | ||||
| 
 | ||||
|       //adatta le date alla commessa se quest'ultima è contenuta nell'intervallo
 | ||||
|       //adatta le date alla commessa se quest'ultima è contenuta nell'intervallo (può essere più breve..
 | ||||
|       //..dell'intervallo selezionato, oppure sovrapporsi solo parzialmente)
 | ||||
|       if (fine_cms < datafine) | ||||
|         datafine = fine_cms; | ||||
|       if (ini_cms > dataini) | ||||
| @ -146,7 +186,8 @@ void TRil_ore_mask::elabora_risorsa(const TString& curr_risorsa, TReport& rep) c | ||||
|       TDate ini_lav, fine_lav; | ||||
|       const long giorni_lavorativi_cms = calcola_giorni_lavorativi_cms(ini_cms, fine_cms, dataini, datafine, ini_lav, fine_lav); | ||||
| 
 | ||||
|       //adesso deve riproporzionare il monte ore sul record sul mese selezionato
 | ||||
|       //adesso deve riproporzionare il monte ore sul record sul mese selezionato (fa tutto il lavoro se ci sono giorni..
 | ||||
|       //..lavorativi sulla commessa in questione)
 | ||||
|       if (giorni_lavorativi_cms > 0) | ||||
|       { | ||||
|         const real tot_ore = rilore_recset.get(RILORE_QTAORE).as_real(); | ||||
| @ -180,34 +221,117 @@ void TRil_ore_mask::elabora_risorsa(const TString& curr_risorsa, TReport& rep) c | ||||
|         { | ||||
|           real prev = record->get(0); | ||||
|           prev += tot_ore_uso_risorsa_nel_mese_per_cms; | ||||
|           record->add(prev, 0); | ||||
|           record->add(prev.string(), 0); | ||||
|         } | ||||
|         else  //'C'onsuntivo (aggiorna tutte le caselle dei giorni lavorativi)
 | ||||
|         { | ||||
|           const real ore_al_giorno = tot_ore / giorni_lavorativi; | ||||
|           for (TData data = ini_lav; data <= fine_lav; ++data) | ||||
|           for (TDate data = ini_lav; data <= fine_lav; ++data) | ||||
|           { | ||||
|             if (!data.is_holday()) | ||||
|             if (giorni_lavorativi == 1 || is_ferial_day(data)) | ||||
|             { | ||||
|               real prev = record->get(data.day()); | ||||
|               prev += ore_al_giorno; | ||||
|               record->add(prev, data.day()); | ||||
|               record->add(prev.string(), data.day()); | ||||
|               real tot = record->get(32); | ||||
|               tot += ore_al_giorno; | ||||
|               record->add(tot.string(), 32); | ||||
|             } | ||||
|           } | ||||
|         } | ||||
| 
 | ||||
|       } //if (giorni_lavorativi_cms > 0)..
 | ||||
|     } //for (bool ok = rilore_recset.move_first();..
 | ||||
| 
 | ||||
|   } | ||||
|   } //for (int i = 0; i < 2; i++)...
 | ||||
| 
 | ||||
|   //finita l'elaborazione che ha riempito l'assoc_array, asegna il medesimo ad un..
 | ||||
|   //..csv_recordset e poi sbatte quest'ultimo (ordinato) nel report
 | ||||
|   TRil_ore_recordset* righe_da_stampare = new TRil_ore_recordset; | ||||
| 
 | ||||
|   FOR_EACH_ASSOC_OBJECT(righe, obj, key, itm) | ||||
|   { | ||||
| #ifdef DBG | ||||
|     TString cazzo_key = key; | ||||
|     if (cazzo_key.find("4.10.146.2/2010") >= 0) | ||||
|       int cazzone = 1; | ||||
| #endif | ||||
| 
 | ||||
|     TToken_string& record_ass = (TToken_string&)*itm; | ||||
|     real totale_c = record_ass.get(32); | ||||
|     totale_c.round(1); | ||||
|     TGeneric_distrib esso(totale_c, 1); | ||||
| 
 | ||||
|     for (int j = 1; j <= 31; j++) | ||||
|     { | ||||
|       real ore = record_ass.get(j); | ||||
|       esso.add(ore); | ||||
|     } | ||||
| 
 | ||||
|     //chiave della riga (Cms-CdC-Fase o CdC-Cms-Fase)
 | ||||
|     TToken_string linea; | ||||
|     linea = key; | ||||
|     linea.replace('|', ' '); | ||||
| 
 | ||||
|     // Totale preventivo
 | ||||
|     real totale_p = record_ass.get(0); | ||||
|     totale_p.round(1); | ||||
|     linea.add(totale_p.string()); | ||||
|      | ||||
|     // Totale consuntivo
 | ||||
|     for (int k = 1; k <= 31; k++) | ||||
|     { | ||||
|       const real ore_giorno = esso.get(); | ||||
|       const char* str_ore = ore_giorno.string(); | ||||
|       linea.add(str_ore, k+1); | ||||
|     } | ||||
|      | ||||
|     linea.add(totale_c.string());  | ||||
| 
 | ||||
|     //aggiunge la riga tokenstringata al csv_recordset
 | ||||
|     righe_da_stampare->new_rec(linea);  | ||||
|   } | ||||
|   //ordina il recordset per chiave
 | ||||
|   righe_da_stampare->sort(); | ||||
| 
 | ||||
| #ifdef DBG | ||||
|   righe_da_stampare->save_as_text("C:/temp/cazzone.txt"); | ||||
| #endif | ||||
| 
 | ||||
|   //setta il recordset ordinato al report
 | ||||
|   rep.set_recordset(righe_da_stampare); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void TRil_ore_mask::elabora() const | ||||
| { | ||||
|   TReport_book book; | ||||
|   TRil_ore_report rep; | ||||
| 
 | ||||
|   //maggico giro per formattare la testata del calendario di pagina nel report
 | ||||
|   const int anno = get_int(F_ANNO); | ||||
|   const int mese = get_int(F_MESE); | ||||
|   const TDate primo_del_mese(1, mese, anno); | ||||
|   TDate ultimo_del_mese = primo_del_mese; | ||||
|   ultimo_del_mese.set_end_month(); | ||||
| 
 | ||||
|   TString16 code; | ||||
| 
 | ||||
|   for (TDate giorno = primo_del_mese; giorno <= ultimo_del_mese; ++giorno) | ||||
|   { | ||||
|     code.format("H0.%d", giorno.day() + 100); | ||||
|     TReport_field* rep_field = rep.field(code); | ||||
| 
 | ||||
|     if (rep_field != NULL) | ||||
|     { | ||||
|       if (!is_ferial_day(giorno)) | ||||
|         rep_field->set_back_color(COLOR_LTGRAY); | ||||
| 
 | ||||
|       code = itow(giorno.wday()); | ||||
|       code.cut(3); | ||||
|       code << '\n' << giorno.day(); | ||||
|       rep_field->set(code); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   //query sulla tabella interessata (risorse o attrezzature)
 | ||||
|   TString16 da_ris_att, a_ris_att; | ||||
| @ -246,55 +370,15 @@ void TRil_ore_mask::elabora() const | ||||
| 
 | ||||
|     const TString& curr_risorsa = recset_ris_att.cursor()->curr().get("CODTAB"); | ||||
| 
 | ||||
|     TReport rep; | ||||
|     rep.load("ca1300a"); | ||||
| 
 | ||||
|     elabora_risorsa(curr_risorsa, rep); | ||||
| 
 | ||||
|     book.add(rep); | ||||
|   } | ||||
| 
 | ||||
|   //e alla fine stampa il book
 | ||||
|   book.preview(); | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Recordset
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| class TRil_ore_recordset : public TCSV_recordset | ||||
| { | ||||
| protected: | ||||
| 
 | ||||
| public: | ||||
|   TRil_ore_recordset(const TMask& mask); | ||||
| 	 | ||||
| 	//virtual const TVariant& get(const char* column_name) const;
 | ||||
| 	//virtual const TVariant& get(unsigned int column) const { return TCSV_recordset::get(column); }
 | ||||
| }; | ||||
| 
 | ||||
| TRil_ore_recordset::TRil_ore_recordset(const TMask& mask)  | ||||
| : TCSV_recordset("CSV(\"\t\")")   //tab separated
 | ||||
| { | ||||
|   FOR_EACH_MASK_FIELD(mask, i, field) | ||||
| 	{ | ||||
| 		const TFieldref* f = field->field(); | ||||
| 		if (f != NULL) | ||||
| 		{ | ||||
| 			const TString& name = f->name(); | ||||
| 			set_var(name, field->get(), true); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Report
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| class TRil_ore_report : public TReport | ||||
| { | ||||
| protected: | ||||
| virtual bool use_mask() { return false; } | ||||
| public: | ||||
|   TRil_ore_report() {} | ||||
| }; | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // Applicazione
 | ||||
|  | ||||
							
								
								
									
										78
									
								
								ci/ci1300a.rep
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										78
									
								
								ci/ci1300a.rep
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,78 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <report name="ci1300a" orientation="2" lpi="6"> | ||||
|  <description>Rilevazione ore mensili per Risorsa</description> | ||||
|  <font face="Arial" size="8" /> | ||||
|  <section type="Head" pattern="1"> | ||||
|   <field border="1" x="30" type="Stringa" align="center" width="4" height="2" id="101" pattern="2" /> | ||||
|   <field border="1" x="34" type="Stringa" align="center" width="4" height="2" id="102" pattern="2" /> | ||||
|   <field border="1" x="38" type="Stringa" align="center" width="4" height="2" id="103" pattern="2" /> | ||||
|   <field border="1" x="42" type="Stringa" align="center" width="4" height="2" id="104" pattern="2" /> | ||||
|   <field border="1" x="46" type="Stringa" align="center" width="4" height="2" id="105" pattern="2" /> | ||||
|   <field border="1" x="50" type="Stringa" align="center" width="4" height="2" id="106" pattern="2" /> | ||||
|   <field border="1" x="54" type="Stringa" align="center" width="4" height="2" id="107" pattern="2" /> | ||||
|   <field border="1" x="58" type="Stringa" align="center" width="4" height="2" id="108" pattern="2" /> | ||||
|   <field border="1" x="62" type="Stringa" align="center" width="4" height="2" id="109" pattern="2" /> | ||||
|   <field border="1" x="66" type="Stringa" align="center" width="4" height="2" id="110" pattern="2" /> | ||||
|   <field border="1" x="70" type="Stringa" align="center" width="4" height="2" id="111" pattern="2" /> | ||||
|   <field border="1" x="74" type="Stringa" align="center" width="4" height="2" id="112" pattern="2" /> | ||||
|   <field border="1" x="78" type="Stringa" align="center" width="4" height="2" id="113" pattern="2" /> | ||||
|   <field border="1" x="82" type="Stringa" align="center" width="4" height="2" id="114" pattern="2" /> | ||||
|   <field border="1" x="86" type="Stringa" align="center" width="4" height="2" id="115" pattern="2" /> | ||||
|   <field border="1" x="90" type="Stringa" align="center" width="4" height="2" id="116" pattern="2" /> | ||||
|   <field border="1" x="94" type="Stringa" align="center" width="4" height="2" id="117" pattern="2" /> | ||||
|   <field border="1" x="98" type="Stringa" align="center" width="4" height="2" id="118" pattern="2" /> | ||||
|   <field border="1" x="102" type="Stringa" align="center" width="4" height="2" id="119" pattern="2" /> | ||||
|   <field border="1" x="106" type="Stringa" align="center" width="4" height="2" id="120" pattern="2" /> | ||||
|   <field border="1" x="110" type="Stringa" align="center" width="4" height="2" id="121" pattern="2" /> | ||||
|   <field border="1" x="114" type="Stringa" align="center" width="4" height="2" id="122" pattern="2" /> | ||||
|   <field border="1" x="118" type="Stringa" align="center" width="4" height="2" id="123" pattern="2" /> | ||||
|   <field border="1" x="122" type="Stringa" align="center" width="4" height="2" id="124" pattern="2" /> | ||||
|   <field border="1" x="126" type="Stringa" align="center" width="4" height="2" id="125" pattern="2" /> | ||||
|   <field border="1" x="130" type="Stringa" align="center" width="4" height="2" id="126" pattern="2" /> | ||||
|   <field border="1" x="134" type="Stringa" align="center" width="4" height="2" id="127" pattern="2" /> | ||||
|   <field border="1" x="138" type="Stringa" align="center" width="4" height="2" id="128" pattern="2" /> | ||||
|   <field border="1" x="142" type="Stringa" align="center" width="4" height="2" id="129" pattern="2" /> | ||||
|   <field border="1" x="146" type="Stringa" align="center" width="4" height="2" id="130" pattern="2" /> | ||||
|   <field border="1" x="150" type="Stringa" align="center" width="4" height="2" id="131" pattern="2" /> | ||||
|  </section> | ||||
|  <section type="Head" level="1" pattern="1" /> | ||||
|  <section type="Body" pattern="1" /> | ||||
|  <section type="Body" level="1" pattern="1"> | ||||
|   <font face="Arial Narrow" size="8" /> | ||||
|   <field x="1" type="Stringa" dynamic_height="1" width="20" height="2" pattern="1"> | ||||
|    <source>A</source> | ||||
|   </field> | ||||
|   <field border="1" x="22" type="Numero" align="right" width="7" pattern="1" text="###@,@@"> | ||||
|    <source>B</source> | ||||
|   </field> | ||||
|   <field border="1" x="30" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <font face="Arial Narrow" size="8" /> | ||||
|    <source>C</source> | ||||
|   </field> | ||||
|   <field border="1" x="34" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <source>D</source> | ||||
|   </field> | ||||
|   <field border="1" x="38" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <font face="Arial Narrow" size="8" /> | ||||
|    <source>E</source> | ||||
|   </field> | ||||
|   <field border="1" x="42" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <source>F</source> | ||||
|   </field> | ||||
|   <field border="1" x="46" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <font face="Arial Narrow" size="8" /> | ||||
|    <source>G</source> | ||||
|   </field> | ||||
|   <field border="1" x="50" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <source>H</source> | ||||
|   </field> | ||||
|   <field border="1" x="54" type="Numero" align="right" width="4" pattern="1" hide_zero="1" text="#@,@@"> | ||||
|    <source>I</source> | ||||
|   </field> | ||||
|   <field border="1" x="153.5" type="Numero" align="right" width="6" pattern="1" text="##@,@@"> | ||||
|    <source>AH</source> | ||||
|   </field> | ||||
|  </section> | ||||
|  <section type="Foot" pattern="1" /> | ||||
|  <section type="Foot" level="1" pattern="1" /> | ||||
| </report> | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user