diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb index 2d0f07f..729a07c 100644 --- a/app/controllers/jobs_controller.rb +++ b/app/controllers/jobs_controller.rb @@ -3,7 +3,7 @@ class JobsController < ApplicationController # GET /jobs or /jobs.json def index - @jobs = Job.all + @jobs = Job.current_jobs end # GET /jobs/1 or /jobs/1.json @@ -23,7 +23,7 @@ class JobsController < ApplicationController respond_to do |format| if @job.save - format.html { redirect_to job_url(@job), notice: 'Job was successfully created.' } + format.html { redirect_to jobs_url(Job.current_jobs), notice: 'Job was successfully created.' } format.json { render :show, status: :created, location: @job } else format.html { render :new, status: :unprocessable_entity } @@ -65,6 +65,8 @@ class JobsController < ApplicationController # Only allow a list of trusted parameters through. def job_params params.require(:job).permit(:operator_id, :costumer_id, :operator_firstname, :operator_lastname, - :costumer_firstname, :costumer_lastname, :paid, :printed_at, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan) + :costumer_firstname, :costumer_lastname, :paid, :printed_at, :intern, + :cost_center, :number_of_plans_a0, :number_of_plans_a1, + :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan) end end diff --git a/app/models/job.rb b/app/models/job.rb index e5a594e..a8cff3a 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -1,4 +1,25 @@ class Job < ApplicationRecord belongs_to :operator, class_name: 'User', optional: true belongs_to :costumer, class_name: 'User', optional: true + + # NOTE: Multiple status if paing before brinting + enum status: { + open: 0, + printing: 1, + ready_for_pickup: 2, + paid: 3, + cancelled: 4 + } + + # BUG: shows the hole day of the utc timezone + scope :today, -> { where('DATE(created_at) = ?', Time.now.utc.to_date) } + + def self.current_jobs + today.order(created_at: :desc, status: :asc) + # today.order(created_at: :desc, status: :asc) + end + + def fullname + [costumer_firstname, ' ', costumer_lastname].join + end end diff --git a/app/views/jobs/_job_tr.html.erb b/app/views/jobs/_job_tr.html.erb new file mode 100644 index 0000000..86fcffb --- /dev/null +++ b/app/views/jobs/_job_tr.html.erb @@ -0,0 +1,23 @@ +
<%= notice %>
<% end %> - <% content_for :title, "Jobs" %> + <% content_for :title, "Current Print Jobs" %> -- <%= link_to "Show this job", job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
- <% end %> +| ID | +Name | +A0 | +A1 | +A2 | +A3 | +Status | +
|---|