Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Collection;
|
||||
|
||||
use ArrayObject;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Iterator;
|
||||
use IteratorAggregate;
|
||||
use Xentral\Modules\SuperSearch\Exception\InvalidArgumentException;
|
||||
use Xentral\Modules\SuperSearch\Exception\InvalidReturnTypeException;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class ItemFormatterCollection implements Iterator
|
||||
{
|
||||
/** @var Iterator $data */
|
||||
private $data;
|
||||
|
||||
/** @var callable $callback */
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @param array|Iterator $data
|
||||
* @param callable|Closure $callback
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($data, $callback)
|
||||
{
|
||||
if (!is_callable($callback, false)) {
|
||||
throw new InvalidArgumentException('Callback is not callable');
|
||||
}
|
||||
$this->callback = $callback;
|
||||
|
||||
$type = gettype($data);
|
||||
if ($type === 'object') {
|
||||
$type = get_class($data);
|
||||
if ($data instanceof Iterator) {
|
||||
$type = 'Iterator';
|
||||
}
|
||||
if ($data instanceof IteratorAggregate) {
|
||||
$type = 'IteratorAggregate';
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'array':
|
||||
$this->data = (new ArrayObject($data))->getIterator();
|
||||
break;
|
||||
|
||||
case 'Iterator':
|
||||
$this->data = $data;
|
||||
break;
|
||||
|
||||
case 'IteratorAggregate':
|
||||
try {
|
||||
$this->data = $data->getIterator();
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException($exception->getMessage(), $exception->getCode(), $exception);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException(sprintf('Unsupported type "%s".', $type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current element
|
||||
*
|
||||
* @throws InvalidReturnTypeException
|
||||
*
|
||||
* @return IndexItem
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$result = call_user_func($this->callback, $this->data->current(), $this->data->key());
|
||||
if (!$result instanceof IndexItem) {
|
||||
throw new InvalidReturnTypeException(sprintf(
|
||||
'Formatter return type is invalid . Callable must return an object with type "%s".',
|
||||
IndexItem::class
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move forward to next element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->data->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the key of the current element
|
||||
*
|
||||
* @return mixed scalar on success, or null on failure.
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->data->key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current position is valid
|
||||
*
|
||||
* @return boolean Returns true on success or false on failure.
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->data->valid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the Iterator to the first element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->data->rewind();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Data;
|
||||
|
||||
use Xentral\Modules\SuperSearch\Exception\InvalidArgumentException;
|
||||
|
||||
final class IndexData
|
||||
{
|
||||
/** @var int $projectId */
|
||||
private $projectId;
|
||||
|
||||
/** @var string $title */
|
||||
private $title;
|
||||
|
||||
/** @var string|null $subTitle */
|
||||
private $subTitle;
|
||||
|
||||
/** @var array|string[] $additionalInfos */
|
||||
private $additionalInfos;
|
||||
|
||||
/** @var string $link */
|
||||
private $link;
|
||||
|
||||
/** @var array $words */
|
||||
private $words;
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $link
|
||||
* @param int $projectId
|
||||
* @param array $words
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($title, $link, $projectId = 0, array $words = [])
|
||||
{
|
||||
if (empty($title)) {
|
||||
$title = 'empty';
|
||||
}
|
||||
if (empty($link)) {
|
||||
throw new InvalidArgumentException('Invalid argument value. $link parameter can not be empty.');
|
||||
}
|
||||
if (!is_int($projectId)) {
|
||||
throw new InvalidArgumentException('Invalid argument type. Parameter $projectId must be type integer.');
|
||||
}
|
||||
|
||||
$this->projectId = (int)$projectId;
|
||||
$this->title = (string)$title;
|
||||
$this->link = (string)$link;
|
||||
$this->addSearchWords($words);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $state
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromDbState(array $state)
|
||||
{
|
||||
return new self(
|
||||
(string)$state['title'],
|
||||
(string)$state['link'],
|
||||
(int)$state['project_id'],
|
||||
(array)$state['search_words']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subTitle
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSubTitle($subTitle)
|
||||
{
|
||||
$subTitle = trim($subTitle);
|
||||
if ($subTitle === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->subTitle = (string)$subTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $additionalInfo
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAdditionalInfo($additionalInfo)
|
||||
{
|
||||
$additionalInfo = trim($additionalInfo);
|
||||
if ($additionalInfo === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->additionalInfos[] = (string)$additionalInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $words
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addSearchWords(array $words)
|
||||
{
|
||||
foreach ($words as $word) {
|
||||
$this->addSearchWord($word);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $word
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addSearchWord($word)
|
||||
{
|
||||
$word = trim($word);
|
||||
if ($word === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->words[] = $word;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSubTitle()
|
||||
{
|
||||
return $this->subTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function getAdditionalInfos()
|
||||
{
|
||||
return $this->additionalInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProjectId()
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWords()
|
||||
{
|
||||
return $this->words;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Data;
|
||||
|
||||
use Xentral\Modules\SuperSearch\Exception\InvalidArgumentException;
|
||||
|
||||
final class IndexIdentifier
|
||||
{
|
||||
/** @var string $name */
|
||||
private $name;
|
||||
|
||||
/** @var int $id */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int|string $id
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($name, $id)
|
||||
{
|
||||
if (empty($name)) {
|
||||
throw new InvalidArgumentException('Invalid argument value. $name parameter can not be empty.');
|
||||
}
|
||||
if (empty($id)) {
|
||||
throw new InvalidArgumentException('Invalid argument value. $id parameter can not be empty.');
|
||||
}
|
||||
if (strlen($name) > 16) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Invalid argument value "%s". Max length for $id is 16 characters.', $name
|
||||
));
|
||||
}
|
||||
if (strlen($id) > 38) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Invalid argument value "%s". Max length for $id is 38 characters.', $id
|
||||
));
|
||||
}
|
||||
if (preg_match('/[^a-z]+/', $name) === 1) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Invalid argument value "%s". Valid characters for $name parameter: a-z', $name
|
||||
));
|
||||
}
|
||||
|
||||
$this->name = (string)$name;
|
||||
$this->id = is_numeric($id) ? (int)$id : (string)$id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Data;
|
||||
|
||||
final class IndexItem
|
||||
{
|
||||
/** @var IndexIdentifier $identifier */
|
||||
public $identifier;
|
||||
|
||||
/** @var IndexData $data */
|
||||
public $data;
|
||||
|
||||
/** @var string|null $module */
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* @param IndexIdentifier $identifier
|
||||
* @param IndexData $data
|
||||
* @param string|null $moduleName
|
||||
*/
|
||||
public function __construct(IndexIdentifier $identifier, IndexData $data, $moduleName = null)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
$this->data = $data;
|
||||
$this->module = $moduleName;
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use Closure;
|
||||
use DateTimeInterface;
|
||||
use Exception;
|
||||
use Xentral\Components\Database\Database;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\Exception\FormatterFailureException;
|
||||
use Xentral\Modules\SuperSearch\Exception\InvalidReturnTypeException;
|
||||
use Xentral\Modules\SuperSearch\Exception\SuperSearchExceptionInterface;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Collection\ItemFormatterCollection;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
abstract class AbstractBulkIndexDatabaseProvider implements
|
||||
SearchIndexProviderInterface,
|
||||
BulkIndexProviderInterface,
|
||||
ItemIndexProviderInterface,
|
||||
DiffIndexProviderInterface
|
||||
{
|
||||
/** @var Database $db */
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @param Database $database
|
||||
*/
|
||||
public function __construct(Database $database)
|
||||
{
|
||||
$this->db = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function configureBaseQuery(SelectQuery $query);
|
||||
|
||||
/**
|
||||
* @param SelectQuery $baseQuery
|
||||
* @param int|string $indexId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function configureItemQuery(SelectQuery $baseQuery, $indexId);
|
||||
|
||||
/**
|
||||
* @param SelectQuery $baseQuery
|
||||
* @param DateTimeInterface $since
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since);
|
||||
|
||||
/**
|
||||
* @param SelectQuery $baseQuery
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function configureCountQuery(SelectQuery $baseQuery);
|
||||
|
||||
/**
|
||||
* @return Closure
|
||||
*/
|
||||
abstract protected function getRowFormatter();
|
||||
|
||||
/**
|
||||
* @return int Anzahl der IndexItems die in einem Durchlauf geschrieben werden
|
||||
*/
|
||||
public function getBulkSize()
|
||||
{
|
||||
return 20000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IndexIdentifier $identifier
|
||||
*
|
||||
* @throws InvalidReturnTypeException
|
||||
*
|
||||
* @return IndexItem|null
|
||||
*/
|
||||
public function getItem(IndexIdentifier $identifier)
|
||||
{
|
||||
$select = $this->db->select();
|
||||
$this->configureBaseQuery($select);
|
||||
$this->configureItemQuery($select, $identifier->getId());
|
||||
|
||||
$row = $this->db->fetchRow(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
|
||||
if (empty($row)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Formatter aufrufen
|
||||
$formatter = $this->getRowFormatter();
|
||||
$item = $formatter($row);
|
||||
} catch (SuperSearchExceptionInterface $exception) {
|
||||
throw new FormatterFailureException(
|
||||
sprintf('Formatter failed. Row data: %s', var_export($row, true)),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
|
||||
// Prüfen ob Formatter den richtigen Typ zurückliefert
|
||||
if (!$item instanceof IndexItem) {
|
||||
$itemType = gettype($item);
|
||||
if ($itemType === 'object') {
|
||||
$itemType = get_class($item);
|
||||
}
|
||||
throw new InvalidReturnTypeException(sprintf(
|
||||
'"%s::getRowFormatter()" returned invalid type. Required type "%s". Returned type "%s".',
|
||||
get_class($this),
|
||||
IndexItem::class,
|
||||
$itemType
|
||||
));
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getItemsSince(DateTimeInterface $since)
|
||||
{
|
||||
$select = $this->db->select();
|
||||
$this->configureBaseQuery($select);
|
||||
$this->configureSinceQuery($select, $since);
|
||||
|
||||
$callback = $this->getRowFormatter();
|
||||
$data = $this->db->fetchAll(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
|
||||
return new ItemFormatterCollection($data, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTotalCount()
|
||||
{
|
||||
$select = $this->db->select();
|
||||
$this->configureBaseQuery($select);
|
||||
$select->resetCols();
|
||||
$this->configureCountQuery($select);
|
||||
|
||||
return (int)$this->db->fetchValue(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
*
|
||||
* @throws InvalidReturnTypeException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return ItemFormatterCollection
|
||||
*/
|
||||
public function getBulkItems($offset, $count)
|
||||
{
|
||||
$select = $this->db->select();
|
||||
$this->configureBaseQuery($select);
|
||||
|
||||
$select->offset($offset);
|
||||
$select->limit($count);
|
||||
|
||||
$callback = $this->getRowFormatter();
|
||||
$data = $this->db->fetchAll(
|
||||
$select->getStatement(),
|
||||
$select->getBindValues()
|
||||
);
|
||||
|
||||
return new ItemFormatterCollection($data, $callback);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class AddressProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'adresse';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'addresses';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Adressen';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'a.id',
|
||||
'a.projekt',
|
||||
'a.name',
|
||||
'a.abteilung',
|
||||
'a.unterabteilung',
|
||||
'a.ansprechpartner',
|
||||
'a.strasse',
|
||||
'a.ort',
|
||||
'a.plz',
|
||||
'a.adresszusatz',
|
||||
'a.telefon',
|
||||
'a.telefax',
|
||||
'a.mobil',
|
||||
'a.email',
|
||||
'a.ustid',
|
||||
'a.kundennummer',
|
||||
'a.lieferantennummer',
|
||||
'a.mitarbeiternummer',
|
||||
])
|
||||
->from('adresse AS a')
|
||||
->where('a.geloescht = ?', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('a.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(a.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('a.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$title = $row['name'];
|
||||
$link = sprintf('index.php?module=adresse&action=edit&id=%d', $row['id']);
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
if (!empty($row['kundennummer'])) {
|
||||
$data->addAdditionalInfo(sprintf('Kunde %s', $row['kundennummer']));
|
||||
}
|
||||
if (!empty($row['lieferantennummer'])) {
|
||||
$data->addAdditionalInfo(sprintf('Lieferant %s', $row['lieferantennummer']));
|
||||
}
|
||||
if (!empty($row['mitarbeiternummer'])) {
|
||||
$data->addAdditionalInfo(sprintf('Mitarbeiter %s', $row['mitarbeiternummer']));
|
||||
}
|
||||
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['abteilung']);
|
||||
$data->addSearchWord($row['unterabteilung']);
|
||||
$data->addSearchWord($row['ansprechpartner']);
|
||||
$data->addSearchWord($row['strasse']);
|
||||
$data->addSearchWord($row['ort']);
|
||||
$data->addSearchWord($row['plz']);
|
||||
$data->addSearchWord($row['adresszusatz']);
|
||||
$data->addSearchWord($row['telefon']);
|
||||
$data->addSearchWord($row['telefax']);
|
||||
$data->addSearchWord($row['mobil']);
|
||||
$data->addSearchWord($row['email']);
|
||||
$data->addSearchWord($row['ustid']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['lieferantennummer']);
|
||||
$data->addSearchWord($row['mitarbeiternummer']);
|
||||
|
||||
$identifier = new IndexIdentifier('addresses', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use Appstore;
|
||||
use Exception;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Collection\ItemFormatterCollection;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class AppProvider implements FullIndexProviderInterface, ItemIndexProviderInterface
|
||||
{
|
||||
/** @var Appstore $appstore */
|
||||
private $appstore;
|
||||
|
||||
/**
|
||||
* @param Appstore $appstore
|
||||
*/
|
||||
public function __construct(Appstore $appstore)
|
||||
{
|
||||
$this->appstore = $appstore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'appstore';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'apps';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Apps';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getItem(IndexIdentifier $identifier)
|
||||
{
|
||||
$moduleKey = $identifier->getId();
|
||||
$modules = $this->appstore->BuildModuleList();
|
||||
if (!isset($modules[$moduleKey])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$formatter = $this->getRowFormatter();
|
||||
|
||||
return $formatter($modules[$moduleKey]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllItems()
|
||||
{
|
||||
$callback = $this->getRowFormatter();
|
||||
|
||||
$modules = $this->appstore->BuildModuleList();
|
||||
unset($modules['appstore_extern']);
|
||||
|
||||
// Module ohne Link entfernen
|
||||
foreach ($modules as $moduleName => $moduleData) {
|
||||
if (empty($moduleData['module_link'])) {
|
||||
unset($modules[$moduleName]);
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemFormatterCollection($modules, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $module) {
|
||||
$projectId = 0;
|
||||
$data = new IndexData($module['title'], $module['module_link'], $projectId);
|
||||
$data->addSearchWord($module['title']);
|
||||
$data->addSearchWord(html_entity_decode($module['title']));
|
||||
$data->addSearchWord($module['description']);
|
||||
$data->addSearchWord($module['category']);
|
||||
$identifier = new IndexIdentifier('apps', $module['key']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class ArticleProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'artikel';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'articles';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Artikel';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'a.id',
|
||||
'a.projekt',
|
||||
'a.nummer',
|
||||
'a.name_de',
|
||||
'a.kurztext_de',
|
||||
'a.herstellernummer',
|
||||
'a.ean',
|
||||
])
|
||||
->from('artikel AS a')
|
||||
->where('a.geloescht = ?', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('a.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(a.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('a.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$link = sprintf('index.php?module=artikel&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($row['nummer'], $link, $projectId);
|
||||
$data->setSubTitle($row['name_de']);
|
||||
$data->addSearchWord($row['nummer']);
|
||||
$data->addSearchWord($row['name_de']);
|
||||
$data->addSearchWord($row['kurztext_de']);
|
||||
$data->addSearchWord($row['herstellernummer']);
|
||||
$data->addSearchWord($row['ean']);
|
||||
|
||||
$identifier = new IndexIdentifier('articles', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Collection\ItemFormatterCollection;
|
||||
|
||||
interface BulkIndexProviderInterface extends SearchIndexProviderInterface
|
||||
{
|
||||
/**
|
||||
* Returns a range of the index items
|
||||
*
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
*
|
||||
* @return ItemFormatterCollection
|
||||
*/
|
||||
public function getBulkItems($start, $limit);
|
||||
|
||||
/**
|
||||
* Returns the number of items to process in one transaction
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBulkSize();
|
||||
|
||||
/**
|
||||
* Returns the total count for all items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalCount();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class CreditNoteProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'gutschrift';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'creditnotes';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Gutschriften';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'gs.id',
|
||||
'gs.projekt',
|
||||
'gs.status',
|
||||
'gs.datum',
|
||||
'gs.belegnr',
|
||||
'gs.rechnung',
|
||||
'gs.name',
|
||||
'gs.kundennummer',
|
||||
'gs.internebemerkung',
|
||||
'gs.ihrebestellnummer',
|
||||
'gs.soll',
|
||||
'gs.zahlungsstatus',
|
||||
'gs.waehrung',
|
||||
])
|
||||
->from('gutschrift AS gs')
|
||||
->where('gs.belegnr != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('gs.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(gs.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('gs.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$rechnungsDatum = date('d.m.Y', strtotime($row['datum']));
|
||||
$title = $row['belegnr'];
|
||||
$link = sprintf('index.php?module=gutschrift&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->setSubTitle($row['name']);
|
||||
$data->addAdditionalInfo($rechnungsDatum);
|
||||
$data->addAdditionalInfo(ucfirst($row['status']));
|
||||
$data->addAdditionalInfo(sprintf('%s %s', number_format($row['soll'], 2, ',', '.'), $row['waehrung']));
|
||||
|
||||
$data->addSearchWord('gutschrift');
|
||||
$data->addSearchWord($row['belegnr']);
|
||||
$data->addSearchWord($row['rechnung']);
|
||||
$data->addSearchWord($row['status']);
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['internebemerkung']);
|
||||
$data->addSearchWord($row['ihrebestellnummer']);
|
||||
|
||||
$identifier = new IndexIdentifier('creditnotes', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class DeliveryNoteProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'lieferschein';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'deliverynote';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Lieferscheine';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'l.id',
|
||||
'l.projekt',
|
||||
'l.datum',
|
||||
'l.belegnr',
|
||||
'l.status',
|
||||
'l.name',
|
||||
'l.kundennummer',
|
||||
'l.internebezeichnung'
|
||||
])
|
||||
->from('lieferschein AS l')
|
||||
->where('l.belegnr != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('l.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(l.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('l.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$lieferscheinDatum = date('d.m.Y', strtotime($row['datum']));
|
||||
$title = $row['belegnr'];
|
||||
$link = sprintf('index.php?module=lieferschein&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->addSearchWord('lieferschein');
|
||||
$data->addSearchWord($row['belegnr']);
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['internebezeichnung']);
|
||||
|
||||
$data->setSubTitle($row['name']);
|
||||
|
||||
$data->addAdditionalInfo($lieferscheinDatum);
|
||||
$data->addAdditionalInfo($row['status']);
|
||||
|
||||
|
||||
$identifier = new IndexIdentifier('deliverynote', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Collection\ItemFormatterCollection;
|
||||
|
||||
interface DiffIndexProviderInterface extends SearchIndexProviderInterface
|
||||
{
|
||||
/**
|
||||
* Returns index items that were changed or created since the passed date time
|
||||
*
|
||||
* @param DateTimeInterface $since
|
||||
*
|
||||
* @return ItemFormatterCollection
|
||||
*/
|
||||
public function getItemsSince(DateTimeInterface $since);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Collection\ItemFormatterCollection;
|
||||
|
||||
interface FullIndexProviderInterface extends SearchIndexProviderInterface
|
||||
{
|
||||
/**
|
||||
* Returns all items; No sectioning, just all items
|
||||
*
|
||||
* Use BulkIndexProviderInterface for large datasets instead
|
||||
*
|
||||
* @return ItemFormatterCollection
|
||||
*/
|
||||
public function getAllItems();
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class InvoiceProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'rechnung';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'invoices';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Rechnungen';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'r.id',
|
||||
'r.projekt',
|
||||
'r.datum',
|
||||
'r.belegnr',
|
||||
'r.auftrag',
|
||||
'r.name',
|
||||
'r.kundennummer',
|
||||
'r.internebemerkung',
|
||||
'r.ihrebestellnummer',
|
||||
'r.soll',
|
||||
'r.zahlungsstatus',
|
||||
'r.waehrung',
|
||||
])
|
||||
->from('rechnung AS r')
|
||||
->where('r.belegnr != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('r.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(r.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('r.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$rechnungsDatum = date('d.m.Y', strtotime($row['datum']));
|
||||
$title = $row['belegnr'];
|
||||
$link = sprintf('index.php?module=rechnung&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->setSubTitle($row['name']);
|
||||
$data->addAdditionalInfo($rechnungsDatum);
|
||||
$data->addAdditionalInfo(ucfirst($row['zahlungsstatus']));
|
||||
$data->addAdditionalInfo(sprintf('%s %s', number_format($row['soll'], 2, ',', '.'), $row['waehrung']));
|
||||
|
||||
$data->addSearchWord('rechnung');
|
||||
$data->addSearchWord($row['belegnr']);
|
||||
$data->addSearchWord($row['auftrag']);
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['internebemerkung']);
|
||||
$data->addSearchWord($row['ihrebestellnummer']);
|
||||
|
||||
$identifier = new IndexIdentifier('invoices', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
interface ItemIndexProviderInterface extends SearchIndexProviderInterface
|
||||
{
|
||||
/**
|
||||
* Returns a single item for writing into the search index
|
||||
*
|
||||
* @param IndexIdentifier $identifier
|
||||
*
|
||||
* @return IndexItem|null
|
||||
*/
|
||||
public function getItem(IndexIdentifier $identifier);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class OfferProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'angebot';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'offers';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Angebote';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'a.id',
|
||||
'a.projekt',
|
||||
'a.datum',
|
||||
'a.belegnr',
|
||||
'a.auftrag', // Auftragsnummer
|
||||
'a.status',
|
||||
'a.name',
|
||||
'a.kundennummer',
|
||||
'a.internebezeichnung',
|
||||
'a.anfrage',
|
||||
'a.gesamtsumme',
|
||||
'a.waehrung',
|
||||
])
|
||||
->from('angebot AS a')
|
||||
->where('a.belegnr != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('a.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(a.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('a.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$documentDate = date('d.m.Y', strtotime($row['datum']));
|
||||
$title = $row['belegnr'];
|
||||
$link = sprintf('index.php?module=angebot&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->setSubTitle($row['name']);
|
||||
$data->addAdditionalInfo($documentDate);
|
||||
$data->addAdditionalInfo(ucfirst($row['status']));
|
||||
$data->addAdditionalInfo(number_format($row['gesamtsumme'], 2, ',', '.') . ' ' . $row['waehrung']);
|
||||
$data->addSearchWord('angebot');
|
||||
$data->addSearchWord($row['belegnr']);
|
||||
$data->addSearchWord($row['auftrag']);
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['internebezeichnung']);
|
||||
$data->addSearchWord($row['anfrage']);
|
||||
|
||||
$identifier = new IndexIdentifier('offers', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class OrderProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'auftrag';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'orders';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Aufträge';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'a.id',
|
||||
'a.projekt',
|
||||
'a.datum',
|
||||
'a.belegnr',
|
||||
'a.internet',
|
||||
'a.angebot', // Angebotsnummer
|
||||
'a.status',
|
||||
'a.name',
|
||||
'a.kundennummer',
|
||||
'a.internebezeichnung',
|
||||
'a.ihrebestellnummer',
|
||||
'a.gesamtsumme',
|
||||
'a.waehrung',
|
||||
])
|
||||
->from('auftrag AS a')
|
||||
->where('a.belegnr != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('a.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(a.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('a.logdatei > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$documentDate = date('d.m.Y', strtotime($row['datum']));
|
||||
$title = $row['belegnr'];
|
||||
$link = sprintf('index.php?module=auftrag&action=edit&id=%d', $row['id']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->setSubTitle($row['name']);
|
||||
$data->addAdditionalInfo($documentDate);
|
||||
$data->addAdditionalInfo(ucfirst($row['status']));
|
||||
$data->addAdditionalInfo(number_format($row['gesamtsumme'], 2, ',', '.') . ' ' . $row['waehrung']);
|
||||
$data->addSearchWord('auftrag');
|
||||
$data->addSearchWord($row['belegnr']);
|
||||
$data->addSearchWord($row['internet']);
|
||||
$data->addSearchWord($row['angebot']);
|
||||
$data->addSearchWord($row['name']);
|
||||
$data->addSearchWord($row['kundennummer']);
|
||||
$data->addSearchWord($row['internebezeichnung']);
|
||||
$data->addSearchWord($row['ihrebestellnummer']);
|
||||
|
||||
$identifier = new IndexIdentifier('orders', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
interface SearchIndexProviderInterface
|
||||
{
|
||||
/**
|
||||
* @return string Nur Kleinbuchstaben erlaubt
|
||||
*/
|
||||
public function getIndexName();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexTitle();
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getModuleName();
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\SuperSearch\SearchIndex\Provider;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexData;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexIdentifier;
|
||||
use Xentral\Modules\SuperSearch\SearchIndex\Data\IndexItem;
|
||||
|
||||
final class TrackingNumberProvider extends AbstractBulkIndexDatabaseProvider
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
return 'lieferschein';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexName()
|
||||
{
|
||||
return 'trackingnumber';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIndexTitle()
|
||||
{
|
||||
return 'Trackingnummer';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureBaseQuery(SelectQuery $query)
|
||||
{
|
||||
$query
|
||||
->cols([
|
||||
'v.id',
|
||||
'v.tracking',
|
||||
'v.lieferschein',
|
||||
'v.projekt',
|
||||
'v.versendet_am'
|
||||
])
|
||||
->from('versand AS v')
|
||||
->where('v.tracking != ?', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureItemQuery(SelectQuery $baseQuery, $indexId)
|
||||
{
|
||||
$baseQuery->where('v.id = ?', (int)$indexId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureCountQuery(SelectQuery $baseQuery)
|
||||
{
|
||||
$baseQuery->cols(['COUNT(v.id)' => 'total_count']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configureSinceQuery(SelectQuery $baseQuery, DateTimeInterface $since)
|
||||
{
|
||||
$baseQuery->where('v.versendet_am > ?', $since->format('Y-m-d H:m:i'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getRowFormatter()
|
||||
{
|
||||
return static function (array $row) {
|
||||
|
||||
$projectId = (int)$row['projekt'];
|
||||
$versandDatum = date('d.m.Y', strtotime($row['versendet_am']));
|
||||
$title = $row['tracking'];
|
||||
$link = sprintf('index.php?module=lieferschein&action=edit&id=%d', $row['lieferschein']);
|
||||
|
||||
$data = new IndexData($title, $link, $projectId);
|
||||
$data->addSearchWord('trackingnummer');
|
||||
$data->addSearchWord($row['tracking']);
|
||||
|
||||
$data->setSubTitle('');
|
||||
|
||||
$data->addAdditionalInfo('Versendet: '.$versandDatum);
|
||||
|
||||
$identifier = new IndexIdentifier('trackingnumber', (int)$row['id']);
|
||||
|
||||
return new IndexItem($identifier, $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user