def get_flag_to_update_type(request): json = {} if "roId" in request.GET: roId = int(request.GET.get("roId")) ro = RoServices(request.session["dealer_id"]) json = {"nextFlag" : ro.getFlagToUpdateType(roId)} return JsonResponse(json)
def delete_media(request): if request.method == "GET": roService = RoServices() roService.deleteImage(request) return HttpResponseRedirect( reverse('flagging:media') + "?roNumber=" + request.GET.get("roNumber"))
def get_ro_details_ajax(request): if "roId" in request.GET: try: roService =RoServices(request.session["dealer_id"]) ro = RO.objects.get(id=int(request.GET.get("roId"))) roDetails = roService.getROdetails(ro.ro_number) color = roService.getColorForRO(ro.ro_number) return render(request,"flagging_app/partial/ro_details.html",{"roDetails" : roDetails}) except Exception as e : return ""
def search_ros_ajax(request): filter_dict = {} value = "" type = "" temp_params = {"isOrdered" : False} page = request.GET.get("page",1) try: filter_dict['status'] = request.GET.get("status","active") if "roNumber" in request.GET: value = filter_dict['ro_number'] = request.GET.get("roNumber") type = "roNumber" elif "advisor" in request.GET: value = filter_dict['advisor'] = request.GET.get("advisor") type = "advisor" elif "flags" in request.GET: value = filter_dict['flags'] = request.GET.get("flags") type = "flags" temp_params["orderBy"] = filter_dict["orderBy"] = request.GET.get("orderBy","ro_date") temp_params["isOrdered"] = True temp_params["order"] = filter_dict["order"] = request.GET.get("order","desc") # if page == 1: temp_params["order"] = "asc" if filter_dict["order"] == "desc" else "desc" # if request.GET.get("order"): # filter_dict["order"] = request.GET.get("order") # temp_params["isOrdered"] = True # temp_params["order"] = request.GET.get("order") # if page == 1: # temp_params["order"] = "asc" if request.GET.get("order") == "desc" else "desc" ro_services = RoServices(request.session["dealer_id"]) ro = ro_services.getRos(filter_dict) paginator = Paginator(ro, 25) ro = paginator.page(page) except PageNotAnInteger: ro = paginator.page(1) except EmptyPage: ro = paginator.page(paginator.num_pages) if len(ro) == 1: temp_params["roDetails"] = ro_services.getROdetails(ro[0].ro.ro_number) temp_params["color"] = ro_services.getColorForRO(ro[0].ro.ro_number) temp_params["ro_list"] = ro temp_params["ro_number"] = value temp_params["status"] = request.GET.get("status","active") temp_params["type"] = type temp_params["page"] = page return render(request,"flagging_app/ro_list.html",temp_params)
def inspection_test(request): dealer_id = request.session["dealer_id"] ro_number = request.GET.get("ro_number") package = request.GET.get("package") categories_items_dict = RoServices().get_inspection_data( ro_number, package, dealer_id) return render(request, "flagging_app/inspection_new.html", {"category_items": categories_items_dict})
def get_shop_notes(request): notes = None template_name ="flagging_app/shop_notes.html" roService = RoServices(request.session["dealer_id"]) if request.method == "GET": notes,roObject = roService.getShopNotes(request.GET) if roObject !=None: roNumber = roObject.ro_number else : roNumber = request.GET.get("ro_number") if "ro_number" in request.GET else "" # if "ajaxRequest" in request.GET: # template_name = "flagging_app/shop_notes_ajax.html" return render(request,template_name,{"notes" : notes,"roNumber":roNumber,"ro" : roObject,"roDetails" : roService.getROdetails(roNumber)})
def add_note(request): # notes = None # ro_number =request.GET.get() roNumber = "" if request.method == "POST": notes,roObject = RoServices(request.session["dealer_id"]).addNote(request.POST, request.user) roNumber = roObject.ro_number return HttpResponseRedirect( reverse('flagging:shop_notes')+"?ro_number=" +roNumber)
def get_results_summary_pdf(request): ro_number = request.GET.get("roNumber") package = request.GET.get("package", None) summary = RoServices().getSummaryDetailsByRoNumber(ro_number, package) template = get_template("flagging_app/inspection_pdf.html") url = settings.SITE_MAIN_URL html = template.render({"url": url, "result_summary": summary}) result = StringIO.StringIO() pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result) if not pdf.err: return HttpResponse(result.getvalue(), content_type='application/pdf') return HttpResponse('We had some errors while creating PFD')
def action_plan(request): params = {} if request.method == "GET": if "roNumber" in request.GET: roNumber = request.GET.get("roNumber") ro = RoServices(request.session["dealer_id"]) params['service'] = ro.getCustomerServiceRequest(request.GET) params['summary'] = ro.getSummaryDetailsByRoNumber(roNumber) params['roDetails'] = ro.getROdetails(roNumber) params['color'] = ro.getColorForRO(roNumber) params['roNumber'] = roNumber params['recommendations'] = ro.getInspectionRecommendationSummary( roNumber) params["inspection"] = ro.getCustomerInspectionRecommendation( roNumber) params["action_plan"] = "true" return render(request, "flagging_app/action_plan.html", params)
def media(request): params = {} if request.method == "GET": if "roNumber" in request.GET: roNumber = request.GET.get("roNumber") roService = RoServices(request.session["dealer_id"]) params["roDetails"] = roService.getROdetails(roNumber) params["color"] = roService.getColorForRO(roNumber) params["images"] = roService.getImagesByRoNumber(roNumber) params["walkArounds"] = roService.getWalkAroundImages(roNumber) params["roNumber"] = roNumber return render(request, "flagging_app/media.html", params)
def edit_recommendation(request): try: id = request.GET.get("id") repair = AppointmentRecommendation.objects.get(id = id) action_plan = None if "action_plan" in request.GET: action_plan = True if "parts" in request.GET: repair.parts = float(request.GET.get("parts")) if "labor" in request.GET: repair.labor = float(request.GET.get("labor")) repair.price = repair.parts + repair.labor repair.save() except Exception as e: pass ro_number = repair.appointment.ro.ro_number inspection = RoServices(request.session["dealer_id"]).getCustomerInspectionRecommendation(ro_number) return render(request,"flagging_app/partial/recommendation.html",{"inspection" : inspection,"action_plan" : action_plan})
def inspection(request): params = {} ro = RoServices(request.session["dealer_id"]) dealer_id = request.session.get("dealer_id") _request = request.GET if request.method == "POST": _request = request.POST ro.processInspectionFields(request) ro_number = _request.get("ro_number", "") default_package = InspectionPackage.objects.filter(dealer=ro.dealer) params["selected_package"] = package = _request.get( "package", None if len(default_package) < 1 else default_package[0].package) params["category_items"] = categories_items_dict = ro.get_inspection_data( ro_number, package, dealer_id) params["ro_number"] = ro_number params["packages"] = ro.get_all_packages() params["name"] = "%s, %s" % (request.user.last_name, request.user.first_name) params["summary"] = ro.getSummaryDetailsByRoNumber(ro_number, package) params["roDetails"] = ro.getROdetails(ro_number) return render(request, "flagging_app/inspection_new.html", params)
def action_plan_pdf(request): params = {} if request.method == "GET": if "roNumber" in request.GET: roNumber = request.GET.get("roNumber") ro = RoServices(request.GET.get("dealer_id")) params['service'] = ro.getCustomerServiceRequest(request.GET) params['summary'] = ro.getSummaryDetailsByRoNumber(roNumber) params['roDetails'] = ro.getROdetails(roNumber) params['color'] = ro.getColorForRO(roNumber) params['roNumber'] = roNumber params['recommendations'] = ro.getInspectionRecommendationSummary( roNumber) params["inspection"] = ro.getCustomerInspectionRecommendation( roNumber) params["action_plan"] = "true" apt = Appointment.objects.get(ro__ro_number=roNumber) first_name = apt.customer.first_name if apt.customer.first_name else " " last_name = apt.customer.last_name if apt.customer.last_name else " " params["vehicle_vin"] = apt.vehicle.vin_number params["customer"] = first_name + " " + last_name params["dealer_code"] = Dealer.objects.get( id=request.GET.get("dealer_id")).dealer_code return render(request, "flagging_app/action_plan_pdf.html", params)
def tech_view(request): # obj = {"test" : "test"} param = {} if "roNumber" in request.GET: roService = RoServices(request.session["dealer_id"]) appointmentService = roService.getCustomerServiceRequest(request.GET) inspection = roService.getCustomerInspectionRecommendation(request.GET.get("roNumber")) roHeadingObject = roService.getROdetails(request.GET.get("roNumber")) param = { "roNumber" : request.GET.get("roNumber"), "service" : appointmentService, "roDetails" : roHeadingObject, "color" : roService.getColorForRO(request.GET.get("roNumber")), "inspection" : inspection } return render(request,"flagging_app/techview.html",param)
def update_flags(request): var = "" if request.method == "GET": appointment = RoServices(request.session["dealer_id"]).get_updated_flags_appointment(request) return render(request,"flagging_app/partial/ro_row_data.html",{"appointment" : appointment})
def get_results_summary(request): params = {} if "roNumber" in request.GET: roNumber = request.GET.get("roNumber") params["summary"] = RoServices().getSummaryDetailsByRoNumber(roNumber) return render(request, "flagging_app/result_summary.html", params)
def getColor(roNumber): return RoServices().getColorForRO(roNumber)
def add_recommendations(request): RoServices(request.session["dealer_id"]).addRecommendations(request) return HttpResponse(RoServices().get_updated_flags_appointment(request))
def get_repair_order_list(request): RoServices().get_repair_order_list("", "", "")
def index(request): ro = RoServices(request.session["dealer_id"]) template_params = ro.getAllFlagsDealer(request.session["dealer_id"]) template_params["user"] = request.user template_params["dealer_code"] =request.session["dealer_code"] return render(request,"flagging_app/base.html",template_params)