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

12

02070743.00569-01 12 01

@status.errors.each do |key,value|

flash[:message] << "<font color=red><image src=\"/images/icon_failure.png\">Error: (#{key})....#{value}</font><br>"#print errors

end

end

else #save failed

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\">There was an error when entering your ticket into the database!<br></font>"

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

flash[:message] << "<font color=red><image src=\"/images/icon_failure.png\">Error: (#{key})....#{value}</font><br>"#print errors

end

redirect_to :action => 'create_ticket'

end

end

end

end

def edit_system_settings

flash[:message]= "<i>This Feature is not yet implemented.</i>"

redirect_to :action => "view_tickets"

end

def edit_ticket_categories

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

end

def edit_ticket_categories_destroy

@category = Category.find(params[:id] :limit => 1)

#render :text => @category.inspect

if @category.destroy

flash[:message]= "<font color=green><image src=\"/images/icon_success.png\"> Ticket Category Destroyed Successfully!</font><br>"

else

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

end

redirect_to :action => "edit_ticket_categories"

end

def edit_ticket_statuses

@statuses = Ticketstatus.find(:all :limit => 100)

end

def edit_ticket_statuses_destroy

# make sure the admin can't delete status 1(new)

if (params[:id]== "1" || params[:id]== "2")

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> Sorry, You can't delete the 'new' or 'resolved' status. They're important to have!</font><br>"

else # The status to be deleted isn't 'new'

101

@status = Ticketstatus.find(params[:id] :limit => 1)

13

02070743.00569-01 12 01

#render :text => @status.inspect

if @status.destroy

flash[:message]= "<font color=green><image src=\"/images/icon_success.png\"> Ticket Status Destroyed Successfully!</font><br>"

else

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

end

end

redirect_to :action => "edit_ticket_statuses"

end

def edit_users

@increment = 100 # show x tickets per page

if params[:offset].nil? # no offset is defined

@offset = 0 # @offset = where to start looking for tickets

else

@offset = params[:offset].to_i

end

@tick_limit = @offset.to_i + @increment.to_i #The max amount of ticks to display

#Dave: I'll come back and add some pagintation here.

@users = User.find(:all,:offset => @offset, :limit => @increment )

end

def edit_users_destroy

@user = User.find(params[:id] :limit => 1)

if @user.id == session[:user][:id]

flash[:message]= "<font color=red><image src=\"/images/icon_failure.png\"> You can't delete the user you're logged in as!</font><br>"

else

if @user.destroy

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

else

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

end

end

redirect_to :action => "edit_users"

end

def edit_user_update

#render :text => params.inspect

@user = User.find(params[:user_id])

flash[:message]= ""

102

if @user.update_attributes(params[:user])

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