muhammad_nasif

Untitled

Dec 11th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. def sales_representative_status(request):
  2. if request.session.is_empty():
  3. return redirect(customer_view.login)
  4. else:
  5. sql = "SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
  6. sql_1 = "select employee_profit(EMPLOYEE_ID) from EMPLOYEES where EMPLOYEE_ID=%s "
  7. employee_id = request.session['employee_id']
  8.  
  9. cursor = connection.cursor()
  10. cursor.execute(sql,[employee_id])
  11. result = cursor.fetchall()
  12. cursor.close()
  13. emp_info = []
  14.  
  15. cursor = connection.cursor()
  16. cursor.execute(sql_1, [employee_id])
  17. result_1 = cursor.fetchall()
  18. cursor.close()
  19.  
  20. profit = result_1[0][0]
  21.  
  22. for i in result:
  23. name = i[1]
  24. designation = i[2]
  25. salary = i[3]
  26. emp_id = employee_id
  27. row = {'name':name,'designation':designation,'salary':salary,'emp_id':emp_id,'profit':profit}
  28. emp_info.append(row)
  29.  
  30. print(emp_info)
  31. flag = 0
  32. designation = request.session['username']
  33. if designation[0:5] == "sales":
  34. flag = 1
  35. else:
  36. flag = 0
  37. return render(request,'sales_representative_status.html',{'emp_info':emp_info,'flag':flag})
  38.  
Add Comment
Please, Sign In to add comment