mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-16 08:31:39 -04:00
lk | adds ability to print multiple receipts for freecyclery clients
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.freecyclery-receipt{
|
||||
.print-receipts, .freecyclery-receipt{
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
border-bottom: 5px solid black;
|
||||
}
|
||||
.receipt{
|
||||
page-break-inside: avoid;
|
||||
margin: 10px;
|
||||
border: 5px solid black;
|
||||
height: 400px;
|
||||
|
||||
@@ -31,6 +31,15 @@ class ClientsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def print_select
|
||||
@clients = Client.includes(:bike).where.not(bike_id: nil).order(application_date: :desc).paginate(:page => params[:page], :per_page => 30)
|
||||
end
|
||||
|
||||
def print_receipts
|
||||
client_ids = print_params.map{|key, value| key if value == "1"}.compact
|
||||
@clients = Client.find(client_ids)
|
||||
end
|
||||
|
||||
private
|
||||
def set_client
|
||||
@client = Client.find(params[:id])
|
||||
@@ -60,4 +69,8 @@ class ClientsController < ApplicationController
|
||||
:pickup_date,
|
||||
:volunteer_at_pickup)
|
||||
end
|
||||
|
||||
def print_params
|
||||
params.require(:print_clients)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ class Bike < ActiveRecord::Base
|
||||
validates :bike_type, presence: true
|
||||
validates :color, presence: true
|
||||
validates :serial_number, presence: true
|
||||
has_one :client
|
||||
|
||||
def self.bike_types
|
||||
[
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Client < ActiveRecord::Base
|
||||
# TODO: figure out why application_date validation is fubar
|
||||
# validates :application_date, presence: true
|
||||
has_one :bike
|
||||
belongs_to :bike
|
||||
belongs_to :agency
|
||||
|
||||
def self.waiting_list
|
||||
@@ -20,8 +20,4 @@ class Client < ActiveRecord::Base
|
||||
Client.all.select{|client| client.application_voided || client.pickup_date}
|
||||
end
|
||||
|
||||
def bike
|
||||
Bike.find(self.bike_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
.col-xs-6
|
||||
.receipt
|
||||
%h2
|
||||
%strong= client.bike.name
|
||||
%br
|
||||
.horizontal-line
|
||||
.client-information
|
||||
= client.name
|
||||
%br
|
||||
= client.agency.agency_name if client.agency
|
||||
.horizontal-line
|
||||
%br
|
||||
Includes:
|
||||
%br
|
||||
= 'Helmet' if client.helmet
|
||||
%br
|
||||
= 'Lock' if client.lock
|
||||
%br
|
||||
%br
|
||||
Date Received
|
||||
%br
|
||||
_______________
|
||||
%br
|
||||
Client Signature
|
||||
%br
|
||||
________________
|
||||
%br
|
||||
Recyclery Volunteer Initials
|
||||
%br
|
||||
___
|
||||
%br
|
||||
CLIENT COPY
|
||||
|
||||
.col-xs-6
|
||||
.receipt
|
||||
%h2
|
||||
%strong= client.bike.name
|
||||
%br
|
||||
.horizontal-line
|
||||
.client-information
|
||||
= client.name
|
||||
%br
|
||||
= client.agency.agency_name if client.agency
|
||||
.horizontal-line
|
||||
.row
|
||||
.col-xs-6
|
||||
%br
|
||||
= 'Will make 25$ payment for lock and helmet' if client.will_pay
|
||||
%br
|
||||
Includes:
|
||||
%br
|
||||
= 'Helmet' if client.helmet
|
||||
%br
|
||||
= 'Lock' if client.lock
|
||||
%br
|
||||
%br
|
||||
Date Received
|
||||
%br
|
||||
_______________
|
||||
%br
|
||||
Client Signature
|
||||
%br
|
||||
________________
|
||||
.col-xs-6
|
||||
.client-info-header CLIENT INFO
|
||||
.client-email= "Agency Email: " + client.agency.email
|
||||
.client-phone= "Agency Phone #: " + client.agency.phone_number
|
||||
.client-photo-consent [ ] I grant consent to the Recyclery to use and publish photographs of me.
|
||||
%br
|
||||
Recyclery Volunteer Initials
|
||||
%br
|
||||
___
|
||||
%br
|
||||
RECYCLERY COPY
|
||||
@@ -0,0 +1,4 @@
|
||||
.container.print-receipts
|
||||
- @clients.each do |client|
|
||||
.row
|
||||
= render partial: "receipt", locals: {client: client}
|
||||
@@ -0,0 +1,18 @@
|
||||
.container
|
||||
%h1 Select the clients whose receipts you would like to print
|
||||
|
||||
=form_tag("/clients/print_receipts", method: "get") do
|
||||
%table.table.table-striped.table-bordered.table-hover
|
||||
%thead
|
||||
%tr
|
||||
%th Client
|
||||
%th Bike
|
||||
%th Select
|
||||
-@clients.each do |client|
|
||||
%tr
|
||||
%td= client.name
|
||||
%td= client.bike.name
|
||||
%td= check_box("print_clients", client.id)
|
||||
=will_paginate @clients
|
||||
%br
|
||||
=submit_tag 'Generate Receipts', class: "btn btn-default"
|
||||
@@ -15,6 +15,8 @@
|
||||
%br
|
||||
= link_to "Freecyclery Agencies", agencies_path
|
||||
%br
|
||||
= link_to "Print Client Receipts", print_select_clients_path
|
||||
%br
|
||||
= link_to "Freecyclery Closed Applications", closed_applications_path
|
||||
%br
|
||||
= link_to "Available Bikes", available_bikes_path
|
||||
|
||||
Reference in New Issue
Block a user