Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Xentral\Components\Database\Database;
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
use Xentral\Modules\Api\Exception\ResourceNotFoundException;
|
||||
use Xentral\Modules\Api\Resource\Exception\EndpointNotAvailableException;
|
||||
use Xentral\Modules\Api\Resource\Feature\FilterFeatureTrait;
|
||||
use Xentral\Modules\Api\Resource\Feature\IncludeFeatureTrait;
|
||||
use Xentral\Modules\Api\Resource\Feature\SortingFeatureTrait;
|
||||
use Xentral\Modules\Api\Resource\Feature\ValidationFeatureTrait;
|
||||
use Xentral\Modules\Api\Resource\Filter\Select\ComplexSearchFilter;
|
||||
use Xentral\Modules\Api\Resource\Filter\Select\SelectFilterInterface;
|
||||
use Xentral\Modules\Api\Resource\Filter\Select\SelectFilterTrait;
|
||||
use Xentral\Modules\Api\Resource\Result\CollectionResult;
|
||||
use Xentral\Modules\Api\Resource\Result\ItemResult;
|
||||
use Xentral\Modules\Api\Validator\Validator;
|
||||
|
||||
abstract class AbstractResource
|
||||
{
|
||||
use SelectFilterTrait;
|
||||
|
||||
use FilterFeatureTrait;
|
||||
use SortingFeatureTrait;
|
||||
use IncludeFeatureTrait;
|
||||
use ValidationFeatureTrait;
|
||||
|
||||
/** @var Database $db */
|
||||
protected $db;
|
||||
|
||||
/** @var Validator $validator */
|
||||
protected $validator;
|
||||
|
||||
/** @return SelectQuery|false */
|
||||
abstract protected function selectAllQuery();
|
||||
|
||||
/** @return SelectQuery|false */
|
||||
abstract protected function selectOneQuery();
|
||||
|
||||
/** @return SelectQuery|false */
|
||||
abstract protected function selectIdsQuery();
|
||||
|
||||
/** @return InsertQuery|false */
|
||||
abstract protected function insertQuery();
|
||||
|
||||
/** @return UpdateQuery|false */
|
||||
abstract protected function updateQuery();
|
||||
|
||||
/** @return UpdateQuery|DeleteQuery|false */
|
||||
abstract protected function deleteQuery();
|
||||
|
||||
/** @return void */
|
||||
abstract protected function configure();
|
||||
|
||||
/**
|
||||
* @param Database $database
|
||||
* @param Validator $validator
|
||||
*/
|
||||
public function __construct(
|
||||
Database $database,
|
||||
Validator $validator
|
||||
) {
|
||||
$this->db = $database;
|
||||
$this->validator = $validator;
|
||||
|
||||
$this->configure();
|
||||
|
||||
// Komplexe Suche immer aktivieren
|
||||
$this->registerSelectFilter(new ComplexSearchFilter());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filter
|
||||
* @param array $sorting
|
||||
* @param array $columns
|
||||
* @param array $includes
|
||||
* @param int $page
|
||||
* @param int $paging
|
||||
*
|
||||
* @return CollectionResult
|
||||
*/
|
||||
public function getList(
|
||||
array $filter = [],
|
||||
array $sorting = [],
|
||||
array $columns = [],
|
||||
array $includes = [],
|
||||
$page = 1,
|
||||
$paging = 20
|
||||
) {
|
||||
/** @var SelectQuery $selectAll */
|
||||
$selectAll = $this->selectAllQuery();
|
||||
|
||||
if (!$selectAll) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$selectAll instanceof SelectQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'selectAllQuery() must return an instance of %s', SelectQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
// Suchfilter und Sortierung hinzufügen
|
||||
$selectAll = $this->applySelectFilter($selectAll, [
|
||||
SelectFilterInterface::TYPE_SEARCHING => $filter,
|
||||
SelectFilterInterface::TYPE_SORTING => $sorting,
|
||||
]);
|
||||
|
||||
// Filter hinzufügen
|
||||
//$selectAll = $this->appendFilterQuery($filter, $selectAll);
|
||||
//$bindValues = $this->appendFilterBindings($filter, $bindValues);
|
||||
|
||||
// Sortierung hinzufügen
|
||||
//$selectAll = $this->appendSorting($sorting, $selectAll);
|
||||
|
||||
/*echo "<pre>";
|
||||
echo $selectAll->getStatement();
|
||||
var_dump($selectAll->getBindValues());
|
||||
echo "</pre>";
|
||||
exit;*/
|
||||
|
||||
// Ergebnisse ermitteln
|
||||
$selectList = clone $selectAll;
|
||||
if (!empty($columns)) {
|
||||
$selectList->resetCols()->cols($columns);
|
||||
}
|
||||
$selectList->page($page)->setPaging($paging);
|
||||
$items = $this->db->fetchAll(
|
||||
$selectList->getStatement(),
|
||||
$selectList->getBindValues()
|
||||
);
|
||||
|
||||
if (count($items) === 0) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
// Gesamtanzahl der Ergebnisse ermitteln
|
||||
$selectCount = clone $selectAll;
|
||||
$selectCount->resetOrderBy()->resetCols()->cols(['COUNT(*)']);
|
||||
$total = (int)$this->db->fetchValue(
|
||||
$selectCount->getStatement(),
|
||||
$selectCount->getBindValues()
|
||||
);
|
||||
$pagination = $this->getPagination($total, count($items), $paging, $page);
|
||||
|
||||
// Includes in Ergebnis integrieren
|
||||
$items = $this->integrateIncludes($includes, $items);
|
||||
|
||||
return new CollectionResult($items, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @param array $columns Spalten überschreiben
|
||||
*
|
||||
* @return CollectionResult
|
||||
*/
|
||||
public function getIds(array $ids, array $columns = [])
|
||||
{
|
||||
/** @var SelectQuery $selectIds */
|
||||
$selectIds = $this->selectIdsQuery();
|
||||
if (!$selectIds) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$selectIds instanceof SelectQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'selectIdsQuery() must return an instance of %s', SelectQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
if (!empty($columns)) {
|
||||
$selectIds->resetCols()->cols($columns);
|
||||
}
|
||||
|
||||
$data = $this->db->fetchAssoc(
|
||||
$selectIds->getStatement(),
|
||||
['ids' => $ids]
|
||||
);
|
||||
|
||||
if (!$data) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
return new CollectionResult($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $includes
|
||||
*
|
||||
* @return ItemResult
|
||||
*/
|
||||
public function getOne($id, array $includes = [])
|
||||
{
|
||||
/** @var SelectQuery $selectOne */
|
||||
$selectOne = $this->selectOneQuery();
|
||||
if (!$selectOne) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$selectOne instanceof SelectQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'selectOneQuery() must return an instance of %s', SelectQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
$data = $this->db->fetchRow($selectOne->getStatement(), ['id' => $id]);
|
||||
|
||||
if (!$data) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
// Includes in Ergebnis integrieren
|
||||
$data = $this->integrateIncludes($includes, $data, false);
|
||||
|
||||
return new ItemResult($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfen ob übergebene ID in Datenbank vorhanden ist
|
||||
*
|
||||
* @param int $id
|
||||
* @param string|null $message Fehlermeldung wenn ID nicht vorhanden ist
|
||||
*/
|
||||
public function checkOrFail($id, $message = null)
|
||||
{
|
||||
/** @var SelectQuery $selectOne */
|
||||
$select = $this->selectOneQuery();
|
||||
if (!$select) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$select instanceof SelectQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'selectOneQuery() must return an instance of %s', SelectQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
$value = $this->db->fetchValue($select->getStatement(), ['id' => $id]);
|
||||
|
||||
if ((int)$value !== (int)$id) {
|
||||
throw new ResourceNotFoundException($message === null ? 'Resource not found' : $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $inputVars
|
||||
* @param array|null $inputMapping Assoc-Array ['Eingabefeld' => 'Datenbankfeld']
|
||||
*
|
||||
* @return ItemResult
|
||||
*/
|
||||
public function edit($id, $inputVars, $inputMapping = null)
|
||||
{
|
||||
$updateQuery = $this->updateQuery();
|
||||
if (!$updateQuery) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$updateQuery instanceof UpdateQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'updateQuery() must return an instance of %s', UpdateQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
// Eingabe validieren
|
||||
$this->validateData($inputVars, $id);
|
||||
$inputVars['id'] = $id;
|
||||
|
||||
// Eingabe- zu Datenbankfeld mappen
|
||||
$inputVars = $this->mapInputData($inputVars, $inputMapping);
|
||||
|
||||
$bindValues = [];
|
||||
foreach ($inputVars as $inputKey => $inputVal) {
|
||||
$updateQuery->col($inputKey);
|
||||
$bindValues[$inputKey] = $inputVal;
|
||||
}
|
||||
|
||||
$this->db->perform($updateQuery->getStatement(), $bindValues);
|
||||
|
||||
// Bei Erfolg die geänderte Resource zurückliefern; mit Success-Flag
|
||||
$result = $this->getOne($id);
|
||||
$result->setSuccess(true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $inputVars
|
||||
* @param array|null $inputMapping Assoc-Array ['Eingabefeld' => 'Datenbankfeld']
|
||||
*
|
||||
* @return ItemResult
|
||||
*/
|
||||
public function insert($inputVars, $inputMapping = null)
|
||||
{
|
||||
$insertQuery = $this->insertQuery();
|
||||
if (!$insertQuery) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$insertQuery instanceof InsertQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'insertQuery() must return an instance of %s', InsertQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
// Eingabe validieren
|
||||
$this->validateData($inputVars);
|
||||
|
||||
// Eingabe- zu Datenbankfeld mappen
|
||||
$inputVars = $this->mapInputData($inputVars, $inputMapping);
|
||||
|
||||
$bindValues = [];
|
||||
foreach ($inputVars as $inputKey => $inputVal) {
|
||||
$insertQuery->col($inputKey);
|
||||
$bindValues[$inputKey] = $inputVal;
|
||||
}
|
||||
|
||||
$this->db->perform($insertQuery->getStatement(), $bindValues);
|
||||
$id = $this->db->lastInsertId();
|
||||
|
||||
// Bei Erfolg die angelegte Resource zurückliefern; mit Success-Flag
|
||||
$result = $this->getOne($id);
|
||||
$result->setSuccess(true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return ItemResult
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$deleteQuery = $this->deleteQuery();
|
||||
if (!$deleteQuery) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$deleteQuery instanceof DeleteQuery && !$deleteQuery instanceof UpdateQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'deleteQuery() must return an instance of %s or %s', DeleteQuery::class, UpdateQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
try {
|
||||
$this->db->perform($deleteQuery->getStatement(), ['id' => $id]);
|
||||
$success = true;
|
||||
} catch (Exception $e) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$result = new ItemResult(['id' => $id]);
|
||||
$result->setSuccess($success);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eingabe- zu Datenbankfeld mappen
|
||||
*
|
||||
* @param array $inputVars
|
||||
* @param array|null $inputMapping Assoc-Array ['Eingabefeld' => 'Datenbankfeld']
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function mapInputData($inputVars, $inputMapping = null)
|
||||
{
|
||||
if (empty($inputMapping)) {
|
||||
return $inputVars;
|
||||
}
|
||||
|
||||
foreach ($inputMapping as $inputKey => $dbKey) {
|
||||
if (empty($inputKey) || empty($dbKey)) {
|
||||
continue;
|
||||
}
|
||||
if ($inputKey === $dbKey) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($inputKey, $inputVars)) {
|
||||
$inputVars[$dbKey] = $inputVars[$inputKey];
|
||||
unset($inputVars[$inputKey]);
|
||||
}
|
||||
}
|
||||
|
||||
return $inputVars;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $itemsTotal
|
||||
* @param int $itemsCurrent
|
||||
* @param int $itemsPerPage
|
||||
* @param int $pageCurrent
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPagination($itemsTotal, $itemsCurrent, $itemsPerPage, $pageCurrent)
|
||||
{
|
||||
return [
|
||||
'items_per_page' => (int)$itemsPerPage,
|
||||
'items_current' => (int)$itemsCurrent,
|
||||
'items_total' => (int)$itemsTotal,
|
||||
'page_current' => (int)$pageCurrent,
|
||||
'page_last' => (int)ceil($itemsTotal / $itemsPerPage),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $resourceClass
|
||||
*
|
||||
* @return AbstractResource
|
||||
*/
|
||||
protected function getResource($resourceClass)
|
||||
{
|
||||
return new $resourceClass(
|
||||
$this->db,
|
||||
$this->validator
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class AddressResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'adresse';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'rolle' => 'ar.rolle %LIKE%',
|
||||
'projekt' => 'a.projekt =',
|
||||
'firma' => 'a.firma =',
|
||||
'typ' => 'a.typ LIKE',
|
||||
'sprache' => 'a.sprache LIKE',
|
||||
'waehrung' => 'a.waehrung LIKE',
|
||||
'land' => 'a.land LIKE',
|
||||
'name' => 'a.name %LIKE%',
|
||||
'name_equals' => 'a.name LIKE',
|
||||
'name_startswith' => 'a.name LIKE%',
|
||||
'name_endswith' => 'a.name %LIKE',
|
||||
'kundennummer' => 'a.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 'a.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 'a.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 'a.kundennummer %LIKE',
|
||||
'lieferantennummer' => 'a.lieferantennummer %LIKE%',
|
||||
'lieferantennummer_equals' => 'a.lieferantennummer LIKE',
|
||||
'lieferantennummer_startswith' => 'a.lieferantennummer LIKE%',
|
||||
'lieferantennummer_endswith' => 'a.lieferantennummer %LIKE',
|
||||
'mitarbeiternummer' => 'a.mitarbeiternummer %LIKE%',
|
||||
'mitarbeiternummer_equals' => 'a.mitarbeiternummer LIKE',
|
||||
'mitarbeiternummer_startswith' => 'a.mitarbeiternummer LIKE%',
|
||||
'mitarbeiternummer_endswith' => 'a.mitarbeiternummer %LIKE',
|
||||
'email' => 'a.email %LIKE%',
|
||||
'email_equals' => 'a.email LIKE',
|
||||
'email_startswith' => 'a.email LIKE%',
|
||||
'email_endswith' => 'a.email %LIKE',
|
||||
'freifeld1' => 'a.freifeld1 %LIKE%',
|
||||
'freifeld2' => 'a.freifeld2 %LIKE%',
|
||||
'freifeld3' => 'a.freifeld3 %LIKE%',
|
||||
'freifeld4' => 'a.freifeld4 %LIKE%',
|
||||
'freifeld5' => 'a.freifeld5 %LIKE%',
|
||||
'freifeld6' => 'a.freifeld6 %LIKE%',
|
||||
'freifeld7' => 'a.freifeld7 %LIKE%',
|
||||
'freifeld8' => 'a.freifeld8 %LIKE%',
|
||||
'freifeld9' => 'a.freifeld9 %LIKE%',
|
||||
'freifeld10' => 'a.freifeld10 %LIKE%',
|
||||
'freifeld1_equals' => 'a.freifeld1 LIKE',
|
||||
'freifeld2_equals' => 'a.freifeld2 LIKE',
|
||||
'freifeld3_equals' => 'a.freifeld3 LIKE',
|
||||
'freifeld4_equals' => 'a.freifeld4 LIKE',
|
||||
'freifeld5_equals' => 'a.freifeld5 LIKE',
|
||||
'freifeld6_equals' => 'a.freifeld6 LIKE',
|
||||
'freifeld7_equals' => 'a.freifeld7 LIKE',
|
||||
'freifeld8_equals' => 'a.freifeld8 LIKE',
|
||||
'freifeld9_equals' => 'a.freifeld9 LIKE',
|
||||
'freifeld10_equals' => 'a.freifeld10 LIKE',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'name' => 'a.name',
|
||||
'kundennummer' => 'a.kundennummer',
|
||||
'lieferantennummer' => 'a.lieferantennummer',
|
||||
'mitarbeiternummer' => 'a.mitarbeiternummer',
|
||||
]);
|
||||
|
||||
/*$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'bezeichnung' => 'required',
|
||||
'type' => 'required',
|
||||
'projekt' => 'numeric',
|
||||
'netto' => 'boolean',
|
||||
'aktiv' => 'boolean',
|
||||
]);*/
|
||||
|
||||
/*$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'a.id',
|
||||
'ar.rolle',
|
||||
'a.typ',
|
||||
'a.marketingsperre',
|
||||
'a.trackingsperre',
|
||||
'a.rechnungsadresse',
|
||||
'a.sprache',
|
||||
'a.name',
|
||||
'a.abteilung',
|
||||
'a.unterabteilung',
|
||||
'a.ansprechpartner',
|
||||
'a.land',
|
||||
'a.strasse',
|
||||
'a.ort',
|
||||
'a.plz',
|
||||
'a.telefon',
|
||||
'a.telefax',
|
||||
'a.mobil',
|
||||
'a.email',
|
||||
'a.ustid',
|
||||
'a.ust_befreit',
|
||||
'a.passwort_gesendet',
|
||||
'a.sonstiges',
|
||||
'a.adresszusatz',
|
||||
'a.kundenfreigabe',
|
||||
'a.steuer',
|
||||
'a.logdatei',
|
||||
'a.kundennummer',
|
||||
'a.lieferantennummer',
|
||||
'a.mitarbeiternummer',
|
||||
'a.konto',
|
||||
'a.blz',
|
||||
'a.bank',
|
||||
'a.inhaber',
|
||||
'a.swift',
|
||||
'a.iban',
|
||||
'a.waehrung',
|
||||
'a.paypal',
|
||||
'a.paypalinhaber',
|
||||
'a.paypalwaehrung',
|
||||
'a.projekt',
|
||||
'a.partner',
|
||||
'a.zahlungsweise',
|
||||
'a.zahlungszieltage',
|
||||
'a.zahlungszieltageskonto',
|
||||
'a.zahlungszielskonto',
|
||||
'a.versandart',
|
||||
'a.kundennummerlieferant',
|
||||
'a.zahlungsweiselieferant',
|
||||
'a.zahlungszieltagelieferant',
|
||||
'a.zahlungszieltageskontolieferant',
|
||||
'a.zahlungszielskontolieferant',
|
||||
'a.versandartlieferant',
|
||||
'a.geloescht',
|
||||
'a.firma',
|
||||
'a.webid',
|
||||
'a.vorname',
|
||||
'a.kennung',
|
||||
'a.sachkonto',
|
||||
'a.filiale',
|
||||
'a.vertrieb',
|
||||
'a.innendienst',
|
||||
'a.verbandsnummer',
|
||||
'a.abweichendeemailab',
|
||||
'a.portofrei_aktiv',
|
||||
'a.portofreiab',
|
||||
'a.infoauftragserfassung',
|
||||
'a.mandatsreferenz',
|
||||
'a.mandatsreferenzdatum',
|
||||
'a.mandatsreferenzaenderung',
|
||||
'a.glaeubigeridentnr',
|
||||
'a.kreditlimit',
|
||||
'a.tour',
|
||||
'a.zahlungskonditionen_festschreiben',
|
||||
'a.rabatte_festschreiben',
|
||||
'a.mlmaktiv',
|
||||
'a.mlmvertragsbeginn',
|
||||
'a.mlmlizenzgebuehrbis',
|
||||
'a.mlmfestsetzenbis',
|
||||
'a.mlmfestsetzen',
|
||||
'a.mlmmindestpunkte',
|
||||
'a.mlmwartekonto',
|
||||
'a.abweichende_rechnungsadresse',
|
||||
'a.rechnung_vorname',
|
||||
'a.rechnung_name',
|
||||
'a.rechnung_titel',
|
||||
'a.rechnung_typ',
|
||||
'a.rechnung_strasse',
|
||||
'a.rechnung_ort',
|
||||
'a.rechnung_plz',
|
||||
'a.rechnung_ansprechpartner',
|
||||
'a.rechnung_land',
|
||||
'a.rechnung_abteilung',
|
||||
'a.rechnung_unterabteilung',
|
||||
'a.rechnung_adresszusatz',
|
||||
'a.rechnung_telefon',
|
||||
'a.rechnung_telefax',
|
||||
'a.rechnung_anschreiben',
|
||||
'a.rechnung_email',
|
||||
'a.geburtstag',
|
||||
'a.rolledatum',
|
||||
'a.liefersperre',
|
||||
'a.liefersperregrund',
|
||||
'a.mlmpositionierung',
|
||||
'a.steuernummer',
|
||||
'a.steuerbefreit',
|
||||
'a.mlmmitmwst',
|
||||
'a.mlmabrechnung',
|
||||
'a.mlmwaehrungauszahlung',
|
||||
'a.mlmauszahlungprojekt',
|
||||
'a.sponsor',
|
||||
'a.geworbenvon',
|
||||
'a.logfile',
|
||||
'a.kalender_aufgaben',
|
||||
'a.verrechnungskontoreisekosten',
|
||||
'a.usereditid',
|
||||
'a.useredittimestamp',
|
||||
'a.rabatt',
|
||||
'a.provision',
|
||||
'a.rabattinformation',
|
||||
'a.rabatt1',
|
||||
'a.rabatt2',
|
||||
'a.rabatt3',
|
||||
'a.rabatt4',
|
||||
'a.rabatt5',
|
||||
'a.internetseite',
|
||||
'a.bonus1',
|
||||
'a.bonus1_ab',
|
||||
'a.bonus2',
|
||||
'a.bonus2_ab',
|
||||
'a.bonus3',
|
||||
'a.bonus3_ab',
|
||||
'a.bonus4',
|
||||
'a.bonus4_ab',
|
||||
'a.bonus5',
|
||||
'a.bonus5_ab',
|
||||
'a.bonus6',
|
||||
'a.bonus6_ab',
|
||||
'a.bonus7',
|
||||
'a.bonus7_ab',
|
||||
'a.bonus8',
|
||||
'a.bonus8_ab',
|
||||
'a.bonus9',
|
||||
'a.bonus9_ab',
|
||||
'a.bonus10',
|
||||
'a.bonus10_ab',
|
||||
'a.rechnung_periode',
|
||||
'a.rechnung_anzahlpapier',
|
||||
'a.rechnung_permail',
|
||||
'a.titel',
|
||||
'a.anschreiben',
|
||||
'a.nachname',
|
||||
'a.arbeitszeitprowoche',
|
||||
'a.folgebestaetigungsperre',
|
||||
'a.lieferantennummerbeikunde',
|
||||
'a.verein_mitglied_seit',
|
||||
'a.verein_mitglied_bis',
|
||||
'a.verein_mitglied_aktiv',
|
||||
'a.verein_spendenbescheinigung',
|
||||
'a.freifeld1',
|
||||
'a.freifeld2',
|
||||
'a.freifeld3',
|
||||
'a.freifeld4',
|
||||
'a.freifeld5',
|
||||
'a.freifeld6',
|
||||
'a.freifeld7',
|
||||
'a.freifeld8',
|
||||
'a.freifeld9',
|
||||
'a.freifeld10',
|
||||
'a.rechnung_papier',
|
||||
'a.angebot_cc',
|
||||
'a.auftrag_cc',
|
||||
'a.rechnung_cc',
|
||||
'a.gutschrift_cc',
|
||||
'a.lieferschein_cc',
|
||||
'a.bestellung_cc',
|
||||
'a.angebot_fax_cc',
|
||||
'a.auftrag_fax_cc',
|
||||
'a.rechnung_fax_cc',
|
||||
'a.gutschrift_fax_cc',
|
||||
'a.lieferschein_fax_cc',
|
||||
'a.bestellung_fax_cc',
|
||||
'a.abperfax',
|
||||
'a.abpermail',
|
||||
'a.kassiereraktiv',
|
||||
'a.kassierernummer',
|
||||
'a.kassiererprojekt',
|
||||
'a.portofreilieferant_aktiv',
|
||||
'a.portofreiablieferant',
|
||||
'a.mandatsreferenzart',
|
||||
'a.mandatsreferenzwdhart',
|
||||
'a.serienbrief',
|
||||
'a.kundennummer_buchhaltung',
|
||||
'a.lieferantennummer_buchhaltung',
|
||||
'a.lead',
|
||||
'a.zahlungsweiseabo',
|
||||
'a.bundesland',
|
||||
'a.mandatsreferenzhinweis',
|
||||
'a.geburtstagkalender',
|
||||
'a.geburtstagskarte',
|
||||
'a.liefersperredatum',
|
||||
'a.umsatzsteuer_lieferant',
|
||||
'a.lat',
|
||||
'a.lng',
|
||||
'a.art',
|
||||
'a.angebot_email',
|
||||
'a.auftrag_email',
|
||||
'a.rechnungs_email',
|
||||
'a.gutschrift_email',
|
||||
'a.lieferschein_email',
|
||||
'a.bestellung_email',
|
||||
'a.firmensepa',
|
||||
'a.anzeigesteuerbelege',
|
||||
'a.gln',
|
||||
'a.rechnung_gln',
|
||||
'a.keinealtersabfrage',
|
||||
'a.lieferbedingung',
|
||||
'a.mlmintranetgesamtestruktur',
|
||||
'a.kommissionskonsignationslager',
|
||||
'a.zollinformationen',
|
||||
'a.bundesstaat',
|
||||
'a.rechnung_bundesstaat',
|
||||
'a.lieferschwellenichtanwenden',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS a')
|
||||
->joinSubSelect(
|
||||
'LEFT',
|
||||
'SELECT ar.adresse, GROUP_CONCAT(LOWER(ar.subjekt)) AS rolle ' .
|
||||
'FROM adresse_rolle AS ar ' .
|
||||
'WHERE (ar.bis = \'0000-00-00\' OR ar.bis >= CURDATE())' .
|
||||
'AND (ar.von = \'0000-00-00\' OR ar.von <= CURDATE())' .
|
||||
'AND (ar.subjekt = \'Kunde\' OR ar.subjekt = \'Lieferant\') ' .
|
||||
'GROUP BY ar.adresse ',
|
||||
'ar',
|
||||
'a.id = ar.adresse'
|
||||
)
|
||||
->where('a.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class AddressTypeResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'adresse_typ';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 't.bezeichnung %LIKE%',
|
||||
'bezeichnung_exakt' => 't.bezeichnung LIKE',
|
||||
'type' => 't.type LIKE',
|
||||
'projekt' => 't.projekt =',
|
||||
'netto' => 't.netto =',
|
||||
'aktiv' => 't.aktiv =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 't.bezeichnung',
|
||||
'type' => 't.type',
|
||||
'projekt' => 't.projekt',
|
||||
'netto' => 't.netto',
|
||||
'aktiv' => 't.aktiv',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'bezeichnung' => 'required',
|
||||
'type' => 'required',
|
||||
'projekt' => 'numeric',
|
||||
'netto' => 'boolean',
|
||||
'aktiv' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
't.id',
|
||||
't.type',
|
||||
't.bezeichnung',
|
||||
't.projekt',
|
||||
't.netto',
|
||||
't.aktiv',
|
||||
])->from(self::TABLE_NAME . ' AS t')
|
||||
->where('t.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('t.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('t.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class ArticleCategoryResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'artikelkategorien';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 'k.bezeichnung %LIKE%',
|
||||
'bezeichnung_exakt' => 'k.bezeichnung LIKE',
|
||||
'projekt' => 'k.projekt =',
|
||||
'parent' => 'k.parent =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'k.bezeichnung',
|
||||
'projekt' => 'k.projekt',
|
||||
'parent' => 'k.parent',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'id_ext' => 'not_present', // @todo
|
||||
'bezeichnung' => 'required|unique:artikelkategorien,bezeichnung',
|
||||
'next_number' => 'numeric',
|
||||
'projekt' => 'numeric',
|
||||
'parent' => 'numeric',
|
||||
'externenummer' => 'numeric',
|
||||
'geloescht' => 'in:0,1',
|
||||
//'id_ext' => 'numeric', @todo
|
||||
// @todo Steuerfelder
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols(['k.*', 'am.id_ext'])->from(self::TABLE_NAME . ' AS k')->where('k.geloescht <> 1')
|
||||
->leftJoin(
|
||||
'api_mapping AS am',
|
||||
'am.id_int = k.id AND am.tabelle = ' . $this->db->escapeString('artikelkategorien')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('k.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('k.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class ArticleFileResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'datei';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
/*$this->registerFilterParams([
|
||||
'bezeichnung' => 'd.bezeichnung %LIKE%',
|
||||
'bezeichnung_exakt' => 'd.bezeichnung LIKE',
|
||||
'projekt' => 'd.projekt =',
|
||||
'parent' => 'd.parent =',
|
||||
]);*/
|
||||
|
||||
/*$this->registerSortingParams([
|
||||
'bezeichnung' => 'd.bezeichnung',
|
||||
'projekt' => 'd.projekt',
|
||||
'parent' => 'd.parent',
|
||||
]);*/
|
||||
|
||||
/*$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'id_ext' => 'not_present', // @todo
|
||||
'bezeichnung' => 'required|unique:artikelkategorien,bezeichnung',
|
||||
'next_number' => 'numeric',
|
||||
'projekt' => 'numeric',
|
||||
'parent' => 'numeric',
|
||||
'externenummer' => 'numeric',
|
||||
'geloescht' => 'in:0,1',
|
||||
//'id_ext' => 'numeric', @todo
|
||||
// @todo Steuerfelder
|
||||
]);*/
|
||||
|
||||
/*$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'd.id',
|
||||
'd.titel',
|
||||
'd.beschreibung',
|
||||
'ds.subjekt',
|
||||
'ds.parameter AS artikel',
|
||||
'd.nummer',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS d')
|
||||
->where('d.geloescht <> 1')
|
||||
->innerJoin(
|
||||
'datei_stichwoerter AS ds',
|
||||
'd.id = ds.datei AND ds.objekt = ' . $this->db->escapeString('Artikel')
|
||||
)
|
||||
/*->innerJoin(
|
||||
'datei_version AS dv',
|
||||
'd.id = dv.datei'
|
||||
)*/
|
||||
/*->joinSubSelect(
|
||||
'INNER',
|
||||
'SELECT MAX(dv.version) AS max_version, dv.datei, dv.ersteller, dv.datum, dv.bemerkung '.
|
||||
'FROM datei_version AS dv '.
|
||||
'GROUP BY dv.datei, dv.ersteller, dv.datum, dv.bemerkung',
|
||||
'dv',
|
||||
'd.id = dv.datei'
|
||||
)*/
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class ArticleResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'artikel';
|
||||
|
||||
/** @var \Api $legacyApi */
|
||||
private $legacyApi;
|
||||
|
||||
/**
|
||||
* @param \Api $api
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLegacyApi($api)
|
||||
{
|
||||
$this->legacyApi = $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'typ' => 'a.typ LIKE',
|
||||
'name_de' => 'a.name_de %LIKE%',
|
||||
'name_de_exakt' => 'a.name_de LIKE',
|
||||
'name_de_startswith' => 'a.name_de LIKE%',
|
||||
'name_de_endswith' => 'a.name_de %LIKE',
|
||||
'name_de_equals' => 'a.name_de LIKE',
|
||||
'name_en' => 'a.name_en %LIKE%',
|
||||
'name_en_exakt' => 'a.name_en LIKE',
|
||||
'name_en_startswith' => 'a.name_en LIKE%',
|
||||
'name_en_endswith' => 'a.name_en %LIKE',
|
||||
'name_en_equals' => 'a.name_en LIKE',
|
||||
'nummer' => 'a.nummer %LIKE%',
|
||||
'nummer_exakt' => 'a.nummer LIKE',
|
||||
'nummer_startswith' => 'a.nummer LIKE%',
|
||||
'nummer_endswith' => 'a.nummer %LIKE',
|
||||
'nummer_equals' => 'a.nummer LIKE',
|
||||
'projekt' => 'a.projekt =',
|
||||
'adresse' => 'a.adresse =',
|
||||
'katalog' => 'a.katalog =',
|
||||
'firma' => 'a.firma =',
|
||||
'ausverkauft' => 'a.ausverkauft =',
|
||||
'startseite' => 'a.startseite =',
|
||||
'topseller' => 'a.topseller =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'name_de' => 'a.name_de',
|
||||
'name_en' => 'a.name_en',
|
||||
'nummer' => 'a.nummer',
|
||||
'typ' => 'a.typ',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'a.shop' => 'not_present',
|
||||
'a.shop2' => 'not_present',
|
||||
'a.shop3' => 'not_present',
|
||||
'a.usereditid' => 'not_present',
|
||||
'a.useredittimestamp' => 'not_present',
|
||||
'a.intern_gesperrtuser' => 'not_present',
|
||||
'a.inbearbeitunguser' => 'not_present',
|
||||
'nummer' => 'required|unique:artikel,nummer',
|
||||
'projekt' => 'numeric',
|
||||
'adresse' => 'numeric',
|
||||
'katalog' => 'numeric',
|
||||
'firma' => 'numeric',
|
||||
'ausverkauft' => 'in:0,1',
|
||||
'geloescht' => 'in:0,1',
|
||||
|
||||
// Keine Default-Values
|
||||
/*'checksum' => 'present',
|
||||
'kurztext_de' => 'present',
|
||||
'kurztext_en' => 'present',
|
||||
'beschreibung_de' => 'present',
|
||||
'beschreibung_en' => 'present',
|
||||
'uebersicht_de' => 'present',
|
||||
'uebersicht_en' => 'present',
|
||||
'links_de' => 'present',
|
||||
'links_en' => 'present',
|
||||
'startseite_de' => 'present',
|
||||
'startseite_en' => 'present',*/
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
'verkaufspreise' => [
|
||||
'key' => 'verkaufspreise',
|
||||
'filter' => [
|
||||
['property' => 'artikel', 'value' => ':id'],
|
||||
],
|
||||
'sort' => ['menge' => 'ASC'],
|
||||
'resource' => SalesPriceResource::class,
|
||||
],
|
||||
'dateien' => [
|
||||
'key' => 'dateien',
|
||||
'filter' => [
|
||||
['property' => 'artikel', 'value' => ':id'],
|
||||
],
|
||||
'resource' => ArticleFileResource::class,
|
||||
],
|
||||
'lagerbestand' => [
|
||||
/**
|
||||
* Sonderfall
|
||||
*
|
||||
* @see ArticleResource::integrateIncludes
|
||||
*/
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function integrateIncludes(array $includes, array &$items, $isCollection = true)
|
||||
{
|
||||
// Ausnahme für "lagerbestand"-Include
|
||||
$lagerbestandIncludeKey = array_search('lagerbestand', $includes, true);
|
||||
if ($lagerbestandIncludeKey !== false) {
|
||||
|
||||
// Mehrere Artikel
|
||||
if ($isCollection) {
|
||||
foreach ($items as &$item) {
|
||||
$articleId = $item['id'];
|
||||
$istLagerartikel = (int)$item['lagerartikel'] === 1;
|
||||
$item['lagerbestand'] =
|
||||
$istLagerartikel
|
||||
? $this->legacyApi->app->erp->ArtikelAnzahlVerkaufbar($articleId, 0, 0, 0, 0, true)
|
||||
: [];
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
|
||||
// Einzelner Artikel
|
||||
if (!$isCollection) {
|
||||
$articleId = $items['id'];
|
||||
$istLagerartikel = (int)$items['lagerartikel'] === 1;
|
||||
$items['lagerbestand'] =
|
||||
$istLagerartikel
|
||||
? $this->legacyApi->app->erp->ArtikelAnzahlVerkaufbar($articleId, 0, 0, 0, 0, true)
|
||||
: [];
|
||||
}
|
||||
|
||||
unset($includes[$lagerbestandIncludeKey]);
|
||||
}
|
||||
|
||||
// Andere Includes normal ausführen
|
||||
return parent::integrateIncludes($includes, $items, $isCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
//'a.*',
|
||||
'a.id',
|
||||
'a.typ',
|
||||
'a.nummer',
|
||||
'a.checksum',
|
||||
'a.projekt',
|
||||
'a.inaktiv',
|
||||
'a.ausverkauft',
|
||||
'a.warengruppe',
|
||||
'a.name_de',
|
||||
'a.name_en',
|
||||
'a.kurztext_de',
|
||||
'a.kurztext_en',
|
||||
'a.beschreibung_de',
|
||||
'a.beschreibung_en',
|
||||
'a.uebersicht_de',
|
||||
'a.uebersicht_en',
|
||||
'a.links_de',
|
||||
'a.links_en',
|
||||
'a.startseite_de',
|
||||
'a.startseite_en',
|
||||
'a.standardbild',
|
||||
'a.herstellerlink',
|
||||
'a.hersteller',
|
||||
'a.teilbar',
|
||||
'a.nteile',
|
||||
'a.seriennummern',
|
||||
'a.lager_platz',
|
||||
'a.lieferzeit',
|
||||
'a.lieferzeitmanuell',
|
||||
'a.sonstiges',
|
||||
'a.gewicht',
|
||||
'a.endmontage',
|
||||
'a.funktionstest',
|
||||
'a.artikelcheckliste',
|
||||
'a.stueckliste',
|
||||
'a.juststueckliste',
|
||||
'a.barcode',
|
||||
'a.hinzugefuegt',
|
||||
'a.pcbdecal',
|
||||
'a.lagerartikel',
|
||||
'a.porto',
|
||||
'a.chargenverwaltung',
|
||||
'a.provisionsartikel',
|
||||
'a.gesperrt',
|
||||
'a.sperrgrund',
|
||||
'a.geloescht',
|
||||
'a.gueltigbis',
|
||||
'a.umsatzsteuer',
|
||||
'a.klasse',
|
||||
'a.adresse',
|
||||
'a.shopartikel',
|
||||
'a.unishopartikel',
|
||||
'a.journalshopartikel',
|
||||
'a.katalog',
|
||||
'a.katalogtext_de',
|
||||
'a.katalogtext_en',
|
||||
'a.katalogbezeichnung_de',
|
||||
'a.katalogbezeichnung_en',
|
||||
'a.neu',
|
||||
'a.topseller',
|
||||
'a.startseite',
|
||||
'a.wichtig',
|
||||
'a.mindestlager',
|
||||
'a.mindestbestellung',
|
||||
'a.partnerprogramm_sperre',
|
||||
'a.internerkommentar',
|
||||
'a.intern_gesperrt',
|
||||
//'a.intern_gesperrtuser',
|
||||
'a.intern_gesperrtgrund',
|
||||
'a.inbearbeitung',
|
||||
//'a.inbearbeitunguser',
|
||||
'a.cache_lagerplatzinhaltmenge',
|
||||
'a.internkommentar',
|
||||
'a.firma',
|
||||
'a.logdatei',
|
||||
'a.anabregs_text',
|
||||
'a.autobestellung',
|
||||
'a.produktion',
|
||||
'a.herstellernummer',
|
||||
'a.restmenge',
|
||||
'a.mlmdirektpraemie',
|
||||
'a.keineeinzelartikelanzeigen',
|
||||
'a.mindesthaltbarkeitsdatum',
|
||||
'a.letzteseriennummer',
|
||||
'a.individualartikel',
|
||||
'a.keinrabatterlaubt',
|
||||
'a.rabatt',
|
||||
'a.rabatt_prozent',
|
||||
'a.geraet',
|
||||
'a.serviceartikel',
|
||||
'a.autoabgleicherlaubt',
|
||||
'a.pseudopreis',
|
||||
'a.freigabenotwendig',
|
||||
'a.freigaberegel',
|
||||
'a.nachbestellt',
|
||||
'a.ean',
|
||||
'a.mlmpunkte',
|
||||
'a.mlmbonuspunkte',
|
||||
'a.mlmkeinepunkteeigenkauf',
|
||||
//'a.shop', // Altlasten; wird zukünftig über artikel_shop gemacht
|
||||
//'a.shop2',
|
||||
//'a.shop3',
|
||||
//'a.usereditid',
|
||||
//'a.useredittimestamp',
|
||||
'a.einheit',
|
||||
'a.webid',
|
||||
'a.lieferzeitmanuell_en',
|
||||
'a.variante',
|
||||
'a.variante_von',
|
||||
'a.produktioninfo',
|
||||
'a.sonderaktion',
|
||||
'a.sonderaktion_en',
|
||||
'a.autolagerlampe',
|
||||
'a.leerfeld',
|
||||
'a.zolltarifnummer',
|
||||
'a.herkunftsland',
|
||||
'a.laenge',
|
||||
'a.breite',
|
||||
'a.hoehe',
|
||||
'a.gebuehr',
|
||||
'a.pseudolager',
|
||||
'a.downloadartikel',
|
||||
'a.matrixprodukt',
|
||||
'a.steuer_erloese_inland_normal',
|
||||
'a.steuer_aufwendung_inland_normal',
|
||||
'a.steuer_erloese_inland_ermaessigt',
|
||||
'a.steuer_aufwendung_inland_ermaessigt',
|
||||
'a.steuer_erloese_inland_steuerfrei',
|
||||
'a.steuer_aufwendung_inland_steuerfrei',
|
||||
'a.steuer_erloese_inland_innergemeinschaftlich',
|
||||
'a.steuer_aufwendung_inland_innergemeinschaftlich',
|
||||
'a.steuer_erloese_inland_eunormal',
|
||||
'a.steuer_erloese_inland_nichtsteuerbar',
|
||||
'a.steuer_erloese_inland_euermaessigt',
|
||||
'a.steuer_aufwendung_inland_nichtsteuerbar',
|
||||
'a.steuer_aufwendung_inland_eunormal',
|
||||
'a.steuer_aufwendung_inland_euermaessigt',
|
||||
'a.steuer_erloese_inland_export',
|
||||
'a.steuer_aufwendung_inland_import',
|
||||
'a.steuer_art_produkt',
|
||||
'a.steuer_art_produkt_download',
|
||||
'a.metadescription_de',
|
||||
'a.metadescription_en',
|
||||
'a.metakeywords_de',
|
||||
'a.metakeywords_en',
|
||||
'a.anabregs_text_en',
|
||||
'a.externeproduktion',
|
||||
'a.bildvorschau',
|
||||
'a.inventursperre',
|
||||
'a.variante_kopie',
|
||||
'a.unikat',
|
||||
'a.generierenummerbeioption',
|
||||
'a.allelieferanten',
|
||||
'a.tagespreise',
|
||||
'a.rohstoffe',
|
||||
'a.ohnepreisimpdf',
|
||||
'a.provisionssperre',
|
||||
'a.dienstleistung',
|
||||
'a.inventurekaktiv',
|
||||
'a.inventurek',
|
||||
'a.hinweis_einfuegen',
|
||||
'a.etikettautodruck',
|
||||
'a.lagerkorrekturwert',
|
||||
'a.autodrucketikett',
|
||||
'a.steuertext_innergemeinschaftlich',
|
||||
'a.steuertext_export',
|
||||
'a.formelmenge',
|
||||
'a.formelpreis',
|
||||
'a.ursprungsregion',
|
||||
'a.bestandalternativartikel',
|
||||
'a.metatitle_de',
|
||||
'a.metatitle_en',
|
||||
'a.vkmeldungunterdruecken',
|
||||
'a.altersfreigabe',
|
||||
'a.unikatbeikopie',
|
||||
'a.steuergruppe',
|
||||
'a.keinskonto',
|
||||
'a.berechneterek',
|
||||
'a.verwendeberechneterek',
|
||||
'a.berechneterekwaehrung',
|
||||
'a.artikelautokalkulation',
|
||||
'a.artikelabschliessenkalkulation',
|
||||
'a.artikelfifokalkulation',
|
||||
'a.freifeld1',
|
||||
'a.freifeld2',
|
||||
'a.freifeld3',
|
||||
'a.freifeld4',
|
||||
'a.freifeld5',
|
||||
'a.freifeld6',
|
||||
'a.freifeld7',
|
||||
'a.freifeld8',
|
||||
'a.freifeld9',
|
||||
'a.freifeld10',
|
||||
'a.freifeld11',
|
||||
'a.freifeld12',
|
||||
'a.freifeld13',
|
||||
'a.freifeld14',
|
||||
'a.freifeld15',
|
||||
'a.freifeld16',
|
||||
'a.freifeld17',
|
||||
'a.freifeld18',
|
||||
'a.freifeld19',
|
||||
'a.freifeld20',
|
||||
'a.freifeld21',
|
||||
'a.freifeld22',
|
||||
'a.freifeld23',
|
||||
'a.freifeld24',
|
||||
'a.freifeld25',
|
||||
'a.freifeld26',
|
||||
'a.freifeld27',
|
||||
'a.freifeld28',
|
||||
'a.freifeld29',
|
||||
'a.freifeld30',
|
||||
'a.freifeld31',
|
||||
'a.freifeld32',
|
||||
'a.freifeld33',
|
||||
'a.freifeld34',
|
||||
'a.freifeld35',
|
||||
'a.freifeld36',
|
||||
'a.freifeld37',
|
||||
'a.freifeld38',
|
||||
'a.freifeld39',
|
||||
'a.freifeld40',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS a')
|
||||
->where('a.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class ArticleSubscriptionGroupResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'abrechnungsartikel_gruppe';
|
||||
|
||||
/** @var array $inputMapping */
|
||||
protected $inputMapping = [
|
||||
'beschreibung' => 'beschreibung2',
|
||||
'bezeichnung' => 'beschreibung',
|
||||
'rabatt' => 'rabatt',
|
||||
'gruppensumme' => 'gruppensumme',
|
||||
'projekt' => 'projekt',
|
||||
'reihenfolge' => 'sort',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $inputValues
|
||||
* @param array|null $inputMapping
|
||||
*
|
||||
* @return Result\ItemResult
|
||||
*/
|
||||
public function insert($inputValues, $inputMapping = null)
|
||||
{
|
||||
$inputValues['extrarechnung'] = 0;
|
||||
|
||||
return parent::insert($inputValues, $this->inputMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $inputVars
|
||||
* @param array|null $inputMapping
|
||||
*
|
||||
* @return Result\ItemResult
|
||||
*/
|
||||
public function edit($id, $inputVars, $inputMapping = null)
|
||||
{
|
||||
return parent::edit($id, $inputVars, $this->inputMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 'g.beschreibung %LIKE%',
|
||||
'bezeichnung_equals' => 'g.beschreibung LIKE',
|
||||
'bezeichnung_startswith' => 'g.beschreibung LIKE%',
|
||||
'bezeichnung_endswith' => 'g.beschreibung %LIKE',
|
||||
'gruppensumme' => 'g.gruppensumme =',
|
||||
'rabatt' => 'g.rabatt =',
|
||||
'rabatt_gt' => 'g.rabatt >',
|
||||
'rabatt_gte' => 'g.rabatt >=',
|
||||
'rabatt_lt' => 'g.rabatt <',
|
||||
'rabatt_lte' => 'g.rabatt <=',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'g.beschreibung',
|
||||
'reihenfolge' => 'g.sort',
|
||||
'rabatt' => 'g.rabatt',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'bezeichnung' => 'required',
|
||||
'rabatt' => 'decimal',
|
||||
'reihenfolge' => 'numeric',
|
||||
'projekt' => 'numeric',
|
||||
'gruppensumme' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'g.id',
|
||||
'g.beschreibung AS bezeichnung',
|
||||
'g.beschreibung2 AS beschreibung',
|
||||
'g.rabatt',
|
||||
'g.gruppensumme',
|
||||
'g.projekt',
|
||||
'g.sort AS reihenfolge',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS g')
|
||||
->where('g.extrarechnung = 0'); // 0 = Gemeinsame Rechnung; 1 = Eigene Rechnung; 2 = Sammelrechnung
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('g.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('g.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class ArticleSubscriptionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'abrechnungsartikel';
|
||||
|
||||
/** @var array $inputMapping */
|
||||
protected $inputMapping = [
|
||||
'reihenfolge' => 'sort',
|
||||
'beschreibung_ersetzen' => 'beschreibungersetzten',
|
||||
'abgerechnet_bis' => 'abgerechnetbis',
|
||||
'dokumenttyp' => 'dokument',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $inputValues
|
||||
* @param array|null $inputMapping
|
||||
*
|
||||
* @return Result\ItemResult
|
||||
*/
|
||||
public function insert($inputValues, $inputMapping = null)
|
||||
{
|
||||
return parent::insert($inputValues, $this->inputMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $inputVars
|
||||
* @param array|null $inputMapping
|
||||
*
|
||||
* @return Result\ItemResult
|
||||
*/
|
||||
public function edit($id, $inputVars, $inputMapping = null)
|
||||
{
|
||||
return parent::edit($id, $inputVars, $this->inputMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'waehrung' => 'aa.waehrung =',
|
||||
'preisart' => 'aa.preisart =',
|
||||
'dokumenttyp' => 'aa.dokument =',
|
||||
'gruppe' => 'aa.gruppe =',
|
||||
'artikel' => 'aa.artikel =',
|
||||
'adresse' => 'aa.adresse =',
|
||||
'kundennummer' => 'ad.kundennummer =',
|
||||
'projekt' => 'aa.projekt =',
|
||||
'bezeichnung' => 'aa.beschreibung %LIKE%',
|
||||
'bezeichnung_equals' => 'aa.beschreibung LIKE',
|
||||
'bezeichnung_startswith' => 'aa.beschreibung LIKE%',
|
||||
'bezeichnung_endswith' => 'aa.beschreibung %LIKE',
|
||||
'rabatt' => 'aa.rabatt =',
|
||||
'rabatt_gt' => 'aa.rabatt >',
|
||||
'rabatt_gte' => 'aa.rabatt >=',
|
||||
'rabatt_lt' => 'aa.rabatt <',
|
||||
'rabatt_lte' => 'aa.rabatt <=',
|
||||
'preis' => 'aa.preis =',
|
||||
'preis_gt' => 'aa.preis >',
|
||||
'preis_gte' => 'aa.preis >=',
|
||||
'preis_lt' => 'aa.preis <',
|
||||
'preis_lte' => 'aa.preis <=',
|
||||
'menge' => 'aa.menge =',
|
||||
'menge_gt' => 'aa.menge >',
|
||||
'menge_gte' => 'aa.menge >=',
|
||||
'menge_lt' => 'aa.menge <',
|
||||
'menge_lte' => 'aa.menge <=',
|
||||
'startdatum' => 'aa.startdatum LIKE',
|
||||
'startdatum_gt' => 'aa.startdatum >',
|
||||
'startdatum_gte' => 'aa.startdatum >=',
|
||||
'startdatum_lt' => 'aa.startdatum <',
|
||||
'startdatum_lte' => 'aa.startdatum <=',
|
||||
'enddatum' => 'aa.enddatum LIKE',
|
||||
'enddatum_gt' => 'aa.enddatum >',
|
||||
'enddatum_gte' => 'aa.enddatum >=',
|
||||
'enddatum_lt' => 'aa.enddatum <',
|
||||
'enddatum_lte' => 'aa.enddatum <=',
|
||||
'abgerechnet_bis' => 'aa.abgerechnetbis LIKE',
|
||||
'abgerechnet_bis_gt' => 'aa.abgerechnetbis >',
|
||||
'abgerechnet_bis_gte' => 'aa.abgerechnetbis >=',
|
||||
'abgerechnet_bis_lt' => 'aa.abgerechnetbis <',
|
||||
'abgerechnet_bis_lte' => 'aa.abgerechnetbis <=',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'aa.bezeichnung',
|
||||
'reihenfolge' => 'aa.sort',
|
||||
'rabatt' => 'aa.rabatt',
|
||||
'preis' => 'aa.preis',
|
||||
'menge' => 'aa.menge',
|
||||
'startdatum' => 'aa.startdatum',
|
||||
'enddatum' => 'aa.enddatum',
|
||||
'abgerechnet_bis' => 'aa.abgerechnetbis',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'abgerechnet_bis' => 'not_present',
|
||||
'beschreibung_ersetzen' => 'in:1,0',
|
||||
'startdatum' => 'date:Y-m-d',
|
||||
'enddatum' => 'date:Y-m-d',
|
||||
'zahlzyklus' => 'numeric',
|
||||
'preis' => 'decimal',
|
||||
'rabatt' => 'decimal',
|
||||
'menge' => 'decimal',
|
||||
'waehrung' => 'upper|length:3',
|
||||
'preisart' => 'in:monat,monatx,jahr,wochen,einmalig,30tage,360tage',
|
||||
'dokumenttyp' => 'in:rechnung,auftrag',
|
||||
'projekt' => 'numeric',
|
||||
'artikel' => 'numeric|db_value:artikel,id',
|
||||
'adresse' => 'numeric',
|
||||
'gruppe' => 'numeric',
|
||||
'reihenfolge' => 'numeric',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'artikel' => [
|
||||
'key' => 'artikel',
|
||||
'resource' => ArticleResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.nummer',
|
||||
'a.name_de',
|
||||
'a.name_en',
|
||||
],
|
||||
],
|
||||
'gruppe' => [
|
||||
'key' => 'gruppe',
|
||||
'resource' => ArticleSubscriptionGroupResource::class,
|
||||
'columns' => [
|
||||
'g.id',
|
||||
'g.beschreibung AS bezeichnung',
|
||||
'g.beschreibung2 AS beschreibung',
|
||||
'g.rabatt',
|
||||
'g.gruppensumme',
|
||||
'g.sort AS reihenfolge',
|
||||
],
|
||||
],
|
||||
'adresse' => [
|
||||
'key' => 'adresse',
|
||||
'resource' => AddressResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.typ',
|
||||
'a.name',
|
||||
'a.ansprechpartner',
|
||||
'a.kundennummer',
|
||||
],
|
||||
],
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'aa.id',
|
||||
'aa.bezeichnung',
|
||||
'aa.beschreibung',
|
||||
'aa.beschreibungersetzten AS beschreibung_ersetzen',
|
||||
//'aa.nummer',
|
||||
'aa.startdatum',
|
||||
'aa.enddatum',
|
||||
'aa.abgerechnetbis AS abgerechnet_bis',
|
||||
'aa.zahlzyklus',
|
||||
'aa.preis',
|
||||
'aa.rabatt',
|
||||
'aa.waehrung',
|
||||
'aa.menge',
|
||||
'aa.preisart', // monat, monatx, jahr, wochen, einmalig
|
||||
'aa.dokument AS dokumenttyp', // rechnung, auftrag
|
||||
'aa.artikel',
|
||||
'aa.gruppe',
|
||||
'aa.adresse',
|
||||
'ad.kundennummer',
|
||||
'aa.sort AS reihenfolge',
|
||||
'aa.projekt',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS aa')
|
||||
->leftJoin('adresse AS ad', 'aa.adresse != 0 AND aa.adresse = ad.id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('aa.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('aa.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeleteQuery
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class CountryResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'laender';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung_de' => 'l.bezeichnung_de %LIKE%',
|
||||
'bezeichnung_en' => 'l.bezeichnung_de %LIKE%',
|
||||
'iso' => 'l.iso =',
|
||||
'eu' => 'l.eu =',
|
||||
'id_ext' => 'am.id_ext =', // @todo
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'l.bezeichnung_de',
|
||||
'bezeichnung_de' => 'l.bezeichnung_de',
|
||||
'bezeichnung_en' => 'l.bezeichnung_en',
|
||||
'iso' => 'l.iso',
|
||||
'eu' => 'l.eu',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'id_ext' => 'not_present', // @todo
|
||||
'bezeichnung_de' => 'required|unique:laender,bezeichnung_de',
|
||||
'bezeichnung_en' => 'required|unique:laender,bezeichnung_en',
|
||||
'iso' => 'required|upper|length:2|unique:laender,iso',
|
||||
'eu' => 'boolean',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols(['l.*', 'am.id_ext'])->from(self::TABLE_NAME . ' AS l')
|
||||
->leftJoin(
|
||||
'api_mapping AS am',
|
||||
'am.id_int = l.id AND am.tabelle = ' . $this->db->escapeString(self::TABLE_NAME)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('l.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('l.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class CrmDocumentResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'dokumente';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'typ' => 'd.typ %LIKE%',
|
||||
'typ_equals' => 'd.typ LIKE',
|
||||
'typ_exakt' => 'd.typ LIKE',
|
||||
'betreff' => 'd.betreff %LIKE%',
|
||||
'betreff_equals' => 'd.betreff LIKE',
|
||||
'betreff_exakt' => 'd.betreff LIKE',
|
||||
'projekt' => 'd.projekt =',
|
||||
'adresse_from' => 'd.adresse_from =',
|
||||
'adresse_to' => 'd.adresse_to =',
|
||||
'deleted' => 'd.deleted =',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'typ' => 'required|in:email,brief,telefon,notiz',
|
||||
'betreff' => 'required',
|
||||
'projekt' => 'numeric',
|
||||
'adresse_from' => 'numeric',
|
||||
'adresse_to' => 'numeric',
|
||||
'signatur' => 'numeric',
|
||||
'fax' => 'boolean',
|
||||
'printer' => 'boolean',
|
||||
'sent' => 'boolean',
|
||||
'deleted' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
'adresse_to' => [
|
||||
'key' => 'adresse_to',
|
||||
'resource' => AddressResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.name',
|
||||
'a.email',
|
||||
'a.strasse',
|
||||
'a.plz',
|
||||
'a.ort',
|
||||
'a.land',
|
||||
'a.ansprechpartner',
|
||||
],
|
||||
],
|
||||
'adresse_from' => [
|
||||
'key' => 'adresse_from',
|
||||
'resource' => AddressResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.name',
|
||||
'a.email',
|
||||
'a.strasse',
|
||||
'a.plz',
|
||||
'a.ort',
|
||||
'a.land',
|
||||
'a.ansprechpartner',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'd.id',
|
||||
'd.adresse_from',
|
||||
'd.adresse_to',
|
||||
'd.typ',
|
||||
'd.von',
|
||||
'd.an',
|
||||
'd.email_an',
|
||||
'd.send_as',
|
||||
'd.email',
|
||||
'd.email_cc',
|
||||
'd.email_bcc',
|
||||
'd.bearbeiter',
|
||||
'd.email_an',
|
||||
'd.firma_an',
|
||||
'd.adresse',
|
||||
'd.ansprechpartner',
|
||||
'd.plz',
|
||||
'd.ort',
|
||||
'd.land',
|
||||
'd.datum',
|
||||
'd.uhrzeit',
|
||||
'd.betreff',
|
||||
'd.content',
|
||||
'd.projekt',
|
||||
'd.internebezeichnung',
|
||||
'd.signatur',
|
||||
'd.fax',
|
||||
'd.sent',
|
||||
'd.printer',
|
||||
'd.deleted',
|
||||
])->from(self::TABLE_NAME . ' AS d');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeleteQuery
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
use Xentral\Modules\Api\Exception\InvalidArgumentException;
|
||||
|
||||
class DeliveryAddressResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'lieferadressen';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'adresse' => 'l.adresse =',
|
||||
'typ' => 'l.typ =',
|
||||
'name' => 'l.name %LIKE%',
|
||||
'name_equals' => 'l.name LIKE',
|
||||
'name_startswith' => 'l.name LIKE%',
|
||||
'name_endswith' => 'l.name %LIKE',
|
||||
'standardlieferadresse' => 'l.standardlieferadresse =',
|
||||
'land' => 'l.land =',
|
||||
'id_ext' => 'am.id_ext =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'typ' => 'l.typ',
|
||||
'name' => 'l.name',
|
||||
'plz' => 'l.plz',
|
||||
'land' => 'l.land',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'id_ext' => 'not_present',
|
||||
'name' => 'required',
|
||||
'adresse' => 'numeric|db_value:adresse,id',
|
||||
'typ' => 'db_value:adresse_typ,type',
|
||||
'land' => 'upper|length:2|db_value:laender,iso',
|
||||
'ust_befreit' => 'in:0,1,2,3',
|
||||
'standardlieferadresse' => 'in:0,1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'l.id',
|
||||
'l.typ',
|
||||
//'l.sprache', // Nicht änderbar über Formular
|
||||
'l.name',
|
||||
'l.abteilung',
|
||||
'l.unterabteilung',
|
||||
'l.strasse',
|
||||
'l.ort',
|
||||
'l.plz',
|
||||
'l.land',
|
||||
'l.telefon',
|
||||
'l.telefax',
|
||||
'l.email',
|
||||
//'l.sonstiges', // Nicht änderbar über Formular
|
||||
'l.adresszusatz',
|
||||
//'l.steuer', // Nicht änderbar über Formular
|
||||
'l.adresse',
|
||||
//'l.ansprechpartner', // Nicht änderbar über Formular
|
||||
'l.standardlieferadresse',
|
||||
'l.gln',
|
||||
'l.ustid',
|
||||
'l.lieferbedingung',
|
||||
'l.ust_befreit',
|
||||
'l.interne_bemerkung',
|
||||
'am.id_ext',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS l')
|
||||
->leftJoin(
|
||||
'api_mapping AS am',
|
||||
'am.id_int = l.id AND am.tabelle = ' . $this->db->escapeString(self::TABLE_NAME)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('l.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('l.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function insert($inputVars)
|
||||
{
|
||||
// SQL-Fehler umgehen: Field 'sprache' doesn't have a default value
|
||||
if (!isset($inputVars['abteilung'])) { $inputVars['abteilung'] = ''; }
|
||||
if (!isset($inputVars['unterabteilung'])) { $inputVars['unterabteilung'] = ''; }
|
||||
if (!isset($inputVars['strasse'])) { $inputVars['strasse'] = ''; }
|
||||
if (!isset($inputVars['ort'])) { $inputVars['ort'] = ''; }
|
||||
if (!isset($inputVars['plz'])) { $inputVars['plz'] = ''; }
|
||||
if (!isset($inputVars['telefon'])) { $inputVars['telefon'] = ''; }
|
||||
if (!isset($inputVars['telefax'])) { $inputVars['telefax'] = ''; }
|
||||
if (!isset($inputVars['email'])) { $inputVars['email'] = ''; }
|
||||
if (!isset($inputVars['steuer'])) { $inputVars['steuer'] = ''; }
|
||||
if (!isset($inputVars['sprache'])) { $inputVars['sprache'] = ''; }
|
||||
if (!isset($inputVars['sonstiges'])) { $inputVars['sonstiges'] = ''; }
|
||||
if (!isset($inputVars['adresszusatz'])) { $inputVars['adresszusatz'] = ''; }
|
||||
if (!isset($inputVars['lieferbedingung'])) { $inputVars['lieferbedingung'] = ''; }
|
||||
|
||||
// Angelegte Daten aus dem Result holen
|
||||
$result = parent::insert($inputVars);
|
||||
$data = $result->getData();
|
||||
|
||||
// Es darf nur eine Standard-Lieferadresse pro Hauptadresse geben!
|
||||
if ((int)$data['standardlieferadresse'] === 1) {
|
||||
$addressId = (int)$data['adresse'];
|
||||
$deliveryAddressId = (int)$data['id'];
|
||||
|
||||
if ($addressId === 0) {
|
||||
throw new InvalidArgumentException('AdressID can not be empty');
|
||||
}
|
||||
if ($deliveryAddressId === 0) {
|
||||
throw new InvalidArgumentException('ID can not be empty');
|
||||
}
|
||||
|
||||
// Vorhandene Standard-Lieferadresse zur "nicht-Standard"-Lieferadresse machen
|
||||
$updateQuery = $this->db->update()
|
||||
->table(self::TABLE_NAME)
|
||||
->cols(['standardlieferadresse' => 0])
|
||||
->where('standardlieferadresse = :eins')
|
||||
->where('adresse = :adresse')
|
||||
->where('id != :id')
|
||||
->bindValues([
|
||||
'eins' => 1,
|
||||
'adresse' => $addressId,
|
||||
'id' => $deliveryAddressId,
|
||||
]);
|
||||
|
||||
$this->db->perform(
|
||||
$updateQuery->getStatement(),
|
||||
$updateQuery->getBindValues()
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeleteQuery
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Gutschriften-Positionen
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentCreditNotePositionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'gutschrift_position';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'sort' => 'gupos.sort',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('gupos.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'gupos.id',
|
||||
//'gupos.gutschrift', // Index
|
||||
'gupos.projekt',
|
||||
'gupos.artikel', // Index
|
||||
'gupos.bezeichnung',
|
||||
'gupos.beschreibung',
|
||||
//'gupos.internerkommentar',
|
||||
'gupos.nummer',
|
||||
'gupos.menge',
|
||||
'gupos.einheit',
|
||||
'gupos.preis',
|
||||
'gupos.waehrung',
|
||||
'gupos.lieferdatum',
|
||||
'gupos.vpe',
|
||||
//'gupos.sort',
|
||||
//'gupos.status',
|
||||
'gupos.umsatzsteuer',
|
||||
'gupos.bemerkung',
|
||||
'gupos.artikelnummerkunde',
|
||||
//'gupos.logdatei',
|
||||
//'gupos.explodiert_parent_artikel',
|
||||
//'gupos.keinrabatterlaubt',
|
||||
//'gupos.grundrabatt',
|
||||
//'gupos.rabattsync',
|
||||
//'gupos.rabatt1',
|
||||
//'gupos.rabatt2',
|
||||
//'gupos.rabatt3',
|
||||
//'gupos.rabatt4',
|
||||
//'gupos.rabatt5',
|
||||
'gupos.rabatt',
|
||||
'gupos.zolltarifnummer',
|
||||
'gupos.herkunftsland',
|
||||
'gupos.lieferdatumkw',
|
||||
'gupos.auftrag_position_id',
|
||||
'gupos.teilprojekt',
|
||||
'gupos.kostenstelle',
|
||||
'gupos.steuersatz',
|
||||
'gupos.steuertext',
|
||||
//'gupos.erloese',
|
||||
//'gupos.erloesefestschreiben',
|
||||
'gupos.einkaufspreiswaehrung',
|
||||
'gupos.einkaufspreis',
|
||||
'gupos.einkaufspreisurspruenglich',
|
||||
//'gupos.einkaufspreisid',
|
||||
//'gupos.ekwaehrung',
|
||||
//'gupos.deckungsbeitrag',
|
||||
//'gupos.freifeld1',
|
||||
//'gupos.freifeld2',
|
||||
//'gupos.freifeld3',
|
||||
//'gupos.freifeld4',
|
||||
//'gupos.freifeld5',
|
||||
//'gupos.freifeld6',
|
||||
//'gupos.freifeld7',
|
||||
//'gupos.freifeld8',
|
||||
//'gupos.freifeld9',
|
||||
//'gupos.freifeld10',
|
||||
//'gupos.freifeld11',
|
||||
//'gupos.freifeld12',
|
||||
//'gupos.freifeld13',
|
||||
//'gupos.freifeld14',
|
||||
//'gupos.freifeld15',
|
||||
//'gupos.freifeld16',
|
||||
//'gupos.freifeld17',
|
||||
//'gupos.freifeld18',
|
||||
//'gupos.freifeld19',
|
||||
//'gupos.freifeld20',
|
||||
//'gupos.freifeld21',
|
||||
//'gupos.freifeld22',
|
||||
//'gupos.freifeld23',
|
||||
//'gupos.freifeld24',
|
||||
//'gupos.freifeld25',
|
||||
//'gupos.freifeld26',
|
||||
//'gupos.freifeld27',
|
||||
//'gupos.freifeld28',
|
||||
//'gupos.freifeld29',
|
||||
//'gupos.freifeld30',
|
||||
//'gupos.freifeld31',
|
||||
//'gupos.freifeld32',
|
||||
//'gupos.freifeld33',
|
||||
//'gupos.freifeld34',
|
||||
//'gupos.freifeld35',
|
||||
//'gupos.freifeld36',
|
||||
//'gupos.freifeld37',
|
||||
//'gupos.freifeld38',
|
||||
//'gupos.freifeld39',
|
||||
//'gupos.freifeld40',
|
||||
//'gupos.formelmenge',
|
||||
//'gupos.formelpreis',
|
||||
'gupos.ohnepreis',
|
||||
'gupos.skontobetrag',
|
||||
'gupos.steuerbetrag',
|
||||
'gupos.skontosperre',
|
||||
'gupos.ausblenden_im_pdf',
|
||||
//'gupos.umsatz_netto_einzeln',
|
||||
//'gupos.umsatz_netto_gesamt',
|
||||
//'gupos.umsatz_brutto_einzeln',
|
||||
//'gupos.umsatz_brutto_gesamt',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS gupos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('gupos.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für das Gutschrift-Protokoll
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentCreditNoteProtocolResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'gutschrift_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'zeit' => 'guproto.zeit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('guproto.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'guproto.id',
|
||||
'guproto.gutschrift',
|
||||
'guproto.zeit',
|
||||
'guproto.bearbeiter',
|
||||
'guproto.grund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS guproto');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('guproto.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Gutschriften/Stornorechnungen
|
||||
*/
|
||||
class DocumentCreditNoteResource extends AbstractResource
|
||||
{
|
||||
/** @var string */
|
||||
const TABLE_NAME = 'gutschrift';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'status' => 'gu.status LIKE',
|
||||
'belegnr' => 'gu.belegnr %LIKE%',
|
||||
'belegnr_equals' => 'gu.belegnr LIKE',
|
||||
'belegnr_startswith' => 'gu.belegnr LIKE%',
|
||||
'belegnr_endswith' => 'gu.belegnr %LIKE',
|
||||
'kundennummer' => 'gu.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 'gu.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 'gu.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 'gu.kundennummer %LIKE',
|
||||
'datum' => 'gu.datum =',
|
||||
'datum_gt' => 'gu.datum >',
|
||||
'datum_gte' => 'gu.datum >=',
|
||||
'datum_lt' => 'gu.datum <',
|
||||
'datum_lte' => 'gu.datum <=',
|
||||
'rechnung' => 'gu.rechnung LIKE',
|
||||
'rechnungid' => 'gu.rechnungid =',
|
||||
'projekt' => 'gu.projekt =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'belegnr' => 'gu.belegnr',
|
||||
'datum' => 'gu.datum',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'positionen' => [
|
||||
'key' => 'positionen',
|
||||
'resource' => DocumentCreditNotePositionResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'gutschrift',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'sort' => 'ASC',
|
||||
],
|
||||
],
|
||||
'protokoll' => [
|
||||
'key' => 'protokoll',
|
||||
'resource' => DocumentCreditNoteProtocolResource::class,
|
||||
'columns' => [
|
||||
'guproto.id',
|
||||
'guproto.zeit',
|
||||
'guproto.bearbeiter',
|
||||
'guproto.grund',
|
||||
],
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'gutschrift',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'zeit' => 'ASC',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('gu.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'gu.id',
|
||||
'gu.firma',
|
||||
'gu.projekt', // Index
|
||||
'gu.status', // Index
|
||||
'gu.anlegeart',
|
||||
'gu.belegnr', // Index
|
||||
'gu.datum', // Index
|
||||
'gu.rechnung',
|
||||
'gu.rechnungid',
|
||||
'gu.stornorechnung',
|
||||
'gu.kundennummer',
|
||||
'gu.bearbeiter',
|
||||
'gu.bearbeiterid',
|
||||
'gu.freitext',
|
||||
'gu.internebemerkung',
|
||||
|
||||
'gu.adresse', // Index
|
||||
'gu.typ',
|
||||
'gu.name',
|
||||
'gu.titel',
|
||||
'gu.ansprechpartnerid',
|
||||
'gu.ansprechpartner',
|
||||
'gu.abteilung',
|
||||
'gu.unterabteilung',
|
||||
'gu.adresszusatz',
|
||||
'gu.strasse',
|
||||
'gu.plz',
|
||||
'gu.ort',
|
||||
'gu.land',
|
||||
'gu.bundesstaat',
|
||||
'gu.telefon',
|
||||
'gu.telefax',
|
||||
'gu.email',
|
||||
'gu.anschreiben',
|
||||
|
||||
//'gu.betreff',
|
||||
//'gu.lieferschein',
|
||||
'gu.versandart',
|
||||
'gu.lieferdatum',
|
||||
'gu.buchhaltung',
|
||||
'gu.zahlungsweise',
|
||||
'gu.zahlungsstatus',
|
||||
'gu.ist',
|
||||
'gu.soll',
|
||||
'gu.zahlungszieltage',
|
||||
'gu.zahlungszieltageskonto',
|
||||
'gu.zahlungszielskonto',
|
||||
'gu.gesamtsumme',
|
||||
//'gu.bank_inhaber',
|
||||
//'gu.bank_institut',
|
||||
//'gu.bank_blz',
|
||||
//'gu.bank_konto',
|
||||
//'gu.kreditkarte_typ',
|
||||
//'gu.kreditkarte_inhaber',
|
||||
//'gu.kreditkarte_nummer',
|
||||
//'gu.kreditkarte_pruefnummer',
|
||||
//'gu.kreditkarte_monat',
|
||||
//'gu.kreditkarte_jahr',
|
||||
//'gu.paypalaccount',
|
||||
'gu.versendet',
|
||||
'gu.versendet_am',
|
||||
'gu.versendet_per',
|
||||
'gu.versendet_durch',
|
||||
//'gu.inbearbeitung',
|
||||
//'gu.logdatei',
|
||||
'gu.manuell_vorabbezahlt',
|
||||
'gu.manuell_vorabbezahlt_hinweis',
|
||||
'gu.nicht_umsatzmindernd',
|
||||
//'gu.dta_datei',
|
||||
//'gu.dta_datei_verband',
|
||||
//'gu.deckungsbeitragcalc',
|
||||
//'gu.deckungsbeitrag',
|
||||
'gu.erloes_netto',
|
||||
'gu.umsatz_netto',
|
||||
'gu.vertriebid', // Index
|
||||
'gu.vertrieb',
|
||||
'gu.aktion',
|
||||
'gu.provision',
|
||||
'gu.provision_summe',
|
||||
//'gu.gruppe', // Index
|
||||
'gu.ihrebestellnummer',
|
||||
//'gu.usereditid', // Index
|
||||
//'gu.useredittimestamp',
|
||||
//'gu.realrabatt',
|
||||
'gu.rabatt',
|
||||
//'gu.rabatt1',
|
||||
//'gu.rabatt2',
|
||||
//'gu.rabatt3',
|
||||
//'gu.rabatt4',
|
||||
//'gu.rabatt5',
|
||||
'gu.steuersatz_normal',
|
||||
'gu.steuersatz_zwischen',
|
||||
'gu.steuersatz_ermaessigt',
|
||||
'gu.steuersatz_starkermaessigt',
|
||||
'gu.steuersatz_dienstleistung',
|
||||
'gu.ustid',
|
||||
'gu.ustbrief',
|
||||
'gu.ustbrief_eingang',
|
||||
'gu.ustbrief_eingang_am',
|
||||
'gu.ust_befreit',
|
||||
'gu.waehrung',
|
||||
'gu.keinsteuersatz',
|
||||
//'gu.schreibschutz',
|
||||
//'gu.pdfarchiviert',
|
||||
//'gu.pdfarchiviertversion',
|
||||
//'gu.ohne_briefpapier',
|
||||
//'gu.lieferid',
|
||||
//'gu.projektfiliale',
|
||||
//'gu.zuarchivieren',
|
||||
'gu.internebezeichnung',
|
||||
//'gu.angelegtam',
|
||||
'gu.sprache',
|
||||
'gu.gln',
|
||||
//'gu.deliverythresholdvatid',
|
||||
'gu.kurs',
|
||||
'gu.ohne_artikeltext',
|
||||
'gu.anzeigesteuer',
|
||||
'gu.kostenstelle',
|
||||
'gu.bodyzusatz',
|
||||
'gu.lieferbedingung',
|
||||
'gu.skontobetrag',
|
||||
'gu.skontoberechnet',
|
||||
'gu.extsoll',
|
||||
])->from(self::TABLE_NAME . ' AS gu');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('gu.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Lieferschein-Positionen
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentDeliveryNotePositionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'lieferschein_position';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'sort' => 'lipos.sort',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('lipos.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'lipos.id',
|
||||
//'lipos.lieferschein', // Index
|
||||
'lipos.projekt',
|
||||
'lipos.artikel', // Index
|
||||
'lipos.bezeichnung',
|
||||
'lipos.beschreibung',
|
||||
//'lipos.internerkommentar',
|
||||
'lipos.nummer',
|
||||
'lipos.menge',
|
||||
'lipos.einheit',
|
||||
'lipos.vpe',
|
||||
'lipos.lieferdatum',
|
||||
'lipos.lieferdatumkw',
|
||||
'lipos.artikelnummerkunde',
|
||||
'lipos.kostenlos',
|
||||
//'lipos.sort',
|
||||
//'lipos.status',
|
||||
//'lipos.ausblenden_im_pdf ',
|
||||
'lipos.bemerkung',
|
||||
'lipos.geliefert',
|
||||
'lipos.abgerechnet',
|
||||
//'lipos.logdatei',
|
||||
//'lipos.lagertext',
|
||||
//'lipos.auftrag_position_id', // Index
|
||||
//'lipos.teilprojekt',
|
||||
//'lipos.freifeld1',
|
||||
//'lipos.freifeld2',
|
||||
//'lipos.freifeld3',
|
||||
//'lipos.freifeld4',
|
||||
//'lipos.freifeld5',
|
||||
//'lipos.freifeld6',
|
||||
//'lipos.freifeld7',
|
||||
//'lipos.freifeld8',
|
||||
//'lipos.freifeld9',
|
||||
//'lipos.freifeld10',
|
||||
//'lipos.freifeld11',
|
||||
//'lipos.freifeld12',
|
||||
//'lipos.freifeld13',
|
||||
//'lipos.freifeld14',
|
||||
//'lipos.freifeld15',
|
||||
//'lipos.freifeld16',
|
||||
//'lipos.freifeld17',
|
||||
//'lipos.freifeld18',
|
||||
//'lipos.freifeld19',
|
||||
//'lipos.freifeld20',
|
||||
//'lipos.freifeld21',
|
||||
//'lipos.freifeld22',
|
||||
//'lipos.freifeld23',
|
||||
//'lipos.freifeld24',
|
||||
//'lipos.freifeld25',
|
||||
//'lipos.freifeld26',
|
||||
//'lipos.freifeld27',
|
||||
//'lipos.freifeld28',
|
||||
//'lipos.freifeld29',
|
||||
//'lipos.freifeld30',
|
||||
//'lipos.freifeld31',
|
||||
//'lipos.freifeld32',
|
||||
//'lipos.freifeld33',
|
||||
//'lipos.freifeld34',
|
||||
//'lipos.freifeld35',
|
||||
//'lipos.freifeld36',
|
||||
//'lipos.freifeld37',
|
||||
//'lipos.freifeld38',
|
||||
//'lipos.freifeld39',
|
||||
//'lipos.freifeld40',
|
||||
'lipos.seriennummer',
|
||||
'lipos.herkunftsland',
|
||||
'lipos.zolltarifnummer',
|
||||
'lipos.zolleinzelwert',
|
||||
'lipos.zollgesamtwert',
|
||||
'lipos.zollwaehrung',
|
||||
'lipos.zolleinzelgewicht',
|
||||
'lipos.zollgesamtgewicht',
|
||||
'lipos.nve',
|
||||
'lipos.packstueck',
|
||||
'lipos.vpemenge',
|
||||
'lipos.einzelstueckmenge',
|
||||
//'lipos.explodiert_parent',
|
||||
//'lipos.explodiert_parent_artikel',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS lipos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('lipos.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für das Lieferschein-Protokoll
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Incldudes verwendet.
|
||||
*/
|
||||
class DocumentDeliveryNoteProtocolResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'lieferschein_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'zeit' => 'liproto.zeit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('liproto.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'liproto.id',
|
||||
'liproto.lieferschein',
|
||||
'liproto.zeit',
|
||||
'liproto.bearbeiter',
|
||||
'liproto.grund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS liproto');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('liproto.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Lieferscheine
|
||||
*/
|
||||
class DocumentDeliveryNoteResource extends AbstractResource
|
||||
{
|
||||
/** @var string */
|
||||
const TABLE_NAME = 'lieferschein';
|
||||
|
||||
/**
|
||||
* @param array $filter
|
||||
* @param array $sorting
|
||||
* @param array $columns
|
||||
* @param array $includes
|
||||
* @param int $page
|
||||
* @param int $paging
|
||||
*
|
||||
* @return Result\CollectionResult
|
||||
*/
|
||||
public function getList(
|
||||
array $filter = [],
|
||||
array $sorting = [],
|
||||
array $columns = [],
|
||||
array $includes = [],
|
||||
$page = 1,
|
||||
$paging = 20
|
||||
) {
|
||||
// Filter für Auftragsnummer über Auftrags-ID verknüpfen
|
||||
if (isset($filter['auftrag']) && !isset($filter['auftragid'])) {
|
||||
$select = $this->db->select()
|
||||
->cols(['a.id'])
|
||||
->from('auftrag AS a')
|
||||
->where('a.belegnr = ?', $filter['auftrag']);
|
||||
if (isset($filter['projekt'])) {
|
||||
$select->where('a.projekt = ?', $filter['projekt']);
|
||||
}
|
||||
$orderId = $this->db->fetchValue($select->getStatement(), $select->getBindValues());
|
||||
if ($orderId > 0) {
|
||||
$filter['auftragid'] = $orderId;
|
||||
unset($filter['auftrag']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::getList($filter, $sorting, $columns, $includes, $page, $paging);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'status' => 'li.status LIKE',
|
||||
'belegnr' => 'li.belegnr %LIKE%',
|
||||
'belegnr_equals' => 'li.belegnr LIKE',
|
||||
'belegnr_startswith' => 'li.belegnr LIKE%',
|
||||
'belegnr_endswith' => 'li.belegnr %LIKE',
|
||||
'kundennummer' => 'li.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 'li.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 'li.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 'li.kundennummer %LIKE',
|
||||
'datum' => 'li.datum =',
|
||||
'datum_gt' => 'li.datum >',
|
||||
'datum_gte' => 'li.datum >=',
|
||||
'datum_lt' => 'li.datum <',
|
||||
'datum_lte' => 'li.datum <=',
|
||||
'auftrag' => 'li.auftrag LIKE',
|
||||
'auftragid' => 'li.auftragid =',
|
||||
'projekt' => 'li.projekt =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'belegnr' => 'li.belegnr',
|
||||
'datum' => 'li.datum',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'positionen' => [
|
||||
'key' => 'positionen',
|
||||
'resource' => DocumentDeliveryNotePositionResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'lieferschein',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'sort' => 'ASC',
|
||||
],
|
||||
],
|
||||
'protokoll' => [
|
||||
'key' => 'protokoll',
|
||||
'resource' => DocumentDeliveryNoteProtocolResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'lieferschein',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'columns' => [
|
||||
'liproto.id',
|
||||
'liproto.zeit',
|
||||
'liproto.bearbeiter',
|
||||
'liproto.grund',
|
||||
],
|
||||
'sort' => [
|
||||
'zeit' => 'ASC',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('li.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'li.id',#
|
||||
'li.firma',#
|
||||
'li.projekt',# // Index
|
||||
'li.status',# // Index
|
||||
'li.lieferscheinart',#
|
||||
'li.belegnr',# // Index
|
||||
'li.kundennummer',#
|
||||
'li.ihrebestellnummer',#
|
||||
'li.datum',# // Index
|
||||
'li.auftrag',#
|
||||
'li.auftragid',# // Index
|
||||
'li.freitext',#
|
||||
|
||||
'li.adresse',# // Index
|
||||
'li.typ',#
|
||||
'li.name',#
|
||||
'li.titel',#
|
||||
'li.ansprechpartnerid',#
|
||||
'li.ansprechpartner',#
|
||||
'li.abteilung',#
|
||||
'li.unterabteilung',#
|
||||
'li.adresszusatz',#
|
||||
'li.strasse',#
|
||||
'li.plz',#
|
||||
'li.ort',#
|
||||
'li.land',# // Index
|
||||
'li.bundesstaat',#
|
||||
'li.telefon',#
|
||||
'li.telefax',#
|
||||
'li.email',#
|
||||
'li.anschreiben',#
|
||||
|
||||
//'li.betreff',#
|
||||
//'li.vertriebid',# // Index
|
||||
//'li.vertrieb',#
|
||||
'li.versandart',#
|
||||
'li.versand',#
|
||||
'li.versendet',#
|
||||
'li.versendet_am',#
|
||||
'li.versendet_per',#
|
||||
'li.versendet_durch',#
|
||||
//'li.inbearbeitung_user',#
|
||||
//'li.logdatei',#
|
||||
//'li.schreibschutz',#
|
||||
'li.ustid',#
|
||||
'li.ust_befreit',#
|
||||
'li.usereditid',# // Index
|
||||
'li.useredittimestamp',#
|
||||
'li.lieferantenretoure',#
|
||||
'li.lieferantenretoureinfo',#
|
||||
'li.lieferant',#
|
||||
'li.pdfarchiviert',#
|
||||
'li.pdfarchiviertversion',#
|
||||
'li.internebemerkung',#
|
||||
'li.ohne_briefpapier',#
|
||||
'li.lieferid',#
|
||||
'li.projektfiliale',#
|
||||
'li.projektfiliale_eingelagert',#
|
||||
'li.zuarchivieren',#
|
||||
'li.internebezeichnung',#
|
||||
'li.kommissionierung',#
|
||||
'li.sprache',#
|
||||
//'li.angelegtam',#
|
||||
//'li.bundesland',#
|
||||
'li.gln',#
|
||||
//'li.rechnungid',#
|
||||
//'li.bearbeiterid',#
|
||||
'li.bearbeiter',#
|
||||
'li.keinerechnung',# // Index
|
||||
'li.ohne_artikeltext',#
|
||||
'li.abweichendebezeichnung',#
|
||||
'li.kostenstelle',#
|
||||
'li.bodyzusatz',#
|
||||
'li.lieferbedingung',#
|
||||
'li.standardlager',#
|
||||
'li.kommissionskonsignationslager',#
|
||||
'li.teillieferungvon',#
|
||||
'li.teillieferungnummer',#
|
||||
'li.kiste',#
|
||||
])->from(self::TABLE_NAME . ' AS li');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('li.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Rechnungs-Positionen
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentInvoicePositionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'rechnung_position';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'sort' => 'repos.sort',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('repos.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'repos.id',
|
||||
//'repos.rechnung', // Index
|
||||
'repos.projekt',
|
||||
'repos.artikel', // Index
|
||||
'repos.bezeichnung',
|
||||
'repos.beschreibung',
|
||||
//'repos.internerkommentar',
|
||||
'repos.nummer',
|
||||
'repos.menge',
|
||||
'repos.preis',
|
||||
'repos.waehrung',
|
||||
'repos.lieferdatum',
|
||||
'repos.vpe',
|
||||
//'repos.sort',
|
||||
//'repos.status',
|
||||
'repos.umsatzsteuer',
|
||||
'repos.bemerkung',
|
||||
//'repos.logdatei',
|
||||
//'repos.explodiert_parent_artikel',
|
||||
//'repos.punkte',
|
||||
//'repos.bonuspunkte',
|
||||
//'repos.mlmdirektpraemie',
|
||||
//'repos.mlm_abgerechnet',
|
||||
//'repos.keinrabatterlaubt',
|
||||
//'repos.grundrabatt',
|
||||
//'repos.rabattsync',
|
||||
//'repos.rabatt1',
|
||||
//'repos.rabatt2',
|
||||
//'repos.rabatt3',
|
||||
//'repos.rabatt4',
|
||||
//'repos.rabatt5',
|
||||
'repos.einheit',
|
||||
'repos.rabatt',
|
||||
'repos.zolltarifnummer',
|
||||
'repos.herkunftsland',
|
||||
'repos.artikelnummerkunde',
|
||||
'repos.lieferdatumkw',
|
||||
//'repos.auftrag_position_id', // Index
|
||||
//'repos.teilprojekt',
|
||||
//'repos.kostenstelle',
|
||||
//'repos.erloese',
|
||||
//'repos.erloesefestschreiben',
|
||||
'repos.einkaufspreiswaehrung',
|
||||
'repos.einkaufspreis',
|
||||
'repos.einkaufspreisurspruenglich',
|
||||
//'repos.einkaufspreisid',
|
||||
//'repos.ekwaehrung',
|
||||
//'repos.deckungsbeitrag',
|
||||
//'repos.freifeld1',
|
||||
//'repos.freifeld2',
|
||||
//'repos.freifeld3',
|
||||
//'repos.freifeld4',
|
||||
//'repos.freifeld5',
|
||||
//'repos.freifeld6',
|
||||
//'repos.freifeld7',
|
||||
//'repos.freifeld8',
|
||||
//'repos.freifeld9',
|
||||
//'repos.freifeld10',
|
||||
//'repos.freifeld11',
|
||||
//'repos.freifeld12',
|
||||
//'repos.freifeld13',
|
||||
//'repos.freifeld14',
|
||||
//'repos.freifeld15',
|
||||
//'repos.freifeld16',
|
||||
//'repos.freifeld17',
|
||||
//'repos.freifeld18',
|
||||
//'repos.freifeld19',
|
||||
//'repos.freifeld20',
|
||||
//'repos.freifeld21',
|
||||
//'repos.freifeld22',
|
||||
//'repos.freifeld23',
|
||||
//'repos.freifeld24',
|
||||
//'repos.freifeld25',
|
||||
//'repos.freifeld26',
|
||||
//'repos.freifeld27',
|
||||
//'repos.freifeld28',
|
||||
//'repos.freifeld29',
|
||||
//'repos.freifeld30',
|
||||
//'repos.freifeld31',
|
||||
//'repos.freifeld32',
|
||||
//'repos.freifeld33',
|
||||
//'repos.freifeld34',
|
||||
//'repos.freifeld35',
|
||||
//'repos.freifeld36',
|
||||
//'repos.freifeld37',
|
||||
//'repos.freifeld38',
|
||||
//'repos.freifeld39',
|
||||
//'repos.freifeld40',
|
||||
//'repos.formelmenge',
|
||||
//'repos.formelpreis',
|
||||
'repos.ohnepreis',
|
||||
'repos.steuersatz',
|
||||
'repos.steuertext',
|
||||
'repos.steuerbetrag',
|
||||
'repos.skontobetrag',
|
||||
'repos.skontosperre',
|
||||
'repos.ausblenden_im_pdf',
|
||||
//'repos.umsatz_netto_einzeln',
|
||||
//'repos.umsatz_netto_gesamt',
|
||||
//'repos.umsatz_brutto_einzeln',
|
||||
//'repos.umsatz_brutto_gesamt',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS repos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('repos.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für das Rechungen-Protokoll
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentInvoiceProtocolResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'rechnung_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'zeit' => 'reproto.zeit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('reproto.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'reproto.id',
|
||||
'reproto.lieferschein',
|
||||
'reproto.zeit',
|
||||
'reproto.bearbeiter',
|
||||
'reproto.grund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS reproto');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('reproto.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
use Xentral\Modules\Api\Resource\Result\ItemResult;
|
||||
|
||||
/**
|
||||
* Ressource für Rechnungen
|
||||
*/
|
||||
class DocumentInvoiceResource extends AbstractResource
|
||||
{
|
||||
/** @var string */
|
||||
const TABLE_NAME = 'rechnung';
|
||||
/** @var string */
|
||||
const POSITION_TABLE_NAME = 'rechnung_position';
|
||||
/** @var string */
|
||||
const PROTOCOL_TABLE_NAME = 'rechnung_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'status' => 're.status LIKE',
|
||||
'belegnr' => 're.belegnr %LIKE%',
|
||||
'belegnr_equals' => 're.belegnr LIKE',
|
||||
'belegnr_startswith' => 're.belegnr LIKE%',
|
||||
'belegnr_endswith' => 're.belegnr %LIKE',
|
||||
'kundennummer' => 're.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 're.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 're.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 're.kundennummer %LIKE',
|
||||
'datum' => 're.datum =',
|
||||
'datum_gt' => 're.datum >',
|
||||
'datum_gte' => 're.datum >=',
|
||||
'datum_lt' => 're.datum <',
|
||||
'datum_lte' => 're.datum <=',
|
||||
'auftrag' => 're.auftrag LIKE',
|
||||
'auftragid' => 're.auftragid =',
|
||||
'projekt' => 're.projekt =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'belegnr' => 're.belegnr',
|
||||
'datum' => 're.datum',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'positionen' => [
|
||||
'key' => 'positionen',
|
||||
'resource' => DocumentInvoicePositionResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'rechnung',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'sort' => 'ASC',
|
||||
],
|
||||
],
|
||||
'protokoll' => [
|
||||
'key' => 'protokoll',
|
||||
'resource' => DocumentInvoiceProtocolResource::class,
|
||||
'columns' => [
|
||||
'reproto.id',
|
||||
'reproto.zeit',
|
||||
'reproto.bearbeiter',
|
||||
'reproto.grund',
|
||||
],
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'rechnung',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'zeit' => 'ASC',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('re.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
're.id',
|
||||
're.firma',
|
||||
're.projekt', // Index
|
||||
're.status', // Index
|
||||
're.belegnr', // Index
|
||||
're.anlegeart',
|
||||
're.datum', // Index
|
||||
're.auftrag',
|
||||
're.auftragid', // Index
|
||||
're.aborechnung',
|
||||
're.kundennummer',
|
||||
're.bearbeiterid',
|
||||
're.bearbeiter',
|
||||
're.freitext',
|
||||
're.aktion',
|
||||
//'re.internebemerkung',
|
||||
|
||||
're.adresse', // Index
|
||||
're.typ',
|
||||
're.name',
|
||||
're.titel',
|
||||
're.ansprechpartnerid',
|
||||
're.ansprechpartner',
|
||||
're.abteilung',
|
||||
're.unterabteilung',
|
||||
're.adresszusatz',
|
||||
're.strasse',
|
||||
're.plz',
|
||||
're.ort',
|
||||
're.land',
|
||||
're.bundesstaat',
|
||||
're.telefon',
|
||||
're.telefax',
|
||||
're.email',
|
||||
're.anschreiben',
|
||||
|
||||
//'re.betreff',
|
||||
//'re.lieferschein',
|
||||
're.versandart',
|
||||
're.lieferdatum',
|
||||
're.buchhaltung',
|
||||
're.zahlungsweise',
|
||||
're.mahnwesenfestsetzen',
|
||||
're.zahlungsstatus', // Index
|
||||
're.ist',
|
||||
're.soll', // Index
|
||||
're.skonto_gegeben',
|
||||
're.zahlungszieltage',
|
||||
're.zahlungszieltageskonto',
|
||||
're.zahlungszielskonto',
|
||||
're.versendet',
|
||||
're.versendet_am',
|
||||
're.versendet_per',
|
||||
're.versendet_durch',
|
||||
're.versendet_mahnwesen',
|
||||
're.mahnwesen',
|
||||
're.mahnwesen_datum',
|
||||
're.mahnwesen_gesperrt',
|
||||
're.mahnwesen_internebemerkung',
|
||||
're.datev_abgeschlossen',
|
||||
//'re.inbearbeitung',
|
||||
//'re.logdatei',
|
||||
//'re.doppel',
|
||||
//'re.autodruck_rz',
|
||||
//'re.autodruck_periode',
|
||||
//'re.autodruck_done',
|
||||
//'re.autodruck_anzahlverband',
|
||||
//'re.autodruck_anzahlkunde',
|
||||
//'re.autodruck_mailverband',
|
||||
//'re.autodruck_mailkunde',
|
||||
//'re.dta_datei_verband',
|
||||
//'re.dta_datei',
|
||||
//'re.deckungsbeitragcalc',
|
||||
//'re.deckungsbeitrag',
|
||||
're.umsatz_netto',
|
||||
're.erloes_netto',
|
||||
//'re.vertriebid', // Index
|
||||
//'re.vertrieb',
|
||||
're.provision',
|
||||
're.provision_summe',
|
||||
//'re.gruppe', // Index
|
||||
//'re.punkte',
|
||||
//'re.bonuspunkte',
|
||||
're.provdatum', // Index
|
||||
're.ihrebestellnummer',
|
||||
//'re.usereditid', // Index
|
||||
//'re.useredittimestamp',
|
||||
//'re.realrabatt',
|
||||
're.rabatt',
|
||||
're.einzugsdatum',
|
||||
//'re.rabatt1',
|
||||
//'re.rabatt2',
|
||||
//'re.rabatt3',
|
||||
//'re.rabatt4',
|
||||
//'re.rabatt5',
|
||||
're.forderungsverlust_datum',
|
||||
're.forderungsverlust_betrag',
|
||||
're.steuersatz_normal',
|
||||
're.steuersatz_zwischen',
|
||||
're.steuersatz_ermaessigt',
|
||||
're.steuersatz_starkermaessigt',
|
||||
're.steuersatz_dienstleistung',
|
||||
're.ustid',
|
||||
're.ust_befreit',
|
||||
're.ustbrief',
|
||||
're.ustbrief_eingang',
|
||||
're.ustbrief_eingang_am',
|
||||
're.waehrung',
|
||||
're.keinsteuersatz',
|
||||
//'re.schreibschutz',
|
||||
//'re.pdfarchiviert',
|
||||
//'re.pdfarchiviertversion',
|
||||
//'re.ohne_briefpapier',
|
||||
//'re.lieferid',
|
||||
//'re.systemfreitext',
|
||||
//'re.projektfiliale',
|
||||
//'re.zuarchivieren',
|
||||
're.internebezeichnung',
|
||||
//'re.angelegtam',
|
||||
're.abweichendebezeichnung',
|
||||
're.bezahlt_am',
|
||||
're.sprache',
|
||||
//'re.bundesland',
|
||||
're.gln',
|
||||
//'re.deliverythresholdvatid',
|
||||
're.kurs',
|
||||
're.ohne_artikeltext',
|
||||
're.anzeigesteuer',
|
||||
're.kostenstelle',
|
||||
're.bodyzusatz',
|
||||
're.lieferbedingung',
|
||||
're.skontobetrag',
|
||||
're.skontoberechnet',
|
||||
're.extsoll',
|
||||
're.teilstorno',
|
||||
])->from(self::TABLE_NAME . ' AS re');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('re.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|DeleteQuery
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::TABLE_NAME)->where("id = :id AND (belegnr = '' OR belegnr = '0')");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|DeleteQuery
|
||||
*/
|
||||
protected function deleteProtocolQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::PROTOCOL_TABLE_NAME)->where('rechnung = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|DeleteQuery
|
||||
*/
|
||||
protected function deletePositionQuery()
|
||||
{
|
||||
return $this->db->delete()->from(self::POSITION_TABLE_NAME)->where('rechnung = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return ItemResult
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$deleteQuery = $this->deleteQuery();
|
||||
if (!$deleteQuery) {
|
||||
throw new EndpointNotAvailableException();
|
||||
}
|
||||
if (!$deleteQuery instanceof DeleteQuery && !$deleteQuery instanceof UpdateQuery) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'deleteQuery() must return an instance of %s or %s', DeleteQuery::class, UpdateQuery::class
|
||||
));
|
||||
}
|
||||
|
||||
try {
|
||||
$affectedRow = (int)$this->db->fetchAffected($deleteQuery->getStatement(), ['id' => $id]);
|
||||
if($affectedRow <= 0) {
|
||||
throw new InvalidArgumentException(sprintf('Invoice can not deleted'));
|
||||
}
|
||||
$deleteQuery = $this->deletePositionQuery();
|
||||
$this->db->perform($deleteQuery->getStatement(), ['id' => $id]);
|
||||
$deleteQuery = $this->deleteProtocolQuery();
|
||||
$this->db->perform($deleteQuery->getStatement(), ['id' => $id]);
|
||||
$success = true;
|
||||
} catch (Exception $e) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$result = new ItemResult(['id' => $id]);
|
||||
$result->setSuccess($success);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Angebotspositionen
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentOfferPositionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'angebot_position';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'sort' => 'anpos.sort',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('anpos.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'anpos.id',
|
||||
//'anpos.angebot', // Index
|
||||
'anpos.projekt',
|
||||
'anpos.artikel', // Index
|
||||
'anpos.bezeichnung',
|
||||
'anpos.beschreibung',
|
||||
//'anpos.internerkommentar',
|
||||
'anpos.nummer',
|
||||
'anpos.menge',
|
||||
'anpos.preis',
|
||||
'anpos.waehrung',
|
||||
'anpos.lieferdatum',
|
||||
'anpos.vpe',
|
||||
//'anpos.sort',
|
||||
//'anpos.status',
|
||||
'anpos.umsatzsteuer',
|
||||
'anpos.bemerkung',
|
||||
'anpos.geliefert',
|
||||
//'anpos.logdatei',
|
||||
//'anpos.punkte',
|
||||
//'anpos.bonuspunkte',
|
||||
//'anpos.mlmdirektpraemie',
|
||||
//'anpos.keinrabatterlaubt',
|
||||
//'anpos.grundrabatt',
|
||||
//'anpos.rabattsync',
|
||||
//'anpos.rabatt1',
|
||||
//'anpos.rabatt2',
|
||||
//'anpos.rabatt3',
|
||||
//'anpos.rabatt4',
|
||||
//'anpos.rabatt5',
|
||||
'anpos.einheit',
|
||||
'anpos.optional',
|
||||
'anpos.rabatt',
|
||||
'anpos.zolltarifnummer',
|
||||
'anpos.herkunftsland',
|
||||
'anpos.artikelnummerkunde',
|
||||
'anpos.lieferdatumkw',
|
||||
//'anpos.teilprojekt',
|
||||
//'anpos.kostenstelle',
|
||||
//'anpos.erloese',
|
||||
//'anpos.erloesefestschreiben',
|
||||
//'anpos.einkaufspreiswaehrung',
|
||||
'anpos.einkaufspreis',
|
||||
'anpos.einkaufspreisurspruenglich',
|
||||
//'anpos.einkaufspreisid',
|
||||
//'anpos.ekwaehrung',
|
||||
//'anpos.deckungsbeitrag',
|
||||
//'anpos.freifeld1',
|
||||
//'anpos.freifeld2',
|
||||
//'anpos.freifeld3',
|
||||
//'anpos.freifeld4',
|
||||
//'anpos.freifeld5',
|
||||
//'anpos.freifeld6',
|
||||
//'anpos.freifeld7',
|
||||
//'anpos.freifeld8',
|
||||
//'anpos.freifeld9',
|
||||
//'anpos.freifeld10',
|
||||
//'anpos.freifeld11',
|
||||
//'anpos.freifeld12',
|
||||
//'anpos.freifeld13',
|
||||
//'anpos.freifeld14',
|
||||
//'anpos.freifeld15',
|
||||
//'anpos.freifeld16',
|
||||
//'anpos.freifeld17',
|
||||
//'anpos.freifeld18',
|
||||
//'anpos.freifeld19',
|
||||
//'anpos.freifeld20',
|
||||
//'anpos.freifeld21',
|
||||
//'anpos.freifeld22',
|
||||
//'anpos.freifeld23',
|
||||
//'anpos.freifeld24',
|
||||
//'anpos.freifeld25',
|
||||
//'anpos.freifeld26',
|
||||
//'anpos.freifeld27',
|
||||
//'anpos.freifeld28',
|
||||
//'anpos.freifeld29',
|
||||
//'anpos.freifeld30',
|
||||
//'anpos.freifeld31',
|
||||
//'anpos.freifeld32',
|
||||
//'anpos.freifeld33',
|
||||
//'anpos.freifeld34',
|
||||
//'anpos.freifeld35',
|
||||
//'anpos.freifeld36',
|
||||
//'anpos.freifeld37',
|
||||
//'anpos.freifeld38',
|
||||
//'anpos.freifeld39',
|
||||
//'anpos.freifeld40',
|
||||
//'anpos.formelmenge',
|
||||
//'anpos.formelpreis',
|
||||
'anpos.ohnepreis',
|
||||
'anpos.textalternativpreis',
|
||||
'anpos.steuersatz',
|
||||
'anpos.steuertext',
|
||||
'anpos.steuerbetrag',
|
||||
'anpos.skontobetrag',
|
||||
'anpos.skontosperre',
|
||||
'anpos.berechnen_aus_teile',
|
||||
'anpos.ausblenden_im_pdf',
|
||||
//'anpos.explodiert_parent',
|
||||
//'anpos.umsatz_netto_einzeln',
|
||||
//'anpos.umsatz_netto_gesamt',
|
||||
//'anpos.umsatz_brutto_einzeln',
|
||||
//'anpos.umsatz_brutto_gesamt',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS anpos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('anpos.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für das Angebots-Protokoll
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Incldudes verwendet.
|
||||
*/
|
||||
class DocumentOfferProtocolResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'angebot_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'zeit' => 'anproto.zeit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('anproto.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'anproto.id',
|
||||
//'anproto.angebot',
|
||||
'anproto.zeit',
|
||||
'anproto.bearbeiter',
|
||||
'anproto.grund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS anproto');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('anproto.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Angebote
|
||||
*/
|
||||
class DocumentOfferResource extends AbstractResource
|
||||
{
|
||||
/** @var string */
|
||||
const TABLE_NAME = 'angebot';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'status' => 'an.status LIKE',
|
||||
'belegnr' => 'an.belegnr %LIKE%',
|
||||
'belegnr_equals' => 'an.belegnr LIKE',
|
||||
'belegnr_startswith' => 'an.belegnr LIKE%',
|
||||
'belegnr_endswith' => 'an.belegnr %LIKE',
|
||||
'kundennummer' => 'an.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 'an.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 'an.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 'an.kundennummer %LIKE',
|
||||
'datum' => 'an.datum =',
|
||||
'datum_gt' => 'an.datum >',
|
||||
'datum_gte' => 'an.datum >=',
|
||||
'datum_lt' => 'an.datum <',
|
||||
'datum_lte' => 'an.datum <=',
|
||||
'projekt' => 'an.projekt =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'belegnr' => 'an.belegnr',
|
||||
'datum' => 'an.datum',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'positionen' => [
|
||||
'key' => 'positionen',
|
||||
'resource' => DocumentOfferPositionResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'angebot',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'sort' => 'ASC',
|
||||
],
|
||||
],
|
||||
'protokoll' => [
|
||||
'key' => 'protokoll',
|
||||
'resource' => DocumentOfferProtocolResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'angebot',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'zeit' => 'ASC',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('an.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'an.id',
|
||||
'an.firma',
|
||||
'an.projekt', // Index
|
||||
'an.status', // Index
|
||||
'an.belegnr', // Index
|
||||
'an.kundennummer',
|
||||
'an.aktion',
|
||||
'an.anfrage',
|
||||
'an.internebezeichnung',
|
||||
'an.datum',
|
||||
'an.gueltigbis',
|
||||
'an.lieferdatum',
|
||||
'an.lieferdatumkw',
|
||||
'an.planedorderdate',
|
||||
'an.abweichendebezeichnung',
|
||||
//'an.auftrag',
|
||||
'an.adresse', // Index
|
||||
'an.typ',
|
||||
'an.name',
|
||||
'an.titel',
|
||||
'an.ansprechpartnerid',
|
||||
'an.ansprechpartner',
|
||||
'an.abteilung',
|
||||
'an.unterabteilung',
|
||||
'an.adresszusatz',
|
||||
'an.strasse',
|
||||
'an.plz',
|
||||
'an.ort',
|
||||
'an.land',
|
||||
'an.bundesstaat',
|
||||
'an.telefon',
|
||||
'an.telefax',
|
||||
'an.email',
|
||||
'an.anschreiben',
|
||||
//'an.betreff',
|
||||
//'an.vertrieb',
|
||||
//'an.vertriebid', // Index
|
||||
//'an.deckungsbeitragcalc',
|
||||
//'an.deckungsbeitrag',
|
||||
'an.gesamtsumme',
|
||||
'an.erloes_netto',
|
||||
'an.umsatz_netto',
|
||||
//'an.provision',
|
||||
//'an.provision_summe',
|
||||
//'an.keinsteuersatz',
|
||||
'an.versandart',
|
||||
'an.lieferbedingung',
|
||||
'an.autoversand',
|
||||
'an.keinporto',
|
||||
'an.gesamtsummeausblenden',
|
||||
'an.zahlungsweise',
|
||||
'an.zahlungszieltage',
|
||||
'an.zahlungszieltageskonto',
|
||||
'an.zahlungszielskonto',
|
||||
'an.skontobetrag',
|
||||
'an.skontoberechnet',
|
||||
//'an.bank_inhaber',
|
||||
//'an.bank_institut',
|
||||
//'an.bank_blz',
|
||||
//'an.bank_konto',
|
||||
//'an.kreditkarte_typ',
|
||||
//'an.kreditkarte_inhaber',
|
||||
//'an.kreditkarte_nummer',
|
||||
//'an.kreditkarte_pruefnummer',
|
||||
//'an.kreditkarte_monat',
|
||||
//'an.kreditkarte_jahr',
|
||||
'an.abweichendelieferadresse',
|
||||
'an.liefername',
|
||||
'an.liefertitel',
|
||||
'an.lieferansprechpartner',
|
||||
'an.lieferabteilung',
|
||||
'an.lieferunterabteilung',
|
||||
'an.lieferadresszusatz',
|
||||
'an.lieferstrasse',
|
||||
'an.lieferort',
|
||||
'an.lieferplz',
|
||||
'an.lieferland',
|
||||
'an.lieferbundesstaat',
|
||||
'an.liefertelefon',
|
||||
'an.liefertelefax',
|
||||
'an.liefermail',
|
||||
'an.lieferid',
|
||||
'an.liefergln',
|
||||
'an.lieferemail',
|
||||
|
||||
'an.abweichenderechnungsadresse',
|
||||
'an.retyp',
|
||||
'an.rechnungname',
|
||||
'an.retelefon',
|
||||
'an.reansprechpartner',
|
||||
'an.retelefax',
|
||||
'an.reabteilung',
|
||||
'an.reemail',
|
||||
'an.reunterabteilung',
|
||||
'an.readresszusatz',
|
||||
'an.restrasse',
|
||||
'an.replz',
|
||||
'an.reort',
|
||||
'an.reland',
|
||||
|
||||
'an.versendet',
|
||||
'an.versendet_am',
|
||||
'an.versendet_per',
|
||||
'an.versendet_durch',
|
||||
//'an.inbearbeitung',
|
||||
//'an.vermerk',
|
||||
//'an.logdatei',
|
||||
//'an.auftragid',
|
||||
//'an.anfrageid',
|
||||
//'an.gruppe', // Index
|
||||
//'an.usereditid', // Index
|
||||
//'an.useredittimestamp',
|
||||
//'an.realrabatt',
|
||||
//'an.rabatt',
|
||||
//'an.rabatt1',
|
||||
//'an.rabatt2',
|
||||
//'an.rabatt3',
|
||||
//'an.rabatt4',
|
||||
//'an.rabatt5',
|
||||
//'an.steuersatz_normal',
|
||||
//'an.steuersatz_zwischen',
|
||||
//'an.steuersatz_ermaessigt',
|
||||
//'an.steuersatz_starkermaessigt',
|
||||
//'an.steuersatz_dienstleistung',
|
||||
//'an.schreibschutz',
|
||||
//'an.pdfarchiviert',
|
||||
//'an.pdfarchiviertversion',
|
||||
//'an.ohne_briefpapier',
|
||||
//'an.projektfiliale',
|
||||
//'an.zuarchivieren',
|
||||
//'an.angelegtam',
|
||||
//'an.kopievon',
|
||||
//'an.kopienummer',
|
||||
'an.gln',
|
||||
'an.bearbeiterid',
|
||||
'an.bearbeiter',
|
||||
'an.ohne_artikeltext',
|
||||
'an.ustid',
|
||||
'an.ust_befreit',
|
||||
'an.anzeigesteuer',
|
||||
'an.waehrung',
|
||||
'an.sprache',
|
||||
'an.kurs',
|
||||
'an.kostenstelle',
|
||||
'an.freitext',
|
||||
'an.internebemerkung',
|
||||
'an.bodyzusatz',
|
||||
'an.shop',
|
||||
'an.shopextid',
|
||||
'an.internet',
|
||||
//'an.transaktionsnummer',
|
||||
//'an.packstation_inhaber',
|
||||
//'an.packstation_station',
|
||||
//'an.packstation_ident',
|
||||
//'an.packstation_plz',
|
||||
//'an.packstation_ort',
|
||||
])->from(self::TABLE_NAME . ' AS an');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('an.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Auftragspositionen
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentSalesOrderPositionResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'auftrag_position';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'sort' => 'aupos.sort',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('aupos.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'aupos.id',
|
||||
'aupos.auftrag', // Index
|
||||
'aupos.projekt',
|
||||
'aupos.artikel', // Index
|
||||
'aupos.bezeichnung',
|
||||
'aupos.beschreibung',
|
||||
//'aupos.internerkommentar',
|
||||
'aupos.nummer',
|
||||
'aupos.menge',
|
||||
'aupos.preis',
|
||||
'aupos.waehrung',
|
||||
'aupos.lieferdatum',
|
||||
'aupos.vpe',
|
||||
//'aupos.sort',
|
||||
//'aupos.status',
|
||||
'aupos.umsatzsteuer',
|
||||
'aupos.bemerkung',
|
||||
'aupos.geliefert',
|
||||
'aupos.geliefert_menge',
|
||||
//'aupos.logdatei',
|
||||
//'aupos.punkte',
|
||||
//'aupos.bonuspunkte',
|
||||
//'aupos.mlmdirektpraemie',
|
||||
//'aupos.keinrabatterlaubt',
|
||||
//'aupos.grundrabatt',
|
||||
//'aupos.rabattsync',
|
||||
//'aupos.rabatt1',
|
||||
//'aupos.rabatt2',
|
||||
//'aupos.rabatt3',
|
||||
//'aupos.rabatt4',
|
||||
//'aupos.rabatt5',
|
||||
'aupos.einheit',
|
||||
'aupos.webid',
|
||||
'aupos.rabatt',
|
||||
'aupos.nachbestelltexternereinkauf',
|
||||
'aupos.potentiellerliefertermin',
|
||||
'aupos.zolleinzelwert',
|
||||
'aupos.zollgesamtwert',
|
||||
'aupos.zollwaehrung',
|
||||
'aupos.zolleinzelgewicht',
|
||||
'aupos.zollgesamtgewicht',
|
||||
'aupos.zolltarifnummer',
|
||||
'aupos.herkunftsland',
|
||||
'aupos.artikelnummerkunde',
|
||||
'aupos.lieferdatumkw',
|
||||
//'aupos.teilprojekt',
|
||||
//'aupos.kostenstelle',
|
||||
//'aupos.erloese',
|
||||
//'aupos.erloesefestschreiben',
|
||||
//'aupos.einkaufspreiswaehrung',
|
||||
'aupos.einkaufspreis',
|
||||
'aupos.einkaufspreisurspruenglich',
|
||||
//'aupos.einkaufspreisid',
|
||||
//'aupos.ekwaehrung',
|
||||
//'aupos.deckungsbeitrag',
|
||||
//'aupos.freifeld1',
|
||||
//'aupos.freifeld2',
|
||||
//'aupos.freifeld3',
|
||||
//'aupos.freifeld4',
|
||||
//'aupos.freifeld5',
|
||||
//'aupos.freifeld6',
|
||||
//'aupos.freifeld7',
|
||||
//'aupos.freifeld8',
|
||||
//'aupos.freifeld9',
|
||||
//'aupos.freifeld10',
|
||||
//'aupos.freifeld11',
|
||||
//'aupos.freifeld12',
|
||||
//'aupos.freifeld13',
|
||||
//'aupos.freifeld14',
|
||||
//'aupos.freifeld15',
|
||||
//'aupos.freifeld16',
|
||||
//'aupos.freifeld17',
|
||||
//'aupos.freifeld18',
|
||||
//'aupos.freifeld19',
|
||||
//'aupos.freifeld20',
|
||||
//'aupos.freifeld21',
|
||||
//'aupos.freifeld22',
|
||||
//'aupos.freifeld23',
|
||||
//'aupos.freifeld24',
|
||||
//'aupos.freifeld25',
|
||||
//'aupos.freifeld26',
|
||||
//'aupos.freifeld27',
|
||||
//'aupos.freifeld28',
|
||||
//'aupos.freifeld29',
|
||||
//'aupos.freifeld30',
|
||||
//'aupos.freifeld31',
|
||||
//'aupos.freifeld32',
|
||||
//'aupos.freifeld33',
|
||||
//'aupos.freifeld34',
|
||||
//'aupos.freifeld35',
|
||||
//'aupos.freifeld36',
|
||||
//'aupos.freifeld37',
|
||||
//'aupos.freifeld38',
|
||||
//'aupos.freifeld39',
|
||||
//'aupos.freifeld40',
|
||||
//'aupos.formelmenge',
|
||||
//'aupos.formelpreis',
|
||||
'aupos.ohnepreis',
|
||||
'aupos.steuersatz',
|
||||
'aupos.steuertext',
|
||||
'aupos.steuerbetrag',
|
||||
'aupos.skontobetrag',
|
||||
'aupos.skontosperre',
|
||||
'aupos.ausblenden_im_pdf',
|
||||
//'aupos.explodiert',
|
||||
//'aupos.explodiert_parent', // Index
|
||||
//'aupos.umsatz_netto_einzeln',
|
||||
//'aupos.umsatz_netto_gesamt',
|
||||
//'aupos.umsatz_brutto_einzeln',
|
||||
//'aupos.umsatz_brutto_gesamt',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS aupos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('aupos.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für das Auftrags-Protokoll
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Includes verwendet.
|
||||
*/
|
||||
class DocumentSalesOrderProtocolResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'auftrag_protokoll';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'zeit' => 'auproto.zeit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('auproto.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'auproto.id',
|
||||
'auproto.auftrag',
|
||||
'auproto.zeit',
|
||||
'auproto.bearbeiter',
|
||||
'auproto.grund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS auproto');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('auproto.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Aufträge (Verkauf)
|
||||
*/
|
||||
class DocumentSalesOrderResource extends AbstractResource
|
||||
{
|
||||
/** @var string */
|
||||
const TABLE_NAME = 'auftrag';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'status' => 'au.status LIKE',
|
||||
'belegnr' => 'au.belegnr %LIKE%',
|
||||
'belegnr_equals' => 'au.belegnr LIKE',
|
||||
'belegnr_startswith' => 'au.belegnr LIKE%',
|
||||
'belegnr_endswith' => 'au.belegnr %LIKE',
|
||||
'kundennummer' => 'au.kundennummer %LIKE%',
|
||||
'kundennummer_equals' => 'au.kundennummer LIKE',
|
||||
'kundennummer_startswith' => 'au.kundennummer LIKE%',
|
||||
'kundennummer_endswith' => 'au.kundennummer %LIKE',
|
||||
'internet' => 'au.internet %LIKE%',
|
||||
'internet_equals' => 'au.internet LIKE',
|
||||
'internet_startswith' => 'au.internet LIKE%',
|
||||
'internet_endswith' => 'au.internet %LIKE',
|
||||
'datum' => 'au.datum =',
|
||||
'datum_gt' => 'au.datum >',
|
||||
'datum_gte' => 'au.datum >=',
|
||||
'datum_lt' => 'au.datum <',
|
||||
'datum_lte' => 'au.datum <=',
|
||||
'angebot' => 'au.angebot LIKE',
|
||||
'angebotid' => 'au.angebotid =',
|
||||
'projekt' => 'au.projekt =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'belegnr' => 'au.belegnr',
|
||||
'datum' => 'au.datum',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'positionen' => [
|
||||
'key' => 'positionen',
|
||||
'resource' => DocumentSalesOrderPositionResource::class,
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'auftrag',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'sort' => 'ASC',
|
||||
],
|
||||
],
|
||||
'protokoll' => [
|
||||
'key' => 'protokoll',
|
||||
'resource' => DocumentSalesOrderProtocolResource::class,
|
||||
'columns' => [
|
||||
'auproto.id',
|
||||
'auproto.zeit',
|
||||
'auproto.bearbeiter',
|
||||
'auproto.grund',
|
||||
],
|
||||
'filter' => [
|
||||
[
|
||||
'property' => 'auftrag',
|
||||
'value' => ':id',
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'zeit' => 'ASC',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('au.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'au.id',
|
||||
'au.firma',
|
||||
'au.projekt', // Index
|
||||
'au.status', // Index
|
||||
'au.belegnr', // Index
|
||||
'au.kundennummer',
|
||||
'au.lieferantenauftrag',
|
||||
'au.lieferant',
|
||||
'au.aktion',
|
||||
'au.angebot',
|
||||
'au.ihrebestellnummer',
|
||||
'au.internet', // Index
|
||||
'au.internebezeichnung',
|
||||
'au.datum',
|
||||
'au.lieferdatum',
|
||||
'au.lieferdatumkw',
|
||||
'au.tatsaechlicheslieferdatum',
|
||||
'au.reservationdate',
|
||||
'au.abweichendebezeichnung',
|
||||
|
||||
'au.adresse', // Index
|
||||
'au.typ',
|
||||
'au.name',
|
||||
'au.titel',
|
||||
'au.ansprechpartnerid',
|
||||
'au.ansprechpartner',
|
||||
'au.abteilung',
|
||||
'au.unterabteilung',
|
||||
'au.adresszusatz',
|
||||
'au.strasse',
|
||||
'au.plz',
|
||||
'au.ort',
|
||||
'au.land',
|
||||
'au.bundesstaat',
|
||||
'au.telefon',
|
||||
'au.telefax',
|
||||
'au.email',
|
||||
'au.anschreiben',
|
||||
//'au.betreff',
|
||||
//'au.vertrieb',
|
||||
//'au.vertriebid', // Index
|
||||
//'au.deckungsbeitragcalc',
|
||||
//'au.deckungsbeitrag',
|
||||
'au.gesamtsumme',
|
||||
'au.erloes_netto',
|
||||
'au.umsatz_netto',
|
||||
//'au.provision',
|
||||
//'au.provision_summe',
|
||||
//'au.keinsteuersatz',
|
||||
|
||||
'au.lager_ok',
|
||||
'au.porto_ok',
|
||||
'au.ust_ok',
|
||||
'au.check_ok',
|
||||
'au.vorkasse_ok',
|
||||
'au.nachnahme_ok',
|
||||
'au.reserviert_ok',
|
||||
'au.partnerid',
|
||||
'au.folgebestaetigung',
|
||||
'au.zahlungsmail',
|
||||
'au.liefertermin_ok',
|
||||
'au.teillieferung_moeglich',
|
||||
'au.kreditlimit_ok',
|
||||
'au.kreditlimit_freigabe',
|
||||
'au.liefersperre_ok',
|
||||
'au.teillieferungvon', // Index
|
||||
'au.teillieferungnummer',
|
||||
|
||||
'au.autofreigabe',
|
||||
'au.freigabe',
|
||||
'au.nachbesserung',
|
||||
'au.abgeschlossen',
|
||||
'au.nachlieferung',
|
||||
'au.versandart',
|
||||
'au.lieferbedingung',
|
||||
'au.autoversand',
|
||||
'au.keinporto',
|
||||
'au.art',
|
||||
'au.fastlane',
|
||||
'au.lieferungtrotzsperre',
|
||||
'au.keinestornomail',
|
||||
'au.keinetrackingmail',
|
||||
'au.zahlungsmailcounter',
|
||||
'au.zahlungsweise',
|
||||
'au.zahlungszieltage',
|
||||
'au.zahlungszieltageskonto',
|
||||
'au.zahlungszielskonto',
|
||||
'au.skontobetrag',
|
||||
'au.skontoberechnet',
|
||||
//'au.bank_inhaber',
|
||||
//'au.bank_institut',
|
||||
//'au.bank_blz',
|
||||
//'au.bank_konto',
|
||||
//'au.kreditkarte_typ',
|
||||
//'au.kreditkarte_inhaber',
|
||||
//'au.kreditkarte_nummer',
|
||||
//'au.kreditkarte_pruefnummer',
|
||||
//'au.kreditkarte_monat',
|
||||
//'au.kreditkarte_jahr',
|
||||
'au.abweichendelieferadresse',
|
||||
'au.liefername',
|
||||
'au.liefertitel',
|
||||
'au.lieferansprechpartner',
|
||||
'au.lieferabteilung',
|
||||
'au.lieferunterabteilung',
|
||||
'au.lieferadresszusatz',
|
||||
'au.lieferstrasse',
|
||||
'au.lieferort',
|
||||
'au.lieferplz',
|
||||
'au.lieferland',
|
||||
'au.lieferbundesstaat',
|
||||
'au.lieferemail',
|
||||
'au.lieferid',
|
||||
'au.liefergln',
|
||||
|
||||
'au.versendet',
|
||||
'au.versendet_am',
|
||||
'au.versendet_per',
|
||||
'au.versendet_durch',
|
||||
//'au.inbearbeitung',
|
||||
//'au.logdatei',
|
||||
'au.angebotid',
|
||||
//'au.rechnungid',
|
||||
//'au.anfrageid',
|
||||
//'au.gruppe', // Index
|
||||
//'au.usereditid', // Index
|
||||
//'au.useredittimestamp',
|
||||
//'au.realrabatt',
|
||||
//'au.rabatt',
|
||||
//'au.rabatt1',
|
||||
//'au.rabatt2',
|
||||
//'au.rabatt3',
|
||||
//'au.rabatt4',
|
||||
//'au.rabatt5',
|
||||
//'au.steuersatz_normal',
|
||||
//'au.steuersatz_zwischen',
|
||||
//'au.steuersatz_ermaessigt',
|
||||
//'au.steuersatz_starkermaessigt',
|
||||
//'au.steuersatz_dienstleistung',
|
||||
//'au.schreibschutz',
|
||||
//'au.pdfarchiviert',
|
||||
//'au.pdfarchiviertversion',
|
||||
//'au.ohne_briefpapier',
|
||||
//'au.projektfiliale',
|
||||
//'au.zuarchivieren',
|
||||
//'au.angelegtam',
|
||||
//'au.partnerausgezahlt',
|
||||
//'au.partnerausgezahltam',
|
||||
//'au.kennen',
|
||||
//'au.rma',
|
||||
//'au.transaktionsnummer', // Index
|
||||
//'au.vorabbezahltmarkieren',
|
||||
//'au.einzugsdatum',
|
||||
//'au.auftragseingangper',
|
||||
//'au.systemfreitext',
|
||||
//'au.saldo',
|
||||
//'au.saldogeprueft',
|
||||
//'au.rabatteportofestschreiben',
|
||||
//'au.deliverythresholdvatid',
|
||||
//'au.lieferantennummer',
|
||||
//'au.lieferantkdrnummer', // Index
|
||||
//'au.webid',
|
||||
//'au.cronjobkommissionierung',
|
||||
//'au.standardlager',
|
||||
//'au.kommissionskonsignationslager',
|
||||
//'au.extsoll',
|
||||
'au.gln',
|
||||
'au.bearbeiterid',
|
||||
'au.bearbeiter',
|
||||
'au.ohne_artikeltext',
|
||||
'au.ustid',
|
||||
'au.ust_befreit',
|
||||
'au.ust_inner',
|
||||
'au.anzeigesteuer',
|
||||
'au.waehrung',
|
||||
'au.sprache',
|
||||
'au.kurs',
|
||||
'au.kostenstelle',
|
||||
'au.freitext',
|
||||
'au.internebemerkung',
|
||||
'au.bodyzusatz',
|
||||
'au.shop',
|
||||
'au.shopextid',
|
||||
'au.shopextstatus',
|
||||
//'au.stornogrund',
|
||||
//'au.stornosonstiges',
|
||||
//'au.stornorueckzahlung',
|
||||
//'au.stornobetrag',
|
||||
//'au.stornobankinhaber',
|
||||
//'au.stornobankkonto',
|
||||
//'au.stornobankblz',
|
||||
//'au.stornobankbank',
|
||||
//'au.stornogutschrift',
|
||||
//'au.stornogutschriftbeleg',
|
||||
//'au.stornowareerhalten',
|
||||
//'au.stornomanuellebearbeitung',
|
||||
//'au.stornokommentar',
|
||||
//'au.stornobezahlt',
|
||||
//'au.stornobezahltam',
|
||||
//'au.stornobezahltvon',
|
||||
//'au.stornoabgeschlossen',
|
||||
//'au.stornorueckzahlungper',
|
||||
//'au.stornowareerhaltenretour',
|
||||
//'au.transaktionsnummer',
|
||||
//'au.packstation_inhaber',
|
||||
//'au.packstation_station',
|
||||
//'au.packstation_ident',
|
||||
//'au.packstation_plz',
|
||||
//'au.packstation_ort',
|
||||
])->from(self::TABLE_NAME . ' AS au');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('s.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource hat keinen eigenen API-Endpunkt (keine URL).
|
||||
* Ressource dient nur als Include für die DocumentScanner-Ressource.
|
||||
*/
|
||||
class DocumentScannerMetaDataResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'docscan_metadata';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'dm.id',
|
||||
'dm.meta_key',
|
||||
'dm.meta_value',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS dm');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class DocumentScannerResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'docscan';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'titel' => 'd.titel %LIKE%',
|
||||
'titel_equals' => 'd.titel LIKE',
|
||||
'titel_startswith' => 'd.titel LIKE%',
|
||||
'titel_endswith' => 'd.titel %LIKE',
|
||||
'dateiname' => 'dv.dateiname %LIKE%',
|
||||
'dateiname_equals' => 'dv.dateiname LIKE',
|
||||
'dateiname_startswith' => 'dv.dateiname LIKE%',
|
||||
'dateiname_endswith' => 'dv.dateiname %LIKE',
|
||||
'datum' => 'dv.datum =',
|
||||
'datum_gt' => 'dv.datum >',
|
||||
'datum_gte' => 'dv.datum >=',
|
||||
'datum_lt' => 'dv.datum <',
|
||||
'datum_lte' => 'dv.datum <=',
|
||||
'belegtyp' => 'dsg.belegtypen %LIKE%',
|
||||
'stichwort' => 'dsg.stichwoerter %LIKE%',
|
||||
'firma' => 'd.firma =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'titel' => 'd.titel',
|
||||
'dateiname' => 'dv.dateiname',
|
||||
'datum' => 'dv.datum',
|
||||
]);
|
||||
|
||||
/*$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'geloescht' => 'in:0,1',
|
||||
]);*/
|
||||
|
||||
$this->registerIncludes([
|
||||
'metadata' => [
|
||||
'key' => 'metadata',
|
||||
'resource' => DocumentScannerMetaDataResource::class,
|
||||
'filter' => [
|
||||
['property' => 'docscan_id', 'value' => ':docscan_id'],
|
||||
],
|
||||
'columns' => [
|
||||
//'dm.id',
|
||||
'dm.meta_key',
|
||||
'dm.meta_value',
|
||||
],
|
||||
],
|
||||
'stichwoerter' => [
|
||||
'key' => 'stichwoerter',
|
||||
'resource' => FileKeywordResource::class,
|
||||
'filter' => [
|
||||
['property' => 'datei', 'value' => ':id'],
|
||||
],
|
||||
'columns' => [
|
||||
'ds.id',
|
||||
'ds.subjekt AS stichwort',
|
||||
'ds.objekt AS belegtyp',
|
||||
'ds.parameter AS beleg_id',
|
||||
'ds.sort',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'd.id',
|
||||
'doc.id AS docscan_id',
|
||||
'd.titel',
|
||||
'd.beschreibung',
|
||||
'd.nummer',
|
||||
'd.firma',
|
||||
'dv.ersteller',
|
||||
'dv.datum',
|
||||
'dv.version',
|
||||
'dv.dateiname',
|
||||
'dv.bemerkung',
|
||||
'dv.size',
|
||||
// 'dsg.belegtypen',
|
||||
// 'dsg.stichwoerter',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS doc')
|
||||
->innerJoin('datei AS d', 'doc.datei = d.id')
|
||||
->innerJoin('datei_stichwoerter AS ds', 'd.id = ds.datei AND ds.objekt LIKE \'DocScan\'')
|
||||
->joinSubSelect(
|
||||
'INNER',
|
||||
'SELECT dv.datei, MAX(dv.id) AS max_id
|
||||
FROM datei_version AS dv
|
||||
GROUP BY dv.datei',
|
||||
'dvm',
|
||||
'd.id = dvm.datei'
|
||||
)
|
||||
->innerJoin(
|
||||
'datei_version AS dv',
|
||||
'd.id = dv.datei AND dv.id = dvm.max_id'
|
||||
)
|
||||
->joinSubSelect( // wird für Filter benötigt
|
||||
'LEFT',
|
||||
'SELECT
|
||||
dsg.datei,
|
||||
GROUP_CONCAT(DISTINCT dsg.subjekt) AS stichwoerter,
|
||||
GROUP_CONCAT(DISTINCT dsg.objekt) AS belegtypen
|
||||
FROM datei_stichwoerter AS dsg
|
||||
GROUP BY dsg.datei',
|
||||
'dsg',
|
||||
'd.id = dsg.datei'
|
||||
)
|
||||
->where('d.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Insert ist möglich; wird aber über den Controller verarbeitet.
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Exception;
|
||||
|
||||
class EndpointNotAvailableException extends \RuntimeException
|
||||
{
|
||||
protected $message = 'API-Endpoint is not available';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Exception;
|
||||
|
||||
class ValidationRequiredException extends \RuntimeException
|
||||
{
|
||||
protected $message = 'Validation is required for inserting and updating resources.';
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Feature;
|
||||
|
||||
use Xentral\Modules\Api\Resource\Filter\Select\SimpleSearchFilter;
|
||||
|
||||
trait FilterFeatureTrait
|
||||
{
|
||||
/**
|
||||
* Festlegen welche Filter erlaubt sind
|
||||
*
|
||||
* @example $this->registerFilterParams([
|
||||
* 'title' => 'l.bezeichnung %LIKE%',
|
||||
* 'title_starts_with' => 'l.bezeichnung LIKE%',
|
||||
* 'title_ends_with' => 'l.bezeichnung %LIKE',
|
||||
* 'title_exact' => 'l.bezeichnung LIKE',
|
||||
* 'project' => 'l.projekt =',
|
||||
* 'project_not' => 'l.projekt !=',
|
||||
* 'amount_min' => 'l.amount >=',
|
||||
* 'amount_max' => 'l.amount <=',
|
||||
* ]);
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
protected function registerFilterParams(array $params)
|
||||
{
|
||||
$this->registerSelectFilter(new SimpleSearchFilter($params));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Feature;
|
||||
|
||||
use Xentral\Modules\Api\Exception\InvalidArgumentException;
|
||||
use Xentral\Modules\Api\Exception\ResourceNotFoundException;
|
||||
use Xentral\Modules\Api\Resource\AbstractResource;
|
||||
|
||||
trait IncludeFeatureTrait
|
||||
{
|
||||
/** @var array $includeSettings */
|
||||
private $includeSettings;
|
||||
|
||||
/**
|
||||
* @example in configure-Methode der Resource:
|
||||
* $this->registerIncludes([
|
||||
* 'projekte' => [
|
||||
* 'key' => 'projekt',
|
||||
* 'resource' => ProjectResource::class,
|
||||
* 'columns' => [
|
||||
* 'p.id',
|
||||
* 'p.name',
|
||||
* 'p.abkuerzung',
|
||||
* 'p.beschreibung',
|
||||
* 'p.farbe',
|
||||
* ],
|
||||
* ],
|
||||
* ]);
|
||||
*
|
||||
* @param array $includes
|
||||
*/
|
||||
protected function registerIncludes($includes)
|
||||
{
|
||||
$this->includeSettings = $includes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $includes
|
||||
* @param array $items
|
||||
* @param bool $isCollection true=Mehrzeilig, false=Assoziatives Array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function integrateIncludes(array $includes, array &$items, $isCollection = true)
|
||||
{
|
||||
// Keine Includes gesetzt
|
||||
if (empty($includes)) {
|
||||
return $items;
|
||||
}
|
||||
if (empty($this->includeSettings)) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
// Doppelte Includes entfernen
|
||||
$includes = array_unique($includes);
|
||||
|
||||
// Einzelnes Item in Collection verwandeln
|
||||
if (!$isCollection) {
|
||||
$items = [$items];
|
||||
}
|
||||
|
||||
foreach ($includes as $includeName) {
|
||||
|
||||
if (empty($includeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$settings = $this->getIncludeSetting($includeName);
|
||||
$subKey = $settings['key'];
|
||||
|
||||
if (empty($subKey)) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Include "%s" not posible. Key is missing.', $includeName
|
||||
));
|
||||
}
|
||||
|
||||
// Nur bestimmte Spalten inkludieren?
|
||||
$columns = isset($settings['columns']) ? $settings['columns'] : [];
|
||||
|
||||
// 1:n Beziehung zwischen Resource und Subresource
|
||||
if (isset($settings['filter'])) {
|
||||
|
||||
/** @var AbstractResource $subResource */
|
||||
$subResource = $this->getResource($settings['resource']);
|
||||
|
||||
foreach ($items as &$item) {
|
||||
|
||||
// Filter aufbereiten
|
||||
$filter = $settings['filter'];
|
||||
foreach ($filter as &$filterItem) {
|
||||
// Filter benötigt Wert aus Haupt-Resource
|
||||
if (strpos($filterItem['value'], ':') === 0) {
|
||||
$key = substr_replace($filterItem['value'], '', 0, 1);
|
||||
$filterItem['value'] = $item[$key];
|
||||
}
|
||||
}
|
||||
unset($filterItem);
|
||||
$filter = ['filter' => $filter]; // In ComplexSearch-Filter wandeln
|
||||
|
||||
// Sortierung vorhanden?
|
||||
$sort = !empty($settings['sort']) ? $settings['sort'] : [];
|
||||
|
||||
try {
|
||||
/** @var AbstractResource $subResource */
|
||||
$subResult = $subResource->getList($filter, $sort, $columns, [], 1, 1000);
|
||||
$subItems = $subResult->getData();
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$subItems = [];
|
||||
}
|
||||
$item[$settings['key']] = $subItems;
|
||||
}
|
||||
unset($item);
|
||||
|
||||
// 1:1 Beziehung zwischen Resource und Subresource
|
||||
} else {
|
||||
|
||||
// Prüfen ob Spalte zum Integrieren in Haupt-Ergebnis existiert
|
||||
if (!$this->arrayColumnExists($items, $subKey)) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Include "%s" not posible. Key "%s" is missing.', $includeName, $subKey
|
||||
));
|
||||
}
|
||||
|
||||
// Benötigte Subresourcen-IDs aus Haupt-Ergebnis holen
|
||||
$subIds = array_unique(array_column($items, $subKey));
|
||||
if (empty($subIds)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Subresourcen anhand der IDs laden
|
||||
try {
|
||||
/** @var AbstractResource $subResource */
|
||||
$subResource = $this->getResource($settings['resource']);
|
||||
$subResult = $subResource->getIds($subIds, $columns);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Gefundene Subresourcen in Haupt-Ergebnis einbinden
|
||||
array_walk($items, function (&$item, $id, $subItems) use ($subKey) {
|
||||
$subId = (int)$item[$subKey];
|
||||
if (isset($subItems[$subId])) {
|
||||
$item[$subKey] = $subItems[$subId];
|
||||
}
|
||||
}, $subResult->getData());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isCollection) {
|
||||
return $items[0];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $includeName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getIncludeSetting($includeName)
|
||||
{
|
||||
if (!isset($this->includeSettings[$includeName])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Include "%s" is not registered.', $includeName)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->includeSettings[$includeName];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $items
|
||||
* @param string $keyName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function arrayColumnExists(array $items, $keyName)
|
||||
{
|
||||
$row = current($items);
|
||||
|
||||
return array_key_exists($keyName, $row);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Feature;
|
||||
|
||||
use Xentral\Modules\Api\Resource\Filter\Select\SortingFilter;
|
||||
|
||||
trait SortingFeatureTrait
|
||||
{
|
||||
/**
|
||||
* Festlegen welche Sortierungen erlaubt sind
|
||||
*
|
||||
* @example $this->registerSortingParams([
|
||||
* 'bezeichnung' => 'k.bezeichnung',
|
||||
* 'projekt' => 'k.projekt',
|
||||
* 'parent' => 'k.parent',
|
||||
* ]);
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
protected function registerSortingParams(array $params)
|
||||
{
|
||||
$this->registerSelectFilter(new SortingFilter($params));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Feature;
|
||||
|
||||
use Rakit\Validation\Validation;
|
||||
use Xentral\Modules\Api\Exception\ValidationErrorException;
|
||||
use Xentral\Modules\Api\Resource\Exception\ValidationRequiredException;
|
||||
|
||||
trait ValidationFeatureTrait
|
||||
{
|
||||
/** @var array $validationRules */
|
||||
private $validationRules;
|
||||
|
||||
/** @var string $resourceTableName */
|
||||
private $resourceTableName;
|
||||
|
||||
/**
|
||||
* Validierungsregeln festlegen
|
||||
*
|
||||
* @example $this->registerValidationRules([
|
||||
* 'id' => 'not_present',
|
||||
* 'bezeichnung' => 'required|unique:artikelkategorien,bezeichnung',
|
||||
* 'next_number' => 'numeric',
|
||||
* 'projekt' => 'numeric',
|
||||
* 'parent' => 'numeric',
|
||||
* 'externenummer' => 'numeric',
|
||||
* 'geloescht' => 'in:0,1',
|
||||
* ]);
|
||||
|
||||
* @see https://github.com/rakit/validation#available-rules
|
||||
*
|
||||
* @param array $rules
|
||||
*/
|
||||
protected function registerValidationRules(array $rules)
|
||||
{
|
||||
$this->validationRules = $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $inputVars
|
||||
* @param int $selfId
|
||||
*/
|
||||
protected function validateData($inputVars, $selfId = null)
|
||||
{
|
||||
if (empty($this->validationRules)) {
|
||||
throw new ValidationRequiredException();
|
||||
}
|
||||
|
||||
// Regeln aufbereiten
|
||||
$rules = $this->validationRules;
|
||||
if ($selfId) {
|
||||
$needle = sprintf('unique:%s,', $this->resourceTableName);
|
||||
foreach ($rules as $ruleKey => $ruleVal) {
|
||||
if ($pos = strpos($ruleVal, $needle)) {
|
||||
|
||||
// Nach Anfang der nachfolgenden Regel suchen
|
||||
$searchPos = $pos + strlen($needle);
|
||||
$insertPos = strpos($ruleVal, '|', $searchPos);
|
||||
|
||||
// Keine weitere Regel gefunden; am Ende anfügen
|
||||
if (!$insertPos) {
|
||||
$insertPos = strlen($ruleVal);
|
||||
}
|
||||
|
||||
// ID als dritten Parameter für UniqueRule übergeben
|
||||
/** @see UniqueRule Parameter "except" */
|
||||
$newRuleVal = substr_replace($ruleVal, ',' . $selfId, $insertPos, 0);
|
||||
|
||||
$rules[$ruleKey] = $newRuleVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @var Validation $validation */
|
||||
$validation = $this->validator->validate($inputVars, $rules);
|
||||
if ($validation->fails()) {
|
||||
throw new ValidationErrorException($validation->errors()->all());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
*/
|
||||
protected function setTableName($tableName)
|
||||
{
|
||||
$this->resourceTableName = $tableName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressource hat keinen eigenen API-Endpunkt (keine URL).
|
||||
* Ressource dient nur als Include für die Dateien-Ressource.
|
||||
*/
|
||||
class FileKeywordResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'datei_stichwoerter';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'ds.id',
|
||||
'ds.subjekt',
|
||||
'ds.objekt',
|
||||
'ds.parameter',
|
||||
'ds.sort',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS ds');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class FileResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'datei';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'titel' => 'd.titel %LIKE%',
|
||||
'titel_equals' => 'd.titel LIKE',
|
||||
'titel_startswith' => 'd.titel LIKE%',
|
||||
'titel_endswith' => 'd.titel %LIKE',
|
||||
'dateiname' => 'dv.dateiname %LIKE%',
|
||||
'dateiname_equals' => 'dv.dateiname LIKE',
|
||||
'dateiname_startswith' => 'dv.dateiname LIKE%',
|
||||
'dateiname_endswith' => 'dv.dateiname %LIKE',
|
||||
'belegtyp' => 'ds.belegtypen %LIKE%',
|
||||
'stichwort' => 'ds.stichwoerter %LIKE%',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'titel' => 'd.titel',
|
||||
'dateiname' => 'dv.dateiname',
|
||||
'datum' => 'dv.datum',
|
||||
]);
|
||||
|
||||
/*$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'geloescht' => 'in:0,1',
|
||||
]);*/
|
||||
|
||||
$this->registerIncludes([
|
||||
'stichwoerter' => [
|
||||
'key' => 'stichwoerter',
|
||||
'resource' => FileKeywordResource::class,
|
||||
'filter' => [
|
||||
['property' => 'datei', 'value' => ':id'],
|
||||
],
|
||||
'columns' => [
|
||||
'ds.id',
|
||||
'ds.subjekt AS stichwort',
|
||||
'ds.objekt AS belegtyp',
|
||||
'ds.parameter AS beleg_id',
|
||||
'ds.sort',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'd.id',
|
||||
'd.titel',
|
||||
'd.beschreibung',
|
||||
'd.nummer',
|
||||
'd.firma',
|
||||
'dv.ersteller',
|
||||
'dv.datum',
|
||||
'dv.version',
|
||||
'dv.dateiname',
|
||||
'dv.bemerkung',
|
||||
'dv.size',
|
||||
'ds.belegtypen',
|
||||
'ds.stichwoerter',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS d')
|
||||
->joinSubSelect(
|
||||
'INNER',
|
||||
'SELECT dv.datei, MAX(dv.id) AS max_id
|
||||
FROM datei_version AS dv
|
||||
GROUP BY dv.datei',
|
||||
'dvm',
|
||||
'd.id = dvm.datei'
|
||||
)
|
||||
->innerJoin(
|
||||
'datei_version AS dv',
|
||||
'd.id = dv.datei AND dv.id = dvm.max_id'
|
||||
)
|
||||
->joinSubSelect(
|
||||
'LEFT',
|
||||
'SELECT
|
||||
ds.datei,
|
||||
GROUP_CONCAT(ds.subjekt) AS stichwoerter,
|
||||
GROUP_CONCAT(ds.objekt) AS belegtypen
|
||||
FROM datei_stichwoerter AS ds
|
||||
GROUP BY ds.datei',
|
||||
'ds',
|
||||
'd.id = ds.datei'
|
||||
)
|
||||
->where('d.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('d.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Insert ist möglich; wird aber über den FileController verarbeitet.
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Filter\Select;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\Api\Exception\InvalidArgumentException;
|
||||
|
||||
class ComplexSearchFilter implements SelectFilterInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param array $filter
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
public function applyFilter(SelectQuery $query, array $filter)
|
||||
{
|
||||
$filterParams = isset($filter['filter']) && is_array($filter['filter']) ? $filter['filter'] : [];
|
||||
|
||||
// Komplexe Suchfilter mit Klammern umschließen
|
||||
return $query->where(function ($inner) use ($filterParams) {
|
||||
$this->appendFilterQuery($inner, $filterParams);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterType()
|
||||
{
|
||||
return SelectFilterInterface::TYPE_SEARCHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $select
|
||||
* @param array $filter
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function appendFilterQuery(SelectQuery $select, array $filter)
|
||||
{
|
||||
// Kein Filter verwendet
|
||||
if (empty($filter)) {
|
||||
return $select;
|
||||
}
|
||||
|
||||
// Spalten aus Query holen
|
||||
$cols = $select->getCols();
|
||||
|
||||
// Filter an SelectQuery anfügen
|
||||
foreach ($filter as $index => $item) {
|
||||
|
||||
if (empty($item['property']) && empty($item['value'])) {
|
||||
throw new InvalidArgumentException('Filter not valid. "property" und "value" required.');
|
||||
}
|
||||
|
||||
// Defaults für optionale Felder setzen
|
||||
if (empty($item['expression'])) {
|
||||
$item['expression'] = 'LIKE';
|
||||
}
|
||||
if (empty($item['operation'])) {
|
||||
$item['operation'] = 'AND';
|
||||
}
|
||||
|
||||
// Aliase ersetzen
|
||||
// Notwendig für Properties die einen Alias haben.
|
||||
// Nach Alias-Feldnamen kann nicht gesucht werden.
|
||||
if (array_key_exists($item['property'], $cols)) {
|
||||
$item['property'] = $cols[$item['property']];
|
||||
}
|
||||
|
||||
switch (strtolower($item['expression'])) {
|
||||
case 'eq':
|
||||
$item['expression'] = '=';
|
||||
break;
|
||||
case 'not':
|
||||
$item['expression'] = '!=';
|
||||
break;
|
||||
case 'lt':
|
||||
$item['expression'] = '<';
|
||||
break;
|
||||
case 'lte':
|
||||
$item['expression'] = '<=';
|
||||
break;
|
||||
case 'gt':
|
||||
$item['expression'] = '>';
|
||||
break;
|
||||
case 'gte':
|
||||
$item['expression'] = '>=';
|
||||
break;
|
||||
case 'like':
|
||||
$item['expression'] = 'LIKE';
|
||||
break;
|
||||
case 'not_like':
|
||||
$item['expression'] = 'NOT LIKE';
|
||||
break;
|
||||
default:
|
||||
$item['expression'] = 'LIKE';
|
||||
break;
|
||||
}
|
||||
|
||||
if (strtoupper($item['operation']) === 'OR') {
|
||||
$select->orWhere(sprintf('%s %s ?', $item['property'], $item['expression']), $item['value']);
|
||||
} else {
|
||||
$select->where(sprintf('%s %s ?', $item['property'], $item['expression']), $item['value']);
|
||||
}
|
||||
}
|
||||
|
||||
return $select;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Filter\Select;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
interface SelectFilterInterface
|
||||
{
|
||||
const TYPE_SORTING = 'sort';
|
||||
const TYPE_SEARCHING = 'search';
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param array $filterParams
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
public function applyFilter(SelectQuery $query, array $filterParams);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterType();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Filter\Select;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
trait SelectFilterTrait
|
||||
{
|
||||
/** @var array $selectFilter */
|
||||
protected $selectFilter = [];
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param array $settings
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function applySelectFilter(SelectQuery $query, array $settings)
|
||||
{
|
||||
foreach ($this->selectFilter as $filter) {
|
||||
/** @var SelectFilterInterface $filter */
|
||||
$query = $filter->applyFilter($query, $settings[$filter->getFilterType()]);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectFilterInterface $filter
|
||||
*/
|
||||
public function registerSelectFilter(SelectFilterInterface $filter)
|
||||
{
|
||||
$this->selectFilter[] = $filter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Filter\Select;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\Api\Exception\InvalidArgumentException;
|
||||
|
||||
class SimpleSearchFilter implements SelectFilterInterface
|
||||
{
|
||||
/** @var array $registeredProperties */
|
||||
protected $registeredProperties;
|
||||
|
||||
/**
|
||||
* @param array $search
|
||||
*/
|
||||
public function __construct(array $search)
|
||||
{
|
||||
$this->registeredProperties = $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param array $filter
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
public function applyFilter(SelectQuery $query, array $filter)
|
||||
{
|
||||
return $this->appendFilterQuery($query, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterType()
|
||||
{
|
||||
return SelectFilterInterface::TYPE_SEARCHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $select
|
||||
* @param array $filter
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function appendFilterQuery(SelectQuery $select, array $filter)
|
||||
{
|
||||
// Kein Filter verwendet
|
||||
if (empty($filter)) {
|
||||
return $select;
|
||||
}
|
||||
|
||||
// Filter an SelectQuery anfügen
|
||||
foreach ($filter as $property => $value) {
|
||||
|
||||
// $_GET['filter'] wird von ComplexSearchFilter verarbeitet
|
||||
/* @see \Xentral\Modules\Api\Resource\Filter\Select\ComplexSearchFilter */
|
||||
if ($property === 'filter') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filterProperty = $this->prepareFilterName($property);
|
||||
$filterValue = $this->prepareFilterValue($property, $value);
|
||||
|
||||
$select->where(sprintf('%s :%s', $filterProperty, $property));
|
||||
$select->bindValue((string)$property, $filterValue);
|
||||
}
|
||||
|
||||
return $select;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filterName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function prepareFilterName($filterName)
|
||||
{
|
||||
$filterProperty = trim($this->getRegisteredProperty($filterName));
|
||||
$filterProperty = str_replace('%', '', $filterProperty); // Prozent aus LIKE-Suche entfernen
|
||||
|
||||
return $filterProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filterName
|
||||
* @param mixed $filterValue
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function prepareFilterValue($filterName, $filterValue)
|
||||
{
|
||||
$filterProperty = trim($this->getRegisteredProperty($filterName));
|
||||
|
||||
// LIKE-Suche aufbereiten
|
||||
if (substr($filterProperty, -6) === ' LIKE%') {
|
||||
$filterValue = "{$filterValue}%";
|
||||
}
|
||||
if (substr($filterProperty, -6) === ' %LIKE') {
|
||||
$filterValue = "%{$filterValue}";
|
||||
}
|
||||
if (substr($filterProperty, -7) === ' %LIKE%') {
|
||||
$filterValue = "%{$filterValue}%";
|
||||
}
|
||||
|
||||
return $filterValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $param
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRegisteredProperty($param)
|
||||
{
|
||||
if (!isset($this->registeredProperties[$param])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Search parameter "%s" is not supported.', $param)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->registeredProperties[$param];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Filter\Select;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Modules\Api\Exception\InvalidArgumentException;
|
||||
|
||||
class SortingFilter implements SelectFilterInterface
|
||||
{
|
||||
/** @var array $sortingParams Erlaubte Sortierungs-Parameter */
|
||||
protected $sortingParams;
|
||||
|
||||
/**
|
||||
* @param array $sortingParams
|
||||
*/
|
||||
public function __construct(array $sortingParams)
|
||||
{
|
||||
$this->sortingParams = $sortingParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQuery $query
|
||||
* @param array $filter
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
public function applyFilter(SelectQuery $query, array $filter)
|
||||
{
|
||||
return $this->appendSorting($query, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterType()
|
||||
{
|
||||
return SelectFilterInterface::TYPE_SORTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sorting
|
||||
* @param SelectQuery $selectQuery
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function appendSorting(SelectQuery $selectQuery, array $sorting)
|
||||
{
|
||||
// Keine Sortier-Parameter vorhanden
|
||||
if (empty($sorting)) {
|
||||
return $selectQuery;
|
||||
}
|
||||
|
||||
foreach ($sorting as $property => $direction) {
|
||||
if (is_int($property)) {
|
||||
$property = $direction;
|
||||
$direction = 'ASC';
|
||||
}
|
||||
|
||||
$direction = strtoupper($direction);
|
||||
if (!in_array($direction, ['ASC', 'DESC'], true)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Sort direction "%s" is invalid', $direction)
|
||||
);
|
||||
}
|
||||
|
||||
$dbProperty = $this->getRegisteredProperty($property);
|
||||
$selectQuery->orderBy([
|
||||
sprintf('%s %s', $dbProperty, $direction)
|
||||
]);
|
||||
}
|
||||
|
||||
return $selectQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $property
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRegisteredProperty($property)
|
||||
{
|
||||
if (!isset($this->sortingParams[$property])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Sorting parameter "%s" is not registered.', $property)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->sortingParams[$property];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class GroupResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'gruppen';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'name' => 'g.name %LIKE%',
|
||||
'name_exakt' => 'g.name LIKE',
|
||||
'kennziffer' => 'g.kennziffer %LIKE%',
|
||||
'kennziffer_exakt' => 'g.kennziffer LIKE',
|
||||
'art' => 'g.art LIKE',
|
||||
'projekt' => 'g.projekt =',
|
||||
'kategorie' => 'g.kategorie =',
|
||||
'aktiv' => 'g.aktiv =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'name' => 'g.name',
|
||||
'art' => 'g.art',
|
||||
'kennziffer' => 'g.kennziffer',
|
||||
'projekt' => 'g.projekt',
|
||||
'kategorie' => 'g.kategorie',
|
||||
'aktiv' => 'g.aktiv',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'name' => 'required',
|
||||
'kennziffer' => 'required|alpha_dash|unique:gruppen,kennziffer',
|
||||
'art' => 'in:gruppe,preisgruppe,verband,regionalgruppe,kategorie,vertreter',
|
||||
'projekt' => 'numeric',
|
||||
'kategorie' => 'numeric',
|
||||
'aktiv' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
// @todo Gruppenkategorien
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'g.id',
|
||||
'g.name',
|
||||
'g.art',
|
||||
'g.kennziffer',
|
||||
'g.internebemerkung',
|
||||
'g.projekt',
|
||||
'g.kategorie',
|
||||
'g.aktiv',
|
||||
])->from(self::TABLE_NAME . ' AS g');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('g.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('g.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class PaymentMethodResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'zahlungsweisen';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 'z.bezeichnung %LIKE%',
|
||||
'bezeichnung_exakt' => 'z.bezeichnung LIKE',
|
||||
'type' => 'z.type %LIKE%',
|
||||
'type_exakt' => 'z.type LIKE',
|
||||
'projekt' => 'z.projekt =',
|
||||
'verhalten' => 'z.verhalten =',
|
||||
'aktiv' => 'z.aktiv =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'z.bezeichnung',
|
||||
'type' => 'z.type',
|
||||
'projekt' => 'z.projekt',
|
||||
'modul' => 'z.modul',
|
||||
'aktiv' => 'z.aktiv',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'einstellungen_json' => 'not_present',
|
||||
'freitext' => 'not_present',
|
||||
'bezeichnung' => 'required',
|
||||
'type' => 'required|unique:zahlungsweisen,type',
|
||||
'projekt' => 'numeric',
|
||||
'aktiv' => 'boolean',
|
||||
'vorkasse' => 'boolean',
|
||||
'automatischbezahlt' => 'boolean',
|
||||
'automatischbezahltverbindlichkeit' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'z.id',
|
||||
'z.type',
|
||||
'z.bezeichnung',
|
||||
'z.freitext',
|
||||
'z.aktiv',
|
||||
'z.automatischbezahlt',
|
||||
'z.automatischbezahltverbindlichkeit',
|
||||
'z.projekt',
|
||||
'z.vorkasse',
|
||||
'z.verhalten',
|
||||
'z.modul',
|
||||
])->from(self::TABLE_NAME . ' AS z')
|
||||
->where('z.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('z.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('z.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class ProjectResource extends AbstractResource
|
||||
{
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()->cols(
|
||||
[
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.verantwortlicher',
|
||||
'p.beschreibung',
|
||||
'p.sonstiges',
|
||||
'p.aktiv',
|
||||
'p.farbe',
|
||||
'p.autoversand',
|
||||
'p.portocheck',
|
||||
'p.automailrechnung',
|
||||
'p.autobestellung',
|
||||
'p.speziallieferschein',
|
||||
'p.lieferscheinbriefpapier',
|
||||
'p.speziallieferscheinbeschriftung',
|
||||
'p.firma',
|
||||
'p.geloescht',
|
||||
]
|
||||
)->from('projekt AS p')->where('p.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('p.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('p.id IN (:ids)');
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
protected function configure()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class PropertyResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'artikeleigenschaften';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams(
|
||||
[
|
||||
'artikel' => 'a.artikel =',
|
||||
'name' => 'a.name =',
|
||||
'typ' => 'a.typ =',
|
||||
'projekt' => 'a.projekt =',
|
||||
'geloescht' => 'a.geloescht =',
|
||||
]
|
||||
);
|
||||
|
||||
$this->registerSortingParams(
|
||||
[
|
||||
'artikel' => 'a.artikel =',
|
||||
'name' => 'a.name =',
|
||||
'typ' => 'a.typ =',
|
||||
'projekt' => 'a.projekt =',
|
||||
'geloescht' => 'a.geloescht =',
|
||||
]
|
||||
);
|
||||
|
||||
$this->registerValidationRules(
|
||||
[
|
||||
'id' => 'not_present',
|
||||
'artikel' => 'integer',
|
||||
'projekt' => 'integer',
|
||||
'geloescht' => 'in:0,1',
|
||||
'name' => 'unique:artikeleigenschaften,name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols(
|
||||
[
|
||||
'a.id',
|
||||
'a.artikel',
|
||||
'a.name',
|
||||
'a.typ',
|
||||
'a.projekt',
|
||||
'a.geloescht',
|
||||
]
|
||||
)
|
||||
->from('artikeleigenschaften AS a');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id IN (:ids)');
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()
|
||||
->table('artikeleigenschaften')
|
||||
->where('id = :id');
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()
|
||||
->from('artikeleigenschaften')
|
||||
->where('id = :id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class PropertyValueResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'artikeleigenschaftenwerte';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams(
|
||||
[
|
||||
'artikeleigenschaften' => 'a.artikeleigenschaften =',
|
||||
'artikel' => 'a.artikel =',
|
||||
'wert' => 'a.wert =',
|
||||
]
|
||||
);
|
||||
|
||||
$this->registerSortingParams(
|
||||
[
|
||||
'artikel' => 'a.artikel =',
|
||||
'wert' => 'a.wert =',
|
||||
]
|
||||
);
|
||||
|
||||
$this->registerValidationRules(
|
||||
[
|
||||
'id' => 'not_present',
|
||||
'artikel' => 'numeric|db_value:artikel,id',
|
||||
'artikeleigenschaften' => 'numeric|db_value:artikeleigenschaften,id',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols(
|
||||
[
|
||||
'a.id',
|
||||
'a.artikeleigenschaften',
|
||||
'a.wert',
|
||||
'a.artikel',
|
||||
]
|
||||
)
|
||||
->from('artikeleigenschaftenwerte AS a');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('a.id IN (:ids)');
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()
|
||||
->table('artikeleigenschaftenwerte')
|
||||
->where('id = :id');
|
||||
}
|
||||
|
||||
/** @return false */
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return $this->db->delete()
|
||||
->from('artikeleigenschaftenwerte')
|
||||
->where('id = :id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\Database;
|
||||
use Xentral\Modules\Api\Validator\Validator;
|
||||
|
||||
class ResourceManager
|
||||
{
|
||||
/** @var Database $db */
|
||||
protected $db;
|
||||
|
||||
/** @var Validator $validator */
|
||||
protected $validator;
|
||||
|
||||
/** @var \Api $legacyApi */
|
||||
protected $legacyApi;
|
||||
|
||||
/** @var array $resources Beinhaltet erzeugte Instanzen */
|
||||
protected $resources = [];
|
||||
|
||||
/**
|
||||
* @param Database $database
|
||||
* @param Validator $validator
|
||||
* @param \Api $api
|
||||
*/
|
||||
public function __construct($database, $validator, $api)
|
||||
{
|
||||
$this->db = $database;
|
||||
$this->validator = $validator;
|
||||
$this->legacyApi = $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource erzeugen
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return AbstractResource
|
||||
*/
|
||||
public function get($className)
|
||||
{
|
||||
$cleanName = $this->convertClassName($className);
|
||||
|
||||
// Resource erzeugen falls noch nicht vorhanden
|
||||
if (!isset($this->resources[$cleanName])) {
|
||||
$this->resources[$cleanName] = new $className(
|
||||
$this->db,
|
||||
$this->validator
|
||||
);
|
||||
|
||||
if ($className === ArticleResource::class) {
|
||||
$this->resources[$cleanName]->setLegacyApi($this->legacyApi);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->resources[$cleanName];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function convertClassName($className)
|
||||
{
|
||||
return str_replace('\\', '_', strtolower($className));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class ResubmissionResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'wiedervorlage';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'adresse' => 'w.adresse =',
|
||||
'bearbeiter' => 'w.bearbeiter =',
|
||||
'adresse_mitarbeiter' => 'w.adresse_mitarbeiter =',
|
||||
'projekt' => 'w.projekt =',
|
||||
'stages' => 'w.stages =',
|
||||
'id_ext' => 'am.id_ext =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'datum_angelegt' => 'w.datum_angelegt',
|
||||
'zeit_angelegt' => 'w.zeit_angelegt',
|
||||
'datum_erinnerung' => 'w.datum_erinnerung',
|
||||
'zeit_erinnerung' => 'w.zeit_erinnerung',
|
||||
'datum_abschluss' => 'w.datum_abschluss',
|
||||
'bezeichnung' => 'w.bezeichnung',
|
||||
'stages' => 'w.stages',
|
||||
'prio' => 'w.prio',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'id_ext' => 'not_present',
|
||||
'datum_angelegt' => 'date:Y-m-d',
|
||||
'zeit_angelegt' => 'time:H:i:s',
|
||||
'datum_erinnerung' => 'required|date:Y-m-d',
|
||||
'zeit_erinnerung' => 'required|time:H:i:s',
|
||||
'datum_abschluss' => 'date:Y-m-d',
|
||||
'bezeichnung' => 'required|min:3',
|
||||
'beschreibung' => 'min:3',
|
||||
'bearbeiter' => 'numeric|db_value:adresse,id',
|
||||
'adresse_mitarbeiter' => 'numeric|db_value:adresse,id',
|
||||
'projekt' => 'numeric|db_value:projekt,id',
|
||||
'stages' => 'numeric|db_value:wiedervorlage_stages,id',
|
||||
'betrag' => 'decimal',
|
||||
'chance' => 'integer|between:0,100',
|
||||
'erinnerung_per_mail' => 'in:0,1',
|
||||
'abgeschlossen' => 'in:0,1',
|
||||
'oeffentlich' => 'in:0,1',
|
||||
'prio' => 'in:0,1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'w.id',
|
||||
'w.adresse',
|
||||
'w.projekt',
|
||||
//'w.adresse_mitarbeier',
|
||||
'w.bezeichnung',
|
||||
'w.beschreibung',
|
||||
//'w.ergebnis',
|
||||
'w.betrag',
|
||||
//'w.erinnerung',
|
||||
'w.erinnerung_per_mail',
|
||||
//'w.erinnerung_empfaenger',
|
||||
//'w.link',
|
||||
//'w.module',
|
||||
//'w.action',
|
||||
//'w.parameter',
|
||||
//'w.status',
|
||||
'w.bearbeiter',
|
||||
'w.adresse_mitarbeiter',
|
||||
'w.datum_angelegt',
|
||||
'w.zeit_angelegt',
|
||||
'w.datum_erinnerung',
|
||||
'w.zeit_erinnerung',
|
||||
'w.datum_abschluss',
|
||||
'w.oeffentlich',
|
||||
'w.abgeschlossen',
|
||||
'w.chance',
|
||||
'w.prio',
|
||||
'w.stages',
|
||||
'w.color',
|
||||
'am.id_ext',
|
||||
])->from(self::TABLE_NAME . ' AS w')
|
||||
->leftJoin(
|
||||
'api_mapping AS am',
|
||||
'am.id_int = w.id AND am.tabelle = ' . $this->db->escapeString(self::TABLE_NAME)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('w.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('w.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Result;
|
||||
|
||||
abstract class AbstractResult
|
||||
{
|
||||
const RESULT_TYPE_ITEM = 'item';
|
||||
const RESULT_TYPE_COLLECTION = 'collection';
|
||||
|
||||
/** @var string $type */
|
||||
protected $type;
|
||||
|
||||
/** @var array $data */
|
||||
protected $data;
|
||||
|
||||
/** @var array $pagination */
|
||||
protected $pagination;
|
||||
|
||||
/** @var bool $success Als Kennzeichen ob Anlegen oder Bearbeiten erfolgreich war */
|
||||
protected $success;
|
||||
|
||||
/**
|
||||
* @param array $collection
|
||||
* @param array $pagination
|
||||
*/
|
||||
abstract public function __construct(array $collection, array $pagination = null);
|
||||
|
||||
/**
|
||||
* Ergebnis als Array zurückgeben
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getResult()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
// Success-Flag ganz oben anzeigen
|
||||
if ($this->success !== null) {
|
||||
$result['success'] = $this->success;
|
||||
}
|
||||
|
||||
$result['data'] = $this->getData();
|
||||
|
||||
// Paginierung als letztes anzeigen
|
||||
if ($this->pagination !== null) {
|
||||
$result['pagination'] = $this->pagination;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPagination()
|
||||
{
|
||||
return $this->pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string [item|collection]
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $success
|
||||
*/
|
||||
public function setSuccess($success)
|
||||
{
|
||||
$this->success = (bool)$success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isItem()
|
||||
{
|
||||
return $this->type === self::RESULT_TYPE_ITEM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCollection()
|
||||
{
|
||||
return $this->type === self::RESULT_TYPE_COLLECTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Result;
|
||||
|
||||
class CollectionResult extends AbstractResult
|
||||
{
|
||||
/**
|
||||
* @param array $collection
|
||||
* @param array|null $pagination
|
||||
*/
|
||||
public function __construct(array $collection, array $pagination = null)
|
||||
{
|
||||
if (empty($pagination)) {
|
||||
//throw new \CountryInvalidArgumentException('CollectionResult must contain pagination'); // @todo für GetIDs
|
||||
}
|
||||
|
||||
if (empty($collection)) {
|
||||
throw new \InvalidArgumentException('CollectionResult can not be empty');
|
||||
}
|
||||
$firstKey = key($collection);
|
||||
if (!is_numeric($firstKey)) {
|
||||
throw new \InvalidArgumentException('CollectionResult can only store an index based array');
|
||||
}
|
||||
if (!is_array($collection[$firstKey]) || empty($collection[$firstKey])) {
|
||||
throw new \RuntimeException('CollectionResult must contain at least one result');
|
||||
}
|
||||
|
||||
// @todo Sicherstellen dass Paginierung passt
|
||||
|
||||
$this->type = self::RESULT_TYPE_COLLECTION;
|
||||
$this->data = $collection;
|
||||
$this->pagination = $pagination;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource\Result;
|
||||
|
||||
class ItemResult extends AbstractResult
|
||||
{
|
||||
/**
|
||||
* @param array $item
|
||||
* @param array|null $pagination
|
||||
*/
|
||||
public function __construct(array $item, array $pagination = null)
|
||||
{
|
||||
if ($pagination !== null) {
|
||||
throw new \InvalidArgumentException('ItemResult can not have pagination');
|
||||
}
|
||||
|
||||
if (empty($item)) {
|
||||
throw new \InvalidArgumentException('ItemResult can not be empty');
|
||||
}
|
||||
if (is_numeric(key($item))) {
|
||||
throw new \InvalidArgumentException('ItemResult can only store an associative array');
|
||||
}
|
||||
|
||||
$this->type = self::RESULT_TYPE_ITEM;
|
||||
$this->data = $item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
class SalesPriceResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'verkaufspreise';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'waehrung' => 'vp.waehrung',
|
||||
'artikel' => 'vp.artikel =',
|
||||
'projekt' => 'vp.projekt =',
|
||||
'adresse' => 'vp.adresse =',
|
||||
'gruppe' => 'vp.gruppe =',
|
||||
'firma' => 'vp.firma =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'preis' => 'vp.preis',
|
||||
'menge' => 'vp.ab_menge',
|
||||
'vpe_menge' => 'vp.vpe_menge',
|
||||
'projekt' => 'k.projekt',
|
||||
]);
|
||||
|
||||
/*$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'bezeichnung' => 'required|unique:artikelkategorien,bezeichnung',
|
||||
'next_number' => 'numeric',
|
||||
'projekt' => 'numeric',
|
||||
'parent' => 'numeric',
|
||||
'externenummer' => 'numeric',
|
||||
'geloescht' => 'in:0,1',
|
||||
]);*/
|
||||
|
||||
/*$this->registerIncludes([
|
||||
'projekte' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'vp.id',
|
||||
'vp.artikel',
|
||||
'vp.objekt',
|
||||
'vp.projekt',
|
||||
'vp.adresse',
|
||||
'vp.preis',
|
||||
'vp.waehrung',
|
||||
'vp.ab_menge',
|
||||
'vp.vpe',
|
||||
'vp.vpe_menge',
|
||||
'vp.angelegt_am',
|
||||
'vp.gueltig_ab',
|
||||
'vp.gueltig_bis',
|
||||
'vp.bemerkung',
|
||||
'vp.firma',
|
||||
'vp.kundenartikelnummer',
|
||||
'vp.nichtberechnet',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS vp')
|
||||
->where('vp.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('vp.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('vp.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class ShippingMethodResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'versandarten';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 'v.bezeichnung %LIKE%',
|
||||
'bezeichnung_exakt' => 'v.bezeichnung LIKE',
|
||||
'type' => 'v.type %LIKE%',
|
||||
'type_exakt' => 'v.type LIKE',
|
||||
'projekt' => 'v.projekt =',
|
||||
'modul' => 'v.modul =',
|
||||
'aktiv' => 'v.aktiv =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 'v.bezeichnung',
|
||||
'type' => 'v.type',
|
||||
'projekt' => 'v.projekt',
|
||||
'modul' => 'v.modul',
|
||||
'aktiv' => 'v.aktiv',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'einstellungen_json' => 'not_present',
|
||||
'bezeichnung' => 'required',
|
||||
'type' => 'required|unique:versandarten,type',
|
||||
'projekt' => 'numeric',
|
||||
'aktiv' => 'boolean',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'v.id',
|
||||
'v.type',
|
||||
'v.bezeichnung',
|
||||
'v.aktiv',
|
||||
'v.projekt',
|
||||
'v.modul',
|
||||
'v.paketmarke_drucker',
|
||||
'v.export_drucker',
|
||||
'v.ausprojekt',
|
||||
'v.versandmail',
|
||||
'v.geschaeftsbrief_vorlage',
|
||||
])->from(self::TABLE_NAME . ' AS v')
|
||||
->where('v.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('v.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('v.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Lager Chargen
|
||||
*/
|
||||
class StorageBatchResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'lager_charge';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'artikel' => 'lc.artikel =',
|
||||
'artikelnummer' => 'a.nummer %LIKE%',
|
||||
'artikelnummer_equals' => 'a.nummer LIKE',
|
||||
'artikelnummer_startswith' => 'a.nummer LIKE%',
|
||||
'artikelnummer_endswith' => 'a.nummer %LIKE',
|
||||
'lagerplatz' => 'lc.lager_platz =',
|
||||
'lagerplatzbezeichnung' => 'lp.kurzbezeichnung %LIKE%',
|
||||
'lagerplatzbezeichnung_equals' => 'lp.kurzbezeichnung LIKE',
|
||||
'lagerplatzbezeichnung_startswith' => 'lp.kurzbezeichnung LIKE%',
|
||||
'lagerplatzbezeichnung_endswith' => 'lp.kurzbezeichnung %LIKE',
|
||||
'charge' => 'lc.charge %LIKE%',
|
||||
'charge_equals' => 'lc.charge LIKE',
|
||||
'charge_startswith' => 'lc.charge LIKE%',
|
||||
'charge_endswith' => 'lc.charge %LIKE',
|
||||
'datum' => 'lc.datum LIKE',
|
||||
'datum_gt' => 'lc.datum >',
|
||||
'datum_gte' => 'lc.datum >=',
|
||||
'datum_lt' => 'lc.datum <',
|
||||
'datum_lte' => 'lc.datum <=',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'lagerplatzbezeichnung' => 'lp.kurzbezeichnung',
|
||||
'artikelnummer' => 'a.nummer',
|
||||
'charge' => 'lc.charge',
|
||||
'datum' => 'lc.datum',
|
||||
'menge' => 'lc_menge.menge',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'artikel' => [
|
||||
'key' => 'artikel',
|
||||
'resource' => ArticleResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.nummer',
|
||||
'a.name_de',
|
||||
'a.name_en',
|
||||
],
|
||||
],
|
||||
'lagerplatz' => [
|
||||
'key' => 'lagerplatz',
|
||||
'resource' => StorageLocationResource::class,
|
||||
'columns' => [
|
||||
'lp.id',
|
||||
'l.bezeichnung AS lager',
|
||||
'lp.kurzbezeichnung',
|
||||
'lp.autolagersperre',
|
||||
'lp.verbrauchslager',
|
||||
'lp.sperrlager',
|
||||
'lp.laenge',
|
||||
'lp.breite',
|
||||
'lp.hoehe',
|
||||
'lp.geloescht',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
//'lc.id',
|
||||
'lc.artikel',
|
||||
'a.nummer AS artikelnummer',
|
||||
'lc.lager_platz AS lagerplatz',
|
||||
'lp.kurzbezeichnung AS lagerplatzbezeichnung',
|
||||
'lc.charge',
|
||||
'lc.datum',
|
||||
'lc_menge.menge',
|
||||
'lc.internebemerkung',
|
||||
//'lc.zwischenlagerid',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS lc')
|
||||
->innerJoin('artikel AS a', 'a.id = lc.artikel AND a.geloescht <> 1')
|
||||
->innerJoin('lager_platz AS lp', 'lc.lager_platz = lp.id')
|
||||
->joinSubSelect(
|
||||
'INNER',
|
||||
'SELECT lc.id, SUM(lc.menge) AS menge
|
||||
FROM lager_charge AS lc
|
||||
GROUP BY lc.artikel, lc.lager_platz, lc.charge',
|
||||
'lc_menge',
|
||||
'lc.id = lc_menge.id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery|false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery|false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery|DeleteQuery|false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\DeleteQuery;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
/**
|
||||
* Ressource für Lager Mindesthaltbarkeitsdatum (MHD)
|
||||
*/
|
||||
class StorageBestBeforeDateResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'lager_mindesthaltbarkeitsdatum';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'artikel' => 'lm.artikel =',
|
||||
'artikelnummer' => 'a.nummer %LIKE%',
|
||||
'artikelnummer_equals' => 'a.nummer LIKE',
|
||||
'artikelnummer_startswith' => 'a.nummer LIKE%',
|
||||
'artikelnummer_endswith' => 'a.nummer %LIKE',
|
||||
'lagerplatz' => 'lm.lager_platz =',
|
||||
'lagerplatzbezeichnung' => 'lp.kurzbezeichnung %LIKE%',
|
||||
'lagerplatzbezeichnung_equals' => 'lp.kurzbezeichnung LIKE',
|
||||
'lagerplatzbezeichnung_startswith' => 'lp.kurzbezeichnung LIKE%',
|
||||
'lagerplatzbezeichnung_endswith' => 'lp.kurzbezeichnung %LIKE',
|
||||
'charge' => 'lm.charge %LIKE%',
|
||||
'charge_equals' => 'lm.charge LIKE',
|
||||
'charge_startswith' => 'lm.charge LIKE%',
|
||||
'charge_endswith' => 'lm.charge %LIKE',
|
||||
'mhddatum' => 'lm.mhddatum LIKE',
|
||||
'mhddatum_gt' => 'lm.mhddatum >',
|
||||
'mhddatum_gte' => 'lm.mhddatum >=',
|
||||
'mhddatum_lt' => 'lm.mhddatum <',
|
||||
'mhddatum_lte' => 'lm.mhddatum <=',
|
||||
'datum' => 'lm.datum LIKE',
|
||||
'datum_gt' => 'lm.datum >',
|
||||
'datum_gte' => 'lm.datum >=',
|
||||
'datum_lt' => 'lm.datum <',
|
||||
'datum_lte' => 'lm.datum <=',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'lagerplatzbezeichnung' => 'lp.kurzbezeichnung',
|
||||
'artikelnummer' => 'a.nummer',
|
||||
'charge' => 'lm.charge',
|
||||
'mhddatum' => 'lm.mhddatum',
|
||||
'datum' => 'lm.datum',
|
||||
'menge' => 'lm_menge.menge',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'artikel' => [
|
||||
'key' => 'artikel',
|
||||
'resource' => ArticleResource::class,
|
||||
'columns' => [
|
||||
'a.id',
|
||||
'a.nummer',
|
||||
'a.name_de',
|
||||
'a.name_en',
|
||||
],
|
||||
],
|
||||
'lagerplatz' => [
|
||||
'key' => 'lagerplatz',
|
||||
'resource' => StorageLocationResource::class,
|
||||
'columns' => [
|
||||
'lp.id',
|
||||
'l.bezeichnung AS lager',
|
||||
'lp.kurzbezeichnung',
|
||||
'lp.autolagersperre',
|
||||
'lp.verbrauchslager',
|
||||
'lp.sperrlager',
|
||||
'lp.laenge',
|
||||
'lp.breite',
|
||||
'lp.hoehe',
|
||||
'lp.geloescht',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
//'lm.id',
|
||||
'lm.artikel',
|
||||
'a.nummer AS artikelnummer',
|
||||
'lm.lager_platz AS lagerplatz',
|
||||
'lp.kurzbezeichnung AS lagerplatzbezeichnung',
|
||||
'lm.charge',
|
||||
'lm.mhddatum',
|
||||
'lm.datum',
|
||||
'lm_menge.menge',
|
||||
'lm.internebemerkung',
|
||||
//'lm.zwischenlagerid',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS lm')
|
||||
->innerJoin('artikel AS a', 'a.id = lm.artikel AND a.geloescht <> 1')
|
||||
->innerJoin('lager_platz AS lp', 'lm.lager_platz = lp.id')
|
||||
->joinSubSelect(
|
||||
'INNER',
|
||||
'SELECT lm.id, SUM(lm.menge) AS menge
|
||||
FROM lager_mindesthaltbarkeitsdatum AS lm
|
||||
GROUP BY lm.artikel, lm.mhddatum, lm.lager_platz, lm.charge',
|
||||
'lm_menge',
|
||||
'lm.id = lm_menge.id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery|false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery|false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery|DeleteQuery|false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
|
||||
/**
|
||||
* Ressoure für Lagerplatz
|
||||
*
|
||||
* Ressource hat keinen eigenen Endpunkt; Ressource wird nur für Incldudes verwendet.
|
||||
*/
|
||||
class StorageLocationResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'lager_platz';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db
|
||||
->select()
|
||||
->cols([
|
||||
'lp.id',
|
||||
'lp.lager',
|
||||
'lp.kurzbezeichnung',
|
||||
'lp.bemerkung',
|
||||
'lp.projekt',
|
||||
'lp.firma',
|
||||
'lp.geloescht',
|
||||
'lp.logdatei',
|
||||
'lp.autolagersperre',
|
||||
'lp.verbrauchslager',
|
||||
'lp.sperrlager',
|
||||
'lp.laenge',
|
||||
'lp.breite',
|
||||
'lp.hoehe',
|
||||
'lp.poslager',
|
||||
'lp.adresse',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS lp')
|
||||
->innerJoin('lager AS l', 'l.id = lp.lager')
|
||||
->where('lp.geloescht <> 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('lp.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('lp.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
|
||||
class TaxRateResource extends AbstractResource
|
||||
{
|
||||
const TABLE_NAME = 'steuersaetze';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'bezeichnung' => 's.bezeichnung %LIKE%',
|
||||
'country_code' => 's.country_code %LIKE%',
|
||||
'satz' => 's.satz =',
|
||||
'aktiv' => 's.aktiv =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'bezeichnung' => 's.bezeichnung',
|
||||
'country_code' => 's.country_code',
|
||||
'satz' => 's.satz',
|
||||
'aktiv' => 's.aktiv',
|
||||
]);
|
||||
|
||||
$this->registerValidationRules([
|
||||
'id' => 'not_present',
|
||||
'bezeichnung' => 'required|unique:steuersaetze,bezeichnung',
|
||||
'satz' => 'required|decimal',
|
||||
'aktiv' => 'boolean',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
's.id',
|
||||
's.bezeichnung',
|
||||
's.country_code',
|
||||
's.satz',
|
||||
's.aktiv',
|
||||
])->from(self::TABLE_NAME . ' AS s');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('s.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('s.id IN (:ids)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Api\Resource;
|
||||
|
||||
use Aura\SqlQuery\Exception;
|
||||
use Xentral\Components\Database\SqlQuery\InsertQuery;
|
||||
use Xentral\Components\Database\SqlQuery\SelectQuery;
|
||||
use Xentral\Components\Database\SqlQuery\UpdateQuery;
|
||||
use Xentral\Modules\Api\Controller\Version1\TrackingNumberController;
|
||||
|
||||
/**
|
||||
* Ressource für Trackingnummern
|
||||
*/
|
||||
class TrackingNumberResource extends AbstractResource
|
||||
{
|
||||
/** @var string TABLE_NAME */
|
||||
const TABLE_NAME = 'versand';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setTableName(self::TABLE_NAME);
|
||||
|
||||
$this->registerFilterParams([
|
||||
'tracking' => 'v.tracking %LIKE%',
|
||||
'tracking_equals' => 'v.tracking LIKE',
|
||||
'tracking_startswith' => 'v.tracking LIKE%',
|
||||
'tracking_endswith' => 'v.tracking %LIKE',
|
||||
'lieferschein' => 'l.belegnr %LIKE%',
|
||||
'lieferschein_equals' => 'l.belegnr LIKE',
|
||||
'lieferschein_startswith' => 'l.belegnr LIKE%',
|
||||
'lieferschein_endswith' => 'l.belegnr %LIKE',
|
||||
'auftrag' => 'au.belegnr %LIKE%',
|
||||
'auftrag_equals' => 'au.belegnr LIKE',
|
||||
'auftrag_startswith' => 'au.belegnr LIKE%',
|
||||
'auftrag_endswith' => 'au.belegnr %LIKE',
|
||||
'internet' => 'au.internet %LIKE%',
|
||||
'internet_equals' => 'au.internet LIKE',
|
||||
'internet_startswith' => 'au.internet LIKE%',
|
||||
'internet_endswith' => 'au.internet %LIKE',
|
||||
'versandart' => 'l.versandart LIKE',
|
||||
'versendet_am' => 'v.versendet_am LIKE',
|
||||
'versendet_am_gt' => 'v.versendet_am >',
|
||||
'versendet_am_gte' => 'v.versendet_am >=',
|
||||
'versendet_am_lt' => 'v.versendet_am <',
|
||||
'versendet_am_lte' => 'v.versendet_am <=',
|
||||
'abgeschlossen' => 'v.abgeschlossen =',
|
||||
'adresse' => 'v.adresse =',
|
||||
'projekt' => 'v.projekt =',
|
||||
'land' => 'l.land =',
|
||||
]);
|
||||
|
||||
$this->registerSortingParams([
|
||||
'tracking' => 'v.tracking',
|
||||
'auftrag' => 'au.belegnr',
|
||||
'lieferschein' => 'l.belegnr',
|
||||
'versandart' => 'l.versandart',
|
||||
'versendet_am' => 'v.versendet_am',
|
||||
'abgeschlossen' => 'v.abgeschlossen',
|
||||
]);
|
||||
|
||||
/** Minimale Validation-Rules; die eigentliche Prüfung findet im Controller statt */
|
||||
/** @see TrackingNumberController */
|
||||
$this->registerValidationRules([
|
||||
'tracking' => 'required',
|
||||
]);
|
||||
|
||||
$this->registerIncludes([
|
||||
'projekt' => [
|
||||
'key' => 'projekt',
|
||||
'resource' => ProjectResource::class,
|
||||
'columns' => [
|
||||
'p.id',
|
||||
'p.name',
|
||||
'p.abkuerzung',
|
||||
'p.beschreibung',
|
||||
'p.farbe',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectAllQuery()
|
||||
{
|
||||
return $this->db->select()
|
||||
->cols([
|
||||
'v.id',
|
||||
'v.tracking',
|
||||
'v.adresse',
|
||||
//'v.auftrag',
|
||||
'au.internet',
|
||||
'au.belegnr AS auftrag',
|
||||
//'v.lieferschein',
|
||||
'l.belegnr AS lieferschein',
|
||||
//'v.rechnung',
|
||||
//'r.belegnr AS rechnung',
|
||||
'v.projekt',
|
||||
//'v.versandart',
|
||||
'l.versandart',
|
||||
'l.land',
|
||||
'v.gewicht',
|
||||
//'v.freigegeben',
|
||||
//'v.bearbeiter',
|
||||
//'v.versender',
|
||||
'v.abgeschlossen',
|
||||
'v.versendet_am',
|
||||
//'v.versandunternehmen',
|
||||
//'v.download',
|
||||
//'v.firma',
|
||||
//'v.logdatei',
|
||||
//'v.keinetrackingmail',
|
||||
//'v.versendet_am_zeitstempel',
|
||||
//'v.weitererlieferschein',
|
||||
'v.anzahlpakete',
|
||||
//'v.gelesen',
|
||||
//'v.paketmarkegedruckt',
|
||||
//'v.papieregedruckt',
|
||||
//'v.versandzweigeteilt',
|
||||
//'v.improzess',
|
||||
//'v.improzessuser',
|
||||
//'v.cronjob',
|
||||
//'v.adressvalidation',
|
||||
'v.retoure',
|
||||
//'v.bundesstaat',
|
||||
'v.klaergrund',
|
||||
])
|
||||
->from(self::TABLE_NAME . ' AS v')
|
||||
->leftJoin('lieferschein AS l', 'v.lieferschein = l.id')
|
||||
->leftJoin('auftrag AS au', 'l.auftragid = au.id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return SelectQuery
|
||||
*/
|
||||
protected function selectOneQuery()
|
||||
{
|
||||
return $this->selectAllQuery()->where('v.id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function selectIdsQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert-Action hat speziellen Controller
|
||||
*
|
||||
* @see TrackingNumberController::createAction()
|
||||
*
|
||||
* @return InsertQuery
|
||||
*/
|
||||
protected function insertQuery()
|
||||
{
|
||||
return $this->db->insert()->into(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update-Action hat speziellen Controller
|
||||
*
|
||||
* @see TrackingNumberController::updateAction()
|
||||
*
|
||||
* @return UpdateQuery
|
||||
*/
|
||||
protected function updateQuery()
|
||||
{
|
||||
return $this->db->update()->table(self::TABLE_NAME)->where('id = :id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
protected function deleteQuery()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user