Files
eminuxCRM/app/controllers/settings_controller.rb
T
eminuxandCursor c4e5f289cf
CI / scan_ruby (push) Failing after 11m20s
CI / scan_js (push) Successful in 10m35s
CI / lint (push) Has been cancelled
Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 23:01:48 +02:00

30 lines
1.1 KiB
Ruby

class SettingsController < ApplicationController
def show
@page_title = "Impostazioni"
@goal = SalesGoal.current(current_project).order(created_at: :desc).first || SalesGoal.new(project: current_project)
@goals = SalesGoal.for_project(current_project).order(start_date: :desc)
@products = Product.ordered
@projects = Project.ordered
end
def update_goal
@goal = params[:id].present? ? SalesGoal.find(params[:id]) : SalesGoal.new
attrs = goal_params.merge(active: true)
attrs[:project_id] ||= current_project&.id
if @goal.update(attrs)
if params[:make_current] == "1" && @goal.project_id.present?
SalesGoal.where(project_id: @goal.project_id).where.not(id: @goal.id).update_all(active: false)
end
redirect_to settings_path, notice: "Obiettivo aggiornato."
else
redirect_to settings_path, alert: @goal.errors.full_messages.to_sentence
end
end
private
def goal_params
params.require(:sales_goal).permit(:name, :metric, :target_value, :start_date, :end_date, :active, :project_id)
end
end