Skip to content
Snippets Groups Projects
Commit 8cdc8fdc authored by pbarroca's avatar pbarroca
Browse files

Multimédia: refacto et correction détection des réservations en cours sur un poste

parent e6d51160
Branches
Tags
No related merge requests found
......@@ -84,13 +84,8 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
* @return int
*/
public function numberOfHoldBetweenTimes($start, $end) {
return Class_Multimedia_DeviceHold::getLoader()->countBy(array(
'role' => 'device',
'model' => $this,
'where' => '(start < ' . $start . ' and end > ' . $end . ')'
. ' or (start > ' . $start . ' and end < ' . $end . ')'
. ' or (start < ' . $end . ' and end > ' . $end . ')'
. ' or (start < ' . $start . ' and end > ' . $start . ')'));
return Class_Multimedia_DeviceHold::getLoader()
->countBetweenTimesForDevice($start, $end, $this);
}
......
......@@ -47,6 +47,23 @@ class Multimedia_DeviceHoldloader extends Storm_Model_Loader {
->where('start > ' . time())
->order('start asc'));
}
/**
* @param $start int
* @param $end int
* @param $device Class_Multimedia_Device
* @return int
*/
public function countBetweenTimesForDevice($start, $end, $device) {
return $this->countBy(array(
'role' => 'device',
'model' => $device,
'where' => '(start <= ' . $start . ' and end >= ' . $end . ')'
. ' or (start > ' . $start . ' and end < ' . $end . ')'
. ' or (start < ' . $end . ' and end > ' . $end . ')'
. ' or (start < ' . $start . ' and end > ' . $start . ')'));
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment