def operation_entries_update(request, index): db, cur = db_set(request) index.replace(" ", "") sql = "SELECT * FROM scrap_operation_dept where Id = '%s'" % (index) cur.execute(sql) request.session["tmp_scrap4"] = cur.fetchall() db.close() tmp_scrap4 = request.session["tmp_scrap4"] if request.POST: operation = request.POST.get("Operation") department = request.POST.get("Dept") db, cur = db_set(request) cql = ( 'update scrap_operation_dept SET Operation = "%s",Dept="%s" WHERE id ="%s"' % (operation, department, index)) cur.execute(cql) db.commit() db.close() return render(request, "scrap_mgmt.html") else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_display_edit_operation_entries.html', {'args': args})
def maint_call_call(request): if request.POST: machinenum = request.POST.get("machine") problem = request.POST.get("reason") priority = request.POST.get("priority") name_who = request.POST.get["whoisonit"] # call external function to produce datetime.datetime.now() t = vacation_temp() # Select prodrptdb db located in views_db db, cur = db_set(request) cur.execute('''INSERT INTO pr_downtime1(machinenum,problem,priority,whoisonit,called4helptime) VALUES(%s,%s,%s,%s,%s)''', (machinenum,problem,priority,name_who,t)) db.commit() db.close() return done_maint_app(request) else: request.session["machinenum"] = "692" form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form rlist = machine_list_display() request.session["refresh_maint"] = 3 return render(request,'maint_call.html', {'List':rlist,'args':args}) return render(request,'maint_call.html')
def scrap_display_entry_edit(request, index): index_category = index db, cur = db_set(request) index.replace(" ", "") sql_scrap2 = "SELECT * FROM tkb_scrap WHERE Id = '%s'" % (index) cur.execute(sql_scrap2) tmp = cur.fetchall() tmp2 = tmp[0] sql = "SELECT Line FROM scrap_part_line WHERE Part = '%s'" % (tmp2) cursor.execute(sql) tmp = cursor.fetchall() scrap_part_line = tmp[0][0] request.session["scrap_part_line"] = scrap_part_line sql = "SELECT DISTINCT Operation FROM scrap_line_operation_category WHERE Line = '%s'" % ( scrap_part_line) cursor.execute(sql) tmp = cursor.fetchall() request.session["scrap_operation_selection"] = tmp # sql_scrap2 = "SELECT scrap_operation FROM tkb_scrap WHERE Id = '%s'" % (index) # cur.execute(sql_scrap2) # tmp = cur.fetchall() # tmp4 = tmp[0] # request.session['operation6'] = tmp4 active = '1.0' sql = "SELECT Part FROM scrap_part_line WHERE Active = '%s' ORDER BY Part ASC" % ( active) cur.execute(sql) tmp = cur.fetchall() request.session["scrap_part_selection"] = tmp # sql = "SELECT Line FROM scrap_part_line WHERE Part = '%s'" %(scrap_part) # cursor.execute(sql) # tmp = cursor.fetchall() # scrap_part_line = tmp[0][0] # request.session["scrap_part_line"] = scrap_part_line # sql = "SELECT DISTINCT Operation FROM scrap_line_operation_category WHERE Line = '%s'" %(scrap_part_line) # cursor.execute(sql) if request.POST: return render(request, "redirect_scrap_display.html") else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_mgmt_display_entry_edit.html', { 'args': args, 'tmp': tmp2 })
def scrap_entries_update(request, index): db, cur = db_set(request) index.replace(" ", "") sql = "SELECT * FROM tkb_scrap where Id = '%s'" % (index) cur.execute(sql) request.session["tmp_scrap3"] = cur.fetchall() db.close() tmp_scrap3 = request.session["tmp_scrap3"] if request.POST: scrap_part = request.POST.get("scrap_part") scrap_operation = request.POST.get("scrap_operation") scrap_category = request.POST.get("scrap_category") scrap_amount = request.POST.get("scrap_amount") scrap_line = request.POST.get("scrap_line") total_cost = request.POST.get("total_cost") date = request.POST.get("date") db, cur = db_set(request) # Calculate new cost but if error (changed operation) keep cost same try: sql2 = "SELECT Dept FROM scrap_operation_dept WHERE Operation = '%s'" % ( scrap_operation) cur.execute(sql2) tmp = cur.fetchall() department = tmp[0][0] sql3 = "SELECT Cost FROM scrap_part_dept_cost WHERE Part = '%s' and Dept = '%s'" % ( scrap_part, department) cur.execute(sql3) tmp = cur.fetchall() cost = tmp[0][0] total_cost = float(cost) * float(scrap_amount) except: dummy = 1 cql = ( 'update tkb_scrap SET scrap_part = "%s",scrap_operation="%s",scrap_amount="%s", scrap_line="%s", total_cost="%s", date="%s" WHERE id ="%s"' % (scrap_part, scrap_operation, scrap_amount, scrap_line, total_cost, date, index)) cur.execute(cql) db.commit() db.close() return render(request, "scrap_mgmt.html") else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_display_edit_entries.html', {'args': args})
def scrap_display_date_pick(request): # t = datetime.datetime.now() date = vacation_set_current9() request.session["date1_default"] = date # request.session["date2_default"] = t if request.POST: request.session["scrap_display_date1"] = request.POST.get( "scrap_display_date1") request.session["scrap_display_date2"] = request.POST.get( "scrap_display_date2") request.session["scrap_display_type"] = "date_selection" return render(request, "redirect_scrap_display.html") else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_display_date_pick_form.html', {'args': args})
def scrap_edit_categories_newentry(request): if request.POST: new_category = request.POST.get("new_category") list1 = request.session['qedit_category_selection'] max1 = 0 for i in list1: if i[1] > max1: max1 = i[1] new1 = [new_category, max1 + 1] list1.append(new1) request.session['qedit_category_selection'] = list1 return render(request, 'scrap_edit_categories_entry.html') else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_edit_categories_newentry.html', {'args': args})
def mgmt_users_logins_edit(request): p = request.session["page_edit"] index = request.session["current_index"] if request.POST: user_name = request.POST.get("user_name") password = request.POST.get("password") department = request.POST.get("department") a = request.POST b = -4 try: b = int(a.get("one")) except: b = -4 db, cursor = db_set(request) cur = db.cursor() if b == -3: # Reroute to the Warning message request.session["bounce"] = 1 request.session["user_logins1"] = user_name request.session["password"] = password request.session["department"] = department return render(request, 'production/redirect_mgmt_users_logins_edit.html') if b == -2: # Cancel Entry and go back to logins list request.session["bounce"] = 0 return render(request, 'production/redirect_mgmt_users_logins.html') else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form a = request.session["user_logins1"] b = request.session["bounce"] return render(request, "production/mgmt_users_logins_edit.html", {'args': args})
def quality_epv_asset_entry(request): if request.POST: asset = request.POST.get("asset") request.session["epv_asset2"] = asset asset = asset + ".0" db, cur = db_set(request) sql = "SELECT Id,date1,shift1,check1,description1,asset1,master1,comment,clock_num FROM quality_epv_checks where description1 = '%s' ORDER BY date1 DESC" % ( asset) cur.execute(sql) tmp2 = cur.fetchall() request.session["asset_epv"] = tmp2 return render(request, 'quality_epv_asset_list.html') else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'quality_epv_asset_entry.html', {'args': args})
def manpower_allocation_interval_pick(request): t = int(time.time()) tm = time.localtime(t) if tm[1] < 10: m = "0" + str(tm[1]) else: m = str(tm[1]) if tm[2] < 10: d = "0" + str(tm[2]) else: d = str(tm[2]) date7 = str(tm[0]) + "-" + m + "-" + d t = int(time.time()) - 86400 tm = time.localtime(t) if tm[1] < 10: m = "0" + str(tm[1]) else: m = str(tm[1]) if tm[2] < 10: d = "0" + str(tm[2]) else: d = str(tm[2]) date6 = str(tm[0]) + "-" + m + "-" + d request.session["date1_default"] = date7 request.session["date2_default"] = date6 if request.POST: request.session["date1_allocation"] = request.POST.get( "scrap_display_date1") request.session["date2_allocation"] = request.POST.get( "scrap_display_date2") return manpower_allocation_calculation(request) else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'manpower_allocation_interval_pick.html', {'args': args})
def maintenance_edit(request): index = request.session["index"] Maint_Manpower = [] request.session["login_department"] = 'Maintenance' Maint_Manpower = maint_manpower(request) # Select prodrptdb db located in views_db db, cursor = db_set(request) SQ_Sup = "SELECT * FROM pr_downtime1 where idnumber='%s'" %(index) cursor.execute(SQ_Sup) tmp = cursor.fetchall() tmp2=tmp[0] request.session["machinenum"] = tmp2[0] request.session["problem"] = tmp2[1] request.session["priority"] = tmp2[3] request.session["manpower"] = tmp2[4] nm = multi_name_breakdown(tmp2[4]) # put all the names in a list that are seperated by a | db.close() if request.POST: machinenum = request.POST.get("machine") problem = request.POST.get("reason") manpower = request.POST.get("manpower") whoisonit = 'tech' a = request.POST try: b=int(a.get("one")) manpower = request.session["manpower"] except: manpower = generate_string(request.session["manpower"],manpower) b=-5 problem = hyphon_fix(problem) # Send text to rid it of nasty hyphon glitches :) db, cursor = db_set(request) cur = db.cursor() asset3 = machinenum[:4] asset2 = machinenum[:3] try: int(asset3) asset4 = asset3 except: asset4 = asset2 try: bql = "SELECT priority FROM tkb_asset_priority where asset_num = '%s'" % (asset4) cur.execute(bql) tmp2 = cur.fetchall() tmp3 = tmp2[0][0] except: tmp3 = 999 priority = int(tmp3) if problem[-3:] == 'WFP': priority = 10000 elif problem[-7:] == 'Project': priority = 5000 if b==-5: # Route to update maintenance manpower but keep editing mql =( 'update pr_downtime1 SET machinenum="%s" WHERE idnumber="%s"' % (machinenum,index)) cur.execute(mql) db.commit() tql =( 'update pr_downtime1 SET problem="%s" WHERE idnumber="%s"' % (problem,index)) cur.execute(tql) db.commit() uql =( 'update pr_downtime1 SET whoisonit="%s" WHERE idnumber="%s"' % (manpower,index)) cur.execute(uql) uql =( 'update pr_downtime1 SET priority="%s" WHERE idnumber="%s"' % (priority,index)) cur.execute(uql) db.commit() db.close() return render(request,'redirect_maint_edit.html') # Need to bounce out to an html and redirect back into a module otherwise infinite loop if b==-4: # Route to update maintenance manpower but keep editing request.session["bounce"] = 0 return render(request,'redirect_maint_mgmt.html') if b==-3: # Route to Update item and back to main mql =( 'update pr_downtime1 SET machinenum="%s" WHERE idnumber="%s"' % (machinenum,index)) cur.execute(mql) db.commit() tql =( 'update pr_downtime1 SET problem="%s" WHERE idnumber="%s"' % (problem,index)) cur.execute(tql) db.commit() uql =( 'update pr_downtime1 SET priority="%s" WHERE idnumber="%s"' % (priority,index)) cur.execute(uql) db.commit() db.close() return render(request,'redirect_maint_mgmt.html') # Need to bounce out to an html and redirect back into a module otherwise infinite loop if b==-2: # Route to bounce and check if we are really going to close this item request.session["bounce"] = 1 return render(request,'redirect_maint_edit.html') # Need to bounce out to an html and redirect back into a module otherwise infinite loop return render(request,'redirect_maint_mgmt.html') # Need to bounce out to an html and redirect back into a module otherwise infinite loop else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request,'maintenance_edit.html',{'args':args,'MList':Maint_Manpower})
def maint_job_entry(request): if request.POST: machinenum = request.POST.get("machine") problem = request.POST.get("reason") priority = request.POST.get("priority") priority = 30000 whoisonit = 'Millwright' # take comment into tx and ensure no "" exist. If they do change them to '' tx = problem tx = ' ' + tx tps = list(tx) # Genius appostrophe fix problem = hyphon_fix(tx) t = vacation_temp() db, cur = db_set(request) asset_test = machinenum[:4] side1 = '0' location1='G' side2 = '0' try: asset3 = machinenum[:4] asset2 = machinenum[:3] try: int(asset3) asset4 = asset3 except: asset4 = asset2 aql = "SELECT * FROM vw_asset_eam_lp where left(Asset,4) = '%s'" %(asset4) cur.execute(aql) tmp2 = cur.fetchall() tmp3 = tmp2[0] asset5 = tmp3[1] + " - " + tmp3[3] location1 = tmp3[3] except: asset5 = machinenum try: bql = "SELECT priority FROM tkb_asset_priority where asset_num = '%s'" % (asset4) cur.execute(bql) tmp2 = cur.fetchall() tmp3 = tmp2[0] except: tmp3 = 999 try: priority = tmp3[0] except: priority = 999 if problem[-3:] == 'WFP': priority = 10000 elif problem[-7:] == 'Project': priority = 5000 # This will determine side of asset and put in breakdown location_check = location1[:1] if location_check < 'G': side1 = '2' elif location_check > 'G': side1 = '1' else: side1 = '0' try: cur.execute('''INSERT INTO pr_downtime1(machinenum,problem,priority,whoisonit,called4helptime,side) VALUES(%s,%s,%s,%s,%s,%s)''', (asset5,problem,priority,whoisonit,t,side1)) db.commit() db.close() except: cur.execute("Alter Table pr_downtime1 ADD Column side VARCHAR(100) DEFAULT '0'") #% (side2) # Add a Column db.commit() cur.execute('''INSERT INTO pr_downtime1(machinenum,problem,priority,whoisonit,called4helptime,side) VALUES(%s,%s,%s,%s,%s,%s)''', (asset5,problem,priority,whoisonit,t,side1)) db.commit() db.close() return render(request,'redirect_maint_mgmt.html') else: request.session["machinenum"] = "692" form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form rlist = machine_list_display() return render(request,'maintenance_down.html', {'List':rlist,'args':args})
def maint_mgmt(request): net1(request) # Sets the app to server or local request.session["TCUR"] = int(time.time()) # Assign current Timestamp to TCUR for proper image and include refresh maint_initialize_rv(request) #initialize request variables request.session["main_screen_color"] = "#abad97" # Color of Background in APP request.session["main_menu_color"] = "#f8fcd7" # Color of Menu Bar in APP request.session["main_body_color"] = "#EBF0CB" request.session["main_body_menu_color"] = "#D2D2D2" request.session["bounce"] = 0 # wildcard = int(request.session["wildcard1"]) whoisonit1 = 'tech' whoisonit2 = 'Engineering' maint_login_check(request) #check if login table exists. If not then create it db, cursor = db_set(request) SQ_Sup = "SELECT * FROM pr_downtime1 where closed IS NULL and whoisonit != '%s' and whoisonit != '%s' ORDER By (priority) ASC" % (whoisonit1,whoisonit2) cursor.execute(SQ_Sup) tmp = cursor.fetchall() tmp = list(tmp) # tmp_list[5] = ('55','66') new_tmp = [] time4 = [] wfp='WFP' project = 'Project' # start_stamp = int(time.mktime(hh.timetuple())) # time_dif = int((t - start_stamp) / float(60)) # tt=4/0 tmp_len = len(tmp) for a1 in range(0,tmp_len - 1): for a2 in range(a1+1,tmp_len): num1 = int(tmp[a1][3]) num2 = int(tmp[a2][3]) if num2 < num1: ttmp = tmp[a2] tmp[a2] = tmp[a1] tmp[a1] = ttmp tmp = tuple(tmp) t = int(time.time()) for i in tmp: date1 = i[2] stamp1 = int(time.mktime(date1.timetuple())) diff1 = int((t - stamp1) / float(60)) time4.append(diff1) time4 = tuple(time4) new_tmp = zip(tmp,time4) if request.session["maint_mgmt_main_switch"] == 0: # Determine a list of names currently active active1 = 0 SQ2 = "SELECT user_name FROM tkb_logins where active1 != '%d'" % (active1) cursor.execute(SQ2) tmp4 = cursor.fetchall() tmp4 = list(tmp4) # Determing a list of names currently assigned to jobs tmp2 = [] tmp3 = [] on1 = [] off1 = [] union1 = [] t4 = [] for i in tmp: nm = multi_name_breakdown(i[4]) if len(nm) == 0: tmp3.append(i[4]) else: for ii in nm: tmp3.append(ii) # need to compare tmp4 and tmp3 and put into two different appends. on1 and off1 for i in tmp4: t4.append(i[0]) found1 = 0 for ii in tmp3: if i[0] == ii: found1 = 1 break if found1 == 1: on1.append(i[0]) else: off1.append(i[0]) request.session["assigned"] = on1 request.session["not_assigned"] = off1 else: dep1 = 'Maintenance' SQ2 = "SELECT * FROM tkb_logins where department = '%s' order by active1 DESC, user_name ASC" % (dep1) cursor.execute(SQ2) tmp4 = cursor.fetchall() tmp4 = list(tmp4) request.session["assigned"] = tmp4 db.close() # if wildcard == 1: # ch1 = request.session["maint_mgmt_login_password_check"] if request.POST: selected1 = request.POST try: selected2 = int(selected1.get("one")) except: selected2 = selected1.get("one") if selected2 == 'choose1': request.session["maint_mgmt_main_switch"] = 1 elif selected2 == 'choose2': temp_list = request.session["assigned"] temp_index =[] temp_select = [] for w in temp_list: d = request.POST.get(str(w[0])) temp_index.append(w[0]) temp_select.append(d) temp_zip = zip(temp_index,temp_select) db, cursor = db_set(request) for w in temp_zip: if w[1] == 'on': w1 = 1 else: w1 = 0 w2 = w[0] pql =( 'update tkb_logins SET active1 ="%d" WHERE Id="%s"' % (w1,w2)) cursor.execute(pql) db.commit() request.session["maint_mgmt_main_switch"] = 0 db.close() else: db, cursor = db_set(request) w1 = 0 dept = 'Maintenance' pql =( 'update tkb_logins SET active1 ="%d" WHERE department="%s"' % (w1,dept)) cursor.execute(pql) db.commit() request.session["maint_mgmt_main_switch"] = 1 db.close() return render(request, "redirect_maint_mgmt.html") # This will be it once we've determined switch request.session["index"] = selected2 return render(request, "maint_edit.html") # return done_edit(request) else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, "maint_mgmt.html",{'index':new_tmp,'wfp':wfp,'project':project,'args':args})
def maint_mgmt(request): maint_initialize_rv(request) #initialize request variables # request.session["test55"] = 1 request.session["main_screen_color"] = "#abad97" # Color of Background in APP request.session["main_menu_color"] = "#f8fcd7" # Color of Menu Bar in APP request.session["main_body_color"] = "#EBF0CB" request.session["main_body_menu_color"] = "#D2D2D2" request.session["bounce"] = 0 # wildcard = int(request.session["wildcard1"]) whoisonit1 = 'tech' whoisonit2 = 'Engineering' maint_login_check(request) #check if login table exists. If not then create it db, cursor = db_set(request) SQ_Sup = "SELECT * FROM pr_downtime1 where closed IS NULL and whoisonit != '%s' and whoisonit != '%s' ORDER BY priority ASC" % (whoisonit1,whoisonit2) cursor.execute(SQ_Sup) tmp = cursor.fetchall() if request.session["maint_mgmt_main_switch"] == 0: # Determine a list of names currently active active1 = 0 SQ2 = "SELECT user_name FROM tkb_logins where active1 != '%d'" % (active1) cursor.execute(SQ2) tmp4 = cursor.fetchall() tmp4 = list(tmp4) # Determing a list of names currently assigned to jobs tmp2 = [] tmp3 = [] on1 = [] off1 = [] union1 = [] t4 = [] for i in tmp: nm = multi_name_breakdown(i[4]) if len(nm) == 0: tmp3.append(i[4]) else: for ii in nm: tmp3.append(ii) # need to compare tmp4 and tmp3 and put into two different appends. on1 and off1 for i in tmp4: t4.append(i[0]) found1 = 0 for ii in tmp3: if i[0] == ii: found1 = 1 break if found1 == 1: on1.append(i[0]) else: off1.append(i[0]) request.session["assigned"] = on1 request.session["not_assigned"] = off1 else: dep1 = 'Maintenance' SQ2 = "SELECT * FROM tkb_logins where department = '%s' order by active1 DESC, user_name ASC" % (dep1) cursor.execute(SQ2) tmp4 = cursor.fetchall() tmp4 = list(tmp4) request.session["assigned"] = tmp4 db.close() # if wildcard == 1: # ch1 = request.session["maint_mgmt_login_password_check"] if request.POST: selected1 = request.POST try: selected2 = int(selected1.get("one")) except: selected2 = selected1.get("one") if selected2 == 'choose1': request.session["maint_mgmt_main_switch"] = 1 elif selected2 == 'choose2': temp_list = request.session["assigned"] temp_index =[] temp_select = [] for w in temp_list: d = request.POST.get(str(w[0])) temp_index.append(w[0]) temp_select.append(d) temp_zip = zip(temp_index,temp_select) db, cursor = db_set(request) for w in temp_zip: if w[1] == 'on': w1 = 1 else: w1 = 0 w2 = w[0] pql =( 'update tkb_logins SET active1 ="%d" WHERE Id="%s"' % (w1,w2)) cursor.execute(pql) db.commit() request.session["maint_mgmt_main_switch"] = 0 db.close() else: db, cursor = db_set(request) w1 = 0 dept = 'Maintenance' pql =( 'update tkb_logins SET active1 ="%d" WHERE department="%s"' % (w1,dept)) cursor.execute(pql) db.commit() request.session["maint_mgmt_main_switch"] = 1 db.close() return render(request, "redirect_maint_mgmt.html") # This will be it once we've determined switch request.session["index"] = selected2 return render(request, "maint_edit.html") # return done_edit(request) else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, "maint_mgmt.html",{'index':tmp,'args':args})
def tpm_display(request): db, cur = db_set(request) sql = "SELECT * FROM quality_tpm_assets order by ABS(Asset) ASC" cur.execute(sql) tmp = cur.fetchall() request.session['tpm_list'] = tmp if request.POST: selected1 = request.POST try: selected2 = int(selected1.get("one")) except: selected2 = selected1.get("one") if selected2 == 'choose1': request.session["tpm_main_switch"] = 1 else: temp_list = request.session["assigned"] return render(request, "redirect_maint_mgmt.html" ) # This will be it once we've determined switch request.session["index"] = selected2 return render(request, "maint_edit.html") # return done_edit(request) else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, "tpm_list.html", {'args': args}) # def kiosk_add_operation(request): # db, cursor = db_set(request) # # index.replace(" ","") # # sql_11 = "SELECT * FROM scrap_line_operation_category where Id = '%s'" % (index) # # cursor.execute(sql_11) # # request.session["tmp_scrap6"] = cursor.fetchall() # # tmp_scrap4 = request.session["tmp_scrap6"] # # This will assign all the values of machines into session variable machine_temp # if request.session["scrap_entry"] == 0: # active = '1.0' # sql = "SELECT Part FROM scrap_part_line WHERE Active = '%s'" %(active) # ##sql = "update scrap_part_line SET Part ='%s' WHERE Active = '%s'" %(active) # cursor.execute(sql) # tmp = cursor.fetchall() # request.session["scrap_part_selection"] = tmp # db.close() # if request.POST: # scrap_category = request.POST.get("scrap_category") # if request.session["scrap_entry"] == 0: # request.session["scrap_part"] = request.POST.get("scrap_part") # scrap_part = request.session["scrap_part"] # request.session["scrap_entry"] = 1 # #print(request.session["scrap_entry"]) # request.session["scrap1"] ='''disabled="true"''' # request.session["scrap2"] ='' # request.session["scrap3"] ='''disabled="true"''' # request.session["scrap4"] ='''disabled="true"''' # #request.session["scrap"] = "Scrap Description:" # #request.session["amount"] = "Asset Num:" # db, cursor = db_set(request) # sql = "SELECT Line FROM scrap_part_line WHERE Part = '%s'" %(scrap_part) # cursor.execute(sql) # tmp = cursor.fetchall() # scrap_part_line = tmp[0][0] # request.session["scrap_part_line"] = scrap_part_line # #r=4/0 # sql = "SELECT DISTINCT Operation FROM scrap_line_operation_category WHERE Line = '%s'" %(scrap_part_line) # cursor.execute(sql) # tmp = cursor.fetchall() # request.session["scrap_operation_selection"] = tmp # db.close() # return render(request, "redirect_edit_category.html") # if request.session["scrap_entry"] == 1: # request.session["scrap_operation"] = request.POST.get("scrap_operation") # request.session["scrap_entry"] = 2 # request.session["scrap1"] ='''disabled="true"''' # request.session["scrap2"] ='''disabled="true"''' # request.session["scrap3"] ='' # # request.session["scrap4"] ='''disabled="true"''' # line = request.session["scrap_part_line"] # # tmp_scrap4 = request.session["tmp_scrap6"] # # db, cursor = db_set(request) # # index.replace(" ","") # # sql = "SELECT * FROM scrap_line_operation_category where Id = '%s'" % (index) # # cursor.execute(sql) # # request.session["tmp_scrap6"] = cursor.fetchall() # # db.close() # # tmp_scrap6 = request.session["tmp_scrap6"] # # if request.POST: # # scrap_category = request.POST.get("scrap_category") # # # scrap_operation =request.POST.get("scrap_operation") # # return render(request, "scrap_mgmt.html") # ## i tried adding an index parameter in the function so this works but didn't work ^^. # ## i wanted to make it so im taking a similar approach as def operationg_entries_update() but I dont think this is quite there # return render(request, "redirect_edit_category.html") # if request.session["scrap_entry"] == 2: # request.session["scrap_category"] = request.POST.get("scrap_category") # scrap_part = request.session["scrap_part"] # scrap_operation = request.session["scrap_operation"] # scrap_category = request.session["scrap_category"] # line = request.session["scrap_part_line"] # active = '1.0' # #r=4/0 # #Put in here that you INSERT into Mysql a new line showing three things above # db, cursor = db_set(request) # cursor.execute('''INSERT INTO scrap_line_operation_category(Line,Operation,Category) VALUES(%s,%s,%s)''', (line,scrap_operation,scrap_category)) # cursor.execute('''INSERT INTO scrap_part_line(Part,Line,Active) VALUES(%s,%s,%s)''', (scrap_part,line,active)) # db.commit() # db.close() # return render(request, "redirect_scrap_mgmt.html") # return render(request, "redirect_scrap_mgmt.html") # else: # form = sup_downForm() # args = {} # args.update(csrf(request)) # args['form'] = form # return render(request,'edit_category.html',{'args':args})
def kiosk_add_category(request): # e = 4/0 db, cursor = db_set(request) # index.replace(" ","") # sql_11 = "SELECT * FROM scrap_line_operation_category where Id = '%s'" % (index) # cursor.execute(sql_11) # request.session["tmp_scrap6"] = cursor.fetchall() # tmp_scrap4 = request.session["tmp_scrap6"] # This will assign all the values of machines into session variable machine_temp if request.session["scrap_entry"] == 0: active = '1.0' sql = "SELECT Part FROM scrap_part_line WHERE Active = '%s'" % (active) ##sql = "update scrap_part_line SET Part ='%s' WHERE Active = '%s'" %(active) cursor.execute(sql) tmp = cursor.fetchall() request.session["scrap_part_selection"] = tmp db.close() if request.POST: scrap_category = request.POST.get("scrap_category") if request.session["scrap_entry"] == 0: request.session["scrap_part"] = request.POST.get("scrap_part") scrap_part = request.session["scrap_part"] request.session["scrap_entry"] = 1 #print(request.session["scrap_entry"]) request.session["scrap1"] = '''disabled="true"''' request.session["scrap2"] = '' request.session["scrap3"] = '''disabled="true"''' request.session["scrap4"] = '''disabled="true"''' #request.session["scrap"] = "Scrap Description:" #request.session["amount"] = "Asset Num:" db, cursor = db_set(request) sql = "SELECT Line FROM scrap_part_line WHERE Part = '%s'" % ( scrap_part) cursor.execute(sql) tmp = cursor.fetchall() scrap_part_line = tmp[0][0] request.session["scrap_part_line"] = scrap_part_line #r=4/0 sql = "SELECT DISTINCT Operation FROM scrap_line_operation_category WHERE Line = '%s'" % ( scrap_part_line) cursor.execute(sql) tmp = cursor.fetchall() request.session["scrap_operation_selection"] = tmp db.close() return render(request, "redirect_edit_category.html") if request.session["scrap_entry"] == 1: request.session["scrap_operation"] = request.POST.get( "scrap_operation") request.session["scrap_entry"] = 2 request.session["scrap1"] = '''disabled="true"''' request.session["scrap2"] = '''disabled="true"''' request.session["scrap3"] = '' # request.session["scrap4"] ='''disabled="true"''' line = request.session["scrap_part_line"] # tmp_scrap4 = request.session["tmp_scrap6"] # db, cursor = db_set(request) # index.replace(" ","") # sql = "SELECT * FROM scrap_line_operation_category where Id = '%s'" % (index) # cursor.execute(sql) # request.session["tmp_scrap6"] = cursor.fetchall() # db.close() # tmp_scrap6 = request.session["tmp_scrap6"] # if request.POST: # scrap_category = request.POST.get("scrap_category") # # scrap_operation =request.POST.get("scrap_operation") # return render(request, "scrap_mgmt.html") ## i tried adding an index parameter in the function so this works but didn't work ^^. ## i wanted to make it so im taking a similar approach as def operationg_entries_update() but I dont think this is quite there return render(request, "redirect_edit_category.html") if request.session["scrap_entry"] == 2: request.session["scrap_category"] = request.POST.get( "scrap_category") scrap_part = request.session["scrap_part"] scrap_operation = request.session["scrap_operation"] scrap_category = request.session["scrap_category"] line = request.session["scrap_part_line"] active = '1.0' #r=4/0 #Put in here that you INSERT into Mysql a new line showing three things above db, cursor = db_set(request) cursor.execute( '''INSERT INTO scrap_line_operation_category(Line,Operation,Category) VALUES(%s,%s,%s)''', (line, scrap_operation, scrap_category)) cursor.execute( '''INSERT INTO scrap_part_line(Part,Line,Active) VALUES(%s,%s,%s)''', (scrap_part, line, active)) db.commit() db.close() return render(request, "redirect_scrap_mgmt.html") return render(request, "redirect_scrap_mgmt.html") else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'edit_category.html', {'args': args})
def scrap_edit_categories(request): db, cursor = db_set(request) if request.session["qedit_entry"] == 0: active = '1.0' sql = "SELECT Part FROM scrap_part_line WHERE Active = '%s' ORDER BY Part ASC" % ( active) cursor.execute(sql) tmp = cursor.fetchall() request.session["qedit_part_selection"] = tmp db.close() if request.POST: qedit_part = request.POST.get("qedit_part") qedit_operation = request.POST.get("qedit_operation") qedit_category = request.POST.get("qedit_category") qedit_amount = request.POST.get("qedit_amount") finish_switch = 0 try: finish_switch = request.POST.get("one") except: finish_switch = 0 if request.session["qedit_entry"] == 0: request.session["qedit_part"] = qedit_part request.session["qedit_entry"] = 1 request.session["qedit1"] = '''disabled="true"''' request.session["qedit2"] = '' db, cursor = db_set(request) sql = "SELECT Line FROM scrap_part_line WHERE Part = '%s'" % ( qedit_part) cursor.execute(sql) tmp = cursor.fetchall() qedit_part_line = tmp[0][0] request.session["qedit_part_line"] = qedit_part_line sql = "SELECT DISTINCT Operation FROM scrap_line_operation_category WHERE Line = '%s'" % ( qedit_part_line) cursor.execute(sql) tmp = cursor.fetchall() request.session["qedit_operation_selection"] = tmp db.close() return render(request, "redirect_scrap_edit_categories.html") if request.session["qedit_entry"] == 1: qedit_part_line = request.session["qedit_part_line"] request.session["qedit_operation"] = qedit_operation db, cursor = db_set(request) sql = "SELECT Category FROM scrap_line_operation_category WHERE Line = '%s' and Operation = '%s' ORDER BY Category ASC" % ( qedit_part_line, qedit_operation) cursor.execute(sql) tmp = cursor.fetchall() a = [] b = [] ctr = 1 for i in tmp: a.append(i[0]) b.append(ctr) ctr += 1 c = zip(a, b) request.session["qedit_category_selection"] = c db.close() return render(request, 'scrap_edit_categories_entry.html') else: form = sup_downForm() args = {} args.update(csrf(request)) args['form'] = form return render(request, 'scrap_edit_categories.html', {'args': args})