diff --git a/lhc_web/lib/core/lhcore/lhdbtrait.php b/lhc_web/lib/core/lhcore/lhdbtrait.php index b25391272f..740640e1ee 100644 --- a/lhc_web/lib/core/lhcore/lhdbtrait.php +++ b/lhc_web/lib/core/lhcore/lhdbtrait.php @@ -401,6 +401,20 @@ public static function getConditions($params, $q) } } + if (isset($params['filterfields']) && count($params['filterfields']) > 0) { + foreach ($params['filterfields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + if (is_array($fieldValue)) { + if (!empty($fieldValue)) { + $conditions[] = $q->expr->in($field, $fieldValue); + } + } else { + $conditions[] = $q->expr->eq($field, $q->bindValue($fieldValue)); + } + } + } + } + if (isset($params['filterin']) && count($params['filterin']) > 0) { foreach ($params['filterin'] as $field => $fieldValue) { if (empty($fieldValue)) { @@ -411,6 +425,18 @@ public static function getConditions($params, $q) } } + if (isset($params['filterinfields']) && count($params['filterinfields']) > 0) { + foreach ($params['filterinfields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + if (empty($fieldValue)) { + break; + } else { + $conditions[] = $q->expr->in($field, $fieldValue); + } + } + } + } + if (isset($params['filterlt']) && count($params['filterlt']) > 0) { foreach ($params['filterlt'] as $field => $fieldValue) { $conditions[] = $q->expr->lt($field, $q->bindValue($fieldValue)); @@ -432,7 +458,7 @@ public static function getConditions($params, $q) } if (isset($params['filtergtfields']) && count($params['filtergtfields']) > 0) { - foreach ($params['filtergtfields'] as $field => $combination) { + foreach ($params['filtergtfields'] as $combination) { foreach ($combination as $field => $fieldValue) { $conditions[] = $q->expr->gt($field, $q->bindValue($fieldValue)); } @@ -441,13 +467,29 @@ public static function getConditions($params, $q) if (isset($params['filtergte']) && count($params['filtergte']) > 0) { foreach ($params['filtergte'] as $field => $fieldValue) { - $conditions[] = $q->expr->gte($field, $fieldValue); + $conditions[] = $q->expr->gte($field, $q->bindValue($fieldValue)); + } + } + + if (isset($params['filtergtefields']) && count($params['filtergtefields']) > 0) { + foreach ($params['filtergtefields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + $conditions[] = $q->expr->gte($field, $q->bindValue($fieldValue)); + } } } if (isset($params['filterlte']) && count($params['filterlte']) > 0) { foreach ($params['filterlte'] as $field => $fieldValue) { - $conditions[] = $q->expr->lte($field, $fieldValue); + $conditions[] = $q->expr->lte($field, $q->bindValue($fieldValue)); + } + } + + if (isset($params['filterltefields']) && count($params['filterltefields']) > 0) { + foreach ($params['filterltefields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + $conditions[] = $q->expr->lte($field, $q->bindValue($fieldValue)); + } } } @@ -483,6 +525,22 @@ public static function getConditions($params, $q) } } + if (isset($params['filterlikefields']) && count($params['filterlikefields']) > 0) { + foreach ($params['filterlikefields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + $conditions[] = $q->expr->like($field, $q->bindValue('%' . $fieldValue . '%')); + } + } + } + + if (isset($params['filternotlikefields']) && count($params['filternotlikefields']) > 0) { + foreach ($params['filternotlikefields'] as $combination) { + foreach ($combination as $field => $fieldValue) { + $conditions[] = $q->expr->not($q->expr->like($field, $q->bindValue('%' . $fieldValue . '%'))); + } + } + } + if (isset($params['filterlikeright']) && count($params['filterlikeright']) > 0) { foreach ($params['filterlikeright'] as $field => $fieldValue) { $conditions[] = $q->expr->like($field, $q->bindValue($fieldValue . '%')); diff --git a/lhc_web/lib/vendor_lhc/LiveHelperChat/mailConv/Webhooks/Continous.php b/lhc_web/lib/vendor_lhc/LiveHelperChat/mailConv/Webhooks/Continous.php index 5c44df9c09..b7d67c9ab4 100644 --- a/lhc_web/lib/vendor_lhc/LiveHelperChat/mailConv/Webhooks/Continous.php +++ b/lhc_web/lib/vendor_lhc/LiveHelperChat/mailConv/Webhooks/Continous.php @@ -179,7 +179,7 @@ public static function processEventMail() } else if ($conditionsCurrent['condition'] == 'notlike') { $filterPrepared['filternotlikefields'][][$conditionAttr] = $valueAttr; } else if ($conditionsCurrent['condition'] == 'contains') { - $filterPrepared['filterinfield'][][$conditionAttr] = explode(',', $valueAttr); + $filterPrepared['filterinfields'][][$conditionAttr] = explode(',', $valueAttr); } } } @@ -209,21 +209,6 @@ public static function processEventMail() if ($conditionsCurrent['type'] == '1') { // Visitor message contains // For that visitor should use event based events or contains just options - /*$paramsMessage = array('limit' => 1, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id), 'filternotin' => array('user_id' => array(-1))); - if ($previousMessageId > 0) { - $paramsMessage['filterlt']['id'] = $previousMessageId; - } - $messageLast = erLhcoreClassModelmsg::findOne($paramsMessage); - if ($messageLast instanceof erLhcoreClassModelmsg) { - $previousMessageId = $messageLast->id; - if ($messageLast->user_id == 0) { - $conditionItemValid = erLhcoreClassGenericBotWorkflow::checkPresenceMessage(array( - 'pattern' => $conditionsCurrent['message_contains'], - 'msg' => $messageLast->msg, - 'words_typo' => 0, - ))['found']; - } - }*/ } elseif ($conditionsCurrent['type'] == '3') { // No response from operator for n seconds $conditionAttr = $conditionsCurrent['attr']; if (strpos($conditionAttr, '{args.') !== false) { diff --git a/lhc_web/modules/lhcron/webhook.php b/lhc_web/modules/lhcron/webhook.php index 0786d3b925..09f3ba60a5 100644 --- a/lhc_web/modules/lhcron/webhook.php +++ b/lhc_web/modules/lhcron/webhook.php @@ -5,6 +5,6 @@ * Run every 20 seconds * * */ -//erLhcoreClassChatWebhookContinuous::processEvent(); +erLhcoreClassChatWebhookContinuous::processEvent(); \LiveHelperChat\mailConv\Webhooks\Continous::processEventMail();