diff --git a/app/Events/ClientCaseToTerrain.php b/app/Events/ClientCaseToTerrain.php new file mode 100644 index 0000000..44d7a45 --- /dev/null +++ b/app/Events/ClientCaseToTerrain.php @@ -0,0 +1,42 @@ +clientCase = $clientCase; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): PrivateChannel + { + return new PrivateChannel('segments'.$this->clientCase->id); + } + + public function broadcastAs(){ + return 'client_case.terrain.add'; + } +} diff --git a/app/Events/ContractToTerrain.php b/app/Events/ContractToTerrain.php new file mode 100644 index 0000000..bd6378d --- /dev/null +++ b/app/Events/ContractToTerrain.php @@ -0,0 +1,43 @@ +contract = $contract; + $this->segment = $segment; + } + + /** + * Get the channels the event should broadcast on. + * + * @return array + */ + public function broadcastOn(): PrivateChannel + { + return new PrivateChannel('contracts.'.$this->segment->id); + } + + public function broadcastAs(){ + return 'contract.terrain.add'; + } +} diff --git a/app/Http/Controllers/ClientCaseContoller.php b/app/Http/Controllers/ClientCaseContoller.php index a4e1624..4fb3404 100644 --- a/app/Http/Controllers/ClientCaseContoller.php +++ b/app/Http/Controllers/ClientCaseContoller.php @@ -131,7 +131,14 @@ public function storeActivity(ClientCase $clientCase, Request $request) { ]); //Create activity - $clientCase->activities()->create($attributes); + $activity = $clientCase->activities()->create($attributes); + + foreach ($activity->decision->events as $e) { + $class = '\\App\\Events\\' . $e->name; + event(new $class($clientCase)); + } + + return to_route('clientCase.show', $clientCase); @@ -156,6 +163,11 @@ public function show(ClientCase $clientCase) 'person' => fn($que) => $que->with(['addresses', 'phones']) ])->where('active', 1)->findOrFail($clientCase->id); + $types = [ + 'address_types' => \App\Models\Person\AddressType::all(), + 'phone_types' => \App\Models\Person\PhoneType::all() + ]; + return Inertia::render('Cases/Show', [ 'client' => $case->client()->with('person', fn($q) => $q->with(['addresses', 'phones']))->firstOrFail(), 'client_case' => $case, @@ -166,7 +178,8 @@ public function show(ClientCase $clientCase) ->orderByDesc('created_at') ->paginate(20, ['*'], 'activities'), 'contract_types' => \App\Models\ContractType::whereNull('deleted_at')->get(), - 'actions' => \App\Models\Action::with('decisions')->get() + 'actions' => \App\Models\Action::with('decisions')->get(), + 'types' => $types ]); } diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index b83a372..90ee927 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -33,6 +33,11 @@ public function show(Client $client, Request $request) { ->with(['person' => fn($que) => $que->with(['addresses','phones'])]) ->findOrFail($client->id); + $types = [ + 'address_types' => \App\Models\Person\AddressType::all(), + 'phone_types' => \App\Models\Person\PhoneType::all() + ]; + return Inertia::render('Client/Show', [ 'client' => $data, 'client_cases' => $data->clientCases() @@ -47,6 +52,7 @@ public function show(Client $client, Request $request) { ->orderByDesc('created_at') ->paginate(15) ->withQueryString(), + 'types' => $types, 'filters' => $request->only(['search']) ]); } @@ -91,4 +97,9 @@ public function store(Request $request) return to_route('client'); } + + public function update(Client $client, Request $request) { + + return to_route('client.show', $client); + } } diff --git a/app/Http/Controllers/PersonController.php b/app/Http/Controllers/PersonController.php index 5ff0712..182b542 100644 --- a/app/Http/Controllers/PersonController.php +++ b/app/Http/Controllers/PersonController.php @@ -4,6 +4,7 @@ use App\Models\Person\Person; use Illuminate\Http\Request; +use Inertia\Inertia; class PersonController extends Controller { @@ -19,4 +20,91 @@ public function create(Request $request){ public function store(Request $request){ } + + public function update(Person $person, Request $request){ + $attributes = $request->validate([ + 'full_name' => 'string|max:255', + 'tax_number' => 'nullable|integer', + 'social_security_number' => 'nullable|integer', + 'description' => 'nullable|string|max:500' + ]); + + $person->update($attributes); + + return response()->json([ + 'person' => [ + 'full_name' => $person->full_name, + 'tax_number' => $person->tax_number, + 'social_security_number' => $person->social_security_number, + 'description' => $person->description + ] + ]); + } + + public function createAddress(Person $person, Request $request){ + $attributes = $request->validate([ + 'address' => 'required|string|max:150', + 'country' => 'nullable|string', + 'type_id' => 'required|integer|exists:address_types,id', + 'description' => 'nullable|string|max:125' + ]); + + $address_id = $person->addresses()->create($attributes)->id; + + return response()->json([ + 'address' => \App\Models\Person\PersonAddress::with(['type'])->findOrFail($address_id) + ]); + } + + public function updateAddress(Person $person, int $address_id, Request $request) + { + $attributes = $request->validate([ + 'address' => 'required|string|max:150', + 'country' => 'nullable|string', + 'type_id' => 'required|integer|exists:address_types,id', + 'description' => 'nullable|string|max:125' + ]); + + $address = $person->addresses()->with(['type'])->findOrFail($address_id); + + $address->update($attributes); + + return response()->json([ + 'address' => $address + ]); + } + + public function createPhone(Person $person, Request $request) + { + $attributes = $request->validate([ + 'nu' => 'required|string|max:50', + 'country_code' => 'nullable|integer', + 'type_id' => 'required|integer|exists:phone_types,id', + 'description' => 'nullable|string|max:125' + ]); + + $phone_id = $person->phones()->create($attributes)->id; + + return response()->json([ + 'phone' => \App\Models\Person\PersonPhone::with(['type'])->findOrFail($phone_id) + ]); + } + + public function updatePhone(Person $person, int $phone_id, Request $request) + { + $attributes = $request->validate([ + 'nu' => 'required|string|max:50', + 'country_code' => 'nullable|integer', + 'type_id' => 'required|integer|exists:phone_types,id', + 'description' => 'nullable|string|max:125' + ]); + + $phone = $person->phones()->with(['type'])->findOrFail($phone_id); + + $phone->update($attributes); + + return response()->json([ + 'phone' => $phone + ]); + } } diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php index cd6a189..bd3ae9e 100644 --- a/app/Http/Controllers/SettingController.php +++ b/app/Http/Controllers/SettingController.php @@ -13,10 +13,10 @@ public function index(Request $request){ return Inertia::render('Settings/Index', [ 'actions' => \App\Models\Action::query() - ->with('decisions', fn($q) => $q->get(['decisions.id'])) + ->with('decisions') ->get(), 'decisions' => \App\Models\Decision::query() - ->with('actions', fn($q) => $q->get(['actions.id'])) + ->with('actions') ->get() ] ); diff --git a/app/Listeners/AddClientCaseToTerrain.php b/app/Listeners/AddClientCaseToTerrain.php new file mode 100644 index 0000000..3e66ccb --- /dev/null +++ b/app/Listeners/AddClientCaseToTerrain.php @@ -0,0 +1,41 @@ +clientCase; + $segment = \App\Models\Segment::where('name','terrain')->firstOrFail(); + + if( $segment ) { + $clientCase->segments()->detach($segment->id); + $clientCase->segments()->attach( + $segment->id, + ); + + \Log::info("Added contract to terrain", ['contract_id' => $clientCase->id, 'segment' => $segment->name ]); + } + } + + public function failed(ClientCaseToTerrain $event, $exception) + { + \Log::error('Failed to update inventory', ['contract_id' => $event->clientCase->id, 'error' => $exception->getMessage()]); + } +} diff --git a/app/Listeners/AddContractToTerrain.php b/app/Listeners/AddContractToTerrain.php new file mode 100644 index 0000000..3faecc1 --- /dev/null +++ b/app/Listeners/AddContractToTerrain.php @@ -0,0 +1,37 @@ +contract; + $segment = $event->segment->where('name', 'terrain')->firstOrFail(); + + if($segment) { + $contract->segments()->attach($segment->id); + //\Log::info("Added contract to terrain", ['contract_id' => $contract->id, 'segment' => $segment->name ]); + } + } + + public function failed(ContractToTerrain $event, $exception) + { + //\Log::error('Failed to update inventory', ['contract_id' => $event->contract->id, 'error' => $exception->getMessage()]); + } +} diff --git a/app/Models/ClientCase.php b/app/Models/ClientCase.php index 0c4d3dc..37663cb 100644 --- a/app/Models/ClientCase.php +++ b/app/Models/ClientCase.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Builder; use Laravel\Scout\Searchable; @@ -47,7 +48,8 @@ public function client(): BelongsTo public function person(): BelongsTo { - return $this->belongsTo(\App\Models\Person\Person::class); + return $this->belongsTo(\App\Models\Person\Person::class) + ->with(['phones', 'addresses']); } public function contracts(): HasMany @@ -59,4 +61,8 @@ public function activities(): HasMany { return $this->hasMany(\App\Models\Activity::class); } + + public function segments(): BelongsToMany { + return $this->belongsToMany(\App\Models\Segment::class)->withTimestamps(); + } } diff --git a/app/Models/Contract.php b/app/Models/Contract.php index 1bfd8c1..9a5342d 100644 --- a/app/Models/Contract.php +++ b/app/Models/Contract.php @@ -3,10 +3,15 @@ namespace App\Models; use App\Traits\Uuid; +use Illuminate\Database\Eloquent\Factories\BelongsToManyRelationship; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; +use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\HasOneOrManyThrough; +use Illuminate\Database\Eloquent\Relations\MorphOne; use Illuminate\Database\Eloquent\SoftDeletes; class Contract extends Model @@ -36,17 +41,16 @@ public function type(): BelongsTo return $this->belongsTo(\App\Models\ContractType::class, 'type_id'); } - public function client(): BelongsTo + public function clientCase(): BelongsTo { - return $this->belongsTo(\App\Models\Person\Person::class, 'client_id'); + return $this->belongsTo(\App\Models\ClientCase::class) + ->with(['person']); } - - public function debtor(): BelongsTo - { - return $this->belongsTo(\App\Models\Person\Person::class, 'debtor_id'); - } - + public function segments(): BelongsToMany { - return $this->belongsToMany(\App\Models\Segment::class); + return $this->belongsToMany(\App\Models\Segment::class) + ->withPivot('active', 'created_at') + ->wherePivot('active', true); } + } diff --git a/app/Models/Event.php b/app/Models/Event.php index 9dce7e8..4c79302 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -4,9 +4,15 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Event extends Model { /** @use HasFactory<\Database\Factories\EventFactory> */ use HasFactory; + + public function decisions(): BelongsToMany + { + return $this->belongsToMany(\App\Models\Decision::class); + } } diff --git a/app/Models/Person/Person.php b/app/Models/Person/Person.php index 627e242..addd535 100644 --- a/app/Models/Person/Person.php +++ b/app/Models/Person/Person.php @@ -76,14 +76,16 @@ public function phones(): HasMany { return $this->hasMany(\App\Models\Person\PersonPhone::class) ->with(['type']) - ->where('active','=',1); + ->where('active','=',1) + ->orderBy('id'); } public function addresses(): HasMany { return $this->hasMany(\App\Models\Person\PersonAddress::class) ->with(['type']) - ->where('active','=',1); + ->where('active','=',1) + ->orderBy('id'); } public function group(): BelongsTo diff --git a/app/Models/Segment.php b/app/Models/Segment.php index 0f24eb6..4b9aba9 100644 --- a/app/Models/Segment.php +++ b/app/Models/Segment.php @@ -14,4 +14,8 @@ class Segment extends Model public function contracts(): BelongsToMany { return $this->belongsToMany(\App\Models\Contract::class); } + + public function clientCase(): BelongsToMany { + return $this->belongsToMany(\App\Models\ClientCase::class)->withTimestamps(); + } } diff --git a/database/migrations/2024_12_14_120317_create_client_case_segment.php b/database/migrations/2024_12_14_120317_create_client_case_segment.php new file mode 100644 index 0000000..aa2e870 --- /dev/null +++ b/database/migrations/2024_12_14_120317_create_client_case_segment.php @@ -0,0 +1,31 @@ +id(); + $table->foreignIdFor(\App\Models\ClientCase::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(\App\Models\Segment::class)->constrained()->onDelete('cascade'); + $table->boolean('active')->default(true); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('client_case_segment'); + } +}; diff --git a/database/migrations/2024_12_15_164010_create_decision_event.php b/database/migrations/2024_12_15_164010_create_decision_event.php new file mode 100644 index 0000000..f8970b6 --- /dev/null +++ b/database/migrations/2024_12_15_164010_create_decision_event.php @@ -0,0 +1,29 @@ +id(); + $table->foreignIdFor(\App\Models\Decision::class); + $table->foreignIdFor(\App\Models\Event::class); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('decision_event'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index c08aa3e..8dee10b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -26,7 +26,8 @@ public function run(): void $this->call([ PersonSeeder::class, SegmentSeeder::class, - ActionSeeder::class + ActionSeeder::class, + EventSeeder::class ]); } } diff --git a/database/seeders/EventSeeder.php b/database/seeders/EventSeeder.php index 2016e5c..4ca981e 100644 --- a/database/seeders/EventSeeder.php +++ b/database/seeders/EventSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\Event; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -12,6 +13,12 @@ class EventSeeder extends Seeder */ public function run(): void { - // + $events = [ + [ 'name' => 'client_case.terrain.add', 'options' => json_encode([]) ] + ]; + + foreach($events as $e) { + Event::create($e); + } } } diff --git a/database/seeders/PersonSeeder.php b/database/seeders/PersonSeeder.php index 50f3475..bd64294 100644 --- a/database/seeders/PersonSeeder.php +++ b/database/seeders/PersonSeeder.php @@ -24,7 +24,7 @@ public function run(): void ]; $personGroups = [ - [ 'name' => 'naročnik', 'description' => '', 'color_tag' => 'blue-400'], + [ 'name' => 'naročnik', 'description' => '', 'color_tag' => 'blue-500'], [ 'name' => 'primer naročnika', 'description' => '', 'color_tag' => 'red-400'] ]; diff --git a/package-lock.json b/package-lock.json index 8f24987..1eb47a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,9 @@ "flowbite-vue": "^0.1.6", "lodash": "^4.17.21", "material-design-icons-iconfont": "^6.7.0", + "preline": "^2.7.0", "tailwindcss-inner-border": "^0.2.0", + "vue-multiselect": "^3.1.0", "vue-search-input": "^1.1.16", "vue3-apexcharts": "^1.7.0", "vuedraggable": "^4.1.0" @@ -2837,6 +2839,15 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "license": "MIT" }, + "node_modules/preline": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/preline/-/preline-2.7.0.tgz", + "integrity": "sha512-xMuMVZ7aftBT1/5/3Rb48i/t+LWQfsUjBX7bls4peqS6h5OZTbIgz0N6eMDzuDlOZF3DiSWLehl00oGlAkvovw==", + "license": "Licensed under MIT and Preline UI Fair Use License", + "dependencies": { + "@popperjs/core": "^2.11.2" + } + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -3552,6 +3563,16 @@ } } }, + "node_modules/vue-multiselect": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vue-multiselect/-/vue-multiselect-3.1.0.tgz", + "integrity": "sha512-+i/fjTqFBpaay9NP+lU7obBeNaw2DdFDFs4mqhsM0aEtKRdvIf7CfREAx2o2B4XDmPrBt1r7x1YCM3BOMLaUgQ==", + "license": "MIT", + "engines": { + "node": ">= 14.18.1", + "npm": ">= 6.14.15" + } + }, "node_modules/vue-resize": { "version": "2.0.0-alpha.1", "resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-2.0.0-alpha.1.tgz", diff --git a/package.json b/package.json index d7a104a..464c156 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "flowbite-vue": "^0.1.6", "lodash": "^4.17.21", "material-design-icons-iconfont": "^6.7.0", + "preline": "^2.7.0", "tailwindcss-inner-border": "^0.2.0", + "vue-multiselect": "^3.1.0", "vue-search-input": "^1.1.16", "vue3-apexcharts": "^1.7.0", "vuedraggable": "^4.1.0" diff --git a/resources/css/app.css b/resources/css/app.css index ce3650b..f54b643 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,5 +1,6 @@ @import '/node_modules/floating-vue/dist/style.css'; @import '/node_modules/vue-search-input/dist/styles.css'; +@import '/node_modules/vue-multiselect/dist/vue-multiselect.min.css'; @tailwind base; @tailwind components; @tailwind utilities; diff --git a/resources/js/Components/AddressCreateForm.vue b/resources/js/Components/AddressCreateForm.vue new file mode 100644 index 0000000..fb673d1 --- /dev/null +++ b/resources/js/Components/AddressCreateForm.vue @@ -0,0 +1,197 @@ + + + \ No newline at end of file diff --git a/resources/js/Components/AddressUpdateForm.vue b/resources/js/Components/AddressUpdateForm.vue new file mode 100644 index 0000000..741c7c7 --- /dev/null +++ b/resources/js/Components/AddressUpdateForm.vue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/resources/js/Components/CusTab.vue b/resources/js/Components/CusTab.vue new file mode 100644 index 0000000..82ff001 --- /dev/null +++ b/resources/js/Components/CusTab.vue @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/resources/js/Components/CusTabs.vue b/resources/js/Components/CusTabs.vue new file mode 100644 index 0000000..359a8e6 --- /dev/null +++ b/resources/js/Components/CusTabs.vue @@ -0,0 +1,38 @@ + + \ No newline at end of file diff --git a/resources/js/Components/PersonInfoGrid.vue b/resources/js/Components/PersonInfoGrid.vue index 33ba7d3..6b4da0b 100644 --- a/resources/js/Components/PersonInfoGrid.vue +++ b/resources/js/Components/PersonInfoGrid.vue @@ -1,43 +1,189 @@ \ No newline at end of file diff --git a/resources/js/Components/PersonUpdateForm.vue b/resources/js/Components/PersonUpdateForm.vue new file mode 100644 index 0000000..277288b --- /dev/null +++ b/resources/js/Components/PersonUpdateForm.vue @@ -0,0 +1,139 @@ + + \ No newline at end of file diff --git a/resources/js/Components/PhoneCreateForm.vue b/resources/js/Components/PhoneCreateForm.vue new file mode 100644 index 0000000..5599c97 --- /dev/null +++ b/resources/js/Components/PhoneCreateForm.vue @@ -0,0 +1,193 @@ + + \ No newline at end of file diff --git a/resources/js/Components/PhoneUpdateForm.vue b/resources/js/Components/PhoneUpdateForm.vue new file mode 100644 index 0000000..741c7c7 --- /dev/null +++ b/resources/js/Components/PhoneUpdateForm.vue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/resources/js/Layouts/AppLayout.vue b/resources/js/Layouts/AppLayout.vue index 732fc69..63b6171 100644 --- a/resources/js/Layouts/AppLayout.vue +++ b/resources/js/Layouts/AppLayout.vue @@ -1,5 +1,5 @@ - -
-
+
+
diff --git a/resources/js/Layouts/Partials/GlobalSearch.vue b/resources/js/Layouts/Partials/GlobalSearch.vue new file mode 100644 index 0000000..2bc042c --- /dev/null +++ b/resources/js/Layouts/Partials/GlobalSearch.vue @@ -0,0 +1,72 @@ + + \ No newline at end of file diff --git a/resources/js/Pages/Cases/Show.vue b/resources/js/Pages/Cases/Show.vue index a8cbacb..e5fcdc3 100644 --- a/resources/js/Pages/Cases/Show.vue +++ b/resources/js/Pages/Cases/Show.vue @@ -1,185 +1,161 @@ \ No newline at end of file +
+ +
+
+
+
+
+ + + + Nova +
+ +
+
+
+
+ + + + diff --git a/resources/js/Pages/Client/Partials/FormCreateCase.vue b/resources/js/Pages/Client/Partials/FormCreateCase.vue new file mode 100644 index 0000000..4684c5d --- /dev/null +++ b/resources/js/Pages/Client/Partials/FormCreateCase.vue @@ -0,0 +1,201 @@ + + \ No newline at end of file diff --git a/resources/js/Pages/Client/Partials/FormUpdateClient.vue b/resources/js/Pages/Client/Partials/FormUpdateClient.vue new file mode 100644 index 0000000..acfc99d --- /dev/null +++ b/resources/js/Pages/Client/Partials/FormUpdateClient.vue @@ -0,0 +1,118 @@ + + \ No newline at end of file diff --git a/resources/js/Pages/Client/Show.vue b/resources/js/Pages/Client/Show.vue index bcede4e..437ec1b 100644 --- a/resources/js/Pages/Client/Show.vue +++ b/resources/js/Pages/Client/Show.vue @@ -3,52 +3,20 @@ import AppLayout from '@/Layouts/AppLayout.vue'; import List from '@/Components/List.vue'; import ListItem from '@/Components/ListItem.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; -import Drawer from '@/Components/Drawer.vue'; -import InputLabel from '@/Components/InputLabel.vue'; -import TextInput from '@/Components/TextInput.vue'; import { ref } from 'vue'; -import { Link, useForm } from '@inertiajs/vue3'; -import ActionMessage from '@/Components/ActionMessage.vue'; +import { Link } from '@inertiajs/vue3'; import SectionTitle from '@/Components/SectionTitle.vue'; import PersonInfoGrid from '@/Components/PersonInfoGrid.vue'; import Pagination from '@/Components/Pagination.vue'; import SearchInput from '@/Components/SearchInput.vue'; +import FormCreateCase from './Partials/FormCreateCase.vue'; const props = defineProps({ client: Object, client_cases: Object, urlPrev: String, - filters: Object -}); - -console.log(props.client_cases) - -const Address = { - address: '', - country: '', - type_id: 1 -} - -const Phone = { - nu: '', - country_code: '00386', - type_id: 1 -} - -const Person = { - first_name: '', - last_name: '', - full_name: '', - tax_number: '', - social_security_number: '', - description: '', - address: Address, - phone: Phone -} - -const formCreateCase = useForm({ - client_uuid: props.client.uuid, - person: Person + filters: Object, + types: Object }); const search = { @@ -65,42 +33,6 @@ const openDrawerCreateCase = () => { drawerCreateCase.value = true; } -const closeDrawer = () => { - drawerCreateCase.value = false -} - -const getMainAddress = (adresses) => { - const addr = adresses.filter( a => a.type.id === 1 )[0] ?? ''; - const country = addr.country !== '' ? ` - ${addr.country}` : ''; - return addr.address !== '' ? addr.address + country : ''; -} - -const getMainPhone = (phones) => { - const pho = phones.filter( a => a.type.id === 1 )[0] ?? ''; - const countryCode = pho.country_code !== null ? `+${pho.country_code} ` : ''; - return pho.nu !== '' ? countryCode + pho.nu: ''; -} -const clientInfo = new Object({ - nu: props.client.person.nu, - full_name: props.client.person.full_name, - main_address: getMainAddress(props.client.person.addresses), - main_phone: getMainPhone(props.client.person.phones), - tax_number: props.client.person.tax_number, - social_security_number: props.client.person.social_security_number, - description: props.client.person.description -}); - -const storeCase = () => { - formCreateCase.post(route('clientCase.store'), { - onSuccess: () => { - closeDrawer(); - formCreateCase.reset(); - console.log(props.client_cases) - } - }); -}; - - \ No newline at end of file diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index d072a4f..1998459 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -6,10 +6,12 @@ import { LinkOptions as C_LINK, TableColumn as C_TD, TableRow as C_TR} from '@/S const props = defineProps({ chart: Object, - people: Array + people: Array, + terrain: Array }); -console.log(props.people) + +console.log(props.terrain) const tablePersonHeader = [ @@ -18,14 +20,21 @@ const tablePersonHeader = [ C_TD.make('Skupina', 'header') ]; -let tablePersonBody = []; +const tblTerrainHead = [ + C_TD.make('Št.', 'header'), + C_TD.make('Naziv', 'header'), + C_TD.make('Začetek', 'header') +]; +let tablePersonBody = []; +let tblTerrainBody = []; + const getRoute = (person) => { if( person.client ){ return {route: 'client.show', options: person.client}; } - return {route: 'clientCase.show', options: person.client_case}; + return {route: 'clientCase.show', options: person}; } props.people.forEach((p) => { @@ -34,12 +43,25 @@ props.people.forEach((p) => { const cols = [ C_TD.make(Number(p.nu), 'body', {}, C_LINK.make(forLink.route, forLink.options, `font-bold hover:text-${p.group.color_tag}`)), C_TD.make(p.full_name, 'body'), - C_TD.make(p.group.name) + C_TD.make(p.group.added_segment, 'body') ]; tablePersonBody.push(C_TR.make(cols, {class: `border-l-4 border-${p.group.color_tag}`})) }); +props.terrain.forEach((t) => { + const forLink = getRoute(t); + const startDate = new Date(t.added_segment).toLocaleDateString('de'); + + const cols = [ + C_TD.make(t.person.nu, 'body', {}, C_LINK.make(forLink.route, forLink.options, `font-bold hover:text-red-400`)), + C_TD.make(t.person.full_name, 'body'), + C_TD.make(startDate, 'body') + ]; + + tblTerrainBody.push(C_TR.make(cols, {class: `border-l-4 border-red-400`})); +}); + - +
diff --git a/resources/js/Pages/Settings/Index.vue b/resources/js/Pages/Settings/Index.vue index 5d50134..c9dfe91 100644 --- a/resources/js/Pages/Settings/Index.vue +++ b/resources/js/Pages/Settings/Index.vue @@ -21,7 +21,7 @@ const activeTab = ref('actions')
- + diff --git a/resources/js/Pages/Settings/Partials/ActionTable.vue b/resources/js/Pages/Settings/Partials/ActionTable.vue index 9abaa34..923aeed 100644 --- a/resources/js/Pages/Settings/Partials/ActionTable.vue +++ b/resources/js/Pages/Settings/Partials/ActionTable.vue @@ -1,12 +1,69 @@ \ No newline at end of file diff --git a/resources/js/Utilities/Icons.js b/resources/js/Utilities/Icons.js index cf0153a..4756496 100644 --- a/resources/js/Utilities/Icons.js +++ b/resources/js/Utilities/Icons.js @@ -1,13 +1,37 @@ -import { ref } from "vue"; - const Icon = { props: { css: { type: String, default: 'text-gray-800' + }, + size: { + type: String, + default: 'md' } - } + }, + methods: { + defineSize: (val) => { + let size = ''; + + switch(val){ + case 'xs': + size = 'w-3 h-3'; + break; + case 'sm': + size = 'w-4 h-4'; + break; + case 'lg': + size = 'w-6 h-6'; + break; + default: + size = 'w-5 h-5'; + break; + } + + return size; + } + }, } const AddressBookIcon = { @@ -15,52 +39,98 @@ const AddressBookIcon = { setup: () => { console.log(this.props) }, - template: `