예제 #1
0
    function getTriggerElems($id_trigger)
    {
        $link = Link::get_link('domoleaf');
        $red = 0;
        $green = 0;
        $blue = 0;
        $id_condition = 0;
        $sql = 'SELECT id_condition,
				       trigger_events_conditions.room_device_id AS room_device_id,
				       optiondef.option_id,
				       value,
				       room_device.name AS device_name,
				       room_device.device_id AS device_id,
				       if(optiondef.name' . $this->getLanguage() . ' = "", optiondef.name, optiondef.name' . $this->getLanguage() . ') AS option_name,
				       operator
				FROM trigger_events_conditions
				JOIN room_device ON room_device.room_device_id = trigger_events_conditions.room_device_id
				JOIN optiondef ON optiondef.option_id = trigger_events_conditions.id_option
				WHERE id_trigger=:trigger_id
				ORDER BY id_condition';
        $req = $link->prepare($sql);
        $req->bindValue(':trigger_id', $id_trigger, PDO::PARAM_INT);
        $req->execute() or die(error_log(serialize($req->errorInfo())));
        $list = '';
        while ($do = $req->fetch(PDO::FETCH_OBJ)) {
            $list[$do->id_condition] = array('trigger_id' => $id_trigger, 'condition_id' => $do->id_condition, 'room_device_id' => $do->room_device_id, 'option_id' => $do->option_id, 'option_value' => $do->value, 'device_name' => $do->device_name, 'device_id' => $do->device_id, 'option_name' => $do->option_name, 'operator' => $do->operator);
            if ($do->option_id == 392 && empty($red)) {
                $red = $do->option_value;
                $id_condition = $do->id_condition;
            }
            if ($do->option_id == 393 && empty($green)) {
                $green = $do->option_value;
                $id_condition = $do->id_condition;
            }
            if ($do->option_id == 394 && empty($blue)) {
                $blue = $do->option_value;
                $id_condition = $do->id_condition;
            }
            if ($do->option_id == 410 && empty($white)) {
                $white = $do->option_value;
                $exec_id = $do->exec_id;
            }
            if (!empty($white) && !empty($red) && !empty($green) && !empty($blue) && !empty($exec_id)) {
                $hexa_color = convertRGBToHexa($red, $green, $blue, $white);
                $white = 0;
                $red = 0;
                $green = 0;
                $blue = 0;
                $list[$exec_id]['option_value'] = $hexa_color;
            } elseif (!empty($red) && !empty($green) && !empty($blue) && !empty($exec_id)) {
                $hexa_color = convertRGBToHexa($red, $green, $blue);
                $red = 0;
                $green = 0;
                $blue = 0;
                $list[$exec_id]['option_value'] = $hexa_color;
            }
        }
        return $list;
    }
예제 #2
0
<?php

include 'header.php';
if (!empty($_GET['iddevice'])) {
    $request = new Api();
    $request->add_request('confDeviceRoomOpt', array($_GET['iddevice']));
    $result = $request->send_request();
    $device_opt = $result->confDeviceRoomOpt;
    echo '<div class="center">' . '<form class="btn center padding-bottom">';
    if (!empty($device_opt->{392}->opt_value) && !empty($device_opt->{393}->opt_value) && !empty($device_opt->{394}->opt_value)) {
        echo '<input type="text" id="color" name="color" value="' . convertRGBToHexa($device_opt->{392}->opt_value, $device_opt->{393}->opt_value, $device_opt->{394}->opt_value) . '" disabled="disabled"/>';
    } else {
        echo '<input type="text" id="color" name="color" value="#000" disabled="disabled"/>';
    }
    echo '</form>';
    if (!empty($_GET['bg_color'])) {
        if ($_GET['bg_color'] == 1) {
            echo '<button class="btn btn-warning" onclick="updateBGColor(\'#eee\', ' . $_GET['userid'] . ', 1)">' . _('Reset') . '&nbsp<span class="glyphicon glyphicon-refresh"></span>' . '</button>';
        } else {
            echo '<button class="btn btn-warning" onclick="updateBGColor(\'#f5f5f5\', ' . $_GET['userid'] . ', 2)">' . _('Reset') . '&nbsp<span class="glyphicon glyphicon-refresh"></span>' . '</button>';
        }
    }
    if (!empty($device_opt->{410})) {
        echo '<br/>' . '<div onclick="Variation(\'' . $_GET['iddevice'] . '\', \'410\', -1, 1)" class="col-xs-4 col-sm-4 col-md-4 col-lg-4 cursor">' . '<i class="fa fa-certificate"></i>' . '</div>';
        if ($device_opt->{410}->opt_value > 0) {
            $val = ceil($device_opt->{410}->opt_value * 100 / 255);
            echo '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">' . '<output id="range-' . $_GET['iddevice'] . '-popup" for="slider-value-' . $_GET['iddevice'] . '-popup">' . $val . '%</output>' . '</div>';
        } else {
            echo '<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">' . '<output id="range-' . $_GET['iddevice'] . '-popup" for="slider-value-' . $_GET['iddevice'] . '-popup">50%</output>' . '</div>';
        }
        echo '<div onclick="Variation(\'' . $_GET['iddevice'] . '\', \'410\', 1, 1)" class="col-xs-4 col-sm-4 col-md-4 col-lg-4 cursor">' . '<i class="fa fa-sun-o"></i>' . '</div>';