HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
HK_Notifications.cpp
Go to the documentation of this file.
1 /*******************************************************************/
9 #include "../headers/Notifications.h"
10 
16 string HK_Notifications::AddNotification(string Name, HK_Date Date, string Message)
17 {
18  string SQL;
19 
20  for(int A = 0; A < GetCount(); A++) {
21  if(
22  Name == GetName(A) &&
23  Date.IsEqual(GetDate(A)) &&
24  Message == GetText(A)
25  )
26  return SQL;
27  }
28 
29  //Add To Database
30  int NotifyID = GetValidID();
31  SQL = "INSERT INTO Notifications VALUES(" + to_string(NotifyID) + ",'";
32  SQL += Name + "','" + Date.ToSortable("/") + "','" + Message + "',0 );";
33 
34  //Add To Notify
35  Add(Name, NotifyID, Date, Message,0);
36 
37  return SQL;
38 }
39 
45 {
46  vector<string> SQL;
47  string Statment;
48  HK_Date Date, Today;
49  int A;
50 
51  for(A = 0; A < Batches.GetCount();A++) {
52  Date = Batches.GetStart(A);
53  if(Today.IsEqual(Date)) {
54  Statment = AddNotification(
55  Batches.GetName(A),
56  Date,
57  "Start Date For " + Batches.GetName(A)
58  );
59  if(!Statment.empty())
60  SQL.push_back(Statment);
61  }
62 
63  Date = Batches.GetCandle(A);
64  if(Today.IsEqual(Date)) {
65  Statment = AddNotification(
66  Batches.GetName(A),
67  Date,
68  "Candle Date For " + Batches.GetName(A)
69  );
70  if(!Statment.empty())
71  SQL.push_back(Statment);
72  }
73 
74  Date = Batches.GetLockdown(A);
75  if(Today.IsEqual(Date)) {
76  Statment = AddNotification(
77  Batches.GetName(A),
78  Date,
79  "Lockdown Date For " + Batches.GetName(A)
80  );
81  if(!Statment.empty())
82  SQL.push_back(Statment);
83  }
84 
85  Date = Batches.GetHatch(A);
86  if(Today.IsEqual(Date)) {
87  Statment = AddNotification(
88  Batches.GetName(A),
89  Date,
90  "Hatch Date For " + Batches.GetName(A)
91  );
92  if(!Statment.empty())
93  SQL.push_back(Statment);
94  }
95  }
96 
97  //Check Reminders
98  for(A = 0; A < Reminders.GetCount(); A++) {
99  Date = Reminders.GetDate(A);
100  if(Today.IsEqual(Date)) {
101  Statment = AddNotification(
102  Reminders.GetName(A),
103  Date,
104  Reminders.GetText(A)
105  );
106  if(!Statment.empty())
107  SQL.push_back(Statment);
108  }
109  }
110  return SQL;
111 }
HK_Date Today
Definition: Declare.h:33
HK_Batches Batches
Definition: Declare.h:44
A Class For Managing Mulitple HK_Batch Objects.
Definition: Batches.h:22
HK_Date GetHatch(int Select)
Returns Hatch Date For Selected Batch.
Definition: HK_Batches.cpp:87
HK_Date GetStart(int Select)
Returns Start Date For Selected Batch.
Definition: HK_Batches.cpp:81
HK_Date GetCandle(int Select)
Returns Candle Date For Selected Batch.
Definition: HK_Batches.cpp:83
int GetCount()
Returns The Number Of Batches Stored.
Definition: HK_Batches.cpp:191
HK_Date GetLockdown(int Select)
Returns Lockdown Date For Selected Batch.
Definition: HK_Batches.cpp:85
string GetName(int Select)
Returns Batch Name For Selected Batch.
Definition: HK_Batches.cpp:63
A Class For Managing Dates.
Definition: Date.h:25
std::string ToSortable(std::string Separator)
Generate A Sortable String For Database.
Definition: HK_Date.cpp:163
bool IsEqual(HK_Date Date)
Checks To See If The Input Date Is Same As Stored Date.
Definition: HK_Date.cpp:325
string AddNotification(string Name, HK_Date Date, string Message)
Returns A SQL Statment For Adding Notification To Database.
vector< string > CheckDates(HK_Batches Batches, HK_Storage Reminders)
Checks The HK_Batches and HK_Storage Objects For New Notifications.
A Class For Storing Values.
Definition: Storage.h:26
HK_Date GetDate(int Select)
Returns The Selected Stored Date.
Definition: HK_Storage.cpp:71
int GetValidID()
Returns A Valid ID For Adding Entries To The Database.
Definition: HK_Storage.cpp:106
int GetCount()
Returns The Number Of Elements Stored.
Definition: HK_Storage.cpp:101
string GetName(int Select)
Returns The Selected Stored Name.
Definition: HK_Storage.cpp:61
string GetText(int Select)
Returns The Selected Stored Text.
Definition: HK_Storage.cpp:91
void Add(string Name, int ID, HK_Date Date, string Text, int Number)
Adds An Item To Storage.
Definition: HK_Storage.cpp:15