dashboard update

This commit is contained in:
phyusin
2018-03-23 18:06:53 +06:30
parent 3e8c3f8225
commit e0fe0ee8ab
5 changed files with 70 additions and 15 deletions

View File

@@ -68,16 +68,26 @@
<!-- Date range for dashboard -->
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.getlocal.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
<span id="fromErr" style="color:red;"></span>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.getlocal.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
<span id="toErr" style="color:red;"></span>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.from_time") %></label>
<input data-behaviour='timepicker' class="form-control timepicker" name="from_time" id="from_time" type="text" value="" placeholder="From Time" style="height: 35px;">
<span id="from_timeErr" style="color:red;"></span>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.to_time") %></label>
<input data-behaviour='timepicker' class="form-control timepicker" name="to_time" id="to_time" type="text" value="" placeholder="To time" style="height: 35px;">
<span id="to_timeErr" style="color:red;"></span>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label></label><br>
<input type="button" value="Generate" class='btn btn-primary btn_generate'>
@@ -340,21 +350,53 @@
$('.btn_generate').on('click',function(){
var from = $("#from").val();
var to = $("#to").val();
var from_time = $("#from_time").val();
var to_time = $("#to_time").val();
if(check(from,to,from_time,to_time)){
var params = '?';
if((from!='' && to!='') && (from_time!='' && to_time!='')){
params += 'from='+from+'&to='+to+'&from_time='+from_time+'&to_time='+to_time;
}else{
params += 'from='+from+'&to='+to;
}
window.location.href = '/dashboard'+params;
}
});
function check(from,to,from_time,to_time){
var status = true;
if((from=='') && (to=='')){
status = false;
$('#fromErr').html("can't be blank");
$('#toErr').html("can't be blank");
}else if((from!='') && (to=='')){
status = false;
$('#fromErr').html("");
$('#toErr').html("can't be blank");
}else if((from=='') && (to!='')){
status = false;
$('#fromErr').html("can't be blank");
$('#toErr').html("");
}else{
status = true;
$('#fromErr').html("");
$('#toErr').html("");
}
if((from!='') && (to!='')){
window.location.href = '/dashboard?from='+from+'&to='+to;
if(((from_time=='') && (to_time=='')) || ((from_time!='') && (to_time!=''))){
status = true;
$('#from_timeErr').html("");
$('#to_timeErr').html("");
}else if((from_time!='') && (to_time=='')){
status = false;
$('#from_timeErr').html("");
$('#to_timeErr').html("can't be blank");
}else if((from_time=='') && (to_time!='')){
status = false;
$('#from_timeErr').html("can't be blank");
$('#to_timeErr').html("");
}
});
return status;
}
</script>