FTP to GIT sync
This commit is contained in:
@@ -3,11 +3,11 @@ class DeviceManager{
|
||||
public static $devices;
|
||||
|
||||
function getAllDevices () {
|
||||
return Db::loadAll ("SELECT * FROM devices");
|
||||
return Db::loadAll ("SELECT * FROM devices WHERE approved != ?", Array(2));
|
||||
}
|
||||
|
||||
function getAllDevicesInRoom ($roomId = "") {
|
||||
return Db::loadAll ("SELECT * FROM devices WHERE room_id = ?", Array($roomId));
|
||||
return Db::loadAll ("SELECT * FROM devices WHERE room_id = ? AND approved != ?", Array($roomId, 2));
|
||||
}
|
||||
|
||||
function getOtherDevices(){
|
||||
|
@@ -70,5 +70,11 @@ class RecordManager{
|
||||
Db::command ('DELETE FROM records WHERE time < ADDDATE(NOW(), INTERVAL -? DAY);', array($day));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: zkontrolovat jestli neco nezbilo po smazaní
|
||||
public static function cleanSubdeviceRecords ($subDeviceId) {
|
||||
Db::command ('DELETE FROM records WHERE subdevice_id = ?);', array($subDeviceId));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -1,55 +1,61 @@
|
||||
<?php
|
||||
class SubDeviceManager
|
||||
{
|
||||
public static $devices;
|
||||
public static $devices;
|
||||
|
||||
public function getAllSubDevices($deviceId)
|
||||
{
|
||||
return Db::loadAll("SELECT * FROM subdevices WHERE device_id = ?", array($deviceId));
|
||||
}
|
||||
public function getAllSubDevices($deviceId)
|
||||
{
|
||||
return Db::loadAll("SELECT * FROM subdevices WHERE device_id = ?", array($deviceId));
|
||||
}
|
||||
|
||||
public function getSubDeviceMaster($subDeviceId)
|
||||
{
|
||||
return Db::loadOne("SELECT * FROM devices WHERE device_id = (SELECT device_id FROM subdevices WHERE subdevice_id = ?)", array($subDeviceId));
|
||||
}
|
||||
public function getSubDeviceMaster($subDeviceId)
|
||||
{
|
||||
return Db::loadOne("SELECT * FROM devices WHERE device_id = (SELECT device_id FROM subdevices WHERE subdevice_id = ?)", array($subDeviceId));
|
||||
}
|
||||
|
||||
public function getSubDeviceByMaster($deviceId, $subDeviceType = null)
|
||||
{
|
||||
if ($subDeviceType == null) {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ?;", array($deviceId));
|
||||
} else {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ? AND type = ?;", array($deviceId, $subDeviceType));
|
||||
}
|
||||
}
|
||||
public function getSubDeviceByMaster($deviceId, $subDeviceType = null)
|
||||
{
|
||||
if ($subDeviceType == null) {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ?;", array($deviceId));
|
||||
} else {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ? AND type = ?;", array($deviceId, $subDeviceType));
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubDeviceByMasterAndType($deviceId, $subDeviceType = null)
|
||||
{
|
||||
if (!empty($subDeviceType)) {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ?;", array($deviceId));
|
||||
} else {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ? AND type = ?;", array($deviceId, $subDeviceType));
|
||||
}
|
||||
}
|
||||
public function getSubDeviceByMasterAndType($deviceId, $subDeviceType = null)
|
||||
{
|
||||
if (!empty($subDeviceType)) {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ?;", array($deviceId));
|
||||
} else {
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE device_id = ? AND type = ?;", array($deviceId, $subDeviceType));
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubDevice($subDeviceId)
|
||||
{
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE subdevice_id = ?;", array($subDeviceId));
|
||||
}
|
||||
public function getSubDevice($subDeviceId)
|
||||
{
|
||||
return Db::loadOne("SELECT * FROM subdevices WHERE subdevice_id = ?;", array($subDeviceId));
|
||||
}
|
||||
|
||||
//check if dubdevice exist
|
||||
//check if dubdevice exist
|
||||
|
||||
public function create($deviceId, $type, $unit)
|
||||
{
|
||||
$record = array(
|
||||
'device_id' => $deviceId,
|
||||
'type' => $type,
|
||||
'unit' => $unit,
|
||||
);
|
||||
try {
|
||||
Db::add('subdevices', $record);
|
||||
} catch (PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
public function create($deviceId, $type, $unit)
|
||||
{
|
||||
$record = array(
|
||||
'device_id' => $deviceId,
|
||||
'type' => $type,
|
||||
'unit' => $unit,
|
||||
);
|
||||
try {
|
||||
Db::add('subdevices', $record);
|
||||
} catch (PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($subDeviceId)
|
||||
{
|
||||
RecordManager::cleanSubdeviceRecords($subDeviceId);
|
||||
return Db::loadAll("DELETE FROM subdevices WHERE subdevice_id = ?", array($subDeviceId));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user