Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : corretto calcolo stato e controlli sulle convocazioni nel giornaliero don./con. git-svn-id: svn://10.65.10.50/trunk@9223 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									b3cd9c64a9
								
							
						
					
					
						commit
						97270ae0c0
					
				
							
								
								
									
										509
									
								
								at/at0200.cpp
									
									
									
									
									
								
							
							
						
						
									
										509
									
								
								at/at0200.cpp
									
									
									
									
									
								
							| @ -460,270 +460,275 @@ int TGiornalieroDC::write(TSheet_field& s) | ||||
| 				if (!exist)					 | ||||
| 				{	 | ||||
| 					err = _sdonazioni->write(TRUE); | ||||
| 				  // controllo se è idoneo
 | ||||
|           bool ctrlsi = FALSE; //devo controllare se è idoneo SI
 | ||||
|           bool ctrlaf = FALSE; //devo controllare se è idoneo AF
 | ||||
| 					bool id_si = FALSE;		// il soggetto è idoneo per si?
 | ||||
| 					bool id_af = FALSE;		// il soggetto è idoneo per af?
 | ||||
| 					char modstato = ' ';      | ||||
| 					TString16 stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 					TString16 statosi = sog.get(SOG_STATOSI);	// stato attuale SI
 | ||||
| 					TString16 statoaf = sog.get(SOG_STATOAF);	// stato attuale AF
 | ||||
| 					TString16 id1 = sog.get(SOG_IDON1);		// idon. 1
 | ||||
| 					TString16 id2 = sog.get(SOG_IDON2);		// idon. 2
 | ||||
| 					TString16 id3 = sog.get(SOG_IDON3);		// idon. 3
 | ||||
| 					TString16 id4 = sog.get(SOG_IDON4);	  // idon. 4
 | ||||
| 					int intsi = sog.get_int(SOG_INTSI);		// intervallo per SI
 | ||||
| 					int intaf = sog.get_int(SOG_INTAF);		// intervallo per AF
 | ||||
| 					//id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (statosi == "ID")) && intsi != 0);		// il soggetto è idoneo SI
 | ||||
| 					//id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (statoaf == "ID")) && intaf != 0);		// il soggetto è idoneo AF
 | ||||
| 					id_si = ((statosi == "ID") && (intsi != 0));		// il soggetto è idoneo SI
 | ||||
| 					id_af = ((statoaf == "ID") && (intaf != 0));		// il soggetto è idoneo AF
 | ||||
| 			  | ||||
| 					int totdon = sog.get_int(SOG_TOTDON); | ||||
| 					TDate dataultdon = sog.get_date(SOG_DATAULTDON); | ||||
| 					sog.put(SOG_TOTDON,totdon+1); | ||||
| 					if (datadonazione > dataultdon) | ||||
| 					if (err == NOERR) | ||||
| 					{ | ||||
| 						sog.put(SOG_DATAULTDON,datadonazione); | ||||
| 						sog.put(SOG_TIPOULTDON,tipodon); | ||||
| 					}  | ||||
|  					if (is_donaz(tipodon,IDON_SI)) | ||||
|  					{ | ||||
|  						ctrlsi = TRUE; | ||||
|  						totdon = sog.get_int(SOG_TOTDONSI); | ||||
|  						sog.put(SOG_TOTDONSI,totdon+1); | ||||
|  						dataultdon = sog.get_date(SOG_DATAULTSI); | ||||
|  						if (datadonazione>dataultdon) | ||||
|  							sog.put(SOG_DATAULTSI,datadonazione); | ||||
| 					} | ||||
|  					if (is_donaz(tipodon,IDON_AF)) | ||||
|  					{ | ||||
|  						ctrlaf = TRUE; | ||||
|  						totdon = sog.get_int(SOG_TOTDONAF); | ||||
|  						sog.put(SOG_TOTDONAF,totdon+1); | ||||
|  						dataultdon = sog.get_date(SOG_DATAULTAF); | ||||
|  						if (datadonazione>dataultdon) | ||||
|  							sog.put(SOG_DATAULTAF,datadonazione); | ||||
| 					} | ||||
| 					dataultdon = sog.get_date(SOG_DATAULTDON);	// data ultima donazione
 | ||||
| 					const TString16 tipoultdon = (sog.get(SOG_TIPOULTDON));	// tipo ultima donazione
 | ||||
| 					TDate datasi(NULLDATE);		// data prossima si calcolata
 | ||||
| 					TDate dataaf(NULLDATE);		// data prossima af calcolata
 | ||||
| 					TDate dataultsi(NULLDATE);	// data ultima donazione si
 | ||||
| 					 | ||||
| 				  modstato = modstato_tcs(stato); | ||||
| 				  // il soggetto è idoneo per il tipo di donazione ?
 | ||||
| 				  if ((ctrlsi) && (!id_si) && (_autoid) && (modstato!='B')) | ||||
| 				  { | ||||
| 						TRectype* key = new TRectype(LF_IDONEITA); | ||||
| 						long codice = sog.get_long(SOG_CODICE); | ||||
| 						key->put(IDO_CODICE, codice); | ||||
| 						int err = _sidoneita->read(key); | ||||
| 						int progido = _sidoneita->rows()+1; | ||||
| 						TRectype& recido = _idoneita->curr(); | ||||
| 						recido.zero(); | ||||
| 						recido.put(IDO_CODICE, codice); | ||||
| 						recido.put(IDO_PROGIDO, progido); | ||||
| 						recido.put(IDO_DATAIDO, datadonazione); | ||||
| 						recido.put(IDO_IDO_SOS, "ID"); | ||||
| 						recido.put(IDO_TIPOIDO, "SI"); | ||||
| 						TString80 resp = user(); | ||||
| 						resp << " - HA DONATO OGGI"; | ||||
| 						recido.put(IDO_RESPONSAB, resp); | ||||
| 						recido.put(IDO_MOTIVO, _motivoid); | ||||
| 						recido.put(IDO_INTERVALLO, sog.get(SOG_INTSI));				 | ||||
| 						if (sog.get_int(SOG_INTSI) == 0) | ||||
| 						{            | ||||
| 							const TString16 sesso = sog.get(SOG_SESSO); | ||||
| 							if (sesso == "2") | ||||
| 							{ | ||||
| 								TDate datanasc = sog.get_date(SOG_DATANASC); | ||||
| 								int eta = datadonazione.year() - datanasc.year();						 | ||||
| 								if(eta <= _etadonne) | ||||
| 									recido.put(IDO_INTERVALLO, _intsi_f1); | ||||
| 								else | ||||
| 									recido.put(IDO_INTERVALLO, _intsi_f2); | ||||
| 							}	 | ||||
| 							else | ||||
| 								recido.put(IDO_INTERVALLO, _intsi_m); | ||||
| 						}					 | ||||
| 						_sidoneita->add_row(recido); | ||||
| 						_sidoneita->rewrite(); | ||||
| 						TRectype* keyc = new TRectype(LF_CONTSAN); | ||||
| 						keyc->put(CON_CODICE, codice); | ||||
| 						err = _scontrolli->read(keyc); | ||||
| 						con_reord(sog.curr(),_scontrolli,_sidoneita); | ||||
| 						sog.rewrite(); | ||||
| 						stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 					  modstato = modstato_tcs(stato);						 | ||||
| 					}						 | ||||
| 				  if ((ctrlaf) && (!id_af) && (_autoid) && (modstato!='B')) | ||||
| 				  { | ||||
| 						TRectype* key = new TRectype(LF_IDONEITA); | ||||
| 						long codice = sog.get_long(SOG_CODICE); | ||||
| 						key->put(IDO_CODICE, codice); | ||||
| 						int err = _sidoneita->read(key); | ||||
| 						int progido = _sidoneita->rows()+1; | ||||
| 						TRectype& recido = _idoneita->curr(); | ||||
| 						recido.zero(); | ||||
| 						recido.put(IDO_CODICE, codice); | ||||
| 						recido.put(IDO_PROGIDO, progido); | ||||
| 						recido.put(IDO_DATAIDO, datadonazione); | ||||
| 						recido.put(IDO_IDO_SOS, "ID"); | ||||
| 						recido.put(IDO_TIPOIDO, "AF"); | ||||
| 						TString80 resp = user(); | ||||
| 						resp << " - HA DONATO OGGI"; | ||||
| 						recido.put(IDO_RESPONSAB, resp); | ||||
| 						recido.put(IDO_MOTIVO, _motivoid); | ||||
| 						recido.put(IDO_INTERVALLO, sog.get(SOG_INTAF));				 | ||||
| 						if (sog.get_int(SOG_INTAF) == 0) | ||||
| 							recido.put(IDO_INTERVALLO, _intaf_m); | ||||
| 						_sidoneita->add_row(recido); | ||||
| 						_sidoneita->rewrite(); | ||||
| 						TRectype* keyc = new TRectype(LF_CONTSAN); | ||||
| 						keyc->put(CON_CODICE, codice); | ||||
| 						err = _scontrolli->read(keyc); | ||||
| 						con_reord(sog.curr(),_scontrolli,_sidoneita); | ||||
| 						sog.rewrite(); | ||||
| 						stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 					  modstato = modstato_tcs(stato); | ||||
| 					} | ||||
| 					sog.get(SOG_STATO);	// stato attuale
 | ||||
| 					statosi = sog.get(SOG_STATOSI);	// stato attuale SI
 | ||||
| 					statoaf = sog.get(SOG_STATOAF);	// stato attuale AF
 | ||||
| 					id1 = sog.get(SOG_IDON1);		// idon. 1
 | ||||
| 					id2 = sog.get(SOG_IDON2);		// idon. 2
 | ||||
| 					id3 = sog.get(SOG_IDON3);		// idon. 3
 | ||||
| 					id4 = sog.get(SOG_IDON4);	  // idon. 4
 | ||||
| 					intsi = sog.get_int(SOG_INTSI);		// intervallo per SI
 | ||||
| 					intaf = sog.get_int(SOG_INTAF);		// intervallo per AF					
 | ||||
| 				  modstato = modstato_tcs(stato); | ||||
| 					if (modstato == 'I' || modstato == 'F')	// il soggetto è idoneo
 | ||||
| 					{  | ||||
| 						//id_si = (is_idon(id1,id2,id3,id4,IDON_SI) && intsi != 0);		// il soggetto è idoneo SI
 | ||||
| 						//id_af = (is_idon(id1,id2,id3,id4,IDON_AF) && intaf != 0);		// il soggetto è idoneo AF
 | ||||
| 					  // controllo se è idoneo
 | ||||
| 	          bool ctrlsi = FALSE; //devo controllare se è idoneo SI
 | ||||
| 	          bool ctrlaf = FALSE; //devo controllare se è idoneo AF
 | ||||
| 						bool id_si = FALSE;		// il soggetto è idoneo per si?
 | ||||
| 						bool id_af = FALSE;		// il soggetto è idoneo per af?
 | ||||
| 						char modstato = ' ';      | ||||
| 						TString16 stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 						TString16 statosi = sog.get(SOG_STATOSI);	// stato attuale SI
 | ||||
| 						TString16 statoaf = sog.get(SOG_STATOAF);	// stato attuale AF
 | ||||
| 						TString16 id1 = sog.get(SOG_IDON1);		// idon. 1
 | ||||
| 						TString16 id2 = sog.get(SOG_IDON2);		// idon. 2
 | ||||
| 						TString16 id3 = sog.get(SOG_IDON3);		// idon. 3
 | ||||
| 						TString16 id4 = sog.get(SOG_IDON4);	  // idon. 4
 | ||||
| 						int intsi = sog.get_int(SOG_INTSI);		// intervallo per SI
 | ||||
| 						int intaf = sog.get_int(SOG_INTAF);		// intervallo per AF
 | ||||
| 						//id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (statosi == "ID")) && intsi != 0);		// il soggetto è idoneo SI
 | ||||
| 						//id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (statoaf == "ID")) && intaf != 0);		// il soggetto è idoneo AF
 | ||||
| 						id_si = ((statosi == "ID") && (intsi != 0));		// il soggetto è idoneo SI
 | ||||
| 						id_af = ((statoaf == "ID") && (intaf != 0));		// il soggetto è idoneo AF
 | ||||
| 				  | ||||
| 						if (dataultdon.ok())		// se ha fatto almeno una donazione
 | ||||
| 						int totdon = sog.get_int(SOG_TOTDON); | ||||
| 						TDate dataultdon = sog.get_date(SOG_DATAULTDON); | ||||
| 						sog.put(SOG_TOTDON,totdon+1); | ||||
| 						if (datadonazione > dataultdon) | ||||
| 						{             | ||||
| 							if (is_donaz(tipoultdon,IDON_SI))	// se l'ultima donazione è una SI
 | ||||
| 							{ | ||||
| 								if (id_si)  | ||||
| 								{ | ||||
| 									datasi=dataultdon; | ||||
| 									datasi+=intsi; | ||||
| 								}	 | ||||
| 				  			if (id_af)  | ||||
| 				  			{ | ||||
| 				  				dataaf=dataultdon; | ||||
| 				  				dataaf+=intaf; | ||||
| 				  			}	 | ||||
| 				      } | ||||
| 				      if (is_donaz(tipoultdon,IDON_AF))	// se l'ultima donazione è una AF
 | ||||
| 				      { | ||||
| 				      	dataultsi = sog.get_date(SOG_DATAULTSI); | ||||
| 								if (id_si) | ||||
| 								{ | ||||
| 									if (intaf != 0) | ||||
| 									{ | ||||
| 										datasi=dataultdon;  | ||||
| 										datasi+=intaf; | ||||
| 									}	 | ||||
| 									else | ||||
| 									{ | ||||
| 										datasi=dataultdon; | ||||
| 									  datasi+=intsi;     | ||||
| 									}   | ||||
| 									if (dataultsi.ok()) | ||||
| 										dataultsi+=intsi; | ||||
| 									if (dataultsi > datasi) | ||||
| 										datasi = dataultsi; | ||||
| 								} | ||||
| 								if (id_af) | ||||
| 								{ | ||||
| 									dataaf=dataultdon; | ||||
| 									dataaf+=intaf; | ||||
| 								}					 | ||||
| 				      }	 | ||||
| 				 		} | ||||
| 				 		else | ||||
| 				 		{ | ||||
| 				 			if (id_si) | ||||
| 				 				datasi=sog.get_date(SOG_DATAULTID); | ||||
| 				 			if (id_af) | ||||
| 				 				dataaf=sog.get_date(SOG_DATAULTID); 				 | ||||
| 				 		} | ||||
| 					}	 | ||||
| 					sog.put(SOG_DATAPROSSI,datasi); | ||||
| 					sog.put(SOG_DATAPROSAF,dataaf); | ||||
| 							sog.put(SOG_DATAULTDON,datadonazione); | ||||
| 							sog.put(SOG_TIPOULTDON,tipodon); | ||||
| 						}  | ||||
| 	 					if (is_donaz(tipodon,IDON_SI)) | ||||
| 	 					{ | ||||
| 	 						ctrlsi = TRUE; | ||||
| 	 						totdon = sog.get_int(SOG_TOTDONSI); | ||||
| 	 						sog.put(SOG_TOTDONSI,totdon+1); | ||||
| 	 						dataultdon = sog.get_date(SOG_DATAULTSI); | ||||
| 	 						if (datadonazione>dataultdon) | ||||
| 	 							sog.put(SOG_DATAULTSI,datadonazione); | ||||
| 						} | ||||
| 	 					if (is_donaz(tipodon,IDON_AF)) | ||||
| 	 					{ | ||||
| 	 						ctrlaf = TRUE; | ||||
| 	 						totdon = sog.get_int(SOG_TOTDONAF); | ||||
| 	 						sog.put(SOG_TOTDONAF,totdon+1); | ||||
| 	 						dataultdon = sog.get_date(SOG_DATAULTAF); | ||||
| 	 						if (datadonazione>dataultdon) | ||||
| 	 							sog.put(SOG_DATAULTAF,datadonazione); | ||||
| 						} | ||||
| 						dataultdon = sog.get_date(SOG_DATAULTDON);	// data ultima donazione
 | ||||
| 						const TString16 tipoultdon = (sog.get(SOG_TIPOULTDON));	// tipo ultima donazione
 | ||||
| 						TDate datasi(NULLDATE);		// data prossima si calcolata
 | ||||
| 						TDate dataaf(NULLDATE);		// data prossima af calcolata
 | ||||
| 						TDate dataultsi(NULLDATE);	// data ultima donazione si
 | ||||
| 						 | ||||
| 					// se la data prossima SI è superiore all'ultima convocazione
 | ||||
| 					// va cancellata, anche dall'archivio convocazioni
 | ||||
| 					TDate dataprossi = sog.get_date(SOG_DATAPROSSI); | ||||
| 					TDate dataconv = sog.get_date(SOG_DATACONV); | ||||
| 					if (dataprossi >= dataconv) | ||||
| 					{ | ||||
| 						rconv.setkey(2); | ||||
| 						rconv.zero(); | ||||
| 						rconv.put(RCV_DATACONV, dataconv); | ||||
| 						rconv.put(RCV_CODICE, codsog); | ||||
| 						int err = rconv.read(); | ||||
| 						if (err == NOERR) | ||||
| 						{ | ||||
| 							rconv.put(RCV_ANNULLATO,TRUE); | ||||
| 							rconv.rewrite(); | ||||
| 					  modstato = modstato_tcs(stato); | ||||
| 					  // il soggetto è idoneo per il tipo di donazione ?
 | ||||
| 					  if ((ctrlsi) && (!id_si) && (_autoid) && (modstato!='B')) | ||||
| 					  { | ||||
| 							TRectype* key = new TRectype(LF_IDONEITA); | ||||
| 							long codice = sog.get_long(SOG_CODICE); | ||||
| 							key->put(IDO_CODICE, codice); | ||||
| 							int err = _sidoneita->read(key); | ||||
| 							int progido = _sidoneita->rows()+1; | ||||
| 							TRectype& recido = _idoneita->curr(); | ||||
| 							recido.zero(); | ||||
| 							recido.put(IDO_CODICE, codice); | ||||
| 							recido.put(IDO_PROGIDO, progido); | ||||
| 							recido.put(IDO_DATAIDO, datadonazione); | ||||
| 							recido.put(IDO_IDO_SOS, "ID"); | ||||
| 							recido.put(IDO_TIPOIDO, "SI"); | ||||
| 							TString80 resp = user(); | ||||
| 							resp << " - HA DONATO OGGI"; | ||||
| 							recido.put(IDO_RESPONSAB, resp); | ||||
| 							recido.put(IDO_MOTIVO, _motivoid); | ||||
| 							recido.put(IDO_INTERVALLO, sog.get(SOG_INTSI));				 | ||||
| 							if (sog.get_int(SOG_INTSI) == 0) | ||||
| 							{            | ||||
| 								const TString16 sesso = sog.get(SOG_SESSO); | ||||
| 								if (sesso == "2") | ||||
| 								{ | ||||
| 									TDate datanasc = sog.get_date(SOG_DATANASC); | ||||
| 									int eta = datadonazione.year() - datanasc.year();						 | ||||
| 									if(eta <= _etadonne) | ||||
| 										recido.put(IDO_INTERVALLO, _intsi_f1); | ||||
| 									else | ||||
| 										recido.put(IDO_INTERVALLO, _intsi_f2); | ||||
| 								}	 | ||||
| 								else | ||||
| 									recido.put(IDO_INTERVALLO, _intsi_m); | ||||
| 							}					 | ||||
| 							_sidoneita->add_row(recido); | ||||
| 							err = _sidoneita->rewrite(); | ||||
| 							TRectype* keyc = new TRectype(LF_CONTSAN); | ||||
| 							keyc->put(CON_CODICE, codice); | ||||
| 							err = _scontrolli->read(keyc); | ||||
| 							con_reord(sog.curr(),_scontrolli,_sidoneita); | ||||
| 							sog.rewrite(); | ||||
| 							stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 						  modstato = modstato_tcs(stato);						 | ||||
| 						}						 | ||||
| 						sog.put(SOG_DATACONV, NULLDATE); | ||||
| 						sog.put(SOG_DATAULTSOL, NULLDATE); | ||||
| 						const int zeroconv = 0; | ||||
| 						sog.put(SOG_NUMCONV, zeroconv); | ||||
| 					} | ||||
| 				  // controllo la sua categoria
 | ||||
| 				  // se dimesso diventa della categoria collegata
 | ||||
| 				  // se non c'e' la categoria collegata ???
 | ||||
|     			TTable ctd("CTD");  | ||||
|     			TString16 catdon = sog.get(SOG_CATDON); | ||||
|     			ctd.put("CODTAB",catdon); | ||||
|     			if (ctd.read() == NOERR) | ||||
|     			{ | ||||
|     				bool dimissione = ctd.get_bool("B0"); | ||||
| 						if (dimissione)           | ||||
| 						{ | ||||
| 							sog.put(SOG_CATDON,ctd.get("S6"));		    				 | ||||
| 							if (ctd.get("S6").not_empty()) | ||||
| 								catdon = ctd.get("S6");							 | ||||
| 							sog.put(SOG_DATADIM,NULLDATE);								 | ||||
| 					  if ((ctrlaf) && (!id_af) && (_autoid) && (modstato!='B')) | ||||
| 					  { | ||||
| 							TRectype* key = new TRectype(LF_IDONEITA); | ||||
| 							long codice = sog.get_long(SOG_CODICE); | ||||
| 							key->put(IDO_CODICE, codice); | ||||
| 							int err = _sidoneita->read(key); | ||||
| 							int progido = _sidoneita->rows()+1; | ||||
| 							TRectype& recido = _idoneita->curr(); | ||||
| 							recido.zero(); | ||||
| 							recido.put(IDO_CODICE, codice); | ||||
| 							recido.put(IDO_PROGIDO, progido); | ||||
| 							recido.put(IDO_DATAIDO, datadonazione); | ||||
| 							recido.put(IDO_IDO_SOS, "ID"); | ||||
| 							recido.put(IDO_TIPOIDO, "AF"); | ||||
| 							TString80 resp = user(); | ||||
| 							resp << " - HA DONATO OGGI"; | ||||
| 							recido.put(IDO_RESPONSAB, resp); | ||||
| 							recido.put(IDO_MOTIVO, _motivoid); | ||||
| 							recido.put(IDO_INTERVALLO, sog.get(SOG_INTAF));				 | ||||
| 							if (sog.get_int(SOG_INTAF) == 0) | ||||
| 								recido.put(IDO_INTERVALLO, _intaf_m); | ||||
| 							_sidoneita->add_row(recido); | ||||
| 							_sidoneita->rewrite(); | ||||
| 							TRectype* keyc = new TRectype(LF_CONTSAN); | ||||
| 							keyc->put(CON_CODICE, codice); | ||||
| 							err = _scontrolli->read(keyc); | ||||
| 							con_reord(sog.curr(),_scontrolli,_sidoneita); | ||||
| 							sog.rewrite(); | ||||
| 							stato = sog.get(SOG_STATO);	// stato attuale
 | ||||
| 						  modstato = modstato_tcs(stato); | ||||
| 						} | ||||
| 						if ((catdon == _catini1 || _catini1.empty()) && (totdon+1>=_numdon1) && _catfin1.not_empty()) | ||||
| 							sog.put(SOG_CATDON, _catfin1); | ||||
| 						const bool tstampata = sog.get_bool(SOG_T_STAMPATA); | ||||
| 						if ((catdon == _catini2 || _catini2.empty()) && (totdon+1>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata)) | ||||
| 							sog.put(SOG_CATDON, _catfin2); | ||||
| 				  } | ||||
| 				  TDate dataisc = sog.get_date(SOG_DATAISC); | ||||
| 				  if (!dataisc.ok() && _dataisc) | ||||
| 				  {             | ||||
| 						if (sog.get_date(SOG_DATAPRISI).ok()) | ||||
| 							sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI)); | ||||
| 						sog.get(SOG_STATO);	// stato attuale
 | ||||
| 						statosi = sog.get(SOG_STATOSI);	// stato attuale SI
 | ||||
| 						statoaf = sog.get(SOG_STATOAF);	// stato attuale AF
 | ||||
| 						id1 = sog.get(SOG_IDON1);		// idon. 1
 | ||||
| 						id2 = sog.get(SOG_IDON2);		// idon. 2
 | ||||
| 						id3 = sog.get(SOG_IDON3);		// idon. 3
 | ||||
| 						id4 = sog.get(SOG_IDON4);	  // idon. 4
 | ||||
| 						intsi = sog.get_int(SOG_INTSI);		// intervallo per SI
 | ||||
| 						intaf = sog.get_int(SOG_INTAF);		// intervallo per AF					
 | ||||
| 					  modstato = modstato_tcs(stato); | ||||
| 						if (modstato == 'I' || modstato == 'F')	// il soggetto è idoneo
 | ||||
| 						{  | ||||
| 							//id_si = (is_idon(id1,id2,id3,id4,IDON_SI) && intsi != 0);		// il soggetto è idoneo SI
 | ||||
| 							//id_af = (is_idon(id1,id2,id3,id4,IDON_AF) && intaf != 0);		// il soggetto è idoneo AF
 | ||||
| 							id_si = ((statosi == "ID") && (intsi != 0));		// il soggetto è idoneo SI
 | ||||
| 							id_af = ((statoaf == "ID") && (intaf != 0));		// il soggetto è idoneo AF
 | ||||
| 							 | ||||
| 							if (dataultdon.ok())		// se ha fatto almeno una donazione
 | ||||
| 							{ | ||||
| 								if (is_donaz(tipoultdon,IDON_SI))	// se l'ultima donazione è una SI
 | ||||
| 								{ | ||||
| 									if (id_si)  | ||||
| 									{ | ||||
| 										datasi=dataultdon; | ||||
| 										datasi+=intsi; | ||||
| 									}	 | ||||
| 					  			if (id_af)  | ||||
| 					  			{ | ||||
| 					  				dataaf=dataultdon; | ||||
| 					  				dataaf+=intaf; | ||||
| 					  			}	 | ||||
| 					      } | ||||
| 					      if (is_donaz(tipoultdon,IDON_AF))	// se l'ultima donazione è una AF
 | ||||
| 					      { | ||||
| 					      	dataultsi = sog.get_date(SOG_DATAULTSI); | ||||
| 									if (id_si) | ||||
| 									{ | ||||
| 										if (intaf != 0) | ||||
| 										{ | ||||
| 											datasi=dataultdon;  | ||||
| 											datasi+=intaf; | ||||
| 										}	 | ||||
| 										else | ||||
| 										{ | ||||
| 											datasi=dataultdon; | ||||
| 										  datasi+=intsi;     | ||||
| 										}   | ||||
| 										if (dataultsi.ok()) | ||||
| 											dataultsi+=intsi; | ||||
| 										if (dataultsi > datasi) | ||||
| 											datasi = dataultsi; | ||||
| 									} | ||||
| 									if (id_af) | ||||
| 									{ | ||||
| 										dataaf=dataultdon; | ||||
| 										dataaf+=intaf; | ||||
| 									}					 | ||||
| 					      }	 | ||||
| 					 		} | ||||
| 					 		else | ||||
| 					 		{ | ||||
| 					 			if (id_si) | ||||
| 					 				datasi=sog.get_date(SOG_DATAULTID); | ||||
| 					 			if (id_af) | ||||
| 					 				dataaf=sog.get_date(SOG_DATAULTID); 				 | ||||
| 					 		} | ||||
| 						}	 | ||||
| 						sog.put(SOG_DATAPROSSI,datasi); | ||||
| 						sog.put(SOG_DATAPROSAF,dataaf); | ||||
| 	 | ||||
| 						// se la data prossima SI è superiore all'ultima convocazione
 | ||||
| 						// va cancellata, anche dall'archivio convocazioni
 | ||||
| 						TDate dataprossi = sog.get_date(SOG_DATAPROSSI); | ||||
| 						TDate dataconv = sog.get_date(SOG_DATACONV); | ||||
| 						if (dataprossi >= dataconv) | ||||
| 						{ | ||||
| 							rconv.setkey(2); | ||||
| 							rconv.zero(); | ||||
| 							rconv.put(RCV_DATACONV, dataconv); | ||||
| 							rconv.put(RCV_CODICE, codsog); | ||||
| 							int err = rconv.read(); | ||||
| 							if (err == NOERR) | ||||
| 							{ | ||||
| 								rconv.put(RCV_ANNULLATO,TRUE); | ||||
| 								rconv.rewrite(); | ||||
| 							}							 | ||||
| 							sog.put(SOG_DATACONV, NULLDATE); | ||||
| 							sog.put(SOG_DATAULTSOL, NULLDATE); | ||||
| 							const int zeroconv = 0; | ||||
| 							sog.put(SOG_NUMCONV, zeroconv); | ||||
| 						} | ||||
| 					  // controllo la sua categoria
 | ||||
| 					  // se dimesso diventa della categoria collegata
 | ||||
| 					  // se non c'e' la categoria collegata ???
 | ||||
| 	    			TTable ctd("CTD");  | ||||
| 	    			TString16 catdon = sog.get(SOG_CATDON); | ||||
| 	    			ctd.put("CODTAB",catdon); | ||||
| 	    			if (ctd.read() == NOERR) | ||||
| 	    			{ | ||||
| 	    				bool dimissione = ctd.get_bool("B0"); | ||||
| 							if (dimissione)           | ||||
| 							{ | ||||
| 								sog.put(SOG_CATDON,ctd.get("S6"));		    				 | ||||
| 								if (ctd.get("S6").not_empty()) | ||||
| 									catdon = ctd.get("S6");							 | ||||
| 								sog.put(SOG_DATADIM,NULLDATE);								 | ||||
| 							}							 | ||||
| 							if ((catdon == _catini1 || _catini1.empty()) && (totdon+1>=_numdon1) && _catfin1.not_empty()) | ||||
| 								sog.put(SOG_CATDON, _catfin1); | ||||
| 							const bool tstampata = sog.get_bool(SOG_T_STAMPATA); | ||||
| 							if ((catdon == _catini2 || _catini2.empty()) && (totdon+1>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata)) | ||||
| 								sog.put(SOG_CATDON, _catfin2); | ||||
| 					  } | ||||
| 					  TDate dataisc = sog.get_date(SOG_DATAISC); | ||||
| 					  if (!dataisc.ok() && _dataisc) | ||||
| 					  {             | ||||
| 							if (sog.get_date(SOG_DATAPRISI).ok()) | ||||
| 								sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI)); | ||||
| 							else | ||||
| 					    { | ||||
| 								const TRectype& riga = _sdonazioni->row(1); | ||||
| 								sog.put(SOG_DATAISC,riga.get(DON_DATADON)); | ||||
| 							}							 | ||||
| 						}				  	 | ||||
| 					  // aggiorno data e utente ultimo aggiornamento
 | ||||
| 					  const TDate oggi(TODAY); | ||||
| 					  sog.put(SOG_DATAULTAGG,oggi); | ||||
| 					  sog.put(SOG_UTENULTAGG,user()); | ||||
| 					  if (err == NOERR) | ||||
| 							sog.rewrite(); | ||||
| 						else | ||||
| 				    { | ||||
| 							const TRectype& riga = _sdonazioni->row(1); | ||||
| 							sog.put(SOG_DATAISC,riga.get(DON_DATADON)); | ||||
| 						{ | ||||
| 							error_box("Errore %d in scrittura archivio soggetti, riga %d", err, rigasog); | ||||
| 							break; | ||||
| 						} | ||||
| 					}					 | ||||
| 				  // aggiorno data e utente ultimo aggiornamento
 | ||||
| 				  const TDate oggi(TODAY); | ||||
| 				  sog.put(SOG_DATAULTAGG,oggi); | ||||
| 				  sog.put(SOG_UTENULTAGG,user()); | ||||
| 				  if (err == NOERR) | ||||
| 						sog.rewrite(); | ||||
| 					else | ||||
| 					{ | ||||
| 						error_box("Errore %d durante la scrittura della riga %d", err, rigasog); | ||||
| 						break; | ||||
| 					} | ||||
| 						error_box("Errore %d in scrittura archivio donazioni, riga %d", err, rigasog); | ||||
| 				}	 | ||||
| 			}				 | ||||
| 		}														 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user