-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.cpp
More file actions
270 lines (202 loc) · 8.17 KB
/
employee.cpp
File metadata and controls
270 lines (202 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/////////////////////////////// *{ WHOLE EMPLOYEE CLASS DEFINED HERE. }* ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "header.h"
//*I-STREAM FRIEND FUNTION TO TAKE INPUT FROM THE USER.*//
istream& operator>>(istream& input , Employee& emp){
cout<<"\n ENTER THE NAME OF THE EMPLOYEE : ";
input>>emp.name;
cout<<"\n ENTER THE PASSWORD OF THE EMPLOYEE : ";
input>>emp.password;
return input;
}
//*USER DEFINED DEFAULT CONSTRUCTOR.*//
Employee::Employee(string name, string password ){
this->name = name;
this->password =password;
}
//*VERIFICATION FUNCTION.*//
bool Employee::LOGIN_VERIFY(){
string read_name="";
string read_password="";
bool login = false;
cout<<"\n ENTER THE NAME OF THE EMPLOYEE : ";
cin>>this->name;
cout<<"\n ENTER THE PASSWORD OF THE EMPLOYEE : ";
cin>>this->password;
ifstream extract("employee_pass.txt" , ios::in );
if(!extract){
cout<<"\n\t\t FILE NOT FOUND. \n\n";
return false;
}
while( extract >> read_name >> read_password){ // EXTRACTIONG DATA FROM FILE.
if(read_name == this->name && read_password == this->password ){
extract.close();
return true;
}
}
extract.close(); // CLOSING FILE TO PREVENT CORRUPTION.
return false;
}
//*MAIN MENU OF EMPLOYEE FUNCTION.*//
void Employee::MAIN_MENU(){
char choice;
char exit;
do{
cout<< "\n\t\t-----------------------------------";
cout<< "\n\t\t| >> WELCOME TO EMPLOYEE MENU << |";
cout<< "\n\t\t-----------------------------------\n\n\n";
buttons(); // CALLING THE BUTTONS FUNCTION.
cout<<"\t\t -"<<setfill('-')<<setw(57)<<"-"<<setfill(' ')<<endl;
cout<<"\t\t | "<<setw(55)<<left<<"<< ENTER THE CORRESPONDING NUMBER TO PROCEED >> "<<"|\n";
cout<<"\t\t | "<<setfill('-')<<setw(55)<<""<<setfill(' ')<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"1. TAKE ORDER FROM STUDENT / STAFF - ADD SALES TO CDS. "<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"2. SEARCH ITEMS. "<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"3. SEE NOTIFICATIONS FROM ADMIN ON LOW STOCK PRODUCTS."<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"4. SEE ONLINE / SCHEDULED ORDERS. "<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"5. PLAY GAMES [ TIME-PASS ]."<<"|\n";
cout<<"\t\t | "<<setw(55)<<left<<"6. LOGOUT FROM THE SITE. "<<"|\n";
cout<<"\t\t -"<<setfill('-')<<setw(57)<<"-"<<setfill(' ')<<endl;
cin>> choice;
loading_line(); // CALLING THE LOADING LINE FUNCTION.
if( choice<='0' || choice>='9' )
{
cout<<"\n\t ################# WARNING ###################\n";
cout<<"\n\t !!!!!! KINDLY AVOID ENTERING CHARACTRES !!!!!! \n";
cout<<"\t ------- RE-ENTER THE CASE ------- \n";
cout<<"\n\t -- [ THE MAIN MENUE WILL BE SHORTLY DISPLAYED ] --\n\n";
continue;
}
if( choice>='0' && choice<='9' )
{
switch (choice)
{
case '1':
{
this->PHYSICAL_ORDER(); // TAKE ORDERS.
break;
}
case '2': // SEARCH ITEM IN STOCK.
{
this->Search_Item();
break;
}
case '3': // LOWER-QUANTITY PRODUCTS.
{
this->Read_Notifications();
break;
}
case '4': // SEE ONLINE ORDERS.
{
this->see_details_of_online_orders();
this->Give_Response_To_Order();
break;
}
case '5': // PLAY GAMES.
{
Play_Games();
break;
}
case '6':
{
cout<<"\t\t -"<<setfill('-')<<setw(50)<<"-"<<setfill(' ')<<endl;
cout<<"\t\t | "<<setw(48)<<left<<" ** TERMINATING THE PROGRAM ** "<<"|\n";
cout<<"\t\t | "<<setw(48)<<left<<" && THANKS FOR COMING && "<<"|\n";
cout<<"\t\t | "<<setw(48)<<left<<" GOOD_BYE"<<"|\n";
cout<<"\t\t -"<<setfill('-')<<setw(50)<<"-"<<setfill(' ')<<endl<<endl;
return;
}
default:
{
cout<<"\n\t\t-----------------------------\n";
cout<<"\t\t| ! ENTER A VALID INPUT ! |\n";
cout<<"\t\t-----------------------------\n";
break;
}
}
cout<< "\n\t\t------------------------------------------------------";
cout<< "\n\t\t| DO YOU WANT TO EXIT FROM EMPLOYEE MENU ? [ Y/N ] |";
cout<< "\n\t\t------------------------------------------------------\n\n";
cin>>exit;
if(exit=='y' || exit=='Y'){
cout<<"\t\t -"<<setfill('-')<<setw(50)<<"-"<<setfill(' ')<<endl;
cout<<"\t\t | "<<setw(48)<<left<<" ** TERMINATING THE PROGRAM ** "<<"|\n";
cout<<"\t\t | "<<setw(48)<<left<<" && THANKS FOR COMING && "<<"|\n";
cout<<"\t\t | "<<setw(48)<<left<<" GOOD_BYE"<<"|\n";
cout<<"\t\t -"<<setfill('-')<<setw(50)<<"-"<<setfill(' ')<<endl<<endl;
break;
}
else if(exit=='n' || exit=='N'){
cout<<"\n\t ******* SELECT THE FUNCTION YOU WANT TO PERFORM AGAIN ******* \n";
}
}
}while(1);
return;
}
///////// *[ SEE ONLINE ORDERS ]* ////////////
void Employee::see_details_of_online_orders()
{
cout<<"\n\t\t----------------------------------------------------------\n";
cout<<"\t\t| **** [ WELCOME TO THE ONLINE ORDER MENU ] **** |\n";
cout<<"\t\t| [ SEE THE DETAILS OF ORDERS PLACED BY THE CUSTOMERS ] |\n";
cout<<"\t\t------------------------------------------------------------\n";
int count=0;
char ch;
fstream read("online.txt" , ios::in);
if(read.is_open())
{
while(!read.eof()){
read.get(ch);
if(ch == '\n'){
count++;
}
}
}
else{
cerr<<"\n FILE NOT FOUND. \n";
return;
}
read.close();
string display[count];
int i=0;
fstream read1("online.txt" , ios::in);
while(!read1.eof()){
getline(read1, display[i]);
cout<<display[i]<<"\n"; //*DISPLAY DATA.*//
i++;
}
read1.close();
cout<<"\n\t\t-------------------------------------------------------\n";
cout<<"\t\t| ** [ SO THAT WERE ALL WITH THE ONLINE ORDERS. ] ** |\n";
cout<<"\t\t| <<<< GOOD BYE >>>> |\n";
cout<<"\t\t---------------------------------------------------------\n";
return;
}
///////// *[ RESPONSE TO ORDER. ]* ////////////
void Employee::Give_Response_To_Order()
{
const int s = 300 , n = 50 ;
char* rev = new char[s]; // ALLOCATING MEMORY IN THE HEAP.
string name;
string user_name;
cout<<"\n\t\t-----------------------------------------------------------\n";
cout<<"\t\t| GIVE RESPONSE TO THE CUSTOMER [STUDENT-STAFF] FROM HERE. |\n";
cout<<"\t\t-------------------------------------------------------------\n";
cin.ignore();
name = this->name;
cout<<" ENTER THE CUSTOMER NAME [ **** ] >>> :: ";
getline(cin , user_name);
cout<<" ENTER YOUR RESPONSE >> \n";
cin.getline(rev , s );
ofstream write("responseOrder.txt" , ios::app ); // WRITING IN APPEND MODE TO AVOID TRUNKING.
if(!write){
cout<<"\n ERROR OPENING FILE \n";
cout<<" CHECK THE FILE NAME \n";
}
else{
write<<"RESPONDED BY :: [ "<<name<<" ] TO { "<<user_name<<" } "<<rev<<endl;
}
write.close(); // CLOSING FILE TO PREVENT CORRUPTION.
delete []rev;
rev = NULL;
return;
}