This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.new_autoservice_requests_qty | |
qty ||= unregistered.count | |
qty | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
unless current_user.service_station.present? | |
redirect_to new_profile_service_station_path | |
else | |
service = current_user.service_station.service_station_comments.where("spare_id = ?", params[:spare_id]) | |
if service.present? | |
redirect_to "/profile/service_station_comments/#{service.first.id}/edit" | |
end | |
@comment = ServiceStationComment.new | |
gon.labor_times_price = current_user.service_station.labor_times_price |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Profile::ServiceStationCommentsController < ApplicationController | |
before_filter :authenticate_user! | |
before_filter :load_spare, only: [:index, :new] | |
def index | |
@comments = ServiceStationComment.all | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h1 Редактировать комментарий об установки детали № #{@spare.number} | |
%h2 Сервисный центр #{@comment.service_station.name} | |
= simple_form_for [:admin, @comment], :html => { id: "comment_form", class: "form-horizontal", role: "form" } do |f| | |
= f.hidden_field :spare_id, value: @spare.id | |
= f.input :time_of_installing_current_part, label: "Ориентировочное время установки (ч.)" | |
= f.input :installing_current_part_price, label: "Стоимость установки (р.)" | |
= f.input :comment, label: "Комментарий", as: :text | |
.form-group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def permit(params) | |
params.permit(:spare_id, :service_station_id, :installing_current_part_price, :time_of_installing_current_part, :labor_times_price,:blocked_at, :comment) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
@spare = Spare.find(params[:service_station_comment][:spare_id]) | |
comment = ServiceStationComment.find(params[:id]) | |
if comment.update permit params[:service_station_comment] | |
redirect_to admin_service_station_path(comment.service_station) | |
else | |
render :edit | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def edit | |
@comment = ServiceStationComment.find(params[:id]) | |
@spare = @comment.spare | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'spreadsheet' | |
xls_file_name = "/tmp/status_data.xls" | |
xls_book = Spreadsheet.open(xls_file_name, "rb") | |
xls_book.worksheet(0).each do |row| | |
puts row[6].value if row[6] and row[6].is_a?(Spreadsheet::Formula) |
NewerOlder