From 05ff4b488cffa8796e7b4bea52384104f92e2a46 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 23 May 2016 19:12:16 +0800 Subject: [PATCH] notification method added for clients and also sorting fixed --- app/controllers/admin/tickets_api_controller.rb | 2 +- app/controllers/admin/tickets_controller.rb | 3 +++ app/helpers/tickets_helper.rb | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/tickets_api_controller.rb b/app/controllers/admin/tickets_api_controller.rb index 4d7d507..4607212 100644 --- a/app/controllers/admin/tickets_api_controller.rb +++ b/app/controllers/admin/tickets_api_controller.rb @@ -80,7 +80,7 @@ class Admin::TicketsApiController < ApplicationController tickets = {} if !site.nil? if params[:type].nil? && params[:query].nil? - site_tickets = site.tickets.desc(:created_at).page(params[:page]).per(5) + site_tickets = site.tickets.order_by([:status, :desc],[:created_at, :desc]).page(params[:page]).per(5) else q = params[:query] t = params[:type] diff --git a/app/controllers/admin/tickets_controller.rb b/app/controllers/admin/tickets_controller.rb index d5eb9ee..da440a4 100644 --- a/app/controllers/admin/tickets_controller.rb +++ b/app/controllers/admin/tickets_controller.rb @@ -196,6 +196,9 @@ class Admin::TicketsController < OrbitAdminController response.internal_response = params[:internal_response] if params[:internal_response].present? response.user_tags = params[:user_tags] if params[:user_tags].present? response.save + if !response.internal_response + notify_response_to_client(tq.ticket) rescue nil + end tq.ticket_query_responses << response if params[:user_tags].present? Thread.new do diff --git a/app/helpers/tickets_helper.rb b/app/helpers/tickets_helper.rb index fa9b9bc..3252914 100644 --- a/app/helpers/tickets_helper.rb +++ b/app/helpers/tickets_helper.rb @@ -23,6 +23,11 @@ module TicketsHelper return html end + def notify_response_to_client(ticket) + network = ONetwork.new("http://" + ticket.registered_site.site_domain, "post") rescue nil + network.request("/store/ticket_response_update",{"ticket_id" => ticket.uid}) if !network.nil? + end + def send_notification_emails(response, ticket) response.user_tags.each do |u| user = User.find(u) rescue nil