diff --git a/database/migrations/2025_05_03_111731_add_issue_and_expiry_date_to_files_table.php b/database/migrations/2025_05_03_111731_add_issue_and_expiry_date_to_files_table.php new file mode 100644 index 000000000..3852a7819 --- /dev/null +++ b/database/migrations/2025_05_03_111731_add_issue_and_expiry_date_to_files_table.php @@ -0,0 +1,29 @@ +date('issue_date')->nullable(); + $table->date('expiry_date')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('activity_files', function (Blueprint $table) { + $table->dropColumn(['issue_date', 'expiry_date']); + }); + } +}; diff --git a/database/migrations/2025_06_06_130944_create_role_field_permissions_table.php b/database/migrations/2025_06_06_130944_create_role_field_permissions_table.php new file mode 100644 index 000000000..945904796 --- /dev/null +++ b/database/migrations/2025_06_06_130944_create_role_field_permissions_table.php @@ -0,0 +1,28 @@ +json('visible_person_fields')->nullable()->after('name'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('roles', function (Blueprint $table) { + $table->dropColumn('visible_person_fields'); + }); + } +}; diff --git a/packages/Webkul/Activity/src/Models/File.php b/packages/Webkul/Activity/src/Models/File.php index efbf90c5b..cc80aeac6 100644 --- a/packages/Webkul/Activity/src/Models/File.php +++ b/packages/Webkul/Activity/src/Models/File.php @@ -31,6 +31,8 @@ class File extends Model implements FileContract 'name', 'path', 'activity_id', + 'issue_date', + 'expiry_date', ]; /** diff --git a/packages/Webkul/Activity/src/Repositories/ActivityRepository.php b/packages/Webkul/Activity/src/Repositories/ActivityRepository.php index 3b4d6a4f8..8398c75b6 100755 --- a/packages/Webkul/Activity/src/Repositories/ActivityRepository.php +++ b/packages/Webkul/Activity/src/Repositories/ActivityRepository.php @@ -14,8 +14,9 @@ class ActivityRepository extends Repository */ public function __construct( protected FileRepository $fileRepository, - Container $container - ) { + Container $container + ) + { parent::__construct($container); } @@ -40,13 +41,15 @@ public function create(array $data) if (isset($data['file'])) { $this->fileRepository->create([ - 'name' => $data['name'] ?? $data['file']->getClientOriginalName(), - 'path' => $data['file']->store('activities/'.$activity->id), + 'issue_date' => $data['issue_date'] ?? null, + 'expiry_date' => $data['expiry_date'] ?? null, + 'name' => $data['name'] ?? $data['file']->getClientOriginalName(), + 'path' => $data['file']->store('activities/' . $activity->id), 'activity_id' => $activity->id, ]); } - if (! isset($data['participants'])) { + if (!isset($data['participants'])) { return $activity; } @@ -68,8 +71,8 @@ public function create(array $data) /** * Update pipeline. * - * @param int $id - * @param string $attribute + * @param int $id + * @param string $attribute * @return \Webkul\Activity\Contracts\Activity */ public function update(array $data, $id, $attribute = 'id') @@ -114,7 +117,7 @@ public function update(array $data, $id, $attribute = 'id') } /** - * @param string $dateRange + * @param string $dateRange * @return mixed */ public function getActivities($dateRange) @@ -143,10 +146,10 @@ public function getActivities($dateRange) } /** - * @param string $startFrom - * @param string $endFrom - * @param array $participants - * @param int $id + * @param string $startFrom + * @param string $endFrom + * @param array $participants + * @param int $id * @return bool */ public function isDurationOverlapping($startFrom, $endFrom, $participants, $id) @@ -176,7 +179,7 @@ public function isDurationOverlapping($startFrom, $endFrom, $participants, $id) }) ->groupBy('activities.id'); - if (! is_null($id)) { + if (!is_null($id)) { $queryBuilder->where('activities.id', '!=', $id); } diff --git a/packages/Webkul/Admin/src/Config/acl.php b/packages/Webkul/Admin/src/Config/acl.php index bb164d2b8..5982d865b 100644 --- a/packages/Webkul/Admin/src/Config/acl.php +++ b/packages/Webkul/Admin/src/Config/acl.php @@ -156,6 +156,11 @@ 'name' => 'admin::app.acl.view', 'route' => 'admin.contacts.persons.view', 'sort' => 5, + ], [ + 'key' => 'contacts.persons.export', + 'name' => 'admin::app.acl.export', + 'route' => 'admin.contacts.persons.export', + 'sort' => 6, ], [ 'key' => 'contacts.organizations', 'name' => 'admin::app.acl.organizations', diff --git a/packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php index bbbeeb9cd..c07ed3d60 100644 --- a/packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php @@ -28,6 +28,7 @@ public function prepareQueryBuilder(): Builder $this->addFilter('id', 'attributes.id'); $this->addFilter('type', 'attributes.type'); $this->addFilter('attribute_type', 'attributes.is_user_defined'); + $queryBuilder->orderBy('attributes.sort_order', 'asc'); return $queryBuilder; } diff --git a/packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php b/packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php index 02a7369fa..db9f338ab 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php @@ -202,6 +202,12 @@ public function download(int $id): StreamedResponse { try { $file = $this->fileRepository->findOrFail($id); + $extension = pathinfo($file->path, PATHINFO_EXTENSION); + + if (!empty($file->name)) { + $customName = $file->name . '_' . $file->activity->title . '.' . $extension; + return Storage::download($file->path, $customName); + } return Storage::download($file->path); } catch (\Exception $exception) { diff --git a/packages/Webkul/Admin/src/Http/Controllers/Contact/Persons/PersonController.php b/packages/Webkul/Admin/src/Http/Controllers/Contact/Persons/PersonController.php index 9ad1d4e3e..d89bd26bf 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Contact/Persons/PersonController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Contact/Persons/PersonController.php @@ -52,6 +52,7 @@ public function create(): View */ public function store(AttributeForm $request): RedirectResponse|JsonResponse { + Event::dispatch('contacts.person.create.before'); $person = $this->personRepository->create($request->all()); @@ -77,7 +78,21 @@ public function show(int $id): View { $person = $this->personRepository->findOrFail($id); - return view('admin::contacts.persons.view', compact('person')); + $user = auth()->user(); + $allowedFields = $user->role->visible_person_fields ?? []; + + // Always include 'id' for routing/model logic + if (!in_array('id', $allowedFields)) { + $allowedFields[] = 'id'; + } + + // $person = $this->personRepository->getModel()->select($allowedFields)->findOrFail($id); + + + + return view('admin::contacts.persons.view', [ + 'person' => (object) $person, + ]); } /** @@ -85,6 +100,7 @@ public function show(int $id): View */ public function edit(int $id): View { + $person = $this->personRepository->findOrFail($id); return view('admin::contacts.persons.edit', compact('person')); diff --git a/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php index cc703ca62..e95c4013a 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php @@ -44,6 +44,7 @@ public function create(): View */ public function store(): RedirectResponse { + $this->validate(request(), [ 'name' => 'required', 'permission_type' => 'required|in:all,custom', @@ -89,6 +90,7 @@ public function edit(int $id): View */ public function update(int $id): RedirectResponse { + $this->validate(request(), [ 'name' => 'required', 'permission_type' => 'required|in:all,custom', @@ -109,7 +111,17 @@ public function update(int $id): RedirectResponse $role = $this->roleRepository->update($data, $id); Event::dispatch('settings.role.update.after', $role); + $list = []; + foreach (request()->keys() as $key) { + if (str_starts_with($key,"field_")){ + if ( request()->get($key) === "1") { + $list[]=str_replace("field_","",$key); + } + } + } + $role->visible_person_fields=$list; + $role->save(); session()->flash('success', trans('admin::app.settings.roles.index.update-success')); return redirect()->back(); diff --git a/packages/Webkul/Admin/src/Http/Resources/ActivityFileResource.php b/packages/Webkul/Admin/src/Http/Resources/ActivityFileResource.php index abfdc0d31..76a5853e3 100644 --- a/packages/Webkul/Admin/src/Http/Resources/ActivityFileResource.php +++ b/packages/Webkul/Admin/src/Http/Resources/ActivityFileResource.php @@ -15,12 +15,14 @@ class ActivityFileResource extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'name' => $this->name, - 'path' => $this->path, - 'url' => $this->url, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'id' => $this->id, + 'name' => $this->name, + 'path' => $this->path, + 'url' => $this->url, + 'issue_date' => $this->issue_date, + 'expiry_date' => $this->expiry_date, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } diff --git a/packages/Webkul/Admin/src/Resources/assets/images/logo.svg b/packages/Webkul/Admin/src/Resources/assets/images/logo.svg index 50755ec62..ef4708bc5 100644 --- a/packages/Webkul/Admin/src/Resources/assets/images/logo.svg +++ b/packages/Webkul/Admin/src/Resources/assets/images/logo.svg @@ -1,6 +1,36 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 7bb10634a..12bd1c800 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -123,6 +123,8 @@ 'description' => 'Description', 'file' => 'File', 'save-btn' => 'Save File', + 'issue-date' => 'Issue Date', + 'expiry-date' => 'Expiry Date', ], 'note' => [ diff --git a/packages/Webkul/Admin/src/Resources/views/activities/index.blade.php b/packages/Webkul/Admin/src/Resources/views/activities/index.blade.php index bb370e2e6..3e3bed79b 100644 --- a/packages/Webkul/Admin/src/Resources/views/activities/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/activities/index.blade.php @@ -11,7 +11,7 @@
- +
@lang('admin::app.activities.index.title')
@@ -19,7 +19,7 @@
- +
@@ -37,7 +37,7 @@ {!! view_render_event('admin.activities.index.activities.after') !!} @pushOnce('scripts') - -@endPushOnce \ No newline at end of file +@endPushOnce diff --git a/packages/Webkul/Admin/src/Resources/views/components/activities/index.blade.php b/packages/Webkul/Admin/src/Resources/views/components/activities/index.blade.php index 7413c42cb..323bde4e5 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/activities/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/activities/index.blade.php @@ -202,22 +202,48 @@ class="dark:text-white" class="flex flex-wrap gap-2" v-if="activity.files.length" > - + + class="flex cursor-pointer items-center gap-1 rounded-md p-1.5" + > + @{{ file.name }} - + + +
+ + + Issue Date : @{{ file.issue_date }} + +
+
+ + + + Expire Date : @{{ file.expiry_date }} + ( + @{{ getRemainingDays(file.expiry_date) }} + ) + + +
+
+ {!! view_render_event('admin.components.activities.content.activity.item.attachments.after') !!} @@ -634,6 +660,21 @@ class="dark:mix-blend-exclusion dark:invert" } }); }, + + getRemainingDays(expiryDate) { + const now = new Date(); + const expiry = new Date(expiryDate); + const diffTime = expiry - now; + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + + if (diffDays > 0) { + return `${diffDays} day(s) left`; + } else if (diffDays === 0) { + return 'Expires today'; + } else { + return `${Math.abs(diffDays)} day(s) ago`; + } + }, }, }); diff --git a/packages/Webkul/Admin/src/Resources/views/components/attributes/view.blade.php b/packages/Webkul/Admin/src/Resources/views/components/attributes/view.blade.php index 93e51fafc..ed7f2f660 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/attributes/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/attributes/view.blade.php @@ -12,14 +12,45 @@
{{ $attribute->name }}
- @include ($typeView, [ - 'attribute' => $attribute, - 'value' => isset($entity) ? $entity[$attribute->code] : null, - 'allowEdit' => $allowEdit, - 'url' => $url, - ]) + + @if($attribute->code === 'rate') + @php + + $rate=isset($entity) ? $entity[$attribute->code] : 0; + + @endphp + +
+ id="star5" name="rate" + value="5"/> + + id="star4" name="rate" + value="4"/> + + id="star3" name="rate" + value="3"/> + + id="star2" name="rate" + value="2"/> + + id="star1" name="rate" + value="1"/> + +
+ + @else + @include ($typeView, [ + 'attribute' => $attribute, + 'value' => isset($entity) ? $entity[$attribute->code] : null, + 'allowEdit' => $allowEdit, + 'url' => $url, + ]) + + @endif + +
@endif @endforeach - \ No newline at end of file + diff --git a/packages/Webkul/Admin/src/Resources/views/components/datagrid/export/index.blade.php b/packages/Webkul/Admin/src/Resources/views/components/datagrid/export/index.blade.php index 58bdcaab4..397adea2b 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/datagrid/export/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/datagrid/export/index.blade.php @@ -1,170 +1,193 @@ - -
- - - @lang('admin::app.export.export') -
-
- -@pushOnce('scripts') - - - + + -@endPushOnce + }); + + @endPushOnce +@endif diff --git a/packages/Webkul/Admin/src/Resources/views/components/layouts/header/index.blade.php b/packages/Webkul/Admin/src/Resources/views/components/layouts/header/index.blade.php index 21f078a08..2bd917384 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/layouts/header/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/layouts/header/index.blade.php @@ -1,9 +1,9 @@ -
+
+ + Next CRM CODE : Loading... +
@@ -42,7 +45,7 @@ class="h-10 sm:hidden" @include('admin::components.layouts.header.mobile.mega-search')
- +
@@ -56,7 +59,7 @@ class="{{ request()->cookie('dark_mode') ? 'icon-light' : 'icon-dark' }} p-1.5 r @include('admin::components.layouts.header.quick-creation')
- + @@ -80,7 +83,7 @@ class="h-full w-full object-cover"
@@ -187,4 +190,21 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-100 }, }); + @endPushOnce diff --git a/packages/Webkul/Admin/src/Resources/views/components/layouts/index.blade.php b/packages/Webkul/Admin/src/Resources/views/components/layouts/index.blade.php index 3420a1da4..8f3eef246 100644 --- a/packages/Webkul/Admin/src/Resources/views/components/layouts/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/components/layouts/index.blade.php @@ -123,11 +123,11 @@ class="group/container sidebar-collapsed flex gap-4"
-
-
-

{!! core()->getConfigData('general.settings.footer.label') !!}

-
-
+{{--
--}} +{{--
--}} +{{--

{!! core()->getConfigData('general.settings.footer.label') !!}

--}} +{{--
--}} +{{--
--}} diff --git a/packages/Webkul/Admin/src/Resources/views/contacts/persons/create.blade.php b/packages/Webkul/Admin/src/Resources/views/contacts/persons/create.blade.php index a975eb325..dc247434c 100644 --- a/packages/Webkul/Admin/src/Resources/views/contacts/persons/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/contacts/persons/create.blade.php @@ -5,7 +5,7 @@ {!! view_render_event('admin.persons.create.form.before') !!} - + -
{!! view_render_event('admin.persons.create.create_button.before') !!} @@ -43,15 +42,90 @@ class="primary-button"
- +
{!! view_render_event('admin.persons.create.form_controls.before') !!} + @php + $attributes = app('Webkul\Attribute\Repositories\AttributeRepository')->findWhere([ + 'entity_type' => 'persons', + ]); + + $should_remove_fields=[]; + + foreach ($attributes as $attribute){ + if($attribute->code==='person_type'){ + + $attributeValues = app('Webkul\Attribute\Repositories\AttributeValueRepository')->findWhere([ + 'entity_type' => 'persons', + 'attribute_id'=>$attribute->id + ])->first(); + + + switch($attributeValues->integer_value){ + case 1: + + break; + case 2: + + $should_remove_fields=['company_name_en','company_name_ar','license_no', + 'company_issue_date','company_expiry_date','partner_2','partner_3','local_agent' + ]; + + break; + case 3: + $should_remove_fields=['company_name_en','company_name_ar','license_no', + 'company_issue_date','company_expiry_date','partner_2','partner_3','local_agent' + ]; + + break; + + } + + } + } + + + array_push($should_remove_fields,'rate'); + + $rate=0; + + + + + + //dump($attributeValues); + + $attributes = $attributes->reject(function ($attribute) use ($should_remove_fields) { + return in_array($attribute->code, $should_remove_fields); + }); + + $rate = intval($rate); + + @endphp + +
+
+ id="star5" name="rate" + value="5"/> + + id="star4" name="rate" + value="4"/> + + id="star3" name="rate" + value="3"/> + + id="star2" name="rate" + value="2"/> + + id="star1" name="rate" + value="1"/> + +
+
- + {!! view_render_event('admin.persons.create.form_controls.after') !!}
diff --git a/packages/Webkul/Admin/src/Resources/views/contacts/persons/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/contacts/persons/edit.blade.php index 4367c4780..d2fc1a0fb 100644 --- a/packages/Webkul/Admin/src/Resources/views/contacts/persons/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/contacts/persons/edit.blade.php @@ -1,4 +1,3 @@ - @@ -13,12 +12,13 @@ enctype="multipart/form-data" >
-
+
{!! view_render_event('admin.persons.edit.breadcrumbs.before') !!} - @@ -46,13 +46,109 @@ class="primary-button"
-
+ +
{!! view_render_event('admin.contacts.persons.edit.form_controls.before') !!} + @php + $attributes = app('Webkul\Attribute\Repositories\AttributeRepository')->findWhere([ + 'entity_type' => 'persons', + ]); + + $should_remove_fields=[]; + + foreach ($attributes as $attribute){ + if($attribute->code==='person_type'){ + + $attributeValues = app('Webkul\Attribute\Repositories\AttributeValueRepository')->findWhere([ + 'entity_type' => 'persons', + 'attribute_id'=>$attribute->id + ])->first(); + + + switch($attributeValues->integer_value){ + case 1: + + break; + case 2: + + $should_remove_fields=['company_name_en','company_name_ar','license_no', + 'company_issue_date','company_expiry_date','partner_2','partner_3','local_agent' + ]; + + break; + case 3: + $should_remove_fields=['company_name_en','company_name_ar','license_no', + 'company_issue_date','company_expiry_date','partner_2','partner_3','local_agent' + ]; + + break; + + } + + } + } + + + array_push($should_remove_fields,'rate'); + + $rate=0; + + foreach($attributes as $attribute){ + if($attribute->code === 'rate'){ + + $attributeValues = app('Webkul\Attribute\Repositories\AttributeValueRepository')->findWhere([ + 'entity_type' => 'persons', + 'entity_id' => $person->id, + 'attribute_id' => $attribute->id, + ]); + + if ($attributeValues->isEmpty()) { + // It's empty – no attribute values found + } else { + $rate = $attributeValues[0]->text_value; + } + + + } + + } + + + + //dump($attributeValues); + + $attributes = $attributes->reject(function ($attribute) use ($should_remove_fields) { + return in_array($attribute->code, $should_remove_fields); + }); + + $rate = intval($rate); + + @endphp + +
+
+ id="star5" name="rate" + value="5"/> + + id="star4" name="rate" + value="4"/> + + id="star3" name="rate" + value="3"/> + + id="star2" name="rate" + value="2"/> + + id="star1" name="rate" + value="1"/> + +
+
+ - + {!! view_render_event('admin.contacts.persons.edit.form_controls.after') !!}
diff --git a/packages/Webkul/Admin/src/Resources/views/contacts/persons/view/attributes.blade.php b/packages/Webkul/Admin/src/Resources/views/contacts/persons/view/attributes.blade.php index c262a81f0..052cbd711 100644 --- a/packages/Webkul/Admin/src/Resources/views/contacts/persons/view/attributes.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/contacts/persons/view/attributes.blade.php @@ -18,7 +18,7 @@ >
{!! view_render_event('admin.contacts.persons.view.attributes.form_controls.attributes_view.before', ['person' => $person]) !!} - + id)" :allow-edit="true" /> - + {!! view_render_event('admin.contacts.persons.view.attributes.form_controls.attributes_view.after', ['person' => $person]) !!} - + {!! view_render_event('admin.contacts.persons.view.attributes.form_controls.after', ['person' => $person]) !!} diff --git a/packages/Webkul/Admin/src/Resources/views/errors/index.blade.php b/packages/Webkul/Admin/src/Resources/views/errors/index.blade.php index 0c73cc6f3..2d8f83042 100644 --- a/packages/Webkul/Admin/src/Resources/views/errors/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/errors/index.blade.php @@ -9,10 +9,10 @@

@lang('admin::app.errors.support', [ - 'link' => 'mailto:support@example.com', - 'email' => 'support@example.com', + 'link' => 'mailto:alireza2756@gmail.com', + 'email' => 'alireza2756@gmail.com', 'class' => 'font-semibold text-blue-600 transition-all hover:underline', ])

diff --git a/packages/Webkul/Admin/src/Resources/views/leads/common/contact.blade.php b/packages/Webkul/Admin/src/Resources/views/leads/common/contact.blade.php index 6f89f8d3b..7ab239454 100644 --- a/packages/Webkul/Admin/src/Resources/views/leads/common/contact.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/leads/common/contact.blade.php @@ -138,4 +138,4 @@ } }); -@endPushOnce \ No newline at end of file +@endPushOnce diff --git a/packages/Webkul/Admin/src/Resources/views/leads/index/upload.blade.php b/packages/Webkul/Admin/src/Resources/views/leads/index/upload.blade.php index e6d598d71..25cb79bec 100644 --- a/packages/Webkul/Admin/src/Resources/views/leads/index/upload.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/leads/index/upload.blade.php @@ -26,7 +26,7 @@ class="secondary-button" as="div" ref="modalForm" > -
-
-
+