コード例 #1
0
 public function init()
 {
     // actions
     // translate
     foreach ($this->actions as $actions => $name) {
         $this->actions[$actions] = Yii::t('app', $name);
     }
     // actions values
     $this->actions_values['taskdefined'] = TaskDefined::getAllIdName();
     $this->actions_values['setting'] = Setting::getAllIdName();
     $this->actions_values['rule'] = Rule::getAllIdName();
     $this->actions_values['rulevalue'] = RuleValue::getAllIdName();
     $this->actions_values['ruleextra'] = RuleExtra::getAllIdName();
     $this->actions_values['ruledate'] = RuleDate::getAllIdName();
     // values
     // translate
     foreach ($this->values as $values => $name) {
         $this->values[$values] = Yii::t('app', $name);
     }
     // values_values
     $this->values_values['taskdefined'] = TaskDefined::getAllIdName();
     $this->values_values['setting'] = Setting::getAllIdName();
     $this->values_values['rule'] = Rule::getAllIdName();
     $this->values_values['rulevalue'] = RuleValue::getAllIdName();
     $this->values_values['ruleextra'] = RuleExtra::getAllIdName();
     $this->values_values['ruledate'] = RuleDate::getAllIdName();
     //$this->values = array_merge($modelRule->values, $modelRule->actions);
     //$this->values_values = $modelRule->values;
     // create weights from 0 to 5
     for ($weight = 0; $weight <= 4; $weight++) {
         $this->weights[$weight] = $weight;
     }
     parent::init();
 }
コード例 #2
0
 public function init()
 {
     // add all task defined as Task::execute to the conditions
     $modelTaskDefined = new TaskDefined();
     $tasksdefined = $modelTaskDefined->getTaskDefinedAll();
     foreach ($tasksdefined as $taskdefined) {
         $this->conditions[sprintf('{"class":"Task","function":"execute","parameter":["%d","%d","%d"]}', $taskdefined['from_device_id'], $taskdefined['to_device_id'], $taskdefined['action_id'])] = sprintf('(%d) %s', $taskdefined['id'], $taskdefined['name']);
     }
     // translate all conditions
     foreach ($this->conditions as $json => $condition) {
         $this->conditions[$json] = Yii::t('app', $condition);
     }
     // add date, condition or task before value condition
     foreach ($this->conditions as $json => $condition) {
         $array = json_decode($json, true);
         switch ($array['class']) {
             case 'php':
                 switch ($array['function']) {
                     case 'date':
                         $this->conditions[$json] = sprintf('date(\'%s\'), %s', $array['parameter'], $condition);
                         break;
                 }
                 break;
             default:
                 $this->conditions[$json] = sprintf('%s, %s', $array['class'], $condition);
         }
     }
     // translate all equations
     foreach ($this->equations as $key => $equation) {
         $this->equations[$key] = Yii::t('app', $equation);
     }
     // key before value equations
     foreach ($this->equations as $key => $equation) {
         $this->equations[$key] = $key . ', ' . $equation;
     }
     // create weights from 0 to 10
     for ($weight = 0; $weight <= 10; $weight++) {
         $this->weights[$weight] = $weight;
     }
     parent::init();
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TaskDefined::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'name' => $this->name, 'from_device_id' => $this->from_device_id, 'to_device_id' => $this->to_device_id, 'action_id' => $this->action_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     return $dataProvider;
 }
コード例 #4
0
 public function init()
 {
     // add all task defined
     $this->job_ids['taskdefined'] = TaskDefined::getAllIdName();
     // add all task defined
     $this->job_ids['rule'] = Rule::getAllIdName();
     // translate all
     foreach ($this->job_ids as $job => $jobs) {
         foreach ($jobs as $id => $name) {
             $this->job_ids[$job][$id] = Yii::t('app', $name);
         }
     }
     // create weights
     for ($key = 0; $key < Cronjob::find()->count(); $key++) {
         $this->weights[$key] = $key;
     }
     $this->weights[$key] = $key;
     parent::init();
 }
コード例 #5
0
 public function init()
 {
     // actions
     // translate
     foreach ($this->conditions as $conditions => $name) {
         $this->conditions[$conditions] = Yii::t('app', $name);
     }
     // actions values
     $this->conditions_values['taskdefined'] = TaskDefined::getAllIdName();
     $this->conditions_values['setting'] = Setting::getAllIdName();
     $this->conditions_values['rule'] = Rule::getAllIdName();
     $this->conditions_values['rulevalue'] = RuleValue::getAllIdName();
     $this->conditions_values['ruleextra'] = RuleExtra::getAllIdName();
     $this->conditions_values['ruledate'] = RuleDate::getAllIdName();
     // equations
     // translate all equations
     foreach ($this->equations as $key => $equation) {
         $this->equations[$key] = Yii::t('app', $equation);
     }
     // key before value equations
     foreach ($this->equations as $key => $equation) {
         $this->equations[$key] = $key . ', ' . $equation;
     }
     // values
     // translate
     foreach ($this->values as $values => $name) {
         $this->values[$values] = Yii::t('app', $name);
     }
     // values_values
     $this->values_values['taskdefined'] = TaskDefined::getAllIdName();
     $this->values_values['setting'] = Setting::getAllIdName();
     $this->values_values['rule'] = Rule::getAllIdName();
     $this->values_values['rulevalue'] = RuleValue::getAllIdName();
     $this->values_values['ruleextra'] = RuleExtra::getAllIdName();
     $this->values_values['ruledate'] = RuleDate::getAllIdName();
     // create weights from 0 to 10
     for ($weight = 0; $weight <= 10; $weight++) {
         $this->weights[$weight] = $weight;
     }
     parent::init();
 }
コード例 #6
0
 public static function ruleExecute($id)
 {
     $model = TaskDefined::findOne($id);
     $data = Task::execute($model->from_device_id, $model->to_device_id, $model->action_id);
     return HelperData::dataExplode($data);
 }
コード例 #7
0
 /**
  * Finds the TaskDefined model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TaskDefined the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TaskDefined::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }