Compare commits
	
		
			2 Commits
		
	
	
		
			adfb564ccc
			...
			9d9304d30e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9d9304d30e | ||
| 
						 | 
					c6f57a3661 | 
@@ -26,8 +26,18 @@ class AutomationsApi extends ApiController
 | 
			
		||||
		$this->requireAuth();
 | 
			
		||||
		$obj = $this->input;
 | 
			
		||||
 | 
			
		||||
		if (
 | 
			
		||||
			empty($obj['name']) ||
 | 
			
		||||
			!isset($obj['name']) ||
 | 
			
		||||
			!isset($obj['conditions']) ||
 | 
			
		||||
			!isset($obj['tasks']) ||
 | 
			
		||||
			!isset($obj['days'])
 | 
			
		||||
		) {
 | 
			
		||||
			throw new Exception("Invalid request payload", 400);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$response = [];
 | 
			
		||||
		$response = AutomationManager::create($obj['name'],$obj['days'], $obj['tasks'], $obj['conditions']);
 | 
			
		||||
		$response = AutomationManager::create($obj['name'],json_encode($obj['days']), json_encode($obj['tasks']), json_encode($obj['conditions']));
 | 
			
		||||
 | 
			
		||||
		$this->response(['value'=>'OK']);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,14 +17,14 @@ class AutomationManager{
 | 
			
		||||
		return Db::command ('UPDATE automation SET executed = 0 WHERE automation_id=?', array ($automationId));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
 | 
			
		||||
		$userId = UserManager::getUserData('user_id');
 | 
			
		||||
	public static function create ($name, $onDays, $doCode, $ifCode, $userId = 1, $automationId = "") {
 | 
			
		||||
		$userId = UserManager::getUserData('user_id', $userId);
 | 
			
		||||
		$scene = array (
 | 
			
		||||
			'name' => $name,
 | 
			
		||||
			'owner_id' => $userId,
 | 
			
		||||
			'on_days' => $onDays,
 | 
			
		||||
			'if_something' => $ifCode,
 | 
			
		||||
			'do_something' => $doCode,
 | 
			
		||||
			'conditions' => $ifCode,
 | 
			
		||||
			'tasks' => $doCode,
 | 
			
		||||
		);
 | 
			
		||||
		try {
 | 
			
		||||
			if ($automationId == "") {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ class SettingsManager{
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static function create ($name, $value, $type = '') {
 | 
			
		||||
		//if (!self::getByName($name)){
 | 
			
		||||
		if (!self::getByName($name)){
 | 
			
		||||
			$setting = array (
 | 
			
		||||
				'name' => $name,
 | 
			
		||||
				'value' => $value,
 | 
			
		||||
@@ -26,7 +26,7 @@ class SettingsManager{
 | 
			
		||||
				echo $error->getMessage();
 | 
			
		||||
				die();
 | 
			
		||||
			}
 | 
			
		||||
		//}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static function update ($name, $value, $type = '') {
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ class DameJidlo extends VirtualDeviceManager
 | 
			
		||||
            echo 'Error:' . curl_error($ch);
 | 
			
		||||
        }
 | 
			
		||||
        curl_close($ch);
 | 
			
		||||
 | 
			
		||||
        var_dump(isset(json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta']) ? json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta'] : 0);
 | 
			
		||||
        return  (isset(json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta']) ? json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta'] : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -80,6 +80,6 @@ class DameJidlo extends VirtualDeviceManager
 | 
			
		||||
        } else if ($value <= 1) {
 | 
			
		||||
            return "less " . $value;
 | 
			
		||||
        }
 | 
			
		||||
		return '';
 | 
			
		||||
		return $value;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user