Good day!
Is it possible to set max value of daterangepicker base on datefrom?.
What I want to accomplish is that when I select date_from, the max date value of date_to will be base from date_from + 9hours.
This is the library I use: https://www.daterangepicker.com/
This is the initial config:
// set reservation schedule
var max_duration = {{ $max_duration->value }};
var start = #if(Auth::user()->isAdmin()) moment() #else moment().add(3,'days') #endif;
var end = #if(Auth::user()->isAdmin()) moment().add(max_duration, 'hours') #else moment().add(3,'days').add(max_duration, 'hours') #endif;
$('#date_range').daterangepicker({
startDate: start,
endDate: end,
minDate: start,
applyButtonClasses: "btn-info",
cancelClass: "btn-danger",
alwaysShowCalendars: true,
timePicker: true,
"timePickerIncrement": 15,
}, reservation_schedule);
reservation_schedule(start, end);
function reservation_schedule(start, end) {
$('#date_range h6').html('<i class="fa fa-calendar-days"></i> ' + start.format('MMM D, YYYY hh:mm a') + ' - ' + end.format('MMM D, YYYY hh:mm a') + '<i class="fa fa-caret-down float-right"></i>');
$('#reservation_schedule').val(start.format('YYYY-MM-DD hh:mm a') + ' - ' + end.format('YYYY-MM-DD hh:mm a'));
}
Thanks in advance.
Related
I want to change the colour of the grouped row in a datatable. I just can't seem to get it to work the way I would like and I'm unsure how to get it too. I have done a drawback and get this to work in the group header but for the life of me I can't get it to work in the grouped row footer.
rowGroup: {
/// Group Header Colour
//startRender: null, SET TO NULL IF GROUP HEADER NOT REQUIRED
startRender: function(rows, group) {
// colour the group header and uncomment to show
// return $('<tr class="group group-start"><td class="' + (group == '1' ? 'green' : (group == '0' ? 'green' : 'green')) + '" colspan="9">' + group + ' ' + ' ('+rows.count() + '</td></tr>');
},
// Below used for Grouping and summing at end of each dept in this case
endRender: function ( rows, group ) {
var filteredData = $('#giftcards').DataTable()
.rows()
.data()
.filter( function ( data, index ) {
return data[groupColumn] == group ? true : false;
} )
.pluck(6) // the column we are counting in this case retail value per dept
.sum();
//return 'Dept: <tr class="rowgroup"><td colspan="9">' + group + '('+ rows.count() + ' rows on page , £' + roundTo(filteredData,2) + 'Retail Sale value for all pages)'; /// Needs multiplied by PD.TotalShelfstockQuantity
return 'Dept: <tr class="group group-start"><td class="' + (group == '1' ? 'green' : (group == '0' ? 'green' : 'green')) + '" colspan="11">' + group + ' ' + '('+ rows.count() +')'
+ ' rows on page , <larger>£ </larger>' + roundTo(filteredData,2) + ' Retail Sale value for all pages)' + '</td></tr>'; /// Needs multiplied by PD.TotalShelfstockQuantity
// $(row).css("background-color", "green");
},
dataSrc: groupColumn,
//backgroundColor = styleEqual('Dept','red')
},`
```
THE BELOW PIECE OF CODE SEEMS TO BE ALMOST THERE - HOWEVER, IT IS ONLY SHOWING IN A FEW COLUMNS - I am not a programmer by the way.
```
return 'Dept: <tr class="group group-start"><td class="' + (group == '1' ? 'green' : (group == '0' ? 'green' : 'green')) + '" colspan="11">' + group + ' ' + '('+ rows.count() +')'
+ ' rows on page , <larger>£ </larger>' + roundTo(filteredData,2) + ' Retail Sale value for all pages)' + '</td></tr>';
```
Thanks in advance. Below is the status as is at minute. I would like the green to populate the entire row.
[![enter image description here](https://i.stack.imgur.com/P46Rz.png)](https://i.stack.imgur.com/P46Rz.png)
I have tried various solutions that were on this forum but I am missing something. I know that' I'm close but no cigar.
I´m using odoo8 and want to create an option group by hour,
I know that I should not mess with core odoo code but it is just add to lines (I hope so), I check an "pivot by hour" module V10 and there are added the same two lines.
in addons\point_of_sale\report\pos_order_report_view.xml I added:
<filter string="Order Hour" context="{'group_by':'date:hour'}" help="Hour of order date"/>
and in server\openerp\modules.py in _read_group_process_groupby() method I added two lines:
def _read_group_process_groupby(self, gb, query, context):
split = gb.split(':')
field_type = self._fields[split[0]].type
gb_function = split[1] if len(split) == 2 else None
temporal = field_type in ('date', 'datetime')
tz_convert = field_type == 'datetime' and context.get('tz') in pytz.all_timezones
qualified_field = self._inherits_join_calc(self._table, split[0], query)
if temporal:
display_formats = {
'hour': 'HH:mm dd MMM yyyy', ###### added by me
'day': 'dd MMM yyyy',
'week': "'W'w YYYY",
'month': 'MMMM yyyy',
'quarter': 'QQQ yyyy',
'year': 'yyyy',
}
time_intervals = {
'hour': dateutil.relativedelta.relativedelta(hours=1), ###### added by me
'day': dateutil.relativedelta.relativedelta(days=1),
'week': datetime.timedelta(days=7),
'month': dateutil.relativedelta.relativedelta(months=1),
'quarter': dateutil.relativedelta.relativedelta(months=3),
'year': dateutil.relativedelta.relativedelta(years=1)
}
if tz_convert:
qualified_field = "timezone('%s', timezone('UTC',%s))" % (context.get('tz', 'UTC'),
qualified_field)
qualified_field = "date_trunc('%s', %s)" % (gb_function or 'month', qualified_field)
if field_type == 'boolean':
qualified_field = "coalesce(%s,false)" % qualified_field
return {
'field': split[0],
'groupby': gb,
'type': field_type,
'display_format': display_formats[gb_function or 'month'] if temporal else None,
'interval': time_intervals[gb_function or 'month'] if temporal else None,
'tz_convert': tz_convert,
'qualified_field': qualified_field
}
the whole traceback is the following:
Make sure that the types you pass to value are the same as the types you indexed on.
You pass the value that is the 'datetime.date' and this Return date object with the same year, month and day. Click Here
You can change it with to datetime.time()
Thanks
In models.py (with path: server/openerp) in _read_group_format_result method
.format_date(
need to be changed to
.format_datetime(
I am using Xamarin Prism along with Sqlite-pcl-net Nuget .
While I write Query to obtain the elements of table between a range of dates as follows
public Task<List<JournalModel>> GetRecieptListAsync(DateTime startdate,DateTime enddate)
{
return database.QueryAsync<JournalModel>("SELECT * FROM [JournalModel] WHERE ( [PromisedDate] BETWEEN " + startdate + " AND " + enddate + ")");
}
StartD and EndD are variables of DateTime Datatype of Format:
StartD MM/dd/yyyy 00:00:00
EndD MM/dd/yyyy 23:59:59
After executing this Query I get a
SQLite.SQLiteException: near "12": syntax error
Which means at the hour of StartD. I hope You know it takes 12:00:00Am at StartD in the Database. Comment if I have to make more clearifications.
In SQLite-pcl-net the default format for Datetime is Ticks.
You can change startdate to startdate.Ticks and enddate to enddate.Ticks.
return database.QueryAsync<JournalModel>("SELECT * FROM [JournalModel] WHERE ( [PromisedDate] BETWEEN " + startdate.Ticks + " AND " + enddate.Ticks + ")");
I want to check if a date is greater than a specified date using VBScript in Classic ASP.
The same thing i got working in the following :
Check if a date is greater than specified date
but the above is using javascript.
I did it using JavaScript as :
var Jun16 = new Date('JUN-2016')
var SelectedDate=new Date("<% =session("month")%>" + "-" + "<% =session("yrs")%>")
if(SelectedDate.getTime() > Jun16.getTime())
{
grossinc=parseInt("<% =rset1("othermontize_benefit") %>") + parseInt("<% =rset1("basic") %>") + parseInt("<% =rset1("house") %>") + parseInt("<% =rset1("utility") %>")
}
else
{
grossinc=parseInt("<% =rset1("gross") %>") + parseInt("<% =rset1("bonus") %>") + parseInt("<% =rset1("arrears") %>") + parseInt("<% =rset1("ot") %>")
}
How can I get the same in vb in classic asp.
EDIT :
the data which is to be compared is in MON AND YYYY format , there is no such any date , month is selected from months dropdown in MON Format and year is selected from years dropdown in yyyy format , now i want to check if the selected criteria is greater than JUN-2016 ?
Thanks.
Something like this should work for you:
jun16 = CDate("Jun-2016") ' jun16 = 01/06/2016 00:00:00
selectedDate = CDate(Session("month") & "-" & Session("year"))
If selectedDate > jun16 Then
Response.Write("Geater")
Else
Response.Write("Less than or equal to")
End If
I have a database table
TABLE subject_loads
id (int)
subject_name (varchar)
time_start (time)
time_end (time)
time_diff (decimal)
When I save it on database, it will first check whether the time is not conflicting from the other time already inputed. If it's okay, then compute the time_start and time_end to give me a difference between the two.
Example, 7:30 AM - 8:30 AM is already in database, when i input 8:00 AM - 9:00 AM it will say "conflicting with the other time". Only I can input before 7:30 AM or after 8:30 AM that doesn't overlap from 7:30 AM - 8:30 AM.
Can someone help on how to do this?
First you need to check if overlapping values (compared to new value) already exist. You will do that with:
$query = $this->db->get_where('subject_loads', array('time_start >= ' => $time_start, 'time_end <= ' => $time_end));
if((int)$query->num_rows() > 0)
{
//similar values exist
}
else
{
//you are free to insert values
}
Second part of issue:
$hm1 = "2:12 AM";
$hm2 = "4:41 PM";
$e = conv($hm2) - conv($hm1);
echo $e;
function conv($time)
{
$expl_time = explode(' ', $time);
$t = explode(":", $expl_time[0]);
if ($expl_time[1] == 'PM' || $expl_time[1] == 'pm')
{
$t[0] += 12;
}
return ($t[0] + round($t[1]/60, 1, PHP_ROUND_HALF_UP));
}