diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb
new file mode 100644
index 0000000..a3336fe
--- /dev/null
+++ b/app/controllers/jobs_controller.rb
@@ -0,0 +1,70 @@
+class JobsController < ApplicationController
+ before_action :set_job, only: %i[ show edit update destroy ]
+
+ # GET /jobs or /jobs.json
+ def index
+ @jobs = Job.all
+ end
+
+ # GET /jobs/1 or /jobs/1.json
+ def show
+ end
+
+ # GET /jobs/new
+ def new
+ @job = Job.new
+ end
+
+ # GET /jobs/1/edit
+ def edit
+ end
+
+ # POST /jobs or /jobs.json
+ def create
+ @job = Job.new(job_params)
+
+ respond_to do |format|
+ if @job.save
+ format.html { redirect_to job_url(@job), notice: "Job was successfully created." }
+ format.json { render :show, status: :created, location: @job }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @job.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /jobs/1 or /jobs/1.json
+ def update
+ respond_to do |format|
+ if @job.update(job_params)
+ format.html { redirect_to job_url(@job), notice: "Job was successfully updated." }
+ format.json { render :show, status: :ok, location: @job }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @job.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /jobs/1 or /jobs/1.json
+ def destroy
+ @job.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to jobs_url, notice: "Job was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_job
+ @job = Job.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def job_params
+ params.require(:job).permit(:operator_id_id, :costumer_id_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)
+ end
+end
diff --git a/app/helpers/jobs_helper.rb b/app/helpers/jobs_helper.rb
new file mode 100644
index 0000000..44c7bf6
--- /dev/null
+++ b/app/helpers/jobs_helper.rb
@@ -0,0 +1,2 @@
+module JobsHelper
+end
diff --git a/app/models/job.rb b/app/models/job.rb
new file mode 100644
index 0000000..0c77567
--- /dev/null
+++ b/app/models/job.rb
@@ -0,0 +1,4 @@
+class Job < ApplicationRecord
+ belongs_to :operator_id
+ belongs_to :costumer_id
+end
diff --git a/app/views/jobs/_form.html.erb b/app/views/jobs/_form.html.erb
new file mode 100644
index 0000000..22fcc88
--- /dev/null
+++ b/app/views/jobs/_form.html.erb
@@ -0,0 +1,92 @@
+<%= form_with(model: job, class: "contents") do |form| %>
+ <% if job.errors.any? %>
+
+
<%= pluralize(job.errors.count, "error") %> prohibited this job from being saved:
+
+
+ <% job.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :operator_id_id %>
+ <%= form.text_field :operator_id_id, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :costumer_id_id %>
+ <%= form.text_field :costumer_id_id, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :operator_firstname %>
+ <%= form.text_field :operator_firstname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :operator_lastname %>
+ <%= form.text_field :operator_lastname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :costumer_firstname %>
+ <%= form.text_field :costumer_firstname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :costumer_lastname %>
+ <%= form.text_field :costumer_lastname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :paid %>
+ <%= form.check_box :paid, class: "block mt-2 h-5 w-5" %>
+
+
+
+ <%= form.label :printed_at %>
+ <%= form.datetime_field :printed_at, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :intern %>
+ <%= form.check_box :intern, class: "block mt-2 h-5 w-5" %>
+
+
+
+ <%= form.label :cost_center %>
+ <%= form.text_field :cost_center, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :number_of_plans_a0 %>
+ <%= form.number_field :number_of_plans_a0, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :number_of_plans_a1 %>
+ <%= form.number_field :number_of_plans_a1, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :number_of_plans_a2 %>
+ <%= form.number_field :number_of_plans_a2, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :number_of_plans_a3 %>
+ <%= form.number_field :number_of_plans_a3, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.label :costum_qm_plan %>
+ <%= form.text_field :costum_qm_plan, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+
+
+
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
+
+<% end %>
diff --git a/app/views/jobs/_job.html.erb b/app/views/jobs/_job.html.erb
new file mode 100644
index 0000000..dbb9932
--- /dev/null
+++ b/app/views/jobs/_job.html.erb
@@ -0,0 +1,77 @@
+
+
+ Operator:
+ <%= job.operator_id_id %>
+
+
+
+ Costumer:
+ <%= job.costumer_id_id %>
+
+
+
+ Operator firstname:
+ <%= job.operator_firstname %>
+
+
+
+ Operator lastname:
+ <%= job.operator_lastname %>
+
+
+
+ Costumer firstname:
+ <%= job.costumer_firstname %>
+
+
+
+ Costumer lastname:
+ <%= job.costumer_lastname %>
+
+
+
+ Paid:
+ <%= job.paid %>
+
+
+
+ Printed at:
+ <%= job.printed_at %>
+
+
+
+ Intern:
+ <%= job.intern %>
+
+
+
+ Cost center:
+ <%= job.cost_center %>
+
+
+
+ Number of plans a0:
+ <%= job.number_of_plans_a0 %>
+
+
+
+ Number of plans a1:
+ <%= job.number_of_plans_a1 %>
+
+
+
+ Number of plans a2:
+ <%= job.number_of_plans_a2 %>
+
+
+
+ Number of plans a3:
+ <%= job.number_of_plans_a3 %>
+
+
+
+ Costum qm plan:
+ <%= job.costum_qm_plan %>
+
+
+
diff --git a/app/views/jobs/_job.json.jbuilder b/app/views/jobs/_job.json.jbuilder
new file mode 100644
index 0000000..324eb8c
--- /dev/null
+++ b/app/views/jobs/_job.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! job, :id, :operator_id_id, :costumer_id_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, :created_at, :updated_at
+json.url job_url(job, format: :json)
diff --git a/app/views/jobs/edit.html.erb b/app/views/jobs/edit.html.erb
new file mode 100644
index 0000000..34c8329
--- /dev/null
+++ b/app/views/jobs/edit.html.erb
@@ -0,0 +1,8 @@
+
+
Editing job
+
+ <%= render "form", job: @job %>
+
+ <%= link_to "Show this job", @job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/jobs/index.html.erb b/app/views/jobs/index.html.erb
new file mode 100644
index 0000000..c3e70cc
--- /dev/null
+++ b/app/views/jobs/index.html.erb
@@ -0,0 +1,21 @@
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+ <% content_for :title, "Jobs" %>
+
+
+
Jobs
+ <%= link_to "New job", new_job_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
+
+
+
+ <% @jobs.each do |job| %>
+ <%= render job %>
+
+ <%= link_to "Show this job", job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <% end %>
+
+
diff --git a/app/views/jobs/index.json.jbuilder b/app/views/jobs/index.json.jbuilder
new file mode 100644
index 0000000..cb98f1d
--- /dev/null
+++ b/app/views/jobs/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @jobs, partial: "jobs/job", as: :job
diff --git a/app/views/jobs/new.html.erb b/app/views/jobs/new.html.erb
new file mode 100644
index 0000000..aa0c983
--- /dev/null
+++ b/app/views/jobs/new.html.erb
@@ -0,0 +1,7 @@
+
+
New job
+
+ <%= render "form", job: @job %>
+
+ <%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
diff --git a/app/views/jobs/show.html.erb b/app/views/jobs/show.html.erb
new file mode 100644
index 0000000..fd8fc26
--- /dev/null
+++ b/app/views/jobs/show.html.erb
@@ -0,0 +1,15 @@
+
+
+ <% if notice.present? %>
+
<%= notice %>
+ <% end %>
+
+ <%= render @job %>
+
+ <%= link_to "Edit this job", edit_job_path(@job), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+
+ <%= button_to "Destroy this job", @job, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
+
+
+
diff --git a/app/views/jobs/show.json.jbuilder b/app/views/jobs/show.json.jbuilder
new file mode 100644
index 0000000..c6d7d68
--- /dev/null
+++ b/app/views/jobs/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "jobs/job", job: @job
diff --git a/config/routes.rb b/config/routes.rb
index a125ef0..7abe017 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
+ resources :jobs
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
@@ -6,5 +7,5 @@ Rails.application.routes.draw do
get "up" => "rails/health#show", as: :rails_health_check
# Defines the root path route ("/")
- # root "posts#index"
+ root "jobs#index"
end
diff --git a/db/migrate/20240727101347_create_jobs.rb b/db/migrate/20240727101347_create_jobs.rb
new file mode 100644
index 0000000..9497dde
--- /dev/null
+++ b/db/migrate/20240727101347_create_jobs.rb
@@ -0,0 +1,23 @@
+class CreateJobs < ActiveRecord::Migration[7.1]
+ def change
+ create_table :jobs do |t|
+ t.references :operator_id, null: false, foreign_key: true
+ t.references :costumer_id, null: false, foreign_key: true
+ t.string :operator_firstname
+ t.string :operator_lastname
+ t.string :costumer_firstname
+ t.string :costumer_lastname
+ t.boolean :paid
+ t.datetime :printed_at
+ t.boolean :intern
+ t.string :cost_center
+ t.integer :number_of_plans_a0
+ t.integer :number_of_plans_a1
+ t.integer :number_of_plans_a2
+ t.integer :number_of_plans_a3
+ t.float :costum_qm_plan
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..ddd323a
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,38 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema[7.1].define(version: 2024_07_27_101347) do
+ create_table "jobs", force: :cascade do |t|
+ t.integer "operator_id_id", null: false
+ t.integer "costumer_id_id", null: false
+ t.string "operator_firstname"
+ t.string "operator_lastname"
+ t.string "costumer_firstname"
+ t.string "costumer_lastname"
+ t.boolean "paid"
+ t.datetime "printed_at"
+ t.boolean "intern"
+ t.string "cost_center"
+ t.integer "number_of_plans_a0"
+ t.integer "number_of_plans_a1"
+ t.integer "number_of_plans_a2"
+ t.integer "number_of_plans_a3"
+ t.float "costum_qm_plan"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["costumer_id_id"], name: "index_jobs_on_costumer_id_id"
+ t.index ["operator_id_id"], name: "index_jobs_on_operator_id_id"
+ end
+
+ add_foreign_key "jobs", "costumer_ids"
+ add_foreign_key "jobs", "operator_ids"
+end
diff --git a/test/controllers/jobs_controller_test.rb b/test/controllers/jobs_controller_test.rb
new file mode 100644
index 0000000..0645b7d
--- /dev/null
+++ b/test/controllers/jobs_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class JobsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @job = jobs(:one)
+ end
+
+ test "should get index" do
+ get jobs_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_job_url
+ assert_response :success
+ end
+
+ test "should create job" do
+ assert_difference("Job.count") do
+ post jobs_url, params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
+ end
+
+ assert_redirected_to job_url(Job.last)
+ end
+
+ test "should show job" do
+ get job_url(@job)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_job_url(@job)
+ assert_response :success
+ end
+
+ test "should update job" do
+ patch job_url(@job), params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
+ assert_redirected_to job_url(@job)
+ end
+
+ test "should destroy job" do
+ assert_difference("Job.count", -1) do
+ delete job_url(@job)
+ end
+
+ assert_redirected_to jobs_url
+ end
+end
diff --git a/test/fixtures/jobs.yml b/test/fixtures/jobs.yml
new file mode 100644
index 0000000..396e27a
--- /dev/null
+++ b/test/fixtures/jobs.yml
@@ -0,0 +1,35 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ operator_id: one
+ costumer_id: one
+ operator_firstname: MyString
+ operator_lastname: MyString
+ costumer_firstname: MyString
+ costumer_lastname: MyString
+ paid: false
+ printed_at: 2024-07-27 12:13:47
+ intern: false
+ cost_center: MyString
+ number_of_plans_a0: 1
+ number_of_plans_a1: 1
+ number_of_plans_a2: 1
+ number_of_plans_a3: 1
+ costum_qm_plan: 1.5
+
+two:
+ operator_id: two
+ costumer_id: two
+ operator_firstname: MyString
+ operator_lastname: MyString
+ costumer_firstname: MyString
+ costumer_lastname: MyString
+ paid: false
+ printed_at: 2024-07-27 12:13:47
+ intern: false
+ cost_center: MyString
+ number_of_plans_a0: 1
+ number_of_plans_a1: 1
+ number_of_plans_a2: 1
+ number_of_plans_a3: 1
+ costum_qm_plan: 1.5
diff --git a/test/models/job_test.rb b/test/models/job_test.rb
new file mode 100644
index 0000000..2750a42
--- /dev/null
+++ b/test/models/job_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class JobTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/system/jobs_test.rb b/test/system/jobs_test.rb
new file mode 100644
index 0000000..2f0830c
--- /dev/null
+++ b/test/system/jobs_test.rb
@@ -0,0 +1,69 @@
+require "application_system_test_case"
+
+class JobsTest < ApplicationSystemTestCase
+ setup do
+ @job = jobs(:one)
+ end
+
+ test "visiting the index" do
+ visit jobs_url
+ assert_selector "h1", text: "Jobs"
+ end
+
+ test "should create job" do
+ visit jobs_url
+ click_on "New job"
+
+ fill_in "Cost center", with: @job.cost_center
+ fill_in "Costum qm plan", with: @job.costum_qm_plan
+ fill_in "Costumer firstname", with: @job.costumer_firstname
+ fill_in "Costumer id", with: @job.costumer_id_id
+ fill_in "Costumer lastname", with: @job.costumer_lastname
+ check "Intern" if @job.intern
+ fill_in "Number of plans a0", with: @job.number_of_plans_a0
+ fill_in "Number of plans a1", with: @job.number_of_plans_a1
+ fill_in "Number of plans a2", with: @job.number_of_plans_a2
+ fill_in "Number of plans a3", with: @job.number_of_plans_a3
+ fill_in "Operator firstname", with: @job.operator_firstname
+ fill_in "Operator id", with: @job.operator_id_id
+ fill_in "Operator lastname", with: @job.operator_lastname
+ check "Paid" if @job.paid
+ fill_in "Printed at", with: @job.printed_at
+ click_on "Create Job"
+
+ assert_text "Job was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Job" do
+ visit job_url(@job)
+ click_on "Edit this job", match: :first
+
+ fill_in "Cost center", with: @job.cost_center
+ fill_in "Costum qm plan", with: @job.costum_qm_plan
+ fill_in "Costumer firstname", with: @job.costumer_firstname
+ fill_in "Costumer id", with: @job.costumer_id_id
+ fill_in "Costumer lastname", with: @job.costumer_lastname
+ check "Intern" if @job.intern
+ fill_in "Number of plans a0", with: @job.number_of_plans_a0
+ fill_in "Number of plans a1", with: @job.number_of_plans_a1
+ fill_in "Number of plans a2", with: @job.number_of_plans_a2
+ fill_in "Number of plans a3", with: @job.number_of_plans_a3
+ fill_in "Operator firstname", with: @job.operator_firstname
+ fill_in "Operator id", with: @job.operator_id_id
+ fill_in "Operator lastname", with: @job.operator_lastname
+ check "Paid" if @job.paid
+ fill_in "Printed at", with: @job.printed_at
+ click_on "Update Job"
+
+ assert_text "Job was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Job" do
+ visit job_url(@job)
+ click_on "Destroy this job", match: :first
+
+ assert_text "Job was successfully destroyed"
+ end
+end