Merge branch 'ui_ux_changes' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes

This commit is contained in:
phyusin
2018-04-05 15:24:17 +06:30
5 changed files with 270 additions and 83 deletions

View File

@@ -56,19 +56,19 @@ class Origami::MovetableController < BaseOrigamiController
end
end
def moving
change_to = params[:change_to] #new
change_from = params[:change_from] #original
bookings = Booking.where('dining_facility_id=?',change_from)
def moving
change_to = params[:change_to] #new
change_from = params[:change_from] #original
bookings = Booking.where('dining_facility_id=?',change_from)
booking_array = Array.new
bookings.each do | booking |
if booking.sale_id.nil? && booking.booking_status != 'moved'
booking_array.push(booking)
end
end
booking_array = Array.new
bookings.each do | booking |
if booking.sale_id.nil? && booking.booking_status != 'moved'
booking_array.push(booking)
end
end
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
# get printer info
@from = (DiningFacility.find(change_from)).name
@@ -78,9 +78,16 @@ class Origami::MovetableController < BaseOrigamiController
@date = DateTime.now
@shop = Shop::ShopDetail
unique_code = "MoveTablePdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by)
end
pdf_no = PrintSetting.where(:unique_code => unique_code).count
#print_settings = PrintSetting.find_by_unique_code(unique_code)
printer_array = []
printer_array = PrintSetting.where(:unique_code => unique_code)
for i in 0..pdf_no
if i != pdf_no
print_settings = printer_array[i]
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by)
end
end
end
end

View File

@@ -6,73 +6,122 @@
<%= f.error_notification %>
<div class="form-inputs p-l-10">
<% if !@survey_data.nil? %>
<%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%>
<%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%>
<%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10' }%>
<%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10' }%>
<%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-10'} %>
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-10' }%>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
<%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
<%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10' }%>
</div>
</div>
</div>
<%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-11'} %>
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11' }%>
<!--<fieldset style="border: 1px solid #BDBDBD;padding: 20px; width: 92%;margin: 20px 0 20px 0;"> -->
<!-- <legend style="font-size: 1.2em !important;font-weight: bold !important;text-align: left !important;border:none;width:100px;">Foreigner</legend> -->
<fieldset class="form-group">
<label class="bmd-label-static">Foreigner Lists</label>
<div class="row clearfix foreignerDiv">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
<div class="hidden" id="newTemplate" >
</div>
</fieldset>
<% else %>
<%= f.input :child , input_html: { class: 'col-md-10' }%>
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
<%= f.input :male , input_html: { class: 'col-md-10' }%>
<%= f.input :female , input_html: { class: 'col-md-10' }%>
<%= f.input :total_customer, input_html: { class: 'col-md-10'} %>
<%= f.input :local , input_html: { class: 'col-md-10' }%>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
<%= f.input :child , input_html: { class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
<% end %>
<div class="hidden" id="newTemplate" >
</div>
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<%= f.input :male , input_html: { class: 'col-md-10' }%>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
<div class="form-group p-l-10 p-r-10">
<%= f.input :female , input_html: { class: 'col-md-10' }%>
</div>
</div>
</div>
<%= f.input :total_customer, input_html: { class: 'col-md-11'} %>
<%= f.input :local , input_html: { class: 'col-md-11' }%>
</div>
<fieldset style="border: 1px solid #BDBDBD;padding: 20px; width: 92%;margin: 20px 0 20px 0;">
<legend style="font-size: 1.2em !important;font-weight: bold !important;text-align: left !important;border:none;width:100px;">Foreigner</legend>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
<div class="hidden" id="newTemplate" >
</div>
</fieldset>
<% end %>
<%if !@dining_facility.nil? %>
<input type="hidden" name="table_id" id="table_id" value="<%= @dining_facility.id %>">
<input type="hidden" name="table_type" id="table_type" value="<%= @table_type %>">
@@ -95,8 +144,8 @@
<%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %>
<%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %>
<%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %>
</div>
<div class="form-actions">
</div>
<div class="form-actions form-inputs p-l-10">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div>
<% end %>
@@ -196,13 +245,17 @@
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
$('.foreignerDiv').removeClass("hidden");
setHeaderBreadCrumb(_SURVEY_);
<% if !@survey_data.nil? %>
addSurveyForeignerLists(<%= @survey_data.foreigner.to_json.html_safe %>);
<% end %>
//click add button for new row
$('#addForeigner').on('click',function(){
$('#newTemplate').removeClass('hidden');
var text_box = '<div id="newRow" class="row clearfix">'
+'<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >'
@@ -213,7 +266,35 @@ var cashier_type = "<%= @cashier_type %>";
+'</select>'
+'</div>'
+'</div>'
+'<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+'<input type="number" name="survey[foreigner][]" class="form-control">'
+'</div>'
+'</div>'
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
+'<button type="button" class="btn btn-danger" id="removeRow">Remove</button>'
+'</div>'
+'</div>';
$('#newTemplate').append(text_box);
});
//click add button for new row
$('#newTemplate').on('click','#addForeigner',function(){
$('#newTemplate').removeClass('hidden');
var text_box = '<div id="newRow" class="row clearfix">'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
+'<option value="<%= ct.value %>">'
+'<%= ct.name %></option>'
+'<%end %>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+'<input type="number" name="survey[foreigner][]" class="form-control">'
+'</div>'
@@ -292,4 +373,84 @@ var cashier_type = "<%= @cashier_type %>";
});
});
function addSurveyForeignerLists(foreigner_lists){
if((foreigner_lists != undefined) && (foreigner_lists != null) && (foreigner_lists != "")){
$('.foreignerDiv').remove();
$('#newTemplate').removeClass('hidden');
foreigner_lists = foreigner_lists.substring(1, (foreigner_lists.length - 1)).replace(new RegExp('"', "g"),'').split(",");
var arr_foreigner = {};
$.each(foreigner_lists,function(key,value){
if(!value.match(/^[0-9]+$/)){
arr_foreigner[value] = 0;
}else{
$.each(arr_foreigner,function(k,val){
if(arr_foreigner[k] == 0){
arr_foreigner[k] = value;
}
});
}
});
// console.log(foreigner_lists);
// console.log(arr_foreigner);
$.each(arr_foreigner, function(key,value){
if(Object.keys(arr_foreigner)[0] == key){
var fgn_template = '<div id="newRow" class="row clearfix">'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
// if (key.toString() == '<%= ct.value.to_s %>')
// var selected = "selected";
// else
// var selected = "";
+'<option value="<%= ct.value %>">'
+'<%= ct.name %></option>'
+'<%end %>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+'<input type="number" name="survey[foreigner][]" class="form-control" value="'+value+'">'
+'</div>'
+'</div>'
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
+'<button type="button" class="btn btn-success" id="addForeigner">Add</button>'
+'</div>'
+'</div>';
}else{
var fgn_template = '<div id="newRow" class="row clearfix">'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
// if (key.toString() == '<%= ct.value.to_s %>')
// var selected = "selected";
// else
// var selected = "";
+'<option value="<%= ct.value %>">'
+'<%= ct.name %></option>'
+'<%end %>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
+'<div class="form-group p-l-10 p-r-10">'
+'<input type="number" name="survey[foreigner][]" class="form-control" value="'+value+'">'
+'</div>'
+'</div>'
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
+'<button type="button" class="btn btn-danger" id="removeRow">Remove</button>'
+'</div>'
+'</div>';
}
$('#newTemplate').append(fgn_template);
});
}
}
</script>

View File

@@ -27,15 +27,29 @@
<tbody>
<% @employees.each do |employee| %>
<tr>
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
<td><%= employee.role %></td>
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td>
<%= link_to t("views.btn.edit"), edit_settings_employee_path(employee),:class => 'btn btn-info btn-sm waves-effect' %>
</td>
</tr>
<% if current_login_employee.role == "administrator" %>
<tr>
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
<td><%= employee.role %></td>
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td>
<%= link_to t("views.btn.edit"), edit_settings_employee_path(employee),:class => 'btn btn-info btn-sm waves-effect' %>
</td>
</tr>
<% else %>
<% if employee.role != "administrator" %>
<tr>
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
<td><%= employee.role %></td>
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td>
<%= link_to t("views.btn.edit"), edit_settings_employee_path(employee),:class => 'btn btn-info btn-sm waves-effect' %>
</td>
</tr>
<% end %>
<% end %>
<% end %>
</tbody>
</table>

View File

@@ -56,6 +56,7 @@
<% total_female = 0 %>
<% total_local = 0 %>
<% total_customer = 0 %>
<% total_foreigner = 0 %>
<% if !@surveys.nil? %>
<% @surveys.each do |survey| %>
<% total_child = total_child.to_i + survey.child.to_i %>
@@ -80,8 +81,11 @@
<% foreigner_lists = foreign.split(",") %>
<% if !foreigner_lists.empty? %>
<% foreigner_lists.each do |fgn| %>
<% unless fgn.match(/[^[:digit:]]+/)
total_foreigner = total_foreigner.to_i + fgn.to_i
end %>
<% if !fgn.scan(/\D/).empty? %>
<%= fgn %> :<% end %> <%= fgn.to_i unless fgn.match(/[^[:digit:]]+/) %><br>
<%= fgn %> :<% end %> <%= fgn.to_i unless fgn.match(/[^[:digit:]]+/) %><br>
<% end %>
<% end %>
<% end %>
@@ -97,7 +101,8 @@
<td><strong><%= total_male %></strong></td>
<td><strong><%= total_female %></strong></td>
<td><strong><%= total_customer %></strong></td>
<td colspan="2"><strong><%= total_local %></strong></td>
<td><strong><%= total_local %></strong></td>
<td><strong><%= total_foreigner %></strong></td>
</tr>
</tbody>
</table>

View File

@@ -12,7 +12,7 @@ class ActionController::Base
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
else8
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"