From 794c839a95d48cd26d397fd9f92f28cc206c43f1 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 19 Aug 2025 05:59:14 +0700 Subject: [PATCH] up new code up new code --- .../Client/helpdesk/FormController.php | 4 +- app/Model/helpdesk/Ticket/Tickets.php | 9 +- ...16_220156_add_dept_id_to_tickets_table.php | 29 +++ .../default1/client/helpdesk/form.blade.php | 227 ++++++------------ 4 files changed, 112 insertions(+), 157 deletions(-) create mode 100644 database/migrations/2025_08_16_220156_add_dept_id_to_tickets_table.php diff --git a/app/Http/Controllers/Client/helpdesk/FormController.php b/app/Http/Controllers/Client/helpdesk/FormController.php index 85d448549..6141a6de2 100644 --- a/app/Http/Controllers/Client/helpdesk/FormController.php +++ b/app/Http/Controllers/Client/helpdesk/FormController.php @@ -23,6 +23,7 @@ use App\Model\helpdesk\Utility\CountryCode; use App\User; use App\Model\helpdesk\Agent\Location; use Exception; +use App\Model\helpdesk\Agent\Department; // classes use Form; use GeoIP; @@ -66,6 +67,7 @@ class FormController extends Controller public function getForm(Help_topic $topic, CountryCode $code) { $locations = Location::all(); + $departments = Department::all(); if (\Config::get('database.install') == '%0%') { return \Redirect::route('licence'); } @@ -87,7 +89,7 @@ class FormController extends Controller [$max_size_in_bytes, $max_size_in_actual] = $this->fileUploadController->file_upload_max_size(); - return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory', 'max_size_in_bytes', 'max_size_in_actual', 'locations'))->with('phonecode', $phonecode); + return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory', 'max_size_in_bytes', 'max_size_in_actual', 'locations', 'departments'))->with('phonecode', $phonecode); } else { return \Redirect::route('home'); } diff --git a/app/Model/helpdesk/Ticket/Tickets.php b/app/Model/helpdesk/Ticket/Tickets.php index 8c4740e64..cada491b0 100644 --- a/app/Model/helpdesk/Ticket/Tickets.php +++ b/app/Model/helpdesk/Ticket/Tickets.php @@ -4,6 +4,7 @@ namespace App\Model\helpdesk\Ticket; use App\BaseModel; use App\Model\helpdesk\Agent\Location; +use App\Model\helpdesk\Agent\Department; class Tickets extends BaseModel { @@ -38,7 +39,8 @@ class Tickets extends BaseModel 'created_at', 'updated_at', 'assigned_to', - 'locationid' // <-- Thêm locationid vào đây + 'locationid', // <-- Thêm locationid vào đây + 'submitdep_id' ]; // Các quan hệ cũ... @@ -71,7 +73,10 @@ class Tickets extends BaseModel { return $this->belongsTo(Location::class, 'locationid', 'locationid'); } - + public function submitDepartment() + { + return $this->belongsTo(Department::class, 'submitdept_id'); + } public function extraFields() { $id = $this->attributes['id']; diff --git a/database/migrations/2025_08_16_220156_add_dept_id_to_tickets_table.php b/database/migrations/2025_08_16_220156_add_dept_id_to_tickets_table.php new file mode 100644 index 000000000..ac5e7a67a --- /dev/null +++ b/database/migrations/2025_08_16_220156_add_dept_id_to_tickets_table.php @@ -0,0 +1,29 @@ +unsignedInteger('submitdept_id')->nullable()->after('id'); + $table->foreign('submitdept_id')->references('id')->on('department')->onDelete('cascade'); + }); + } + + public function down() + { + Schema::table('tickets', function (Blueprint $table) { + $table->dropForeign(['submitdept_id']); + $table->dropColumn('submitdept_id'); + }); + } +}; diff --git a/resources/views/themes/default1/client/helpdesk/form.blade.php b/resources/views/themes/default1/client/helpdesk/form.blade.php index 0dfbcdd0c..9f840a226 100644 --- a/resources/views/themes/default1/client/helpdesk/form.blade.php +++ b/resources/views/themes/default1/client/helpdesk/form.blade.php @@ -7,35 +7,26 @@ @section('submit') class = "nav-item active" @stop - + @section('breadcrumb') - {{--
--}} -
@stop - + @section('check') - + @stop - -@section('content') +@section('content')
@if (Session::has('message'))
- + {!! Session::get('message') !!}
@endif + @if (count($errors) > 0) @if (Session::has('check')) @@ -104,51 +97,39 @@ $encrypted_token = $encrypter->encrypt(csrf_token()); ?> + {!! Form::open(['route' => 'client.form.post', 'method' => 'post', 'enctype' => 'multipart/form-data']) !!}
- -
- +
-

- - {!! Lang::get('lang.submit_a_ticket') !!} + {!! Lang::get('lang.submit_a_ticket') !!}

- @if (Auth::user()) - {!! Form::hidden('Name', Auth::user()->user_name, ['class' => 'form-control']) !!} + {!! Form::hidden('Name', Auth::user()->user_name) !!} + {!! Form::hidden('Email', Auth::user()->email) !!} + {!! Form::hidden('mobile', Auth::user()->mobile) !!} + {!! Form::hidden('Code', Auth::user()->country_code) !!} + {!! Form::hidden('Phone', Auth::user()->phone_number) !!} @else
{!! Form::label('Name', Lang::get('lang.name')) !!} * {!! Form::text('Name', null, ['class' => 'form-control']) !!}
- @endif - @if (Auth::user()) - - {!! Form::hidden('Email', Auth::user()->email, ['class' => 'form-control']) !!} - @else
{!! Form::label('Email', Lang::get('lang.email')) !!} - @if ($email_mandatory->status == 1 || $email_mandatory->status == '1') + @if ($email_mandatory->status == 1) * @endif {!! Form::email('Email', null, ['class' => 'form-control']) !!}
- @endif - - @if (!Auth::user())
{!! Form::label('Code', Lang::get('lang.country-code')) !!} - @if ($email_mandatory->status == 0 || $email_mandatory->status == '0') - * - @endif - {!! Form::text('Code', null, [ 'class' => 'form-control', 'placeholder' => $phonecode, @@ -157,71 +138,39 @@
{!! Form::label('mobile', Lang::get('lang.mobile_number')) !!} - @if ($email_mandatory->status == 0 || $email_mandatory->status == '0') - * - @endif {!! Form::text('mobile', null, ['class' => 'form-control']) !!}
{!! Form::label('Phone', Lang::get('lang.phone')) !!} {!! Form::text('Phone', null, ['class' => 'form-control']) !!}
- @else - {!! Form::hidden('mobile', Auth::user()->mobile, ['class' => 'form-control']) !!} - {!! Form::hidden('Code', Auth::user()->country_code, ['class' => 'form-control']) !!} - {!! Form::hidden('Phone', Auth::user()->phone_number, ['class' => 'form-control']) !!} - @endif -
- {!! Form::label('help_topic', Lang::get('lang.choose_a_help_topic')) !!} - {!! $errors->first('help_topic', ':message') !!} - get(); - // - ?> - -
- - where('option_name', '=', 'user_priority')->first(); - $user_Priority = $Priority->status; - ?> - - @if (Auth::user()) - - @if (Auth::user()->active == 1) - @if ($user_Priority == 1) -
-
-
- -
-
- get(); ?> - {!! Form::select('priority', ['Priority' => $Priority->pluck('priority_desc', 'priority_id')->toArray()], null, [ - 'class' => 'form-control select', - ]) !!} -
-
-
- @endif - @endif - @endif -
- {!! Form::label('Subject', Lang::get('lang.subject')) !!} * - {!! Form::text('Subject', null, ['class' => 'form-control']) !!} -
-
-
- + +
+ +
+ get(); ?> +
-
+ + +
+ get(); ?> + {!! Form::select('priority', $Priority->pluck('priority_desc', 'priority_id')->toArray(), null, [ + 'class' => 'form-control', + ]) !!} +
+
+ + +
+ +
+ + +
+ +
+ + +
+ {!! Form::label('Subject', Lang::get('lang.subject')) !!} * + {!! Form::text('Subject', null, ['class' => 'form-control']) !!} +
+ +
{!! Form::label('Details', Lang::get('lang.message')) !!} * {!! Form::textarea('Details', null, ['class' => 'form-control']) !!}
+ +

{!! Lang::get('lang.max') !!}. {!! $max_size_in_actual !!}
+ {{-- Event fire --}} -
-
+ +
{!! Form::button(' ' . Lang::get('lang.submit'), [ 'type' => 'submit', - 'class' => 'btn btn-info float-right', - 'style' => 'style="border-color: rgb(0, 192, 239); background-color: rgb(0, 154, 186); color: white;', - 'onclick' => 'this.disabled=true;this.innerHTML="Sending, please wait...";this.form.submit();', - 'data-v-fce8d630', + 'class' => 'btn btn-primary', ]) !!}
-
-
- {!! Form::close() !!}
+ {!! Form::close() !!}
- - @stop