CC-3285 : show over booked error message
checking if percentage is over 100.
This commit is contained in:
parent
1080bf692f
commit
c23491b257
3 changed files with 89 additions and 23 deletions
|
@ -58,21 +58,19 @@ class Application_Model_ShowInstance {
|
||||||
/**
|
/**
|
||||||
* Return the start time of the Show (UTC time)
|
* Return the start time of the Show (UTC time)
|
||||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||||
* TODO: make this function return a DateTime object instead.
|
|
||||||
*/
|
*/
|
||||||
public function getShowInstanceStart()
|
public function getShowInstanceStart($format="Y-m-d H:i:s")
|
||||||
{
|
{
|
||||||
return $this->_showInstance->getDbStarts();
|
return $this->_showInstance->getDbStarts($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the end time of the Show (UTC time)
|
* Return the end time of the Show (UTC time)
|
||||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||||
* TODO: make this function return a DateTime object instead.
|
|
||||||
*/
|
*/
|
||||||
public function getShowInstanceEnd()
|
public function getShowInstanceEnd($format="Y-m-d H:i:s")
|
||||||
{
|
{
|
||||||
return $this->_showInstance->getDbEnds();
|
return $this->_showInstance->getDbEnds($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStartDate()
|
public function getStartDate()
|
||||||
|
@ -607,20 +605,26 @@ class Application_Model_ShowInstance {
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTimeScheduledSecs()
|
||||||
|
{
|
||||||
|
$time_filled = $this->getTimeScheduled();
|
||||||
|
return Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDurationSecs()
|
||||||
|
{
|
||||||
|
$ends = $this->getShowInstanceEnd(null);
|
||||||
|
$starts = $this->getShowInstanceStart(null);
|
||||||
|
return $ends->format('U') - $starts->format('U');
|
||||||
|
}
|
||||||
|
|
||||||
public function getPercentScheduled()
|
public function getPercentScheduled()
|
||||||
{
|
{
|
||||||
$start_timestamp = $this->getShowInstanceStart();
|
$durationSeconds = $this->getDurationSecs();
|
||||||
$end_timestamp = $this->getShowInstanceEnd();
|
$timeSeconds = $this->getTimeScheduledSecs();
|
||||||
$time_filled = $this->getTimeScheduled();
|
|
||||||
|
|
||||||
$s_epoch = strtotime($start_timestamp);
|
$percent = ceil(($timeSeconds / $durationSeconds) * 100);
|
||||||
$e_epoch = strtotime($end_timestamp);
|
|
||||||
$i_epoch = Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
|
||||||
|
|
||||||
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
|
|
||||||
|
|
||||||
if ($percent > 100)
|
|
||||||
$percent = 100;
|
|
||||||
|
|
||||||
return $percent;
|
return $percent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,67 @@ class CcShowInstances extends BaseCcShowInstances {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [starts] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw DateTime object will be returned.
|
||||||
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getDbStarts($format = 'Y-m-d H:i:s')
|
||||||
|
{
|
||||||
|
if ($this->starts === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($this->starts, new DateTimeZone("UTC"));
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($format === null) {
|
||||||
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||||
|
return $dt;
|
||||||
|
} elseif (strpos($format, '%') !== false) {
|
||||||
|
return strftime($format, $dt->format('U'));
|
||||||
|
} else {
|
||||||
|
return $dt->format($format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [ends] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw DateTime object will be returned.
|
||||||
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getDbEnds($format = 'Y-m-d H:i:s')
|
||||||
|
{
|
||||||
|
if ($this->ends === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($this->ends, new DateTimeZone("UTC"));
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($format === null) {
|
||||||
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||||
|
return $dt;
|
||||||
|
} elseif (strpos($format, '%') !== false) {
|
||||||
|
return strftime($format, $dt->format('U'));
|
||||||
|
} else {
|
||||||
|
return $dt->format($format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // CcShowInstances
|
} // CcShowInstances
|
||||||
|
|
|
@ -11,11 +11,10 @@ function closeDialog(event, ui) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkShowLength() {
|
function checkShowLength(json) {
|
||||||
var showFilled = $("#show_time_filled").text().split('.')[0];
|
var percent = json.percentFilled;
|
||||||
var showLength = $("#show_length").text();
|
|
||||||
|
|
||||||
if (showFilled > showLength){
|
if (percent > 100){
|
||||||
$("#show_time_warning")
|
$("#show_time_warning")
|
||||||
.text("Shows longer than their scheduled time will be cut off by a following show.")
|
.text("Shows longer than their scheduled time will be cut off by a following show.")
|
||||||
.show();
|
.show();
|
||||||
|
@ -41,7 +40,7 @@ function setScheduleDialogHtml(json) {
|
||||||
$("#show_time_filled").empty().append(json.timeFilled);
|
$("#show_time_filled").empty().append(json.timeFilled);
|
||||||
$("#show_progressbar").progressbar( "value" , json.percentFilled );
|
$("#show_progressbar").progressbar( "value" , json.percentFilled );
|
||||||
|
|
||||||
checkShowLength();
|
checkShowLength(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setScheduleDialogEvents(dialog) {
|
function setScheduleDialogEvents(dialog) {
|
||||||
|
@ -298,7 +297,7 @@ function buildScheduleDialog(json){
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
checkShowLength();
|
checkShowLength(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue