mirror of
https://github.com/Karaka-Management/oms-ClientManagement.git
synced 2026-02-13 23:38:43 +00:00
code fixes
This commit is contained in:
parent
ec1d64cf96
commit
77481c127f
|
|
@ -18,10 +18,10 @@ use Modules\ClientManagement\Models\SettingsEnum;
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
"description" => "Default item segmentation (segment, section, sales group, product group)",
|
"description" => "Default item segmentation (segment, section, sales group, product group)",
|
||||||
'type' => 'setting',
|
'type' => 'setting',
|
||||||
'name' => SettingsEnum::DEFAULT_SEGMENTATION,
|
'name' => SettingsEnum::DEFAULT_SEGMENTATION,
|
||||||
'content' => '{"segment":1, "section":1, "client_group":1}',
|
'content' => '{"segment":1, "section":1, "client_group":1}',
|
||||||
'pattern' => '',
|
'pattern' => '',
|
||||||
'module' => ApiController::NAME,
|
'module' => ApiController::NAME,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@
|
||||||
{ "value": "FI" },
|
{ "value": "FI" },
|
||||||
{ "value": "FR" },
|
{ "value": "FR" },
|
||||||
{ "value": "DE" },
|
{ "value": "DE" },
|
||||||
|
{ "value": "DE_0" },
|
||||||
{ "value": "GR" },
|
{ "value": "GR" },
|
||||||
{ "value": "HU" },
|
{ "value": "HU" },
|
||||||
{ "value": "IE" },
|
{ "value": "IE" },
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,9 @@ final class Installer extends InstallerAbstract
|
||||||
$attrValues = self::createClientAttributeValues($app, $attrTypes, $attributes);
|
$attrValues = self::createClientAttributeValues($app, $attrTypes, $attributes);
|
||||||
|
|
||||||
$data = include __DIR__ . '/Install/Admin.install.php';
|
$data = include __DIR__ . '/Install/Admin.install.php';
|
||||||
$content = \json_decode($data[0]['content'], true);
|
|
||||||
|
|
||||||
|
/** @var array $content */
|
||||||
|
$content = \json_decode($data[0]['content'], true);
|
||||||
foreach ($content as $type => $_) {
|
foreach ($content as $type => $_) {
|
||||||
$content[$type] = \reset($attrValues[$type])['id'];
|
$content[$type] = \reset($attrValues[$type])['id'];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,16 @@ final class ApiController extends Controller
|
||||||
return $client->id === 0 ? null : $client;
|
return $client->id === 0 ? null : $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set VAT for client
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param Client $client Client
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setVAT(RequestAbstract $request, Client $client) : void
|
public function setVAT(RequestAbstract $request, Client $client) : void
|
||||||
{
|
{
|
||||||
/** @var \Modules\Attribute\Models\AttributeType $type */
|
/** @var \Modules\Attribute\Models\AttributeType $type */
|
||||||
|
|
@ -105,6 +115,16 @@ final class ApiController extends Controller
|
||||||
->apiClientAttributeCreate($internalRequest, $internalResponse);
|
->apiClientAttributeCreate($internalRequest, $internalResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate VAT of client
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param Client $client Client
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function validateVAT(RequestAbstract $request, Client $client) : array
|
public function validateVAT(RequestAbstract $request, Client $client) : array
|
||||||
{
|
{
|
||||||
/** @var \Modules\Organization\Models\Unit $unit */
|
/** @var \Modules\Organization\Models\Unit $unit */
|
||||||
|
|
@ -146,6 +166,16 @@ final class ApiController extends Controller
|
||||||
return $validate;
|
return $validate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tax code for client
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param Client $client Client
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function defineTaxCode(RequestAbstract $request, Client $client) : void
|
public function defineTaxCode(RequestAbstract $request, Client $client) : void
|
||||||
{
|
{
|
||||||
/** @var \Modules\Organization\Models\Unit $unit */
|
/** @var \Modules\Organization\Models\Unit $unit */
|
||||||
|
|
@ -246,16 +276,31 @@ final class ApiController extends Controller
|
||||||
$this->createStandardCreateResponse($request, $response, $client);
|
$this->createStandardCreateResponse($request, $response, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create client segmentation.
|
||||||
|
*
|
||||||
|
* Default: segment->section->sales_group and to the side client_type
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param Client $client Client
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function createClientSegmentation(RequestAbstract $request, ResponseAbstract $response, Client $client) : void
|
private function createClientSegmentation(RequestAbstract $request, ResponseAbstract $response, Client $client) : void
|
||||||
{
|
{
|
||||||
/** @var \Model\Setting $settings */
|
/** @var \Model\Setting $settings */
|
||||||
$settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_SEGMENTATION);
|
$settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_SEGMENTATION);
|
||||||
|
|
||||||
|
/** @var array $segmentation */
|
||||||
$segmentation = \json_decode($settings->content, true);
|
$segmentation = \json_decode($settings->content, true);
|
||||||
if ($segmentation === false || $segmentation === null) {
|
if ($segmentation === false || $segmentation === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var \Modules\Attribute\Models\AttributeType[] $types */
|
||||||
$types = ClientAttributeTypeMapper::getAll()
|
$types = ClientAttributeTypeMapper::getAll()
|
||||||
->where('name', \array_keys($segmentation), 'IN')
|
->where('name', \array_keys($segmentation), 'IN')
|
||||||
->execute();
|
->execute();
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,6 @@ final class BackendController extends Controller
|
||||||
$pkValue = $request->getDataString('number');
|
$pkValue = $request->getDataString('number');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Modules\ClientManagement\Models\Client */
|
|
||||||
$view->data['client'] = ClientMapper::get()
|
$view->data['client'] = ClientMapper::get()
|
||||||
->with('account')
|
->with('account')
|
||||||
->with('account/addresses')
|
->with('account/addresses')
|
||||||
|
|
@ -253,7 +252,6 @@ final class BackendController extends Controller
|
||||||
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
||||||
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
|
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
|
||||||
|
|
||||||
/** @var \Modules\Attribute\Models\AttributeType[] */
|
|
||||||
$view->data['attributeTypes'] = ClientAttributeTypeMapper::getAll()
|
$view->data['attributeTypes'] = ClientAttributeTypeMapper::getAll()
|
||||||
->with('l11n')
|
->with('l11n')
|
||||||
->where('l11n/language', $response->header->l11n->language)
|
->where('l11n/language', $response->header->l11n->language)
|
||||||
|
|
@ -292,7 +290,6 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
$view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing');
|
$view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing');
|
||||||
|
|
||||||
/** @var \Modules\Billing\Models\Price\Price[] */
|
|
||||||
$view->data['prices'] = $view->data['hasBilling']
|
$view->data['prices'] = $view->data['hasBilling']
|
||||||
? \Modules\Billing\Models\Price\PriceMapper::getAll()
|
? \Modules\Billing\Models\Price\PriceMapper::getAll()
|
||||||
->where('client', $view->data['client']->id)
|
->where('client', $view->data['client']->id)
|
||||||
|
|
@ -300,6 +297,7 @@ final class BackendController extends Controller
|
||||||
->execute()
|
->execute()
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
/** @var \Modules\Attribute\Models\AttributeType[] $tmp */
|
||||||
$tmp = ItemAttributeTypeMapper::getAll()
|
$tmp = ItemAttributeTypeMapper::getAll()
|
||||||
->with('defaults')
|
->with('defaults')
|
||||||
->with('defaults/l11n')
|
->with('defaults/l11n')
|
||||||
|
|
@ -308,8 +306,8 @@ final class BackendController extends Controller
|
||||||
'sales_tax_code', 'purchase_tax_code',
|
'sales_tax_code', 'purchase_tax_code',
|
||||||
], 'IN')
|
], 'IN')
|
||||||
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
|
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
|
||||||
->where(ItemAttributeValueL11nMapper::getColumnByMember('ref'), '=', null)
|
->where(ItemAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
|
||||||
->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language'), '=', $response->header->l11n->language))
|
->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$defaultAttributeTypes = [];
|
$defaultAttributeTypes = [];
|
||||||
|
|
@ -319,6 +317,7 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
$view->data['defaultAttributeTypes'] = $defaultAttributeTypes;
|
$view->data['defaultAttributeTypes'] = $defaultAttributeTypes;
|
||||||
|
|
||||||
|
/** @var \Modules\Attribute\Models\AttributeType[] $tmp */
|
||||||
$tmp = ClientAttributeTypeMapper::getAll()
|
$tmp = ClientAttributeTypeMapper::getAll()
|
||||||
->with('defaults')
|
->with('defaults')
|
||||||
->with('defaults/l11n')
|
->with('defaults/l11n')
|
||||||
|
|
@ -327,8 +326,8 @@ final class BackendController extends Controller
|
||||||
'sales_tax_code',
|
'sales_tax_code',
|
||||||
], 'IN')
|
], 'IN')
|
||||||
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
|
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
|
||||||
->where(ClientAttributeValueL11nMapper::getColumnByMember('ref'), '=', null)
|
->where(ClientAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
|
||||||
->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language'), '=', $response->header->l11n->language))
|
->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$clientSegmentationTypes = [];
|
$clientSegmentationTypes = [];
|
||||||
|
|
@ -359,7 +358,6 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
// @todo join audit with files, attributes, localization, prices, notes, ...
|
// @todo join audit with files, attributes, localization, prices, notes, ...
|
||||||
|
|
||||||
/** @var \Modules\Media\Models\Media[] */
|
|
||||||
$view->data['files'] = MediaMapper::getAll()
|
$view->data['files'] = MediaMapper::getAll()
|
||||||
->with('types')
|
->with('types')
|
||||||
->join('id', ClientMapper::class, 'files') // id = media id, files = client relations
|
->join('id', ClientMapper::class, 'files') // id = media id, files = client relations
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ final class SearchController extends Controller
|
||||||
*/
|
*/
|
||||||
public function searchGeneral(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
public function searchGeneral(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||||
{
|
{
|
||||||
$names = \explode(' ', ($request->getDataString('search') ?? ''));
|
$names = \explode(' ', ($request->getDataString('search') ?? ''));
|
||||||
$names[] = ($request->getDataString('search') ?? '');
|
$names[] = ($request->getDataString('search') ?? '');
|
||||||
|
|
||||||
$mapper = ClientMapper::getAll()
|
$mapper = ClientMapper::getAll()
|
||||||
|
|
@ -72,7 +72,7 @@ final class SearchController extends Controller
|
||||||
// Get item profile image
|
// Get item profile image
|
||||||
// @feature Create a new read mapper function that returns relation models instead of its own model
|
// @feature Create a new read mapper function that returns relation models instead of its own model
|
||||||
// https://github.com/Karaka-Management/phpOMS/issues/320
|
// https://github.com/Karaka-Management/phpOMS/issues/320
|
||||||
$query = new Builder($this->app->dbPool->get());
|
$query = new Builder($this->app->dbPool->get());
|
||||||
$iResults = $query->selectAs(ClientMapper::HAS_MANY['files']['external'], 'file')
|
$iResults = $query->selectAs(ClientMapper::HAS_MANY['files']['external'], 'file')
|
||||||
->from(ClientMapper::TABLE)
|
->from(ClientMapper::TABLE)
|
||||||
->leftJoin(ClientMapper::HAS_MANY['files']['table'])
|
->leftJoin(ClientMapper::HAS_MANY['files']['table'])
|
||||||
|
|
@ -92,16 +92,16 @@ final class SearchController extends Controller
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$results[] = [
|
$results[] = [
|
||||||
'title' => $account->account->name1 . ' ' . $account->account->name2,
|
'title' => $account->account->name1 . ' ' . $account->account->name2,
|
||||||
'link' => '{/base}/sales/client/view?id=' . $account->id,
|
'link' => '{/base}/sales/client/view?id=' . $account->id,
|
||||||
'email' => $account->account->getContactByType(ContactType::EMAIL)->content,
|
'email' => $account->account->getContactByType(ContactType::EMAIL)->content,
|
||||||
'phone' => $account->account->getContactByType(ContactType::PHONE)->content,
|
'phone' => $account->account->getContactByType(ContactType::PHONE)->content,
|
||||||
'city' => $account->mainAddress?->city,
|
'city' => $account->mainAddress->city,
|
||||||
'image' => $image->id === 0
|
'image' => $image->id === 0
|
||||||
? 'Web/Backend/img/logo_grey.png'
|
? 'Web/Backend/img/logo_grey.png'
|
||||||
: $image->getPath(),
|
: $image->getPath(),
|
||||||
'type' => 'list_accounts',
|
'type' => 'list_accounts',
|
||||||
'module' => 'Client Management',
|
'module' => 'Client Management',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ return ['ClientManagement' => [
|
||||||
'Purchase' => 'Kaufen',
|
'Purchase' => 'Kaufen',
|
||||||
'Quantity' => 'Menge',
|
'Quantity' => 'Menge',
|
||||||
'RecentInvoices' => 'Neuste Rechnungen',
|
'RecentInvoices' => 'Neuste Rechnungen',
|
||||||
'Region' => 'Region',
|
|
||||||
'Sales' => 'Umsatz',
|
'Sales' => 'Umsatz',
|
||||||
'Segment' => 'Segment',
|
'Segment' => 'Segment',
|
||||||
'Segments' => 'Segmente',
|
'Segments' => 'Segmente',
|
||||||
|
|
@ -92,7 +91,6 @@ return ['ClientManagement' => [
|
||||||
'YTDSales' => 'Ytd Sales',
|
'YTDSales' => 'Ytd Sales',
|
||||||
'Zip' => 'Postleitzahl',
|
'Zip' => 'Postleitzahl',
|
||||||
'ItemProductGroup' => 'Artikel Produktgruppe',
|
'ItemProductGroup' => 'Artikel Produktgruppe',
|
||||||
'ItemSalesGroup' => 'Artikel Umsatzgruppe',
|
|
||||||
'Promocode' => 'Promocode',
|
'Promocode' => 'Promocode',
|
||||||
'Region' => 'Region',
|
'Region' => 'Region',
|
||||||
'Materials' => 'Materialien',
|
'Materials' => 'Materialien',
|
||||||
|
|
@ -104,7 +102,6 @@ return ['ClientManagement' => [
|
||||||
'PrimarySupplier' => 'Hauptlieferant',
|
'PrimarySupplier' => 'Hauptlieferant',
|
||||||
'LeadTime' => 'Lieferzeit',
|
'LeadTime' => 'Lieferzeit',
|
||||||
'UnitQuantity' => 'Einheitsmenge',
|
'UnitQuantity' => 'Einheitsmenge',
|
||||||
'UnitPrice' => 'Einheitspreis',
|
|
||||||
'Lieferanten' => 'Lieferanten',
|
'Lieferanten' => 'Lieferanten',
|
||||||
'CostCenter' => 'Kostenstelle',
|
'CostCenter' => 'Kostenstelle',
|
||||||
'CostObject' => 'Kostenträger',
|
'CostObject' => 'Kostenträger',
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ return ['ClientManagement' => [
|
||||||
'Purchase' => 'Purchase',
|
'Purchase' => 'Purchase',
|
||||||
'Quantity' => 'Quantity',
|
'Quantity' => 'Quantity',
|
||||||
'RecentInvoices' => 'Recent Invoices',
|
'RecentInvoices' => 'Recent Invoices',
|
||||||
'Region' => 'Region',
|
|
||||||
'Sales' => 'Sales',
|
'Sales' => 'Sales',
|
||||||
'Segment' => 'Segment',
|
'Segment' => 'Segment',
|
||||||
'Segments' => 'Segments',
|
'Segments' => 'Segments',
|
||||||
|
|
@ -88,13 +87,11 @@ return ['ClientManagement' => [
|
||||||
'Title' => 'Title',
|
'Title' => 'Title',
|
||||||
'TotalPrice' => 'Total price',
|
'TotalPrice' => 'Total price',
|
||||||
'Type' => 'Type',
|
'Type' => 'Type',
|
||||||
'UnitPrice' => 'Unit price',
|
|
||||||
'Website' => 'Website',
|
'Website' => 'Website',
|
||||||
'Wire' => 'Wire',
|
'Wire' => 'Wire',
|
||||||
'YTDSales' => 'YTD Sales',
|
'YTDSales' => 'YTD Sales',
|
||||||
'Zip' => 'Zip',
|
'Zip' => 'Zip',
|
||||||
'ItemProductGroup' => 'Item Product Group',
|
'ItemProductGroup' => 'Item Product Group',
|
||||||
'ItemSalesGroup' => 'Item Sales Group',
|
|
||||||
'Promocode' => 'Promocode',
|
'Promocode' => 'Promocode',
|
||||||
'Region' => 'Region',
|
'Region' => 'Region',
|
||||||
'Materials' => 'Materials',
|
'Materials' => 'Materials',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user