CC-2289:differentiate-between-time-and-duration
- some change in date populating rules - change on start date/time triggers change in end date/time - change on end date/time will triggers background turning into red color to notify user that end date/time is earlier than start date/time. - need to do more work once I get img file from Vladmir
This commit is contained in:
parent
1dabbacca2
commit
6a15f51aac
4 changed files with 127 additions and 4 deletions
|
@ -104,6 +104,9 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
}elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 23) {
|
||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration > 24h'));
|
||||
$valid = false;
|
||||
}elseif( strstr($formData["add_show_duration"], '-') ){
|
||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
return $valid;
|
||||
|
|
|
@ -28,7 +28,30 @@ class Application_Model_Nowplaying
|
|||
//format duration
|
||||
$duration = explode('.', $dbRow['clip_length']);
|
||||
$duration = explode(':', $duration[0]);
|
||||
$duration = $duration[0].'h'.$duration[1].'m'.$duration[2].'s';
|
||||
|
||||
if($duration[2] == 0){
|
||||
$duration[2] = '';
|
||||
}else{
|
||||
$duration[2] = intval($duration[2],10).'s';
|
||||
}
|
||||
|
||||
if($duration[1] == 0){
|
||||
if($duration[2] == ''){
|
||||
$duration[1] = '';
|
||||
}else{
|
||||
$duration[1] = intval($duration[1],10).'m';
|
||||
}
|
||||
}else{
|
||||
$duration[1] = intval($duration[1],10).'m';
|
||||
}
|
||||
|
||||
if($duration[0] == 0){
|
||||
$duration[0] = '';
|
||||
}else{
|
||||
$duration[0] = intval($duration[0],10).'h';
|
||||
}
|
||||
|
||||
$duration = $duration[0].$duration[1].$duration[2];
|
||||
|
||||
$dataTablesRows[] = array($type, $dbRow['show_starts'], $itemStart[0], $itemEnd[0],
|
||||
$duration, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
|
||||
|
|
|
@ -114,9 +114,15 @@ label.wrapp-label input[type="checkbox"] {
|
|||
|
||||
#add_show_start_time {
|
||||
float: left;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#add_show_end_time, #add_show_end_date_no_repeat, #add_show_start_date {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#add_show_duration {
|
||||
background: #AAAAAA;
|
||||
cursor: default;
|
||||
width: 100px;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ function endDpSelect(dateText, inst) {
|
|||
time = dateText.split("-");
|
||||
date = new Date(time[0], time[1] - 1, time[2]);
|
||||
|
||||
$("#add_show_start_date").datepicker( "option", "maxDate", date);
|
||||
//$("#add_show_start_date").datepicker( "option", "maxDate", date);
|
||||
if (inst.input)
|
||||
inst.input.trigger('change');
|
||||
}
|
||||
|
@ -318,14 +318,70 @@ function setAddShowEvents() {
|
|||
});
|
||||
});
|
||||
|
||||
// auto puplate end date and time
|
||||
$('#add_show_start_time, #add_show_start_date, #add_show_end_date_no_repeat, #add_show_end_time').change(function(){
|
||||
// when start date/time changes, set end date/time to start date/time+1 hr
|
||||
$('#add_show_start_date, #add_show_start_time').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000));
|
||||
}
|
||||
|
||||
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
||||
var endTimeFormat = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
|
||||
|
||||
$('#add_show_end_date_no_repeat').val(endDateFormat);
|
||||
$('#add_show_end_time').val(endTimeFormat);
|
||||
|
||||
// calculate duration
|
||||
calculateDuration(endDateTime, startDateTime);
|
||||
});
|
||||
|
||||
// when end date/time changes, check if the changed date is in past of start date/time
|
||||
$('#add_show_end_date_no_repeat, #add_show_end_time').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
$('#add_show_end_date_no_repeat').css('background', '#F49C9C');
|
||||
$('#add_show_end_time').css('background', '#F49C9C');
|
||||
}else{
|
||||
$('#add_show_end_date_no_repeat').css('background', '');
|
||||
$('#add_show_end_time').css('background', '');
|
||||
}
|
||||
|
||||
// calculate duration
|
||||
calculateDuration(endDateTime, startDateTime);
|
||||
});
|
||||
// auto puplate end date and time
|
||||
/*$('#add_show_start_date, #add_show_end_time_no_repeat').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]);
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]);
|
||||
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
if($(this) == $('#add_show_start_date')){
|
||||
var endDateTemp = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
||||
$('#add_show_end_date_no_repeat').val(endDateTemp);
|
||||
}else{
|
||||
var startDateTemp = startDateTime.getFullYear() + '-' + pad(startDateTime.getMonth()+1,2) + '-' + pad(startDateTime.getDate(),2);
|
||||
$('#add_show_end_date_no_repeat').val(startDateTemp);
|
||||
}
|
||||
}
|
||||
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
|
||||
// if changed start time is greater than end, set end time to start time + 1 hour
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000));
|
||||
|
@ -339,7 +395,42 @@ function setAddShowEvents() {
|
|||
|
||||
// calculate duration
|
||||
calculateDuration(endDateTime, startDateTime)
|
||||
|
||||
})
|
||||
$('#add_show_start_time, #add_show_end_time').change(function(){
|
||||
var startDate = $('#add_show_start_date').val().split('-');
|
||||
var startDateTime = new Date(startDate[1]+' '+startDate[2]+','+startDate[0]+' '+$('#add_show_start_time').val());
|
||||
|
||||
var endDate = $('#add_show_end_date_no_repeat').val().split('-');
|
||||
var endDateTime = new Date(endDate[1]+' '+endDate[2]+','+endDate[0]+' '+$('#add_show_end_time').val());
|
||||
|
||||
if($(this) == $('#add_show_start_time')){
|
||||
// if changed start time is greater than end, set end time to start time + 1 hour
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000));
|
||||
}
|
||||
|
||||
var endDate = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
||||
var endTime = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
|
||||
|
||||
$('#add_show_end_date_no_repeat').val(endDate);
|
||||
$('#add_show_end_time').val(endTime);
|
||||
}else{
|
||||
// if changed start time is greater than end, set end time to start time + 1 hour
|
||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000));
|
||||
}
|
||||
|
||||
var endDate = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
||||
var endTime = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
|
||||
|
||||
$('#add_show_end_date_no_repeat').val(endDate);
|
||||
$('#add_show_end_time').val(endTime);
|
||||
}
|
||||
|
||||
// calculate duration
|
||||
calculateDuration(endDateTime, startDateTime)
|
||||
})*/
|
||||
|
||||
function calculateDuration(endDateTime, startDateTime){
|
||||
var duration;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue