示例#1
0
 public static function getEventSid()
 {
     $event = Event::select('id', 'name', 'event_sid')->get();
     $result = array();
     foreach ($event as $value) {
         $result[$value->id] = $value->event_sid . ' - (' . $value->name . ')';
     }
     return $result;
 }
 public function postAddDataEvents()
 {
     $input = Input::only('name', 'event_sid');
     $input['name'] = e($input['name']);
     $input['terminal_id'] = $this->getTerminalId();
     //проверяем данные
     $errors = Events::add($input);
     if ($errors) {
         return $errors;
     }
     $event = new Event();
     $event->newEvent($input);
     $message = 'Данные изменены';
     return array('message' => $message);
 }
示例#3
0
 public function setUp()
 {
     parent::setUp();
     Config::set('termId', 1);
     IncomeEvent::truncate();
     Event::truncate();
     Terminal::truncate();
     Rule::truncate();
     ResultSignal::truncate();
     Signal::truncate();
     Terminal::create(array('name' => 'test', 'url' => 'http://test', 'queue' => 'queueTest', 'key' => 'key'));
     Event::create(array('terminal_id' => 1, 'name' => 'Хочу есть', 'event_sid' => 'im_hungry'));
     Signal::create(array('terminal_id' => 1, 'name' => 'Иди кушай', 'signal_sid' => 'go_eat'));
     Signal::create(array('terminal_id' => 1, 'name' => 'Жди', 'signal_sid' => 'wait'));
     Signal::create(array('terminal_id' => 1, 'name' => 'Терпи до дома', 'signal_sid' => 'endure'));
     Rule::create(array('terminal_id' => 1, 'name' => 'Иди кушай', 'event_id' => 1, 'rule' => 'time >= 13.00 AND time <= 14.00 AND have_money === true', 'signal_id' => 1, 'flag_active' => true));
     Rule::create(array('terminal_id' => 1, 'name' => 'Жди', 'event_id' => 1, 'rule' => 'time < 13.00', 'signal_id' => 2, 'flag_active' => true));
     Rule::create(array('terminal_id' => 1, 'name' => 'Терпи до дома', 'event_id' => 1, 'rule' => 'time > 14.00', 'signal_id' => 3, 'flag_active' => true));
 }
示例#4
0
 /**
  * @param $data
  *
  * @return Rule[]
  */
 public function CalcFitRules($data)
 {
     $eventData = json_decode($data['data'], true);
     if (json_last_error() != JSON_ERROR_NONE) {
         return ['error' => 'JSON error'];
     }
     //Записываем событие в базу
     $this->incomeEvent = new IncomeEvent();
     $this->incomeEvent->newIncomeEvent($data['term'], $data['event'], $eventData);
     //Если не находим событие - отдаём ошибку
     $event = Event::getEvent($data['term'], $data['event']);
     if ($event == null) {
         Log::info('Правило ' . $data['event'] . ' не найдено');
         return ['error' => 'Unknown event'];
     }
     //Получаем все правила теминала по событию
     $rules = Rule::getRules($data['term'], $event->id);
     $countRules = count($rules);
     Log::info("Всего найдено правил: {$countRules}");
     //Определяем соответсвующие запросу правила
     $rulesHandler = new RulesHandler();
     $fitRules = $rulesHandler->getFitRules($rules, $eventData);
     return $fitRules;
 }
					<div class="col-sm-9">
						<?php 
echo Form::input('text', 'name', '', array('placeholder' => 'Название', 'class' => 'form-control', 'id' => 'inputNameAdd', 'required' => 'required'));
?>
					</div>
					<div id="errorNameAdd" class="text-danger text-center"></div>
				</div>

				<div class="form-group row">
					<?php 
echo Form::label('inputEventSidAdd', 'event_sid', array('class' => 'col-sm-3 control-label'));
?>
					<div class="col-sm-9">
						<div class="EventSid">
							<?php 
echo Form::select('EventSid', Event::getEventSid(), '', array('class' => 'form-control', 'id' => 'inputEventSidAdd', 'required' => 'required'));
?>
						</div>
					</div>
					<div id="errorEventSidAdd" class="text-danger text-center"></div>
				</div>

				<div class="form-group row">
					<?php 
echo Form::label('inputRuleAdd', 'Условие', array('class' => 'col-sm-3 control-label'));
?>
					<div class="col-sm-9">
						<?php 
echo Form::input('text', 'rule', '', array('placeholder' => 'rule', 'class' => 'form-control', 'id' => 'inputRuleAdd'));
?>
					</div>