I am writing a booking system for rental of counts of revenue in the rail. As the owner of the resource, Together, wants to see the total amount of resources.
Mem is a good option for the calendar, except that I fail to find a way to show this percentage by time. Suppose the total resource is 100:
- 20 units from 12-January-2013 to 20 February 2013
- From 15-January-2013 Client-B books till 1-March-2013 30 units
I want to see the booked capacity
- 12-January-2013 to 14-January-2013 = 20% (Booking with client-A )
- By 30th January 2013 - 20th February 2013 = 50% (20
- From February 21, 2013 to March 1, 2013 = 30% (Booking from Client-B only
Gradually, I collected these gems
- Mani 'incident Mani 'table_builder'
- Mani 'watu_table_builder'
- Mani 'calendar_date_select'
Below Code famous lesson Lascate # 213.
index_calendar.html.erb
& lt;% = @ date.prev_month.strftime ("% B% Y ")% & gt; & lt;% = calendar_for (@budgetings, year = & gt; @ date.year, month = & date; date.prev_month.month) do this; calendar | & gt; ; & Lt;% = calendar.head ('Sun', 'Mon', 'Mars', 'Mercury', 'Thor', 'Venus', 'Saturn')% & gt; & lt;% calendar.day : Day_method = & gt ;: from_date). Date, booking & Gt%; & Lt;% = date.day% & gt; & Lt; Ul & gt; & Lt;% for reservation in booking% & gt; & Lt; Li & gt; & Lt;% = link_to h (bookingcampetti), booking% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt;% end% & gt; & Lt;% end% & gt;
is optional:
& lt; Li & gt; & Lt;% = LINK_TO hour (booking.total_capacity (date)), booking% & gt; & Lt; / Li & gt;
I have tried to combine it with booking.rb two methods:
It shows that the book From the percentage of units received-)
def capacity @ a = Resource.find_by_id (self.resource_id) .units [(self.units/@a*100) .to_s + "%"] .
This shows total bookings only from ~ to_date
DRF total_package (day) @ wall = booking.jux (: Resources). In the <{code}
booking model ("# {day}" and "time and time" :
- :
- :
- :
- :
- :
Resource Model <
- : Units
Thanks, Nick
booking_days / index_calendar.html .rb
The booking_days_controller.rb
def was backed up with index_calendar @date = params [: month]? Date.strptime (parameter [months], "% Y-% m"): dend=@date.next_month.end_of_month rid = Resource.find_by_user_id Date.today dstart=@date.prev_month.beginning_of_month (session [: user_id]) .id sql = ["Select @row: = @row + 1 as the id, select ts.dat as the day, sum (from bookings.value) as the value" + "(choose the adapter ('# { Dstart} ', Numl000ki) as Dat "+" num1000 where adddate (' # {dstart} ', num1000.i) & lt; =' ts as # {dend} '), resource, " + "select booking JOIN (@row: = 0) R" + "where bookings.resources_id = resources.id and resources.id = # {rid} and adddate (bookings.from_time, -1) & lt; = ts .dat and ts.dat & lt; = bookings.till_time group Ts.dat "].] @booking_days Join = BookingDay.find_by_sql (sql) response_to do | Format | Format.html # index_calendar.html.erb format.json {render json: @booking_days} End End
Booking_days "On-Fly" has been created and is not stored in DB.
The structure of Booking_day is {: id,: value ,: day}.
The booking object is stored in DB and this structure is the basis of all the information shown in the calendar through the booking_day object: {_the_time ,: to_time ,: from_time ,: source_id ,: value_} .
Number1000 = 0 ... 999
nick
No comments:
Post a Comment