Photo Field in Customer,Employee and Commissionor
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
//= require bootstrap-notify/bootstrap-notify.js
|
||||
//= require node-waves/waves.js
|
||||
//= require sweetalert/sweetalert.min.js
|
||||
//= require fileinput.min
|
||||
//= require BSBMaterial/turbolink_admin.js
|
||||
//= require BSBMaterial/demo.js
|
||||
//= require custom.js
|
||||
@@ -34,4 +35,24 @@ $(document).on('turbolinks:load', function() {
|
||||
weekStart: 1,
|
||||
time: false
|
||||
});
|
||||
});
|
||||
|
||||
$("#customer_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,6 +104,66 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#shop_logo").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$("#commissioner_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$("#employee_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
// first input focus for all form
|
||||
$('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus();
|
||||
|
||||
|
||||
@@ -9,12 +9,37 @@
|
||||
//= require bootstrap-notify/bootstrap-notify.js
|
||||
//= require node-waves/waves.js
|
||||
//= require sweetalert/sweetalert.min.js
|
||||
//= require fileinput.min
|
||||
//= require cable
|
||||
//= require turbolinks
|
||||
//= require BSBMaterial/turbolink_admin.js
|
||||
//= require BSBMaterial/demo.js
|
||||
//= require custom.js
|
||||
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
|
||||
$("#customer_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.datetimepicker').bootstrapMaterialDatePicker({
|
||||
format: 'DD-MM-YYYY - HH:mm',
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
@import "BSBMaterial/style";
|
||||
@import "BSBMaterial/themes/all-themes";
|
||||
@import "reset";
|
||||
@import "fileinput.min";
|
||||
|
||||
.sx-margin-0 {
|
||||
margin: 0 !important;
|
||||
|
||||
@@ -396,7 +396,7 @@ end
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -91,6 +91,6 @@ class Settings::CommissionersController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active, :image_path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,6 +68,6 @@ class Settings::EmployeesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :role, :emp_id, :password)
|
||||
params.require(:employee).permit(:name, :role, :emp_id, :password, :image_path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,4 +7,7 @@ class Commissioner < ApplicationRecord
|
||||
|
||||
# validations
|
||||
validates_presence_of :name
|
||||
|
||||
# Commissioner Image Uploader
|
||||
mount_uploader :image_path, CommissionerImageUploader
|
||||
end
|
||||
|
||||
@@ -2,6 +2,9 @@ class Customer < ApplicationRecord
|
||||
|
||||
#self.primary_key = :customer_id
|
||||
|
||||
# Customer Image Uploader
|
||||
mount_uploader :image_path, CustomerImageUploader
|
||||
|
||||
before_create :generate_custom_id
|
||||
has_many :orders
|
||||
has_many :sales
|
||||
|
||||
@@ -8,6 +8,9 @@ class Employee < ApplicationRecord
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||
|
||||
# Employee Image Uploader
|
||||
mount_uploader :image_path, EmployeeImageUploader
|
||||
|
||||
def self.all_emp_except_waiter
|
||||
Employee.where('role!=?','waiter')
|
||||
end
|
||||
|
||||
59
app/uploaders/commissioner_image_uploader.rb
Normal file
59
app/uploaders/commissioner_image_uploader.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
class CommissionerImageUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
|
||||
def root
|
||||
Rails.root.join 'public/'
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"image/commissioner_images"
|
||||
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# def cache_dir
|
||||
# '/tmp/images'
|
||||
# end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url(*args)
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||
#
|
||||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||
# end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process scale: [200, 300]
|
||||
process :resize_to_fit => [200, 150]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
# version :thumb do
|
||||
# process resize_to_fit: [50, 50]
|
||||
# end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_whitelist
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
end
|
||||
59
app/uploaders/customer_image_uploader.rb
Normal file
59
app/uploaders/customer_image_uploader.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
class CustomerImageUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
|
||||
def root
|
||||
Rails.root.join 'public/'
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"image/customer_images"
|
||||
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# def cache_dir
|
||||
# '/tmp/images'
|
||||
# end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url(*args)
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||
#
|
||||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||
# end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process scale: [200, 300]
|
||||
process :resize_to_fit => [200, 150]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
# version :thumb do
|
||||
# process resize_to_fit: [50, 50]
|
||||
# end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_whitelist
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
end
|
||||
59
app/uploaders/employee_image_uploader.rb
Normal file
59
app/uploaders/employee_image_uploader.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
class EmployeeImageUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
|
||||
def root
|
||||
Rails.root.join 'public/'
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"image/employee_images"
|
||||
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# def cache_dir
|
||||
# '/tmp/images'
|
||||
# end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url(*args)
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||
#
|
||||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||
# end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process scale: [200, 300]
|
||||
process :resize_to_fit => [200, 150]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
# version :thumb do
|
||||
# process resize_to_fit: [50, 50]
|
||||
# end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_whitelist
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
end
|
||||
@@ -90,6 +90,21 @@
|
||||
<label><%= t("views.right_panel.detail.date_of_birth") %></label>
|
||||
<%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><%= t("views.right_panel.detail.customer_photo") %></label>
|
||||
<div class="panel padding-10">
|
||||
<div class="menu-item-img">
|
||||
<% if f.object.image_path? %>
|
||||
<p><%= f.object.name %></p>
|
||||
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
||||
<% else %>
|
||||
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><%= t("views.right_panel.detail.select_customer_type") %></label>
|
||||
@@ -164,6 +179,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
// Read Card Reader
|
||||
$("#paypar_account_no").on('focus', function(e){
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
</div>
|
||||
</nav>
|
||||
<script type="text/javascript">
|
||||
var otherPayment = location.href.split('/')[location.href.split('/').length -1 ];
|
||||
document.getElementById("otherPayment").innerHTML = otherPayment;
|
||||
if((document.getElementById("otherPayment")!=undefined) && (document.getElementById("otherPayment")!=null) && (document.getElementById("otherPayment")!="")){
|
||||
var otherPayment = location.href.split('/')[location.href.split('/').length -1 ];
|
||||
document.getElementById("otherPayment").innerHTML = otherPayment;
|
||||
}
|
||||
</script>
|
||||
@@ -1,11 +1,27 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
||||
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<%= simple_form_for([:settings, @commissioner]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="form-inputs">
|
||||
<div class="form-group p-l-15">
|
||||
<%= f.input :name %>
|
||||
|
||||
<label>Commissioner Image</label>
|
||||
<div class="panel padding-10">
|
||||
<div class="form-group">
|
||||
<div class="menu-item-img">
|
||||
<% if f.object.image_path? %>
|
||||
<p><%= f.object.name %></p>
|
||||
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
||||
<% else %>
|
||||
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= f.label :emp_id, 'Employee' %>
|
||||
|
||||
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %>
|
||||
@@ -29,7 +45,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
<td style="width:20%"><%= t("views.right_panel.detail.name") %></td>
|
||||
<td><%= @commissioner.name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%"><%= t("views.right_panel.detail.commissioner_photo") %></td>
|
||||
<td><%= image_tag @commissioner.image_path, :size => '200x200'%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%"><%= t("views.right_panel.detail.employee") %> <%= t("views.right_panel.detail.name") %></td>
|
||||
<td><%= @commissioner.employee.name rescue '-' %></td>
|
||||
|
||||
@@ -12,6 +12,22 @@
|
||||
<%= f.input :password %>
|
||||
|
||||
</div>
|
||||
<div class="form-inputs p-l-15">
|
||||
<label>Employee Image</label>
|
||||
<div class="panel padding-10">
|
||||
<div class="form-group">
|
||||
<div class="menu-item-img">
|
||||
<% if f.object.image_path? %>
|
||||
<p><%= f.object.name %></p>
|
||||
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
||||
<% else %>
|
||||
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions p-l-15">
|
||||
<%= f.submit t('views.btn.submit'),:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
<th><%= t("views.right_panel.detail.updated_at") %></th>
|
||||
<td><%= @employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.employee_photo") %></th>
|
||||
<td><%= image_tag @employee.image_path, :size => '200x200'%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user