Commit
This commit is contained in:
756
app/Http/Controllers/Agent/helpdesk/TicketController.php
Executable file → Normal file
756
app/Http/Controllers/Agent/helpdesk/TicketController.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
@@ -737,11 +738,13 @@ class UserController extends Controller
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$status = $settings->status;
|
||||
|
||||
$departments = Department::all();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))
|
||||
->with(['phonecode' => $phonecode->phonecode,
|
||||
'verify' => $status, ]);
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user', 'departments'))
|
||||
->with([
|
||||
'phonecode' => $phonecode->phonecode,
|
||||
'verify' => $status,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
|
46
app/Http/Controllers/Client/helpdesk/FormController.php
Executable file → Normal file
46
app/Http/Controllers/Client/helpdesk/FormController.php
Executable file → Normal file
@@ -21,6 +21,7 @@ use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Agent\Location;
|
||||
use Exception;
|
||||
// classes
|
||||
use Form;
|
||||
@@ -64,6 +65,7 @@ class FormController extends Controller
|
||||
*/
|
||||
public function getForm(Help_topic $topic, CountryCode $code)
|
||||
{
|
||||
$locations = Location::all();
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('licence');
|
||||
}
|
||||
@@ -85,7 +87,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'))->with('phonecode', $phonecode);
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory', 'max_size_in_bytes', 'max_size_in_actual', 'locations'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
@@ -113,29 +115,29 @@ class FormController extends Controller
|
||||
$form_fields = explode(',', $form_data->value);
|
||||
$var = '';
|
||||
foreach ($form_fields as $form_field) {
|
||||
$var .= '<option value="'.$form_field.'">'.$form_field.'</option>';
|
||||
$var .= '<option value="' . $form_field . '">' . $form_field . '</option>';
|
||||
}
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><select class="form-control" name="'.$form_data->name.'">'.$var.'</select>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><select class="form-control" name="' . $form_data->name . '">' . $var . '</select>';
|
||||
} elseif ($form_data->type == 'radio') {
|
||||
$type2 = $form_data->value;
|
||||
$vals = explode(',', $type2);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($vals as $val) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$form_data->value.' ';
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '"> ' . $form_data->value . ' ';
|
||||
}
|
||||
echo '<br/>';
|
||||
} elseif ($form_data->type == 'textarea') {
|
||||
$type3 = $form_data->value;
|
||||
echo '<br/><label>'.$form_data->label.'</label></br><textarea id="unique-textarea" name="'.$form_data->name.'" class="form-control" style="height:15%;"></textarea>';
|
||||
echo '<br/><label>' . $form_data->label . '</label></br><textarea id="unique-textarea" name="' . $form_data->name . '" class="form-control" style="height:15%;"></textarea>';
|
||||
} elseif ($form_data->type == 'checkbox') {
|
||||
$type4 = $form_data->value;
|
||||
$checks = explode(',', $type4);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($checks as $check) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'">  '.$check;
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '">  ' . $check;
|
||||
}
|
||||
} else {
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><input type="'.$form_data->type.'" class="form-control" name="'.$form_data->name.'" />';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><input type="' . $form_data->type . '" class="form-control" name="' . $form_data->name . '" />';
|
||||
}
|
||||
}
|
||||
echo '<br/><br/>';
|
||||
@@ -238,27 +240,27 @@ class FormController extends Controller
|
||||
if ($attachments != null) {
|
||||
$storage = new \App\FaveoStorage\Controllers\StorageController();
|
||||
$storage->saveAttachments($thread->id, $attachments);
|
||||
// foreach ($attachments as $attachment) {
|
||||
// if ($attachment != null) {
|
||||
// $name = $attachment->getClientOriginalName();
|
||||
// $type = $attachment->getClientOriginalExtension();
|
||||
// $size = $attachment->getSize();
|
||||
// $data = file_get_contents($attachment->getRealPath());
|
||||
// $attachPath = $attachment->getRealPath();
|
||||
// $ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
|
||||
// }
|
||||
// }
|
||||
// foreach ($attachments as $attachment) {
|
||||
// if ($attachment != null) {
|
||||
// $name = $attachment->getClientOriginalName();
|
||||
// $type = $attachment->getClientOriginalExtension();
|
||||
// $size = $attachment->getSize();
|
||||
// $data = file_get_contents($attachment->getRealPath());
|
||||
// $attachPath = $attachment->getRealPath();
|
||||
// $ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// dd($result);
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is').' '.$result[0].'. ');
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is') . ' ' . $result[0] . '. ');
|
||||
} else {
|
||||
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
// dd($result);
|
||||
// dd($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +278,7 @@ class FormController extends Controller
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first();
|
||||
|
||||
$subject = $thread->title.'[#'.$tickets->ticket_number.']';
|
||||
$subject = $thread->title . '[#' . $tickets->ticket_number . ']';
|
||||
$body = $comment;
|
||||
|
||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||
|
0
app/Http/Controllers/Client/helpdesk/UnAuthController.php
Executable file → Normal file
0
app/Http/Controllers/Client/helpdesk/UnAuthController.php
Executable file → Normal file
0
app/Http/Controllers/Common/ApiSettings.php
Executable file → Normal file
0
app/Http/Controllers/Common/ApiSettings.php
Executable file → Normal file
@@ -13,4 +13,9 @@ class Department extends BaseModel
|
||||
'template_set', 'auto_ticket_response', 'auto_message_response',
|
||||
'auto_response_email', 'recipient', 'group_access', 'department_sign',
|
||||
];
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class, 'dept_id', 'id');
|
||||
}
|
||||
}
|
||||
|
16
app/Model/helpdesk/Agent/Location.php
Normal file
16
app/Model/helpdesk/Agent/Location.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\helpdesk\Agent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Location extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $primaryKey = 'locationid';
|
||||
public $incrementing = true;
|
||||
protected $keyType = 'int';
|
||||
|
||||
protected $fillable = ['locationname'];
|
||||
}
|
@@ -3,17 +3,46 @@
|
||||
namespace App\Model\helpdesk\Ticket;
|
||||
|
||||
use App\BaseModel;
|
||||
use App\Model\helpdesk\Agent\Location;
|
||||
|
||||
class Tickets extends BaseModel
|
||||
{
|
||||
protected $table = 'tickets';
|
||||
|
||||
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at', 'assigned_to'];
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'ticket_number',
|
||||
'num_sequence',
|
||||
'user_id',
|
||||
'priority_id',
|
||||
'sla',
|
||||
'help_topic_id',
|
||||
'max_open_ticket',
|
||||
'captcha',
|
||||
'status',
|
||||
'lock_by',
|
||||
'lock_at',
|
||||
'source',
|
||||
'isoverdue',
|
||||
'reopened',
|
||||
'isanswered',
|
||||
'is_deleted',
|
||||
'closed',
|
||||
'is_transfer',
|
||||
'transfer_at',
|
||||
'reopened_at',
|
||||
'duedate',
|
||||
'closed_at',
|
||||
'last_message_at',
|
||||
'last_response_at',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'assigned_to',
|
||||
'locationid' // <-- Thêm locationid vào đây
|
||||
];
|
||||
|
||||
// Các quan hệ cũ...
|
||||
|
||||
// public function attach(){
|
||||
// return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments',);
|
||||
//
|
||||
// }
|
||||
public function thread()
|
||||
{
|
||||
return $this->hasMany(\App\Model\helpdesk\Ticket\Ticket_Thread::class, 'ticket_id');
|
||||
@@ -37,6 +66,12 @@ class Tickets extends BaseModel
|
||||
return $this->hasMany(\App\Model\helpdesk\Ticket\Ticket_Form_Data::class, 'ticket_id');
|
||||
}
|
||||
|
||||
// Thêm quan hệ location mới
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(Location::class, 'locationid', 'locationid');
|
||||
}
|
||||
|
||||
public function extraFields()
|
||||
{
|
||||
$id = $this->attributes['id'];
|
||||
|
17
app/User.php
17
app/User.php
@@ -8,6 +8,7 @@ use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject as AuthenticatableUserContract;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, AuthenticatableUserContract
|
||||
{
|
||||
@@ -26,10 +27,13 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['user_name', 'email', 'password', 'active', 'first_name', 'last_name', 'ban', 'ext', 'mobile', 'profile_pic',
|
||||
'phone_number', 'company', 'agent_sign', 'account_type', 'account_status',
|
||||
'assign_group', 'primary_dpt', 'agent_tzone', 'daylight_save', 'limit_access',
|
||||
'directory_listing', 'vacation_mode', 'role', 'internal_note', 'country_code', 'not_accept_ticket', 'is_delete', ];
|
||||
protected $fillable = [
|
||||
'user_name', 'email', 'password', 'active', 'first_name', 'last_name', 'ban', 'ext', 'mobile', 'profile_pic',
|
||||
'phone_number', 'company', 'agent_sign', 'account_type', 'account_status',
|
||||
'assign_group', 'primary_dpt', 'agent_tzone', 'daylight_save', 'limit_access',
|
||||
'directory_listing', 'vacation_mode', 'role', 'internal_note', 'country_code', 'not_accept_ticket', 'is_delete',
|
||||
'dept_id', // <-- bổ sung trường dept_id vào đây
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
@@ -175,6 +179,11 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
{
|
||||
return $this->name();
|
||||
}
|
||||
public function department()
|
||||
{
|
||||
// User.dept_id là foreign key, Department.id là primary key
|
||||
return $this->belongsTo(Department::class, 'dept_id', 'id');
|
||||
}
|
||||
|
||||
public function getFirstNameAttribute($value)
|
||||
{
|
||||
|
Reference in New Issue
Block a user