Календарь
parent
05a3f8eeb1
commit
97ec6562f7
|
|
@ -34,7 +34,8 @@ class PipiCarInstallCommands extends InstallCommand
|
||||||
'owners', // Владелец авто
|
'owners', // Владелец авто
|
||||||
'auto', // авто
|
'auto', // авто
|
||||||
'applications', //Заявки
|
'applications', //Заявки
|
||||||
'pipi_users' // Добавление логики для пользователей
|
'pipi_users', // Добавление логики для пользователей
|
||||||
|
'auto_calendar' // Добавление логики для пользователей
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use A7kz\Platform\Models\UniModel;
|
use A7kz\Platform\Models\UniModel;
|
||||||
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
||||||
|
use App\Modules\auto\Enums\AutoStatusEnums;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
@ -218,4 +219,40 @@ class Sync1cApiController extends Controller
|
||||||
return response()->json(['error' => 'Failed to synchronize owner contracts'], 500);
|
return response()->json(['error' => 'Failed to synchronize owner contracts'], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function syncCarCalendar(Request $request) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
Log::error('Запрос календаря пришел');
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$segments = Segment::listActive();
|
||||||
|
|
||||||
|
foreach ($segments as $segment) {
|
||||||
|
foreach ($request->all() as $value) {
|
||||||
|
UniModel::model('pipi_owner_contracts', $segment->connector)->updateOrCreate(
|
||||||
|
[
|
||||||
|
'auto_id' => UniModel::model('pipi_auto')->where('name', $value['Имущество'])->first()?->id,
|
||||||
|
'date' => $this->formatDate($value['Дата']),
|
||||||
|
'status' => AutoStatusEnums::from($value['Статус'])->name
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'auto_id' => UniModel::model('pipi_auto')->where('name', $value['Имущество'])->first()?->id,
|
||||||
|
'date' => $this->formatDate($value['Дата']),
|
||||||
|
'status' => AutoStatusEnums::from($value['Статус'])->name
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json(['message' => 'Calendar synchronized successfully'], 200);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
Log::error('Error syncing calendar: ' . $e->getMessage());
|
||||||
|
return response()->json(['error' => 'Failed to synchronize calendar'], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\auto\Enums;
|
||||||
|
|
||||||
|
enum AutoStatusEnums: string
|
||||||
|
{
|
||||||
|
case Free = 'free';
|
||||||
|
case Rent = 'Аренда';
|
||||||
|
case Service = 'Сервис';
|
||||||
|
case Blocked = 'Забронирован';
|
||||||
|
case Waiting = 'waiting';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"admin": [
|
||||||
|
"default",
|
||||||
|
"add",
|
||||||
|
"show",
|
||||||
|
"edit",
|
||||||
|
"delete"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
{
|
||||||
|
"module": "pipicar",
|
||||||
|
"name": "pipicar.auto_calendar",
|
||||||
|
"type": "crud",
|
||||||
|
"title": "Календарь Автомобилей",
|
||||||
|
"data": {
|
||||||
|
"table": "pipi_auto_calendar",
|
||||||
|
"pk": "id",
|
||||||
|
"limit": 25,
|
||||||
|
"segment": true,
|
||||||
|
"timestamp": false,
|
||||||
|
"fields": {
|
||||||
|
"id": {
|
||||||
|
"type": "pk"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ui": {
|
||||||
|
"grid": {
|
||||||
|
"title": "Цвета Автомобилей",
|
||||||
|
"template": "app.base.crud.grid",
|
||||||
|
"cols": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"caption": "Название цвета"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"action": {
|
||||||
|
"head": [
|
||||||
|
"add"
|
||||||
|
],
|
||||||
|
"row": [
|
||||||
|
"edit",
|
||||||
|
"delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"filter": {
|
||||||
|
"template": "app.base.crud.filter",
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"cols": [
|
||||||
|
{
|
||||||
|
"size": 6,
|
||||||
|
"input": {
|
||||||
|
"name": "name",
|
||||||
|
"label": "Название цвета"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"forms": {
|
||||||
|
"add": {
|
||||||
|
"title": "Добавление цвета",
|
||||||
|
"template": "app.base.crud.form",
|
||||||
|
"form": {
|
||||||
|
"submits": "struct:crud.form.edit.submits",
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"cols": [
|
||||||
|
{
|
||||||
|
"size": 12,
|
||||||
|
"input": {
|
||||||
|
"name": "name",
|
||||||
|
"label": "Название"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"edit": {
|
||||||
|
"title": "Редактирование цвета",
|
||||||
|
"template": "app.base.crud.form",
|
||||||
|
"form": {
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"cols": [
|
||||||
|
{
|
||||||
|
"size": 12,
|
||||||
|
"input": {
|
||||||
|
"name": "name",
|
||||||
|
"label": "Название"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"submits": "struct:crud.form.edit.submits"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"actions": "struct:crud.actions"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$segments = Segment::listActive();
|
||||||
|
foreach ($segments as $segment) {
|
||||||
|
Schema::connection($segment->connector)->create('pipi_auto_calendar', static function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('auto_id')->nullable()->comment('Автомобиль');
|
||||||
|
$table->date('date')->nullable()->comment('Дата');
|
||||||
|
$table->string('status')->nullable()->comment('Статус');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use A7kz\Platform\Models\UniModel;
|
||||||
|
use A7kz\Platform\Modules\Platform\Core\Facades\Core;
|
||||||
|
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use \A7kz\Platform\Commands\InstallScript;
|
||||||
|
|
||||||
|
return new class extends \A7kz\Platform\Commands\InstallScript {
|
||||||
|
|
||||||
|
public function install($module_name, $module_version)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($module_name, $module_version): void
|
||||||
|
{
|
||||||
|
$this->upgrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function upgrade(): void
|
||||||
|
{
|
||||||
|
$segments = Segment::listActive();
|
||||||
|
foreach ($segments as $segment) {
|
||||||
|
if (!Schema::connection($segment->connector)->hasTable('pipi_auto_calendar')) {
|
||||||
|
Schema::connection($segment->connector)->create('pipi_auto_calendar', static function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('auto_id')->nullable()->comment('Автомобиль');
|
||||||
|
$table->date('date')->nullable()->comment('Дата');
|
||||||
|
$table->string('status')->nullable()->comment('Статус');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -20,6 +20,7 @@ Route::prefix('1c')->group(function () {
|
||||||
Route::post('syncAutoData', [Sync1cApiController::class, 'syncAutoData']);
|
Route::post('syncAutoData', [Sync1cApiController::class, 'syncAutoData']);
|
||||||
Route::post('syncOwners', [Sync1cApiController::class, 'syncOwners']);
|
Route::post('syncOwners', [Sync1cApiController::class, 'syncOwners']);
|
||||||
Route::post('syncOwnerContracts', [Sync1cApiController::class, 'syncOwnerContracts']);
|
Route::post('syncOwnerContracts', [Sync1cApiController::class, 'syncOwnerContracts']);
|
||||||
|
Route::post('syncCarCalendar', [Sync1cApiController::class, 'syncCarCalendar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('mobile')->group(function () {
|
Route::prefix('mobile')->group(function () {
|
||||||
|
|
@ -28,3 +29,7 @@ Route::prefix('mobile')->group(function () {
|
||||||
Route::post('getApplications', [MobileApiController::class, 'getApplications']);
|
Route::post('getApplications', [MobileApiController::class, 'getApplications']);
|
||||||
Route::post('login', [MobileApiController::class, 'login']);
|
Route::post('login', [MobileApiController::class, 'login']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/', function (Request $request) {
|
||||||
|
dd(123);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue