Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Пример диплома специалиста / 007 Текст програми.docx
Скачиваний:
13
Добавлен:
28.03.2016
Размер:
157.39 Кб
Скачать

22

02070743.00569-01 12 01

def collapse_ticket

render :layout => false

end

def create_ticket

if request.post?

@user = User.find(session[:user][:id])

if params[:ticket][:category]== "none"#category is blank

flash[:message]= "Please Specify а category.<br>"

else#everything's cool so far...

#Create Ticket object and populate---------------------

@ticket = Ticket.new(params[:ticket])

@ticket.ticketstatus_id = 1

@ticket.user_id = session[:user][:id]

if @ticket.save#save ticket & text in db.

flash[:message]= "<font color=green><image src=\"/images/icon_success.png\"> Your ticket was successfully created!</font><br>"

#Create Tickettext object and populate-----------------

@ticket_text = Tickettext.new()

@ticket_text.text_content = params[:ticket][:text_content]

@ticket_text.user_id = session[:user][:id]

@ticket_text.post_type = "user-post"

@ticket_text.ticket_id = @ticket.id

if @ticket_text.save#Add the text to the ticket

flash[:message] << "<font color=green><image src=\"/images/icon_success.png\"> Your post was added to the ticket successfully!</font><br>"

flash[:message] << "<font color=green><image src=\"/images/icon_info.png\"> <b>Your new ticket number is: #{@ticket.id}</font>"

make_log(@ticket.id, "Created Ticket!")

redirect_to :action => 'view_tickets'

else #tickettext save failed

flash[:message]= "There was an error when adding your post to the ticket!"

end

else #save failed

flash[:message]= "There was an error when entering your ticket into the database!<br>"

@ticket.errors.each do |key, error|

flash[:message] << error

end

redirect_to :controller => 'tech' :action => 'open_ticket'

end

end

end

end

def edit_account

@user = User.find(session[:user][:id])

end

def edit_tickets

111

end

23

02070743.00569-01 12 01

def expand_ticket

render :layout => false

end

def login

if request.post?

if session[:user]= User.authenticate(params[:user][:email], Digest::SHA256.hexdigest(params[:user][:password]))

flash[:message]= "<font color=green><image src=\"/images/icon_success.png\"> Login Successful!</font><br>"

#redirect_to_stored

redirect_to :controller => 'tech' :action => "view_tickets"

else # authentication failed!

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> Login failed!</font><br>"

redirect_to :controller => "tech" :action => "index"

end

end

end

def lookup_ticket

@ticket = Ticket.find(params[:ticket][:id] :limit => 1) #look up the ticket to make sure it exists

rescue ActiveRecord::RecordNotFound # If the ticket doesn't exist...

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> I couldn't find ticket: #{params[:ticket][:id]}</font><br>"

redirect_to :action => "view_tickets"

end

def make_log(ticketid = 0, msg = "") #log only certain actions(see above in before_filter to specify what actions to log)

@log = Ticketlog.new(:log_type => "#{params[:action]}", :ticket_id => ticketid :user_id => session[:user][:id] :log => "#{msg}")

if @log.save

#do nothing

else

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> Error saving log!</font>"

logger.info "Failed creating log!"

end

end

def open_ticket

@user = User.find(session[:user][:id])

@categories = Category.find(:all :limit => 100)

@statuses = Ticketstatus.find(:all)

end

def save_post

if request.post?

112

flash[:message]= ""

Соседние файлы в папке Пример диплома специалиста