diff --git a/Admin/Install/Admin.install.php b/Admin/Install/Admin.install.php index 096918f..7ec3a28 100644 --- a/Admin/Install/Admin.install.php +++ b/Admin/Install/Admin.install.php @@ -18,10 +18,10 @@ use Modules\ClientManagement\Models\SettingsEnum; return [ [ "description" => "Default item segmentation (segment, section, sales group, product group)", - 'type' => 'setting', - 'name' => SettingsEnum::DEFAULT_SEGMENTATION, - 'content' => '{"segment":1, "section":1, "client_group":1}', - 'pattern' => '', - 'module' => ApiController::NAME, + 'type' => 'setting', + 'name' => SettingsEnum::DEFAULT_SEGMENTATION, + 'content' => '{"segment":1, "section":1, "client_group":1}', + 'pattern' => '', + 'module' => ApiController::NAME, ], ]; diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json index c8bb287..bc5bb08 100755 --- a/Admin/Install/attributes.json +++ b/Admin/Install/attributes.json @@ -245,6 +245,7 @@ { "value": "FI" }, { "value": "FR" }, { "value": "DE" }, + { "value": "DE_0" }, { "value": "GR" }, { "value": "HU" }, { "value": "IE" }, diff --git a/Admin/Installer.php b/Admin/Installer.php index a2cfba3..2c308dd 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -62,8 +62,9 @@ final class Installer extends InstallerAbstract $attrValues = self::createClientAttributeValues($app, $attrTypes, $attributes); $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 => $_) { $content[$type] = \reset($attrValues[$type])['id']; } diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 8da45ee..3334459 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -88,6 +88,16 @@ final class ApiController extends Controller 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 { /** @var \Modules\Attribute\Models\AttributeType $type */ @@ -105,6 +115,16 @@ final class ApiController extends Controller ->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 { /** @var \Modules\Organization\Models\Unit $unit */ @@ -146,6 +166,16 @@ final class ApiController extends Controller 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 { /** @var \Modules\Organization\Models\Unit $unit */ @@ -246,16 +276,31 @@ final class ApiController extends Controller $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 { /** @var \Model\Setting $settings */ $settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_SEGMENTATION); + /** @var array $segmentation */ $segmentation = \json_decode($settings->content, true); if ($segmentation === false || $segmentation === null) { return; } + /** @var \Modules\Attribute\Models\AttributeType[] $types */ $types = ClientAttributeTypeMapper::getAll() ->where('name', \array_keys($segmentation), 'IN') ->execute(); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 8b48645..6839a3e 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -226,7 +226,6 @@ final class BackendController extends Controller $pkValue = $request->getDataString('number'); } - /** @var \Modules\ClientManagement\Models\Client */ $view->data['client'] = ClientMapper::get() ->with('account') ->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']->data['default_localization'] = $this->app->l11nServer; - /** @var \Modules\Attribute\Models\AttributeType[] */ $view->data['attributeTypes'] = ClientAttributeTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) @@ -292,7 +290,6 @@ final class BackendController extends Controller $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); - /** @var \Modules\Billing\Models\Price\Price[] */ $view->data['prices'] = $view->data['hasBilling'] ? \Modules\Billing\Models\Price\PriceMapper::getAll() ->where('client', $view->data['client']->id) @@ -300,6 +297,7 @@ final class BackendController extends Controller ->execute() : []; + /** @var \Modules\Attribute\Models\AttributeType[] $tmp */ $tmp = ItemAttributeTypeMapper::getAll() ->with('defaults') ->with('defaults/l11n') @@ -308,8 +306,8 @@ final class BackendController extends Controller 'sales_tax_code', 'purchase_tax_code', ], 'IN') ->where('defaults/l11n', (new Where($this->app->dbPool->get())) - ->where(ItemAttributeValueL11nMapper::getColumnByMember('ref'), '=', null) - ->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language'), '=', $response->header->l11n->language)) + ->where(ItemAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null) + ->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language)) ->execute(); $defaultAttributeTypes = []; @@ -319,6 +317,7 @@ final class BackendController extends Controller $view->data['defaultAttributeTypes'] = $defaultAttributeTypes; + /** @var \Modules\Attribute\Models\AttributeType[] $tmp */ $tmp = ClientAttributeTypeMapper::getAll() ->with('defaults') ->with('defaults/l11n') @@ -327,8 +326,8 @@ final class BackendController extends Controller 'sales_tax_code', ], 'IN') ->where('defaults/l11n', (new Where($this->app->dbPool->get())) - ->where(ClientAttributeValueL11nMapper::getColumnByMember('ref'), '=', null) - ->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language'), '=', $response->header->l11n->language)) + ->where(ClientAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null) + ->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language)) ->execute(); $clientSegmentationTypes = []; @@ -359,7 +358,6 @@ final class BackendController extends Controller // @todo join audit with files, attributes, localization, prices, notes, ... - /** @var \Modules\Media\Models\Media[] */ $view->data['files'] = MediaMapper::getAll() ->with('types') ->join('id', ClientMapper::class, 'files') // id = media id, files = client relations diff --git a/Controller/SearchController.php b/Controller/SearchController.php index 40d6e25..03e4a3d 100644 --- a/Controller/SearchController.php +++ b/Controller/SearchController.php @@ -48,7 +48,7 @@ final class SearchController extends Controller */ public function searchGeneral(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void { - $names = \explode(' ', ($request->getDataString('search') ?? '')); + $names = \explode(' ', ($request->getDataString('search') ?? '')); $names[] = ($request->getDataString('search') ?? ''); $mapper = ClientMapper::getAll() @@ -72,7 +72,7 @@ final class SearchController extends Controller // Get item profile image // @feature Create a new read mapper function that returns relation models instead of its own model // 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') ->from(ClientMapper::TABLE) ->leftJoin(ClientMapper::HAS_MANY['files']['table']) @@ -92,16 +92,16 @@ final class SearchController extends Controller ->execute(); $results[] = [ - 'title' => $account->account->name1 . ' ' . $account->account->name2, - 'link' => '{/base}/sales/client/view?id=' . $account->id, + 'title' => $account->account->name1 . ' ' . $account->account->name2, + 'link' => '{/base}/sales/client/view?id=' . $account->id, 'email' => $account->account->getContactByType(ContactType::EMAIL)->content, 'phone' => $account->account->getContactByType(ContactType::PHONE)->content, - 'city' => $account->mainAddress?->city, + 'city' => $account->mainAddress->city, 'image' => $image->id === 0 ? 'Web/Backend/img/logo_grey.png' : $image->getPath(), - 'type' => 'list_accounts', - 'module' => 'Client Management', + 'type' => 'list_accounts', + 'module' => 'Client Management', ]; } diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index dbb92ec..c4daa15 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -77,7 +77,6 @@ return ['ClientManagement' => [ 'Purchase' => 'Kaufen', 'Quantity' => 'Menge', 'RecentInvoices' => 'Neuste Rechnungen', - 'Region' => 'Region', 'Sales' => 'Umsatz', 'Segment' => 'Segment', 'Segments' => 'Segmente', @@ -92,7 +91,6 @@ return ['ClientManagement' => [ 'YTDSales' => 'Ytd Sales', 'Zip' => 'Postleitzahl', 'ItemProductGroup' => 'Artikel Produktgruppe', - 'ItemSalesGroup' => 'Artikel Umsatzgruppe', 'Promocode' => 'Promocode', 'Region' => 'Region', 'Materials' => 'Materialien', @@ -104,7 +102,6 @@ return ['ClientManagement' => [ 'PrimarySupplier' => 'Hauptlieferant', 'LeadTime' => 'Lieferzeit', 'UnitQuantity' => 'Einheitsmenge', - 'UnitPrice' => 'Einheitspreis', 'Lieferanten' => 'Lieferanten', 'CostCenter' => 'Kostenstelle', 'CostObject' => 'Kostenträger', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 40ae16a..d42d25a 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -79,7 +79,6 @@ return ['ClientManagement' => [ 'Purchase' => 'Purchase', 'Quantity' => 'Quantity', 'RecentInvoices' => 'Recent Invoices', - 'Region' => 'Region', 'Sales' => 'Sales', 'Segment' => 'Segment', 'Segments' => 'Segments', @@ -88,13 +87,11 @@ return ['ClientManagement' => [ 'Title' => 'Title', 'TotalPrice' => 'Total price', 'Type' => 'Type', - 'UnitPrice' => 'Unit price', 'Website' => 'Website', 'Wire' => 'Wire', 'YTDSales' => 'YTD Sales', 'Zip' => 'Zip', 'ItemProductGroup' => 'Item Product Group', - 'ItemSalesGroup' => 'Item Sales Group', 'Promocode' => 'Promocode', 'Region' => 'Region', 'Materials' => 'Materials',