8 #include "../headers/Documents.h"
27 tinyxml2::XMLDocument doc;
29 tinyxml2::XMLNode * root = doc.NewElement(
"HatchKeeper");
31 doc.InsertFirstChild(root);
35 tinyxml2::XMLElement * tmp = doc.NewElement(
"Version");
37 root->InsertEndChild(tmp);
43 tinyxml2::XMLElement * batchNum = doc.NewElement(
"Batches");
45 root->InsertEndChild(batchNum);
50 tinyxml2::XMLElement * batchdata = doc.NewElement(
"Batch");
51 batchNum->InsertEndChild(batchdata);
54 tmp = doc.NewElement(
"Name");
56 batchdata->InsertEndChild(tmp);
59 tmp = doc.NewElement(
"Type");
61 batchdata->InsertEndChild(tmp);
64 tmp = doc.NewElement(
"Breed");
66 batchdata->InsertEndChild(tmp);
69 tmp = doc.NewElement(
"Eggs");
71 batchdata->InsertEndChild(tmp);
74 tmp = doc.NewElement(
"Fertile");
76 batchdata->InsertEndChild(tmp);
79 tmp = doc.NewElement(
"Chicks");
81 batchdata->InsertEndChild(tmp);
84 tmp = doc.NewElement(
"Comments");
86 batchdata->InsertEndChild(tmp);
89 tmp = doc.NewElement(
"Incubator");
91 batchdata->InsertEndChild(tmp);
94 tmp = doc.NewElement(
"Group");
96 batchdata->InsertEndChild(tmp);
99 tmp = doc.NewElement(
"Start");
101 batchdata->InsertEndChild(tmp);
104 tmp = doc.NewElement(
"Candle");
106 batchdata->InsertEndChild(tmp);
109 tmp = doc.NewElement(
"Lockdown");
111 batchdata->InsertEndChild(tmp);
114 tmp = doc.NewElement(
"Hatch");
116 batchdata->InsertEndChild(tmp);
119 tmp = doc.NewElement(
"Adv");
121 batchdata->InsertEndChild(tmp);
129 tinyxml2::XMLElement * advanced = doc.NewElement(
"Advanced");
130 advanced->SetAttribute(
"EggCount", AdvData.
GetEggCount());
131 advanced->SetAttribute(
"WeightUnit", AdvData.
GetUnit());
132 batchdata->InsertEndChild(advanced);
136 tinyxml2::XMLElement * egg = doc.NewElement(
"Egg");
137 advanced->InsertEndChild(egg);
140 tmp = doc.NewElement(
"Tag1");
142 egg->InsertEndChild(tmp);
144 tmp = doc.NewElement(
"Tag2");
146 egg->InsertEndChild(tmp);
148 tmp = doc.NewElement(
"Tag3");
150 egg->InsertEndChild(tmp);
153 tmp = doc.NewElement(
"Fertile");
155 egg->InsertEndChild(tmp);
158 tmp = doc.NewElement(
"Pipped");
160 egg->InsertEndChild(tmp);
163 tmp = doc.NewElement(
"Result");
165 egg->InsertEndChild(tmp);
168 tmp = doc.NewElement(
"Date");
170 egg->InsertEndChild(tmp);
173 tmp = doc.NewElement(
"Comments");
175 egg->InsertEndChild(tmp);
178 tinyxml2::XMLElement * days = doc.NewElement(
"Days");
180 egg->InsertEndChild(days);
182 for(
int c = 0; c < AdvData.
GetEgg(b).GetDays(); c++) {
187 tinyxml2::XMLElement * day = doc.NewElement(
"Day");
188 days->InsertEndChild(day);
191 tmp = doc.NewElement(
"Weight");
192 tmp->SetText(weights[c].GetString().c_str());
193 day->InsertEndChild(tmp);
196 tmp = doc.NewElement(
"Comments");
197 tmp->SetText(comms[c].c_str());
198 day->InsertEndChild(tmp);
207 tinyxml2::XMLElement * grps = doc.NewElement(
"Groups");
208 root->InsertEndChild(grps);
211 tinyxml2::XMLElement * grp = doc.NewElement(
"Group");
214 grps->InsertEndChild(grp);
220 tinyxml2::XMLElement * typs = doc.NewElement(
"Types");
221 root->InsertEndChild(typs);
224 tinyxml2::XMLElement * typ = doc.NewElement(
"Type");
227 typs->InsertEndChild(typ);
233 tinyxml2::XMLElement * bres = doc.NewElement(
"Breeds");
234 root->InsertEndChild(bres);
237 tinyxml2::XMLElement * bre = doc.NewElement(
"Breed");
241 bres->InsertEndChild(bre);
247 tinyxml2::XMLElement * schs = doc.NewElement(
"Schedules");
248 root->InsertEndChild(schs);
251 tinyxml2::XMLElement * sch = doc.NewElement(
"Schedule");
254 schs->InsertEndChild(sch);
259 if(doc.SaveFile(Filename.c_str()) != tinyxml2::XML_SUCCESS)
274 int version,BNumber,count1, Int1, Int2, Int3,a;
275 string tenStars =
"**********",GName, GComment, Str1;
281 tinyxml2::XMLDocument doc;
283 if(doc.LoadFile(Filename.c_str()) == tinyxml2::XML_SUCCESS) {
284 tinyxml2::XMLNode * root = doc.FirstChildElement(
"HatchKeeper");
289 tinyxml2::XMLElement * version = root->FirstChildElement(
"Version");
291 version->QueryIntText(&ver);
293 tinyxml2::XMLElement * batches = root->FirstChildElement(
"Batches");
296 if(batches !=
nullptr) {
297 for(tinyxml2::XMLElement * batch = batches->FirstChildElement(
"Batch"); batch != NULL; batch = batch->NextSiblingElement()) {
301 tinyxml2::XMLElement * tmp = batch->FirstChildElement(
"Name");
312 tmp = batch->FirstChildElement(
"Type");
316 tmp = batch->FirstChildElement(
"Breed");
321 tmp = batch->FirstChildElement(
"Eggs");
322 tmp->QueryIntText(&eggs);
327 tmp = batch->FirstChildElement(
"Fertile");
328 tmp->QueryIntText(&fertile);
333 tmp = batch->FirstChildElement(
"Chicks");
334 tmp->QueryIntText(&chicks);
338 tmp = batch->FirstChildElement(
"Comments");
342 tmp = batch->FirstChildElement(
"Incubator");
346 tmp = batch->FirstChildElement(
"Group");
350 tmp = batch->FirstChildElement(
"Start");
354 tmp = batch->FirstChildElement(
"Candle");
358 tmp = batch->FirstChildElement(
"Lockdown");
362 tmp = batch->FirstChildElement(
"Hatch");
367 tmp = batch->FirstChildElement(
"Adv");
368 tmp->QueryIntText(&advStat);
377 tinyxml2::XMLElement * advanced = batch->FirstChildElement(
"Advanced");
378 Adv.
SetUnit(advanced->IntAttribute(
"WeightUnit",0));
380 for(tinyxml2::XMLElement * egg = advanced->FirstChildElement(
"Egg"); egg != NULL; egg = egg->NextSiblingElement()) {
383 tmp = egg->FirstChildElement(
"Tag1");
386 tmp = egg->FirstChildElement(
"Tag2");
389 tmp = egg->FirstChildElement(
"Tag3");
393 tmp = egg->FirstChildElement(
"Date");
397 tmp = egg->FirstChildElement(
"Comments");
403 tmp = egg->FirstChildElement(
"Fertile");
404 tmp->QueryIntText(&tempInt);
408 tmp = egg->FirstChildElement(
"Pipped");
409 tmp->QueryIntText(&tempInt);
413 tmp = egg->FirstChildElement(
"Result");
414 tmp->QueryIntText(&tempInt);
418 tinyxml2::XMLElement * days = egg->FirstChildElement(
"Days");
421 vector<HK_Weight> weights;
422 vector<string> comms;
424 for(tinyxml2::XMLElement * day = days->FirstChildElement(
"Day"); day != NULL; day = day->NextSiblingElement()) {
425 tmp = day->FirstChildElement(
"Weight");
426 tmpWeight.
Set(tmp->GetText());
427 weights.push_back(tmpWeight);
429 tmp = day->FirstChildElement(
"Comments");
430 comms.push_back(tmp->GetText());
443 vector<string> tempSQL = Batch.
GetSQL();
444 SQL.insert(SQL.end(),tempSQL.begin(),tempSQL.end());
450 tinyxml2::XMLElement * grps = root->FirstChildElement(
"Groups");
451 if(grps !=
nullptr) {
452 for(tinyxml2::XMLElement * grp = grps->FirstChildElement(
"Group"); grp != NULL; grp = grp->NextSiblingElement(
"Group")) {
457 Groups->
Add(grp->GetText(),
id,grp->Attribute(
"Comments",0));
458 SQL.push_back(
"INSERT INTO Groups VALUES(" + to_string(
id) +
",'" + grp->GetText() +
"','"+grp->Attribute(
"Comments",0) +
"');");
463 tinyxml2::XMLElement * typs = root->FirstChildElement(
"Types");
464 if(typs !=
nullptr) {
465 for(tinyxml2::XMLElement * typ = typs->FirstChildElement(
"Type"); typ != NULL; typ = typ->NextSiblingElement(
"Type")) {
472 Types->
Add(typ->GetText(),
id,typ->Attribute(
"Days",0));
474 SQL.push_back(
"INSERT INTO Types VALUES(" + to_string(
id) +
",'"+ typ->GetText() +
"',"+ typ->Attribute(
"Days",0) +
");");
479 tinyxml2::XMLElement * brds = root->FirstChildElement(
"Breeds");
480 if(typs !=
nullptr) {
481 for(tinyxml2::XMLElement * brd = brds->FirstChildElement(
"Breed"); brd != NULL; brd = brd->NextSiblingElement(
"Breed")) {
488 Breeds->
Add(brd->GetText(),
id,brd->Attribute(
"Type",0),brd->IntAttribute(
"Days",0));
490 SQL.push_back(
"INSERT INTO Breeds VALUES(" + to_string(
id) +
",'"+ brd->GetText() +
"','"+ brd->Attribute(
"Type",0) +
"',"+ brd->Attribute(
"Days",0) +
" );");
495 tinyxml2::XMLElement * schs = root->FirstChildElement(
"Schedules");
496 if(typs !=
nullptr) {
497 for(tinyxml2::XMLElement * sch = schs->FirstChildElement(
"Schedule"); sch != NULL; sch = sch->NextSiblingElement(
"Schedule")) {
504 Schedules->
Add(sch->GetText(),
id,sch->Attribute(
"Date",0));
506 SQL.push_back(
"INSERT INTO Schedules VALUES(" + to_string(
id) +
",'"+ sch->GetText() +
"',"+ sch->Attribute(
"Date",0) +
");");
512 streambuf *cinBackup = cin.rdbuf();
513 ifstream inFile(Filename.c_str());
516 cout<<
"Log: Error Reading .hkbf File!"<<endl;
520 cout<<
"Log: Reading .hkbf File: "<<Filename<<endl;
522 cin.rdbuf(inFile.rdbuf());
546 cin>>Int1>>Int2>>Int3;
547 Date.
SetDate(Int1, Int2, Int3);
550 cin>>Int1>>Int2>>Int3;
551 Date.
SetDate(Int1, Int2, Int3);
554 cin>>Int1>>Int2>>Int3;
555 Date.
SetDate(Int1, Int2, Int3);
558 cin>>Int1>>Int2>>Int3;
559 Date.
SetDate(Int1, Int2, Int3);
576 while(getline(cin, line)) {
590 vector<string> tempSQL = Batch.
GetSQL();
591 SQL.insert(SQL.end(),tempSQL.begin(),tempSQL.end());
600 while(a < 2) { getline(cin, Str1);a++;}
607 while(a < 2){ getline(cin, Str1);a++; }
610 cin>>Int1>>Int2>>Int3;
611 Date.
SetDate(Int1, Int2, Int3);
614 cin>>Int1>>Int2>>Int3;
615 Date.
SetDate(Int1, Int2, Int3);
618 cin>>Int1>>Int2>>Int3;
619 Date.
SetDate(Int1, Int2, Int3);
622 cin>>Int1>>Int2>>Int3;
623 Date.
SetDate(Int1, Int2, Int3);
633 while(a < 2){ getline(cin, Str1); a++; }
637 while(a < 1){ getline(cin, Str1); a++; }
642 while(getline(cin, line)){ Str1 += line +
"\n"; }
650 vector<string> tempSQL = Batch.
GetSQL();
651 SQL.insert(SQL.end(),tempSQL.begin(),tempSQL.end());
658 while(a < 2){ getline(cin, GName); a++; }
660 for(count1 = 0; count1 < BNumber;count1++) {
666 Batch.
SetName(Str1 +
"_Imported");
672 while(a < 2){ getline(cin, Str1);a++; }
675 cin>>Int1>>Int2>>Int3;
676 Date.
SetDate(Int1, Int2, Int3);
679 cin>>Int1>>Int2>>Int3;
680 Date.
SetDate(Int1, Int2, Int3);
683 cin>>Int1>>Int2>>Int3;
684 Date.
SetDate(Int1, Int2, Int3);
687 cin>>Int1>>Int2>>Int3;
688 Date.
SetDate(Int1, Int2, Int3);
698 while(a < 2){ getline(cin, Str1); a++; }
706 while(getline(cin, line)) {
722 vector<string> tempSQL = Batch.
GetSQL();
723 SQL.insert(SQL.end(),tempSQL.begin(),tempSQL.end());
727 while(getline(cin, line)) {
731 GComment += line +
"\n";
739 SQL.push_back(
"INSERT INTO Groups VALUES(" + to_string(
id) +
",'" + GName +
"','" + GComment +
"');");
744 cin.rdbuf(cinBackup);
760 string Report =
"\t" + Batch.
GetName() +
"\n\n" \
761 "Type:..................." + Batch.
GetType() +
"\n\n" \
762 "Breed:.................." + Batch.
GetBreed() +
"\n\n" \
767 "Number Of Eggs:........." + to_string(Batch.
GetEggs()) +
"\n\n" \
768 "Number Fertile:........." + to_string(Batch.
GetFertile()) +
"\n" \
769 "Percent Were Fertile:..." + to_string(Batch.
PercentFertile()) +
"%\n\n" \
770 "Chicks Hatched:........." + to_string(Batch.
GetChicks()) +
"\n" \
771 "Percent of Total:......." + to_string(Batch.
PercentOfTotal()) +
"%\n" \
773 "Percent of Fertile:....." + to_string(Batch.
PercentOfFertile()) +
"%\n\n" \
780 Report +=
"\n\n********************************************************\n" \
781 "Egg Data For " + Batch.
GetName() +
"\n" \
782 "********************************************************\n\n";
788 for(
int A = 0; A < Batch.
GetEggs(); A++){
791 Report +=
"Egg " + to_string(A+1) +
":\n\n";
795 Report += Tag1[0] +
" : Not Set\n";
797 Report += Tag1[0] +
" : " + Egg.
GetTag1() +
"\n";
800 Report += Tag2[0] +
" : Not Set\n";
802 Report += Tag2[0] +
" : " + Egg.
GetTag2() +
"\n";
805 Report += Tag3[0] +
" : Not Set\n";
807 Report += Tag3[0] +
" : " + Egg.
GetTag3() +
"\n";
811 Report +=
"Fertile: False\n";
813 Report +=
"Fertile: True\n";
816 Report +=
"Pipped: False\n\n";
818 Report +=
"Pipped: True\n\n";
830 Report +=
"Egg Comments:\n" + Egg.
GetComments() +
"\n\n";
833 Report +=
"Day: Weight: % Lost: Comments\n" \
834 "________________________________________________________\n";
836 for(
int Day = 0; Day < Egg.
GetDays(); Day++) {
837 Report += to_string(Day + 1) +
" " + Egg.
GetDayWeight()[Day].GetString();
844 Report +=
"________________________________________________________\n";
846 Report +=
"Total % Weight Lost: " + to_string(Egg.
CalcTotalLoss()) +
"%\n\n";
849 Report +=
"Avg % Weight Loss For All Eggs In Batch: " + to_string(Adv.
CalcAvgLoss()) +
"%\n\n";
859 string HTML =
"<table border='10' width='100%'><tr><td width='50%'>";
860 HTML +=
"<table style='width:100%;'>";
861 HTML +=
"<tr><td>Name</td><td>" + Batch.
GetName() +
"</td></tr>";
862 HTML +=
"<tr><td>Type</td><td>" + Batch.
GetType() +
"</td></tr>";
863 HTML +=
"<tr><td>Breed</td><td>" + Batch.
GetBreed() +
"</td></tr>";
864 HTML +=
"<tr><td><hr/></td><td><hr/></td></tr>";
869 HTML +=
"<tr><td><hr/></td><td><hr/></td></tr>";
870 HTML +=
"<tr><td>Number Of Eggs</td><td>" + to_string(Batch.
GetEggs()) +
"</td></tr>";
871 HTML +=
"<tr><td>Number Fertile</td><td>" + to_string(Batch.
GetFertile()) +
"</td></tr>";
872 HTML +=
"<tr><td>% Were Fertile</td><td>" + to_string(Batch.
PercentFertile()) +
"%</td></tr>";
873 HTML +=
"<tr><td><hr/></td><td><hr/></td></tr>";
874 HTML +=
"<tr><td>Chicks Hatched</td><td>" + to_string( Batch.
GetChicks()) +
"</td></tr>";
875 HTML +=
"<tr><td>% Of Fertile Hatched</td><td>" + to_string(Batch.
PercentOfFertile()) +
"%</td></tr>";
876 HTML +=
"<tr><td>% Of Total Hatched</td><td>" + to_string(Batch.
PercentOfTotal()) +
"%</td></tr>";
878 HTML +=
"</table></td><td><table width='100%'><tr>";
879 HTML +=
"<td style='width:50%;text-align:left'><p>0%</p></td>";
880 HTML +=
"<td style='width:50%;text-align:right'><p>100%</p></td>";
881 HTML +=
"</tr></table>";
884 HTML +=
"<label>% Were Fertile</label><hr width='";
886 HTML +=
"1%' size='20'/>";
890 HTML +=
"<label>% Of Fertile Hatched</label><hr width='";
892 HTML +=
"1%' size='20'/>";
896 HTML +=
"<label>% Of Total Hatched</label><hr width='";
898 HTML +=
"1%' size='20'/>";
902 HTML +=
"<label>% Of Total Unhatched</label><hr width='";
904 HTML +=
"1%' size='20'/>";
908 HTML +=
"</td></tr><tr><td colspan='2'>"+Batch.
GetComments();
909 HTML +=
"<hr/><hr/><hr/><hr/></td></tr>";
928 TD1 +=
"<tr valign='top'><td colspan='2'>Egg:</td><td colspan='2'>" + to_string(A+1) +
"</td></tr>";
932 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag1[0]+
":</td><td colspan='2'>Not Set</td></tr>";
934 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag1[0]+
":</td><td colspan='2'>"+Egg.
GetTag1()+
"</td></tr>";
937 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag2[0]+
":</td><td colspan='2'>Not Set</td></tr>";
939 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag2[0]+
":</td><td colspan='2'>"+Egg.
GetTag2()+
"</td></tr>";
942 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag3[0]+
":</td><td colspan='2'>Not Set</td></tr>";
944 TD1 +=
"<tr valign='top'><td colspan='2'>"+Tag3[0]+
":</td><td colspan='2'>"+Egg.
GetTag3()+
"</td></tr>";
946 TD1 +=
"<tr><td colspan='2'><hr/></td><td colspan='2'><hr/></td></tr>" \
947 "<tr><td>Day:</td><td>Weight:</td><td>% Lost:</td><td>Comments</td></tr>";
953 TD2 +=
"<tr><td colspan='2'>Fertile:</td><td colspan='2'>False</td></tr>";
955 TD2 +=
"<tr><td colspan='2'>Fertile:</td><td colspan='2'>True</td></tr>";
958 TD2 +=
"<tr><td colspan='2'>Pipped:</td><td colspan='2'>False</td></tr>";
960 TD2 +=
"<tr><td colspan='2'>Pipped:</td><td colspan='2'>True</td></tr>";
963 TD2 +=
"<tr><td colspan='2'>";
965 TD2 +=
"Unknown Result:";
972 "</td></tr><tr><td colspan='2'>Comments:</td><td colspan='2'>" + Egg.
GetComments() + \
973 "</tr><tr><td colspan='2'><hr/></td><td colspan='2'><hr/></td></tr>" \
974 "<tr><td>Day:</td><td>Weight:</td><td>% Lost:</td><td>Comments</td></tr>";
976 for(
int Day = 0; Day < Egg.
GetDays(); Day++){
978 TD1 +=
"<tr><td>" + to_string(Day + 1) +
"</td><td>" + Egg.
GetDayWeight()[Day].GetString();
983 TD1 +=
"</td><td>" + to_string(Egg.
CalcDayLoss(Day)) + \
986 TD2 +=
"<tr><td>" + to_string(Day + 1) +
"</td><td>" + Egg.
GetDayWeight()[Day].GetString();
991 TD2 +=
"</td><td>" + to_string(Egg.
CalcDayLoss(Day)) + \
995 TD1 +=
"<tr><td colspan='2'>Total % Weight Lost:</td><td colspan='2'>" + \
999 TD2 +=
"<tr><td colspan='2'><hr/></td><td colspan='2'><hr/></td></tr>";
1002 TD2 +=
"<tr><td colspan='2'><hr/></td><td colspan='2'><hr/></td></tr>";
1005 HTML +=
"<tr><td valign='top' ><table>" + TD1 +
"</table><td><table valign='top' >" + \
1006 TD2 +
"</table></td></tr>";
1021 string Report =
"********************************************************";
1022 Report +=
"\nReport For Group: " + GroupName +
"\n\n";
1023 Report +=
"********************************************************\n\n";
1026 for(
int A = 0; A < GrBatches.
GetCount(); A++) {
1028 Report +=
"\n\n********************************************************\n\n";
1031 Report +=
"Averages For This Group:\n\n";
1032 Report +=
"********************************************************\n\n";
1033 Report +=
"Total Eggs In This Group = " + to_string(GrBatches.
TotalEggs()) +
"\n";
1034 Report +=
"Total Chicks From This Group = " + to_string(GrBatches.
TotalChicks()) +
"\n";
1035 Report +=
"Average % Were Fertile = " + to_string(GrBatches.
AvgFertile()) +
"%\n";
1036 Report +=
"Average % Of Fertile Hatched = " + to_string(GrBatches.
AvgFertileHatch()) +
"%\n";
1037 Report +=
"Average % Of Total Hatched = " + to_string(GrBatches.
AvgTotalHatch()) +
"%\n";
1038 Report +=
"Average % Of Total Unhatched = " + to_string(GrBatches.
AvgTotalUnHatch()) +
"%\n";
1041 Report +=
"\n********************************************************\n";
1042 Report +=
"Group Comments:\n";
1043 Report +=
"********************************************************\n\n";
1044 Report +=
"\n" + Comments +
"\n\n";
1054 string Report =
"<html><head><title>Group: " + GroupName;
1055 Report +=
" Report</title></head><body><table width='100%' ><tr><td><h1 style='text-align:center;'>Group: ";
1056 Report += GroupName +
" Report</h1></td></tr>";
1058 for(
int A = 0; A < GrBatches.
GetCount(); A++)
1062 Report +=
"<tr><td><table border='10' width='100%' >";
1063 Report +=
"<tr><td colspan='2' style='text-align:center'><h2>Group Statisics</h2></td></tr>";
1064 Report +=
"<tr><td>" + to_string(GrBatches.
TotalEggs()) +
" Total Eggs In Group</td>";
1065 Report +=
"<td>" + to_string(GrBatches.
TotalChicks()) +
" Total Chicks In Group</td></tr><tr>";
1066 Report +=
"<td>" + to_string(GrBatches.
AvgFertile()) +
"% (Avg) Were Fertile</td>";
1067 Report +=
"<td>" + to_string(GrBatches.
AvgFertileHatch()) +
"% (Avg) Of Fertile Hatched</td></tr><tr>";
1068 Report +=
"<td>" + to_string(GrBatches.
AvgTotalHatch()) +
"% (Avg) Of Total Hatched</td>";
1069 Report +=
"<td>" + to_string(GrBatches.
AvgTotalUnHatch()) +
"% (Avg) Of Total Unhatched</td></tr>";
1070 Report +=
"<tr><td colspan='2'>Group Comments:\n"+ Comments +
"</td></tr>";
1071 Report +=
"</table></body></html>";
1080 string calEnd =
"\n";
1084 string calEnd =
"\r\n";
1088 string ModName = Batch.
GetName();
1090 for(
unsigned int A = 0; A < ModName.length(); A++)
1091 if(ModName[A] ==
' ')
1106 iCal +=
"BEGIN:VCALENDAR" + calEnd;
1107 iCal +=
"PRODID:-//HatchKeeper//HatchKeeper-v0.80.0//EN" + calEnd;
1108 iCal +=
"VERSION:2.0" + calEnd;
1109 iCal +=
"CALSCALE:GREGORIAN" + calEnd;
1110 iCal +=
"X-WR-CALNAME:" + Batch.
GetName() + calEnd;
1111 iCal +=
"X-WR-CALDESC:This Was Automatically Generated by HatchKeeper" + calEnd;
1116 iCal +=
"BEGIN:VEVENT" + calEnd;
1117 iCal +=
"DTSTART;VALUE=DATE:" + S.
ToSortable(
"") + calEnd;
1118 iCal +=
"DTEND;VALUE=DATE:" + I.
ToSortable(
"") + calEnd;
1120 iCal +=
"UID:" + ModName + S.
ToSortable(
"") + calEnd;
1122 iCal +=
"DESCRIPTION: Start Date For " + Batch.
GetName() + calEnd;
1124 iCal +=
"LOCATION:" + calEnd;
1125 iCal +=
"SEQUENCE:0" + calEnd;
1126 iCal +=
"STATUS:CONFIRMED" + calEnd;
1127 iCal +=
"SUMMARY:Start Date for " + Batch.
GetName() + calEnd;
1128 iCal +=
"TRANSP:TRANSPARENT" + calEnd;
1129 iCal +=
"END:VEVENT" + calEnd;
1135 iCal +=
"BEGIN:VEVENT" + calEnd;
1136 iCal +=
"DTSTART;VALUE=DATE:" + C.
ToSortable(
"") + calEnd;
1137 iCal +=
"DTEND;VALUE=DATE:" + I.
ToSortable(
"") + calEnd;
1139 iCal +=
"UID:" + to_string(C.
GetDay()) + ModName + to_string(C.
GetMonth()) + to_string(C.
GetYear()) + calEnd;
1141 iCal +=
"DESCRIPTION: Candle Date For " + Batch.
GetName() + calEnd;
1143 iCal +=
"LOCATION:" + calEnd;
1144 iCal +=
"SEQUENCE:0" + calEnd;
1145 iCal +=
"STATUS:CONFIRMED" + calEnd;
1146 iCal +=
"SUMMARY:Candle Date For " + Batch.
GetName() + calEnd;
1147 iCal +=
"TRANSP:TRANSPARENT" + calEnd;
1148 iCal +=
"END:VEVENT" + calEnd;
1154 iCal +=
"BEGIN:VEVENT" + calEnd;
1155 iCal +=
"DTSTART;VALUE=DATE:" + L.
ToSortable(
"") + calEnd;
1156 iCal +=
"DTEND;VALUE=DATE:" + I.
ToSortable(
"") + calEnd;
1158 iCal +=
"UID:" + to_string(L.
GetDay()) + to_string(L.
GetMonth()) + ModName + to_string(L.
GetYear()) + calEnd;
1160 iCal +=
"DESCRIPTION: Lockdown For " + Batch.
GetName() + calEnd;
1162 iCal +=
"LOCATION:" + calEnd;
1163 iCal +=
"SEQUENCE:0" + calEnd;
1164 iCal +=
"STATUS:CONFIRMED" + calEnd;
1165 iCal +=
"SUMMARY:Lockdown/Remove Turners For " + Batch.
GetName() + calEnd;
1166 iCal +=
"TRANSP:TRANSPARENT" + calEnd;
1167 iCal +=
"END:VEVENT" + calEnd;
1173 iCal +=
"BEGIN:VEVENT" + calEnd;
1174 iCal +=
"DTSTART;VALUE=DATE:" + H.
ToSortable(
"") + calEnd;
1175 iCal +=
"DTEND;VALUE=DATE:" + I.
ToSortable(
"") + calEnd;
1177 iCal +=
"UID:" + H.
ToSortable(
"") + ModName + calEnd;
1179 iCal +=
"DESCRIPTION: Hatch Date For " + Batch.
GetName() + calEnd;
1181 iCal +=
"LOCATION:" + calEnd;
1182 iCal +=
"SEQUENCE:0" + calEnd;
1183 iCal +=
"STATUS:CONFIRMED" + calEnd;
1184 iCal +=
"SUMMARY:Hatch Date for " + Batch.
GetName() + calEnd;
1185 iCal +=
"TRANSP:TRANSPARENT" + calEnd;
1186 iCal +=
"END:VEVENT" + calEnd;
1190 iCal +=
"END:VCALENDAR" + calEnd;
1200 string calEnd =
"\n";
1204 string calEnd =
"\r\n";
1207 string iCal =
"BEGIN:VCALENDAR" + calEnd;
1208 iCal +=
"PRODID:-//HatchKeeper//HatchKeeper-v0.80.0//EN" + calEnd;
1209 iCal +=
"VERSION:2.0" + calEnd;
1210 iCal +=
"CALSCALE:GREGORIAN" + calEnd;
1211 iCal +=
"X-WR-CALNAME:" + GroupName + calEnd;
1212 iCal +=
"X-WR-CALDESC:This Was Automatically Generated by HatchKeeper" + calEnd;
1214 for(
int A = 0; A < GrBatches.
GetCount(); A++)
1217 iCal +=
"END:VCALENDAR" + calEnd;
1225 vector<string> Events;
1226 int a,count1, count2;
1227 int datesPerDay = 0;
1242 for(count2 = count1; Day <= CalDate.
DaysInMonth(); count2++) {
1244 n1[count2] = to_string(Day);
1252 Events.push_back(
"Day " + to_string(Day) +
": Start Date For " +
Batches.
GetName(a));
1254 if(datesPerDay == 3)
1255 r1[count2] = r1[count2] +
"<br />";
1257 r1[count2] = r1[count2] +
" SD,";
1264 Events.push_back(
"Day " + to_string(Day) +
": Candle Date For " +
Batches.
GetName(a));
1266 if(datesPerDay == 3)
1267 r1[count2] = r1[count2] +
"<br />";
1269 r1[count2] = r1[count2] +
" CD,";
1275 Events.push_back(
"Day " + to_string(Day) +
": Lockdown Date For " +
Batches.
GetName(a));
1277 if(datesPerDay == 3)
1278 r1[count2] = r1[count2] +
"<br />";
1280 r1[count2] = r1[count2] +
" LD,";
1286 Events.push_back(
"Day " + to_string(Day) +
": Hatch Date For " +
Batches.
GetName(a));
1288 if(datesPerDay == 3)
1289 r1[count2] = r1[count2] +
"<br />";
1291 r1[count2] = r1[count2] +
" HD,";
1300 if(datesPerDay <= 3)
1301 r1[count2] = r1[count2] +
"<br />";
1308 for(count1 = count2; count1 < 42; count1++){
1315 string HTML =
"<html>\n<head>\n<title>HatchKeeper Calendar</title>";
1316 HTML +=
"</head>\n<body>";
1317 HTML +=
"<p><small>SD = Start Date.</small> <small>CD = Candle Date.</small> <small>LD = Lockdown Date.</small> <small>HD = Hatch Date.</small></p>";
1319 HTML +=
"<table align='center' width='100%' border='3'>";
1321 HTML +=
"<td><pre> Sun </pre></td>";
1322 HTML +=
"<td><pre> Mon </pre></td>";
1323 HTML +=
"<td><pre> Tue </pre></td>";
1324 HTML +=
"<td><pre> Wed </pre></td>";
1325 HTML +=
"<td><pre> Thu </pre></td>";
1326 HTML +=
"<td><pre> Fri </pre></td>";
1327 HTML +=
"<td><pre> Sat </pre></td>";
1330 HTML +=
"<td>" + n1[0] +
"<br /> <small>" + r1[0] +
" </small> </td>";
1331 HTML +=
"<td>" + n1[1] +
"<br /> <small>" + r1[1] +
" </small> </td>";
1332 HTML +=
"<td>" + n1[2] +
"<br /> <small>" + r1[2] +
" </small> </td>";
1333 HTML +=
"<td>" + n1[3] +
"<br /> <small>" + r1[3] +
" </small> </td>";
1334 HTML +=
"<td>" + n1[4] +
"<br /> <small>" + r1[4] +
" </small> </td>";
1335 HTML +=
"<td>" + n1[5] +
"<br /> <small>" + r1[5] +
" </small> </td>";
1336 HTML +=
"<td>" + n1[6] +
"<br /> <small>" + r1[6] +
" </small> </td>";
1339 HTML +=
"<td>" + n1[7] +
"<br /> <small>" + r1[7] +
" </small> </td>";
1340 HTML +=
"<td>" + n1[8] +
"<br /> <small>" + r1[8] +
" </small> </td>";
1341 HTML +=
"<td>" + n1[9] +
"<br /> <small>" + r1[9] +
" </small> </td>";
1342 HTML +=
"<td>" + n1[10] +
"<br /> <small>" + r1[10] +
" </small> </td>";
1343 HTML +=
"<td>" + n1[11] +
"<br /> <small>" + r1[11] +
" </small> </td>";
1344 HTML +=
"<td>" + n1[12] +
"<br /> <small>" + r1[12] +
" </small> </td>";
1345 HTML +=
"<td>" + n1[13] +
"<br /> <small>" + r1[13] +
" </small> </td>";
1348 HTML +=
"<td>" + n1[14] +
"<br /> <small>" + r1[14] +
" </small> </td>";
1349 HTML +=
"<td>" + n1[15] +
"<br /> <small>" + r1[15] +
" </small> </td>";
1350 HTML +=
"<td>" + n1[16] +
"<br /> <small>" + r1[16] +
" </small> </td>";
1351 HTML +=
"<td>" + n1[17] +
"<br /> <small>" + r1[17] +
" </small> </td>";
1352 HTML +=
"<td>" + n1[18] +
"<br /> <small>" + r1[18] +
" </small> </td>";
1353 HTML +=
"<td>" + n1[19] +
"<br /> <small>" + r1[19] +
" </small> </td>";
1354 HTML +=
"<td>" + n1[20] +
"<br /> <small>" + r1[20] +
" </small> </td>";
1357 HTML +=
"<td>" + n1[21] +
"<br /> <small>" + r1[21] +
" </small> </td>";
1358 HTML +=
"<td>" + n1[22] +
"<br /> <small>" + r1[22] +
" </small> </td>";
1359 HTML +=
"<td>" + n1[23] +
"<br /> <small>" + r1[23] +
" </small> </td>";
1360 HTML +=
"<td>" + n1[24] +
"<br /> <small>" + r1[24] +
" </small> </td>";
1361 HTML +=
"<td>" + n1[25] +
"<br /> <small>" + r1[25] +
" </small> </td>";
1362 HTML +=
"<td>" + n1[26] +
"<br /> <small>" + r1[26] +
" </small> </td>";
1363 HTML +=
"<td>" + n1[27] +
"<br /> <small>" + r1[27] +
" </small> </td>";
1366 HTML +=
"<td>" + n1[28] +
"<br /> <small>" + r1[28] +
" </small> </td>";
1367 HTML +=
"<td>" + n1[29] +
"<br /> <small>" + r1[29] +
" </small> </td>";
1368 HTML +=
"<td>" + n1[30] +
"<br /> <small>" + r1[30] +
" </small> </td>";
1369 HTML +=
"<td>" + n1[31] +
"<br /> <small>" + r1[31] +
" </small> </td>";
1370 HTML +=
"<td>" + n1[32] +
"<br /> <small>" + r1[32] +
" </small> </td>";
1371 HTML +=
"<td>" + n1[33] +
"<br /> <small>" + r1[33] +
" </small> </td>";
1372 HTML +=
"<td>" + n1[34] +
"<br /> <small>" + r1[34] +
" </small> </td>";
1375 HTML +=
"<td>" + n1[35] +
"<br /> <small>" + r1[35] +
" </small> </td>";
1376 HTML +=
"<td>" + n1[36] +
"<br /> <small>" + r1[36] +
" </small> </td>";
1377 HTML +=
"<td>" + n1[37] +
"<br /> <small>" + r1[37] +
" </small> </td>";
1378 HTML +=
"<td>" + n1[38] +
"<br /> <small>" + r1[38] +
" </small> </td>";
1379 HTML +=
"<td>" + n1[39] +
"<br /> <small>" + r1[39] +
" </small> </td>";
1380 HTML +=
"<td>" + n1[40] +
"<br /> <small>" + r1[40] +
" </small> </td>";
1381 HTML +=
"<td>" + n1[41] +
"<br /> <small>" + r1[41] +
" </small> </td>";
1382 HTML +=
"</tr>\n</table>\n</p>";
1384 HTML +=
"<p>Dates For This Month</p>\n <ul align='center'>";
1386 for(a = 0; a < Events.size(); a++)
1387 HTML +=
"<li><small>" + Events[a] +
"</small></li>";
1389 HTML +=
"</ul></ul>\n</p>\n</body>\n</html>";
A Class For Managing Multiple HK_Egg Instances.
HK_Egg GetEgg(int Select)
Returns The Selected Egg.
int GetEggCount()
Returns The Number Of Eggs.
void AddEgg(HK_Egg Egg)
Adds An HK_Egg To HK_AdvEggs Vector.
void SetID(int ID)
Sets ID.
int CalcAvgLoss()
Returns The Average Weight Loss For All Eggs In Batch.
void SetUnit(int Unit)
Sets Weight Unit Used.
int GetUnit()
Returns Weight Unit.
Holds Data For One Batch, Includes Basic Set/Get Methods.
int PercentOfTotal()
Returns The Percentage Of Total Eggs That Hatched.
void SetAdv(int Adv)
Sets Batch Advanced Status.
int PercentFertile()
Returns The Percentage Of Eggs That Were Fertile.
void SetID(int ID)
Sets Batch ID.
void SetAdvanced(HK_Advanced Adv)
Sets Batch Advanced Data.
void SetCandle(HK_Date Candle)
Sets Batch Candle Date.
int GetChicks()
Returns Number Of Hatched Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetChicks()
HK_Date GetCandle()
Returns Batch Candle Date.
vector< string > GetSQL()
Returns An SQL String To Set Batch In Database.
string GetName()
Returns Batch Name.
int GetFertile()
Returns Number Of Fertile Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetFertile()
void SetFertile(int Fertile)
Sets Batch Fertile Eggs.
void SetName(string Name)
Sets Batch Name.
HK_Date GetStart()
Returns Batch Start Date.
void SetRemind(int Remind)
Sets Batch Remind Status For Notifications.
int GetEggs()
Returns Number Of Eggs In Batch.
void SetType(string Type)
Sets Batch Type.
void SetIncubator(string Incubator)
Sets Batch Incubator.
HK_Date GetLockdown()
Returns Batch Lockdown Date.
void SetChicks(int Chicks)
Sets Batch Hatched Eggs.
void SetComments(string Comments)
Sets Batch Comments.
string GetComments()
Returns Batch Comments.
void SetBreed(string Breed)
Sets Batch Breed.
string GetBreed()
Returns Batch Breed.
void SetHatch(HK_Date Hatch)
Sets Batch Hatch Date.
void SetEggs(int Eggs)
Sets Batch Eggs.
int PercentOfTotalUnhatched()
Returns The Percentage Of Total Eggs That Didn't Hatch.
int PercentOfFertile()
Returns The Percentage Of Fertile Eggs That Hatched.
void SetStart(HK_Date Start)
Sets Batch Start Date.
int GetID()
Returns Batch ID.
HK_Advanced GetAdvanced()
Returns Batch Advanced Egg Data.
int GetAdv()
Returns Batch Advanced Status.
string GetType()
Returns Batch Type.
void SetLockdown(HK_Date Lockdown)
Sets Batch Lockdown Date.
void SetGroup(string Group)
Sets Batch Group.
HK_Date GetHatch()
Returns Batch Hatch Date.
A Class For Managing Mulitple HK_Batch Objects.
HK_Advanced GetAdvanced(int Select)
Returns Advanced Egg Data Selected Batch.
HK_Date GetHatch(int Select)
Returns Hatch Date For Selected Batch.
HK_Date GetStart(int Select)
Returns Start Date For Selected Batch.
void Add(HK_Batch Batch)
Adds Another HK_Batch.
int AvgTotalUnHatch()
Returns Average Percentage Of Total Eggs That Did Not Hatch In This HK_Batches Instance.
int AvgFertileHatch()
Returns Average Percentage Of Fertile Eggs That Hatched In This HK_Batches Instance.
string GetIncubator(int Select)
Returns Batch Incubator For Selected Batch.
int GetAdv(int Select)
Returns Advanced Status For Selected Batch.
int GetValidID()
Returns An ID That Isn't Used By Any HK_Batch In This HK_Batches Instance.
int AvgFertile()
Returns Average Percentage Of Eggs Fertile In This HK_Batches Instance.
int GetChicks(int Select)
Returns Number Of Hatched Eggs For Selected Batch.
int GetFertile(int Select)
Returns Number Of Fertile Eggs For Selected Batch.
HK_Date GetCandle(int Select)
Returns Candle Date For Selected Batch.
int TotalEggs()
Returns Total Number Of Eggs In This HK_Batches Instance.
string GetType(int Select)
Returns Batch Type For Selected Batch.
int AvgTotalHatch()
Returns Average Percentage Of Total Eggs That Hatched In This HK_Batches Instance.
HK_Batch GetBatch(int Select)
Returns The Selected Batch.
bool IsValidName(string Name)
Returns True If Name Isn't Already In Use.
string GetGroup(int Select)
Returns Batch Group For Selected Batch.
int GetEggs(int Select)
Returns Number Of Eggs For Selected Batch.
int GetCount()
Returns The Number Of Batches Stored.
HK_Date GetLockdown(int Select)
Returns Lockdown Date For Selected Batch.
string GetComments(int Select)
Returns Batch Comments For Selected Batch.
int TotalChicks()
Returns Total Number Of Chicks In This HK_Batches Instance.
string GetName(int Select)
Returns Batch Name For Selected Batch.
string GetBreed(int Select)
Returns Batch Breed For Selected Batch.
A Class For Managing Dates.
int GetMonth()
Returns Month Value.
std::string ToSortable(std::string Separator)
Generate A Sortable String For Database.
std::string ToReadable(std::string Separator, int Mode)
Generate A Readable String.
int StartDayOfWeek()
Returns What Day Of The Week This HK_Date Month Starts.
bool AddDays(int Days)
Adds Days To This HK_Date.
int GetDay()
Returns Day Value.
bool IsEqual(HK_Date Date)
Checks To See If The Input Date Is Same As Stored Date.
int DaysInMonth()
Returns The Number Of Days In HK_Month. LeapYear Is Checked.
bool SetDate(int Days, int Month, int Year)
Sets Day, Month, and Year.
int GetYear()
Returns Year Value.
HK_Documents()
Constructor.
string BatchTextReport(HK_Batch Batch, HK_KeyValue Settings)
Returns A Text Batch Report For Archiving Batch Data.
string BatchICal(HK_Batch Batch, bool DatesOnly)
Generates iCal Text With Batch Data.
vector< string > ImportHKBF(string Filename, HK_Batches *Batches, HK_Storage *Groups, HK_Storage *Types, HK_Storage *Breeds, HK_Storage *Schedules)
Tries Reading And Generating HK_Batch Objects From HKBF.
string GroupHTMLReport(HK_Batches GrBatches, string GroupName, string Comments, HK_KeyValue Settings)
string GroupTextReport(HK_Batches GrBatches, string GroupName, string Comments, HK_KeyValue Settings)
Generates A Text Group Report For Archiving.
string GroupICal(HK_Batches GrBatches, string GroupName)
Generates iCal Text With Group Data.
string BatchHTMLReport(HK_Batch Batch, HK_KeyValue Settings)
Returns An HTML String For Printing Reports.
string HTMLCalendar(HK_Date Selection, HK_Batches Batches)
Generates A HTML Calendar For This HK_Month Using Dates From Batches.
bool ExportHKBF(string Filename, HK_Batches Batches, HK_Storage Groups)
Overloaded: Exports Multiple Batches, and a Group To A hkbf(xml) File.
A Class For Storing And Retieving Data For One Egg.
int GetResult()
Returns -1 If No Result, 0 If Hatched, And 2 If Egg Quit.
string GetComments()
Returns Egg Comments.
int CalcDayLoss(int Day)
Returns The Percentage Of Weight Lost From Previous Weighing.
void SetDayWeight(vector< HK_Weight > Weight)
Sets Weight For All Days.
void SetDate(HK_Date Date)
Sets Result Date.
void SetComments(string Comments)
Sets Egg Comments.
int GetDays()
Returns The Number Of Days For This Egg.
string GetTag2()
Returns Tag 2 As A String.
int CalcTotalLoss()
Returns The Total Percentage Of Weight Lost By This Egg.
void SetResult(int Result)
Sets Result Status.
HK_Date GetDate()
Returns The Date For The Result.
string GetTag3()
Returns Tag 3 As A String.
void SetTag3(string Tag)
Sets The Third Tag.
void SetTag1(string Tag)
Sets The First Tag.
void SetFertile(int Fertile)
Sets Fertile Status.
vector< string > GetDayComments()
Returns An Array Containing A Comment For Every Day.
vector< HK_Weight > GetDayWeight()
Returns An Array Containing A Weight For Every Day.
void SetPipped(int Pipped)
Sets Pip Status.
void SetTag2(string Tag)
Sets The Second Tag.
int GetPipped()
Returns 0 If Egg Is Not Pipped And 1 If It Is.
string GetTag1()
Returns Tag 1 As A String.
int GetFertile()
Returns 0 If Egg Is Not Fertile And 1 If It Is.
void SetDayComments(vector< string > Comments)
Sets Comments For All Days.
Version And Other Information For HatchKeeper.
std::string GetVersion()
Returns The Version Of HatchKeeper.
A Key and Value Type Storage.
vector< string > GetArray(int Selection)
Returns The Selected Value As An Array Of Strings.
int GetInt(int Selection)
Returns The Selected Setting Value As An Integer.
A Class For Storing Values.
bool IsValidName(string Name)
Returns True If Name Isn't Already In Use.
HK_Date GetDate(int Select)
Returns The Selected Stored Date.
int GetValidID()
Returns A Valid ID For Adding Entries To The Database.
int GetCount()
Returns The Number Of Elements Stored.
int GetNumber(int Select)
Returns The Selected Stored Number.
string GetName(int Select)
Returns The Selected Stored Name.
string GetText(int Select)
Returns The Selected Stored Text.
void Add(string Name, int ID, HK_Date Date, string Text, int Number)
Adds An Item To Storage.
A Class For Managing Data For One Weight.
void Set(float Weight)
Sets The Weight Value Using A Float.