diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php new file mode 100644 index 0000000..cf3558a --- /dev/null +++ b/app/Http/Controllers/ApiController.php @@ -0,0 +1,175 @@ +validate($validationRules); + $segments = Segment::listActive(); + + foreach ($segments as $segment) { + foreach ($validatedData as $value) { + UniModel::model($modelName, $segment->connector)->updateOrCreate( + ['code' => $value['Код']], + array_merge($this->mapAttributes($value), $extraProcessing ? $extraProcessing($value, $segment) : []) + ); + } + } + + if (isset($extraProcessing)) { + foreach ($validatedData as $value) { + $this->processParentRelation($modelName, $value); + } + } + + DB::commit(); + return response()->json(['message' => ucfirst($modelName) . ' data synchronized successfully'], 200); + } catch (Exception $e) { + DB::rollBack(); + Log::error('Error syncing ' . $modelName . ' data: ' . $e->getMessage()); + return response()->json(['error' => 'Failed to synchronize ' . $modelName . ' data'], 500); + } + } + + private function mapAttributes($data) + { + return [ + 'is_group' => (bool)($data['ЭтоГруппа'] ?? false), + 'name' => $data['Наименование'] ?? null, + 'comments' => $data['Комментарий'] ?? null, + 'iin' => $data['ИдентификационныйКодЛичности'] ?? null, + 'kbe' => $data['КБЕ'] ?? null, + 'okpo_code' => $data['КодПоОКПО'] ?? null, + 'main_contact' => $data['ОсновноеКонтактноеЛицо'] ?? null, + 'bank_account' => $data['ОсновнойБанковскийСчет'] ?? null, + 'address' => $data['Адрес'] ?? null, + 'phone' => $data['Телефон'] ?? null, + 'mail' => $data['Почта'] ?? null, + 'id_number' => $data['УдНомер'] ?? null, + 'id_date' => $data['УдДата'] ?? null, + 'issued' => $data['УдВыдан'] ?? null, + 'contract_id' => $data['ОсновнойДоговор'] ?? null, + 'deleted_at' => $data['ПометкаУдаления'] ? now() : null, + ]; + } + + private function processParentRelation($modelName, $data) + { + $model = UniModel::model($modelName)->where('name', $data['Наименование'])->first(); + + if ($model && !empty($data['Родитель'])) { + $parent = UniModel::model($modelName)->where('name', $data['Родитель'])->first(); + if ($parent) { + $model->parent_id = $parent->id; + $model->save(); + } + } + } + + public function syncAutoData(Request $request) + { + $validationRules = [ + '*.Код' => 'required|string', + '*.Наименование' => 'required|string', + '*.Тип' => 'required|string', + '*.Класс' => 'required|string', + '*.Марка' => 'required|string', + '*.Модель' => 'required|string', + '*.Цвет' => 'required|string', + '*.СерийныйНомер' => 'nullable|string', + '*.ГосНомер' => 'nullable|string', + '*.ГодПроизводства' => 'nullable|integer', + '*.НомерТехПаспорта' => 'nullable|string', + '*.ДатаТехпаспорта' => 'nullable|date', + '*.ОценочнаяСтоимость' => 'nullable|numeric', + '*.ВладелецИмущества' => 'required|string', + '*.ВДоверенномУправлении' => 'required|boolean', + '*.ПроцентВладельца' => 'nullable|numeric', + '*.НеИспользовать' => 'required|boolean', + '*.Предопределенный' => 'required|boolean', + '*.ИмяПредопределенныхДанных' => 'nullable|string', + '*.ПометкаУдаления' => 'required|boolean', + ]; + + $extraProcessing = function ($value, $segment) { + return [ + 'type_id' => UniModel::model('pipi_auto_types', $segment->connector) + ->firstOrCreate(['name' => $value['Тип']])->id, + 'class_id' => UniModel::model('pipi_auto_classes', $segment->connector) + ->firstOrCreate(['name' => $value['Класс']])->id, + 'brand_id' => UniModel::model('pipi_auto_brands', $segment->connector) + ->firstOrCreate(['name' => $value['Марка']])->id, + 'model_id' => UniModel::model('pipi_brand_models', $segment->connector) + ->firstOrCreate([ + 'name' => $value['Модель'], + 'brand_id' => UniModel::model('pipi_auto_brands', $segment->connector) + ->firstOrCreate(['name' => $value['Марка']])->id, + ])->id, + 'color_id' => UniModel::model('pipi_auto_colors', $segment->connector) + ->firstOrCreate(['name' => $value['Цвет']])->id, + 'owner_id' => UniModel::model('pipi_owners', $segment->connector) + ->firstOrCreate(['name' => $value['ВладелецИмущества']])->id, + ]; + }; + + return $this->syncData($request, 'pipi_auto', $validationRules, $extraProcessing); + } + + public function syncOwners(Request $request) + { + $validationRules = [ + '*.Код' => 'required|string', + '*.Наименование' => 'required|string', + '*.Комментарий' => 'nullable|string', + '*.ИдентификационныйКодЛичности' => 'nullable|string', + '*.КБЕ' => 'nullable|string', + '*.КодПоОКПО' => 'nullable|string', + '*.ОсновноеКонтактноеЛицо' => 'nullable|string', + '*.ОсновнойБанковскийСчет' => 'nullable|string', + '*.Адрес' => 'nullable|string', + '*.Телефон' => 'nullable|string', + '*.Почта' => 'nullable|string', + '*.УдНомер' => 'nullable|string', + '*.УдДата' => 'nullable|date', + '*.УдВыдан' => 'nullable|string', + '*.ОсновнойДоговор' => 'nullable|string', + '*.ЭтоГруппа' => 'required|boolean', + '*.ПометкаУдаления' => 'required|boolean', + '*.Родитель' => 'nullable|string', + ]; + + return $this->syncData($request, 'pipi_owners', $validationRules); + } + + public function syncOwnerContracts(Request $request) + { + $validationRules = [ + '*.Код' => 'required|string', + '*.Наименование' => 'required|string', + '*.Комментарий' => 'nullable|string', + '*.Организация' => 'nullable|string', + '*.НомерДоговора' => 'required|string', + '*.ДатаДоговора' => 'nullable|date', + '*.ДатаНачалаДействияДоговора' => 'nullable|date', + '*.ДатаОкончанияДействияДоговора' => 'nullable|date', + '*.УсловияОплаты' => 'nullable|string', + '*.ЭтоГруппа' => 'required|boolean', + '*.ПометкаУдаления' => 'required|boolean', + '*.Родитель' => 'nullable|string', + ]; + + return $this->syncData($request, 'pipi_owner_contracts', $validationRules); + } +} diff --git a/modules/auto_brands/app.json b/modules/auto_brands/app.json index 6b283eb..cae25e3 100644 --- a/modules/auto_brands/app.json +++ b/modules/auto_brands/app.json @@ -1,258 +1,52 @@ { "module": "pipicar", - "name": "pipicar.auto", + "name": "pipicar.auto_brands", "type": "crud", - "title": "Автомобили", + "title": "Бренды Автомобилей", "data": { - "table": "auto", + "table": "pipi_auto_brands", "pk": "id", "limit": 25, - "sort_order": "asc", - "sort_field": "code", "segment": true, "timestamp": false, "fields": { "id": { "type": "pk" }, - "code": { - "type": "string", - "validation": "required" - }, - "name_ru": { - "type": "text" - }, - "name_kz": { - "type": "text" - }, - "account_type": { - "type": "foreign", - "table": "ref_base_group", - "foreign": "id", - "display": [ - "data_name_{lk}" - ], - "where": "data_type = 'T01'" - }, - "article_source": { - "type": "string", - "validation": "nullable" - }, - "element_source": { - "type": "string", - "validation": "nullable" - }, - "mo_num": { - "type": "int", - "validation": "nullable|integer" - }, - "used_by_documents": { - "type": "bool", - "validation": "nullable" - }, - "used_by_system": { - "type": "bool", - "validation": "nullable" - }, - "type_of_organization": { - "type": "foreign", - "table": "ref_property_types", - "foreign": "id", - "display": [ - "value", - "name" - ], - "validation": "nullable|int", - "label": "Тип собственности" - }, - "accounts_plan_part": { - "type": "foreign", - "table": "ref_accounts_plan_part", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "nullable|string", - "label": "Раздел плана счетов" - }, - "accounts_plan_particle": { - "type": "foreign", - "table": "ref_accounts_plan_particle", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "required|string", - "label": "Подраздел плана счетов" - }, - "started_at": { - "type": "date", - "validation": "required|date" - }, - "ended_at": { - "type": "date", - "validation": "nullable|date" - }, - "whitespace": { - "type": "virtual" + "name": { + "type": "string" } } }, "ui": { "grid": { - "title": "План счетов", + "title": "Бренды Автомобилей", "template": "app.base.crud.grid", "cols": [ { - "name": "code", - "caption": "Счёт" - }, - { - "name": "name_kz", - "caption": "Наименование на казахском" - }, - { - "name": "name_ru", - "caption": "Наименование на русском" - }, - { - "name": "account_type", - "caption": "Тип счёта" - }, - { - "name": "used_by_documents", - "caption": "Исп. в первич. док-тах" - }, - { - "name": "used_by_system", - "caption": "Исп. системой" - }, - { - "name": "accounts_plan_particle", - "caption": "Подраздел плана счетов" - }, - { - "name": "type_of_organization", - "caption": "Тип плана счетов" - }, - { - "name": "started_at", - "caption": "Дата начала действия" - }, - { - "name": "ended_at", - "caption": "Дата окончания действия" - }, - { - "name": "id", - "caption": "ИД" + "name": "name", + "caption": "Название бренда" } ], "action": { "head": [ "add" + ], + "row": [ + "edit", + "delete" ] }, "filter": { "template": "app.base.crud.filter", "rows": [ - { - "cols": [ - { - "size": 1, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 3, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 1, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 1, - "input": { - "name": "id", - "label": "ИД" - } - }, - { - "size": 3, - "input": { - "name": "used_by_documents", - "label": "Исп. только в первич. документах" - } - }, - { - "size": 3, - "input": { - "name": "used_by_system", - "label": "Исп. только системой" - } - } - ] - }, { "cols": [ { "size": 6, "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 6, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "type_of_organization", - "label": "Тип плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" + "name": "name", + "label": "Название бренда" } } ] @@ -262,137 +56,18 @@ }, "forms": { "add": { - "title": "Добавление записи в справочник \"План счетов\"", + "title": "Добавление бренда", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], - "submits": "struct:accounting.form.edit.submits", + "submits": "struct:crud.form.edit.submits", "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название бренда" } } ] @@ -401,142 +76,23 @@ } }, "edit": { - "title": "Редактирование записи в справочнике \"План счетов\"", + "title": "Редактирование бренда", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название бренда" } } ] } ], - "submits": "struct:accounting.form.edit.submits" + "submits": "struct:crud.form.edit.submits" } } } diff --git a/modules/auto_classes/app.json b/modules/auto_classes/app.json index 6b283eb..dff9833 100644 --- a/modules/auto_classes/app.json +++ b/modules/auto_classes/app.json @@ -1,258 +1,52 @@ { "module": "pipicar", - "name": "pipicar.auto", + "name": "pipicar.auto_classes", "type": "crud", - "title": "Автомобили", + "title": "Классы автомобилей", "data": { - "table": "auto", + "table": "pipi_auto_classes", "pk": "id", "limit": 25, - "sort_order": "asc", - "sort_field": "code", "segment": true, "timestamp": false, "fields": { "id": { "type": "pk" }, - "code": { - "type": "string", - "validation": "required" - }, - "name_ru": { - "type": "text" - }, - "name_kz": { - "type": "text" - }, - "account_type": { - "type": "foreign", - "table": "ref_base_group", - "foreign": "id", - "display": [ - "data_name_{lk}" - ], - "where": "data_type = 'T01'" - }, - "article_source": { - "type": "string", - "validation": "nullable" - }, - "element_source": { - "type": "string", - "validation": "nullable" - }, - "mo_num": { - "type": "int", - "validation": "nullable|integer" - }, - "used_by_documents": { - "type": "bool", - "validation": "nullable" - }, - "used_by_system": { - "type": "bool", - "validation": "nullable" - }, - "type_of_organization": { - "type": "foreign", - "table": "ref_property_types", - "foreign": "id", - "display": [ - "value", - "name" - ], - "validation": "nullable|int", - "label": "Тип собственности" - }, - "accounts_plan_part": { - "type": "foreign", - "table": "ref_accounts_plan_part", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "nullable|string", - "label": "Раздел плана счетов" - }, - "accounts_plan_particle": { - "type": "foreign", - "table": "ref_accounts_plan_particle", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "required|string", - "label": "Подраздел плана счетов" - }, - "started_at": { - "type": "date", - "validation": "required|date" - }, - "ended_at": { - "type": "date", - "validation": "nullable|date" - }, - "whitespace": { - "type": "virtual" + "name": { + "type": "string" } } }, "ui": { "grid": { - "title": "План счетов", + "title": "Классы автомобилей", "template": "app.base.crud.grid", "cols": [ { - "name": "code", - "caption": "Счёт" - }, - { - "name": "name_kz", - "caption": "Наименование на казахском" - }, - { - "name": "name_ru", - "caption": "Наименование на русском" - }, - { - "name": "account_type", - "caption": "Тип счёта" - }, - { - "name": "used_by_documents", - "caption": "Исп. в первич. док-тах" - }, - { - "name": "used_by_system", - "caption": "Исп. системой" - }, - { - "name": "accounts_plan_particle", - "caption": "Подраздел плана счетов" - }, - { - "name": "type_of_organization", - "caption": "Тип плана счетов" - }, - { - "name": "started_at", - "caption": "Дата начала действия" - }, - { - "name": "ended_at", - "caption": "Дата окончания действия" - }, - { - "name": "id", - "caption": "ИД" + "name": "name", + "caption": "Название класса" } ], "action": { "head": [ "add" + ], + "row": [ + "edit", + "delete" ] }, "filter": { "template": "app.base.crud.filter", "rows": [ - { - "cols": [ - { - "size": 1, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 3, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 1, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 1, - "input": { - "name": "id", - "label": "ИД" - } - }, - { - "size": 3, - "input": { - "name": "used_by_documents", - "label": "Исп. только в первич. документах" - } - }, - { - "size": 3, - "input": { - "name": "used_by_system", - "label": "Исп. только системой" - } - } - ] - }, { "cols": [ { "size": 6, "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 6, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "type_of_organization", - "label": "Тип плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" + "name": "name", + "label": "Название класса" } } ] @@ -262,137 +56,18 @@ }, "forms": { "add": { - "title": "Добавление записи в справочник \"План счетов\"", + "title": "Добавление класса", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], - "submits": "struct:accounting.form.edit.submits", + "submits": "struct:crud.form.edit.submits", "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название класса" } } ] @@ -401,142 +76,23 @@ } }, "edit": { - "title": "Редактирование записи в справочнике \"План счетов\"", + "title": "Редактирование класса", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название класса" } } ] } ], - "submits": "struct:accounting.form.edit.submits" + "submits": "struct:crud.form.edit.submits" } } } diff --git a/modules/auto_colors/app.json b/modules/auto_colors/app.json index 6b283eb..2c186ef 100644 --- a/modules/auto_colors/app.json +++ b/modules/auto_colors/app.json @@ -1,258 +1,52 @@ { "module": "pipicar", - "name": "pipicar.auto", + "name": "pipicar.auto_colors", "type": "crud", - "title": "Автомобили", + "title": "Цвета Автомобилей", "data": { - "table": "auto", + "table": "pipi_auto_colors", "pk": "id", "limit": 25, - "sort_order": "asc", - "sort_field": "code", "segment": true, "timestamp": false, "fields": { "id": { "type": "pk" }, - "code": { - "type": "string", - "validation": "required" - }, - "name_ru": { - "type": "text" - }, - "name_kz": { - "type": "text" - }, - "account_type": { - "type": "foreign", - "table": "ref_base_group", - "foreign": "id", - "display": [ - "data_name_{lk}" - ], - "where": "data_type = 'T01'" - }, - "article_source": { - "type": "string", - "validation": "nullable" - }, - "element_source": { - "type": "string", - "validation": "nullable" - }, - "mo_num": { - "type": "int", - "validation": "nullable|integer" - }, - "used_by_documents": { - "type": "bool", - "validation": "nullable" - }, - "used_by_system": { - "type": "bool", - "validation": "nullable" - }, - "type_of_organization": { - "type": "foreign", - "table": "ref_property_types", - "foreign": "id", - "display": [ - "value", - "name" - ], - "validation": "nullable|int", - "label": "Тип собственности" - }, - "accounts_plan_part": { - "type": "foreign", - "table": "ref_accounts_plan_part", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "nullable|string", - "label": "Раздел плана счетов" - }, - "accounts_plan_particle": { - "type": "foreign", - "table": "ref_accounts_plan_particle", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "required|string", - "label": "Подраздел плана счетов" - }, - "started_at": { - "type": "date", - "validation": "required|date" - }, - "ended_at": { - "type": "date", - "validation": "nullable|date" - }, - "whitespace": { - "type": "virtual" + "name": { + "type": "string" } } }, "ui": { "grid": { - "title": "План счетов", + "title": "Цвета Автомобилей", "template": "app.base.crud.grid", "cols": [ { - "name": "code", - "caption": "Счёт" - }, - { - "name": "name_kz", - "caption": "Наименование на казахском" - }, - { - "name": "name_ru", - "caption": "Наименование на русском" - }, - { - "name": "account_type", - "caption": "Тип счёта" - }, - { - "name": "used_by_documents", - "caption": "Исп. в первич. док-тах" - }, - { - "name": "used_by_system", - "caption": "Исп. системой" - }, - { - "name": "accounts_plan_particle", - "caption": "Подраздел плана счетов" - }, - { - "name": "type_of_organization", - "caption": "Тип плана счетов" - }, - { - "name": "started_at", - "caption": "Дата начала действия" - }, - { - "name": "ended_at", - "caption": "Дата окончания действия" - }, - { - "name": "id", - "caption": "ИД" + "name": "name", + "caption": "Название цвета" } ], "action": { "head": [ "add" + ], + "row": [ + "edit", + "delete" ] }, "filter": { "template": "app.base.crud.filter", "rows": [ - { - "cols": [ - { - "size": 1, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 3, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 1, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 1, - "input": { - "name": "id", - "label": "ИД" - } - }, - { - "size": 3, - "input": { - "name": "used_by_documents", - "label": "Исп. только в первич. документах" - } - }, - { - "size": 3, - "input": { - "name": "used_by_system", - "label": "Исп. только системой" - } - } - ] - }, { "cols": [ { "size": 6, "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 6, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "type_of_organization", - "label": "Тип плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" + "name": "name", + "label": "Название цвета" } } ] @@ -262,137 +56,18 @@ }, "forms": { "add": { - "title": "Добавление записи в справочник \"План счетов\"", + "title": "Добавление цвета", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], - "submits": "struct:accounting.form.edit.submits", + "submits": "struct:crud.form.edit.submits", "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название" } } ] @@ -401,142 +76,23 @@ } }, "edit": { - "title": "Редактирование записи в справочнике \"План счетов\"", + "title": "Редактирование цвета", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название" } } ] } ], - "submits": "struct:accounting.form.edit.submits" + "submits": "struct:crud.form.edit.submits" } } } diff --git a/modules/auto_types/app.json b/modules/auto_types/app.json index 6b283eb..d42465b 100644 --- a/modules/auto_types/app.json +++ b/modules/auto_types/app.json @@ -1,258 +1,52 @@ { "module": "pipicar", - "name": "pipicar.auto", + "name": "pipicar.auto_types", "type": "crud", - "title": "Автомобили", + "title": "Типы Автомобилей", "data": { - "table": "auto", + "table": "pipi_auto_types", "pk": "id", "limit": 25, - "sort_order": "asc", - "sort_field": "code", "segment": true, "timestamp": false, "fields": { "id": { "type": "pk" }, - "code": { - "type": "string", - "validation": "required" - }, - "name_ru": { - "type": "text" - }, - "name_kz": { - "type": "text" - }, - "account_type": { - "type": "foreign", - "table": "ref_base_group", - "foreign": "id", - "display": [ - "data_name_{lk}" - ], - "where": "data_type = 'T01'" - }, - "article_source": { - "type": "string", - "validation": "nullable" - }, - "element_source": { - "type": "string", - "validation": "nullable" - }, - "mo_num": { - "type": "int", - "validation": "nullable|integer" - }, - "used_by_documents": { - "type": "bool", - "validation": "nullable" - }, - "used_by_system": { - "type": "bool", - "validation": "nullable" - }, - "type_of_organization": { - "type": "foreign", - "table": "ref_property_types", - "foreign": "id", - "display": [ - "value", - "name" - ], - "validation": "nullable|int", - "label": "Тип собственности" - }, - "accounts_plan_part": { - "type": "foreign", - "table": "ref_accounts_plan_part", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "nullable|string", - "label": "Раздел плана счетов" - }, - "accounts_plan_particle": { - "type": "foreign", - "table": "ref_accounts_plan_particle", - "foreign": "id", - "display": [ - "code", - "name_{lk}" - ], - "validation": "required|string", - "label": "Подраздел плана счетов" - }, - "started_at": { - "type": "date", - "validation": "required|date" - }, - "ended_at": { - "type": "date", - "validation": "nullable|date" - }, - "whitespace": { - "type": "virtual" + "name": { + "type": "string" } } }, "ui": { "grid": { - "title": "План счетов", + "title": "Типы Автомобилей", "template": "app.base.crud.grid", "cols": [ { - "name": "code", - "caption": "Счёт" - }, - { - "name": "name_kz", - "caption": "Наименование на казахском" - }, - { - "name": "name_ru", - "caption": "Наименование на русском" - }, - { - "name": "account_type", - "caption": "Тип счёта" - }, - { - "name": "used_by_documents", - "caption": "Исп. в первич. док-тах" - }, - { - "name": "used_by_system", - "caption": "Исп. системой" - }, - { - "name": "accounts_plan_particle", - "caption": "Подраздел плана счетов" - }, - { - "name": "type_of_organization", - "caption": "Тип плана счетов" - }, - { - "name": "started_at", - "caption": "Дата начала действия" - }, - { - "name": "ended_at", - "caption": "Дата окончания действия" - }, - { - "name": "id", - "caption": "ИД" + "name": "name", + "caption": "Название типа" } ], "action": { "head": [ "add" + ], + "row": [ + "edit", + "delete" ] }, "filter": { "template": "app.base.crud.filter", "rows": [ - { - "cols": [ - { - "size": 1, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 3, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 1, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 1, - "input": { - "name": "id", - "label": "ИД" - } - }, - { - "size": 3, - "input": { - "name": "used_by_documents", - "label": "Исп. только в первич. документах" - } - }, - { - "size": 3, - "input": { - "name": "used_by_system", - "label": "Исп. только системой" - } - } - ] - }, { "cols": [ { "size": 6, "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 6, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "type_of_organization", - "label": "Тип плана счетов" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" + "name": "name", + "label": "Название типа" } } ] @@ -262,137 +56,18 @@ }, "forms": { "add": { - "title": "Добавление записи в справочник \"План счетов\"", + "title": "Добавление типа", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], - "submits": "struct:accounting.form.edit.submits", + "submits": "struct:crud.form.edit.submits", "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название типа" } } ] @@ -401,142 +76,23 @@ } }, "edit": { - "title": "Редактирование записи в справочнике \"План счетов\"", + "title": "Редактирование типа", "template": "app.base.crud.form", "form": { - "inject_component": [ - "Js.Refs.AccountsPlan" - ], "rows": [ - { - "cols": [ - { - "size": 2, - "input": { - "name": "code", - "label": "Cчёт" - } - }, - { - "size": 2, - "input": { - "name": "mo_num", - "label": "МО №" - } - }, - { - "size": 4, - "input": { - "name": "started_at", - "label": "Дата начала действия" - } - }, - { - "size": 4, - "input": { - "name": "ended_at", - "label": "Дата окончания действия" - } - } - ] - }, { "cols": [ { "size": 12, "input": { - "name": "type_of_organization", - "label": "Тип плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_part", - "label": "Раздел плана счетов", - "readonly": true - } - }, - { - "size": 12, - "input": { - "name": "accounts_plan_particle", - "label": "Подраздел плана счетов", - "js_event": { - "onchange": "accountPlanParticleChange" - } - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "name_kz", - "label": "Наименование на казахском" - } - }, - { - "size": 12, - "input": { - "name": "name_ru", - "label": "Наименование на русском" - } - } - ] - }, - { - "cols": [ - { - "size": 4, - "input": { - "name": "account_type", - "label": "Тип счёта" - } - }, - { - "size": 12, - "input": { - "name": "article_source", - "label": "Источник статьи" - } - }, - { - "size": 12, - "input": { - "name": "element_source", - "label": "Источник элемента" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_documents", - "label": "Используется только в первичных документах" - } - } - ] - }, - { - "cols": [ - { - "size": 12, - "input": { - "name": "used_by_system", - "label": "Используется только системой" + "name": "name", + "label": "Название типа" } } ] } ], - "submits": "struct:accounting.form.edit.submits" + "submits": "struct:crud.form.edit.submits" } } } diff --git a/routes/api.php b/routes/api.php index 889937e..6f5a962 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,7 +13,10 @@ use Illuminate\Support\Facades\Route; | be assigned to the "api" middleware group. Make something great! | */ +use App\Http\Controllers\ApiController; -Route::middleware('auth:sanctum')->get('/user', function (Request $request) { - return $request->user(); +Route::prefix('1c')->group(function () { + Route::post('syncAutoData', [ApiController::class, 'syncAutoData']); + Route::post('syncOwners', [ApiController::class, 'syncOwners']); + Route::post('syncOwnerContracts', [ApiController::class, 'syncOwnerContracts']); });