-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappendix ai.txt
471 lines (469 loc) · 21.3 KB
/
appendix ai.txt
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
flask import Flask, render_template, flash, request, session,send_file
from flask import render_template, redirect, url_for, request
#from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField
from werkzeug.utils import secure_filename
import datetime
import mysql.connector
import sys
app = Flask(__name__)
app.config['DEBUG']
app.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
@app.route("/")
def homepage():
return render_template('index.html')
@app.route("/AdminLogin")
def AdminLogin():
alert = 'sdgsdhgdfjh'
#return render_template('goback.html', data=alert)
return render_template('AdminLogin.html')
@app.route("/CompanyLogin")
def CompanyLogin():
return render_template('CompanyLogin.html')
@app.route("/NewCompany")
def NewCompany():
return render_template('NewCompany.html')
@app.route("/UserLogin")
def UserLogin():
return render_template('UserLogin.html')
@app.route("/NewUser")
def NewUser():
return render_template('NewUser.html')
@app.route("/NewInsurance")
def NewInsurance():
return render_template('NewInsurance.html')
@app.route("/AbookInfo")
def AbookInfo():
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM Booktb ")
data = cur.fetchall()
return render_template('AbookInfo.html',data=data)
@app.route("/AdminHome")
def AdminHome():
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM regtb ")
data = cur.fetchall()
return render_template('AdminHome.html',data=data)
@app.route("/AdminCompanyInfo")
def AdminCompanyInfo():
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where Status='waiting' ")
data = cur.fetchall()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where Status !='waiting' ")
data1 = cur.fetchall()
return render_template('AdminCompanyInfo.html', data=data, data1=data1)
@app.route("/AdminInsurInfo")
def AdminInsurInfo():
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb ")
data = cur.fetchall()
return render_template('AdminInsurInfo.html',data=data )
@app.route("/AClaimInfo")
def AClaimInfo():
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb ")
data = cur.fetchall()
return render_template('AClaimInfo.html',data=data )
@app.route("/appr")
def appr():
cid = request.args.get('cid')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"update companytb set Status='Active' where UserName='" + str(cid) + "' ")
conn.commit()
conn.close()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where Status='waiting' ")
data = cur.fetchall()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where Status!='waiting' ")
data1 = cur.fetchall()
return render_template('AdminCompanyInfo.html', data=data, data1=data1 )
@app.route("/remove")
def remove():
cuname = session['cname']
did = request.args.get('did')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("delete from insurtb where Id='"+ did +"' ")
conn.commit()
conn.close()
conn=mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb where CompanyNAme ='"+ cuname +"' ")
data = cur.fetchall()
return render_template('CompanyInsurInfo.html', data=data )
@app.route("/UserHome")
def UserHome():
user = session['uname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM regtb where username='" + user + "'")
data = cur.fetchall()
return render_template('UserHome.html',data=data)
@app.route("/CompanyHome")
def CompanyHome():
cuname = session['cname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where username='" + cuname + "'")
data = cur.fetchall()
return render_template('CompanyHome.html', data=data)
@app.route("/CBooking")
def CBooking():
cuname = session['cname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM booktb where CompanyName='" + cuname + "'")
data = cur.fetchall()
return render_template('CBooking.html', data=data)
@app.route("/adminlogin", methods=['GET', 'POST'])
def adminlogin():
error = None
if request.method == 'POST':
if request.form['uname'] == 'admin' or request.form['password'] == 'admin':
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM regtb ")
data = cur.fetchall()
return render_template('AdminHome.html' , data=data)
else:
return render_template('index.html', error=error)
@app.route("/companylogin", methods=['GET', 'POST'])
def companylogin():
error = None
if request.method == 'POST':
username = request.form['uname']
password = request.form['password']
session['cname'] = request.form['uname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * from companytb where username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
alert = 'Username or Password is wrong'
return render_template('goback.html', data=alert)
else:
print(data[0])
session['uid'] = data[0]
status = data[9]
if( status == 'waiting'):
alert = 'Waiting For Company Approval'
return render_template('goback.html', data=alert)
else:
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM companytb where username='" + username + "' and Password='" + password + "'")
data = cur.fetchall()
return render_template('CompanyHome.html', data=data)
@app.route("/userlogin", methods=['GET', 'POST'])
def userlogin():
if request.method == 'POST':
username = request.form['uname']
password = request.form['password']
session['uname'] = request.form['uname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * from regtb where username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
alert = 'Username or Password is wrong'
render_template('goback.html', data=alert)
else:
print(data[0])
session['uid'] = data[0]
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM regtb where username='" + username + "' and Password='" + password + "'")
data = cur.fetchall()
return render_template('UserHome.html', data=data )
@app.route("/Search")
def Search():
#date = datetime.datetime.now().strftime('%d-%b-%Y')
#print(date)
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb ")
data = cur.fetchall()
return render_template('Search.html',data=data)
@app.route("/dsearch", methods=['GET', 'POST'])
def dsearch():
crname = request.form['crname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb where CropsName like '%" + crname +"%' ")
data = cur.fetchall()
return render_template('Search.html',data=data)
@app.route("/fullInfo")
def fullInfo():
did = request.args.get('did')
session['did'] = did
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb where id='" + did + "' ")
data1 = cur.fetchall()
return render_template('InsureFullInfo.html',data=data1 )
@app.route("/Book", methods=['GET', 'POST'])
def Book():
if request.method == 'POST':
uname = session['uname']
did = session['did']
ctype = request.form['ctype']
cardno = request.form['cardno']
cvno = request.form['cvno']
date = datetime.datetime.now().strftime('%d-%b-%Y')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * FROM insurtb where id='" + did + "'")
data = cursor.fetchone()
if data:
insid = data[1]
coname= data[2]
insurName = data[4]
price = data[5]
camt=data[7]
else:
return 'Incorrect username / password !'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * FROM regtb where UserName='" + uname + "'")
data = cursor.fetchone()
if data:
Mobile = data[4]
Email= data[3]
else:
return 'Incorrect username / password !'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT count(*) as count FROM booktb ")
data = cursor.fetchone()
if data:
count = data[0]
if count == 0:
count =1;
else:
count+=1
else:
return 'Incorrect username / password !'
print(count)
Bookingid="BOOKID00" + str(count)
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"INSERT INTO booktb VALUES ('','" + Bookingid + "','"+ insid +"','"+ coname +"','" + insurName + "','" + uname + "','" + Mobile + "','" + Email + "','" + str(price) + "','"+ ctype +"','"+ cardno +"','"+ cvno +"','"+ date +"','waiting','"+camt+"')")
conn.commit()
conn.close()
# return 'file register successfully'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM booktb where UserName= '"+ uname +"' ")
data = cur.fetchall()
return render_template('UbookInfo.html' , data =data )
@app.route("/UBookInfo")
def UBookInfo():
uname = session['uname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
# cursor = conn.cursor()
cur = conn.cursor()
cur.execute("SELECT * FROM booktb where UserName='" + uname +"' ")
data = cur.fetchall()
return render_template('UBookInfo.html', data=data)
@app.route("/cfullInfo")
def cfullInfo():
cid = request.args.get('cid')
session['cid'] = cid
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM booktb where id='" + cid + "' ")
data1 = cur.fetchall()
return render_template('UClaim.html',data=data1 )
@app.route("/CBook", methods=['GET', 'POST'])
def CBook():
if request.method == 'POST':
uname = session['uname']
cid =session['cid']
cinfo = request.form['cinfo']
file = request.files['file']
file.save("static/upload/" + file.filename)
file1 = request.files['file1']
file1.save("static/upload/" + file1.filename)
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * FROM booktb where id='" + cid + "'")
data = cursor.fetchone()
if data:
coname = data[3]
insurName = data[4]
camt=data[14]
else:
return 'Incorrect username / password !'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * FROM regtb where UserName='" + uname + "'")
data = cursor.fetchone()
if data:
Mobile = data[4]
Email= data[3]
else:
return 'Incorrect username / password !'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"INSERT INTO claimtb VALUES ('" + cid + "','"+ uname +"','"+ Mobile +"','" + Email + "','" + insurName + "','" + camt + "','" + cinfo + "','" + file.filename + "','"+ file1.filename +"','waiting','"+coname+"')")
conn.commit()
conn.close()
# return 'file register successfully'
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where UserName= '"+ uname +"' ")
data = cur.fetchall()
return render_template('UClaimInfo.html' , data =data )
@app.route("/UClaimInfo")
def UClaimInfo():
uname = session['uname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where UserName='" + uname + "' ")
data1 = cur.fetchall()
return render_template('UClaimInfo.html',data=data1 )
@app.route("/CInsuranceClaim")
def CInsuranceClaim():
cuname = session['cname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where CompanyName='" + cuname + "' ")
data1 = cur.fetchall()
return render_template('CInsuranceClaim.html',data=data1 )
@app.route('/download')
def download():
id = request.args.get('id')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute("SELECT * FROM claimtb where Isuranceid = '" + str(id) + "' ")
data = cursor.fetchone()
if data:
filename = "static\\upload\\"+data[8]
return send_file(filename, as_attachment=True)
else:
return 'Incorrect username / password !'
@app.route("/Aappr")
def Aappr():
cid = request.args.get('cid')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"update claimtb set Status='Approved' where Isuranceid='" + str(cid) + "' ")
conn.commit()
conn.close()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where Status='waiting' ")
data = cur.fetchall()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where Status!='waiting' ")
data1 = cur.fetchall()
return render_template('CInsuranceClaim.html', data=data, data1=data1 )
@app.route("/Rappr")
def Rappr():
cid = request.args.get('cid')
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"update claimtb set Status='Reject' where Isuranceid='" + str(cid) + "' ")
conn.commit()
conn.close()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where Status='waiting' ")
data = cur.fetchall()
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM claimtb where Status!='waiting' ")
data1 = cur.fetchall()
return render_template('CInsuranceClaim.html', data=data, data1=data1 )
@app.route("/newuser", methods=['GET', 'POST'])
def newuser():
if request.method == 'POST':
name1 = request.form['name']
gender1 = request.form['gender']
Age = request.form['age']
email = request.form['email']
pnumber = request.form['phone']
address = request.form['address']
uname = request.form['uname']
password = request.form['psw']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"INSERT INTO regtb VALUES ('" + name1 + "','" + gender1 + "','" + Age + "','" + email + "','" + pnumber + "','" + address + "','" + uname + "','" + password + "')")
conn.commit()
conn.close()
# return 'file register successfully'
return render_template('UserLogin.html')
@app.route("/newcompany", methods=['GET', 'POST'])
def newcompany():
if request.method == 'POST':
name1 = request.form['name']
regno = request.form['regno']
phone = request.form['phone']
phone2 = request.form['phone2']
email = request.form['email']
website = request.form['website']
address = request.form['address']
uname = request.form['uname']
password = request.form['psw']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"INSERT INTO companytb VALUES ('" + name1 + "','" + regno + "','" + phone + "','" + phone2 + "','" + email + "','" + website + "','"+address+"','" + uname + "','" + password + "','waiting')")
conn.commit()
conn.close()
return render_template('CompanyLogin.html')
@app.route("/newinsur", methods=['GET', 'POST'])
def newinsur():
if request.method == 'POST':
cname = session['cname']
id = request.form['id']
crname = request.form['crname']
iname = request.form['iname']
pamt = request.form['pamt']
vali = request.form['vali']
camt = request.form['camt']
info = request.form['info']
file = request.files['file']
file.save("static/upload/" + file.filename)
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cursor = conn.cursor()
cursor.execute(
"INSERT INTO insurtb VALUES ('','"+ id +"','" + cname + "','" + crname + "','" + iname + "','"+ pamt +"','" + vali + "','" + camt + "','" + info + "','" + file.filename + "')")
conn.commit()
conn.close()
alert = 'New Insurance Info register successfully'
return render_template('goback.html',data=alert )
@app.route("/CompanyInsurInfo")
def CompanyInsurInfo():
cuname = session['cname']
conn = mysql.connector.connect(user='root', password='', host='localhost', database='1Agriinsurancedb')
cur = conn.cursor()
cur.execute("SELECT * FROM insurtb where CompanyName ='"+ cuname +"' ")
data = cur.fetchall()
return render_template('CompanyInsurInfo.html',data=data)
if __name__ == '__main__':
app.run(debug=True, use_reloader=True)