update v1.0.5
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
<?php namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CannedRequest;
|
||||
use App\Http\Requests\helpdesk\CannedUpdateRequest;
|
||||
|
||||
// model
|
||||
use App\Model\helpdesk\Agent_panel\Canned;
|
||||
use App\User;
|
||||
|
||||
// classes
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* UserController
|
||||
* CannedController
|
||||
*
|
||||
* This controller is for all the functionalities of Canned response for Agents in the Agent Panel
|
||||
*
|
||||
* @package Controllers
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
@@ -23,108 +31,122 @@ class CannedController extends Controller {
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
$this->middleware('role.agent');
|
||||
// $this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
* Display a listing of the Canned Responses.
|
||||
* @return type View
|
||||
*/
|
||||
public function index() {
|
||||
return view('themes.default1.agent.helpdesk.canned.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return type Response
|
||||
* Show the form for creating a new Canned Response
|
||||
* @return type View
|
||||
*/
|
||||
public function create() {
|
||||
return view('themes.default1.agent.helpdesk.canned.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param type User $user
|
||||
* @param type Sys_userRequest $request
|
||||
* @return type Response
|
||||
* Store a newly created Canned Response.
|
||||
* @param type CannedRequest $request
|
||||
* @param type Canned $canned
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(CannedRequest $request, Canned $canned) {
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
$canned->save();
|
||||
return redirect()->route('canned.list')->with('success','Added Successfully');
|
||||
try {
|
||||
// saving inputs
|
||||
$canned->save();
|
||||
return redirect()->route('canned.list')->with('success','Added Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
* Show the form for editing the Canned Response.
|
||||
* @param type $id
|
||||
* @param type Canned $canned
|
||||
* @return type View
|
||||
*/
|
||||
public function edit($id, Canned $canned) {
|
||||
// fetching requested canned response
|
||||
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id','=',$id)->first();
|
||||
return view('themes.default1.agent.helpdesk.canned.edit',compact('canned'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @param type Sys_userUpdate $request
|
||||
* @return type Response
|
||||
* Update the Canned Response in database.
|
||||
* @param type $id
|
||||
* @param type CannedUpdateRequest $request
|
||||
* @param type Canned $canned
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function update($id, CannedUpdateRequest $request, Canned $canned) {
|
||||
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->where('id','=',$id)->where('user_id', '=', \Auth::user()->id)->first();
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
$canned->save();
|
||||
|
||||
return redirect()->route('canned.list')->with('success','Updated Successfully');
|
||||
try {
|
||||
// saving inputs
|
||||
$canned->save();
|
||||
return redirect()->route('canned.list')->with('success','Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
* Delete the Canned Response from storage.
|
||||
* @param type $id
|
||||
* @param type Canned $canned
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Canned $canned) {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->whereId($id)->first();
|
||||
/* delete the selected field */
|
||||
/* Check whether function success or not */
|
||||
if ($canned->delete() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->route('canned.list')->with('fails', 'User can not Delete');
|
||||
}
|
||||
return view('themes.default1.agent.helpdesk.canned.destroy');
|
||||
$canned = $canned->whereId($id)->first();
|
||||
/* delete the selected field */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$canned->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get canned
|
||||
* Fetch Canned Response in the ticket detail page.
|
||||
* @param type $id
|
||||
* @return type json
|
||||
*/
|
||||
public function get_canned($id) {
|
||||
// checking for the canned response with requested value
|
||||
if($id != "zzz") {
|
||||
// fetching canned response
|
||||
$canned = Canned::where('id','=',$id)->where('user_id','=',\Auth::user()->id)->first();
|
||||
$msg = $canned->message;
|
||||
} else {
|
||||
$msg = "";
|
||||
}
|
||||
// returning the canned response in JSON format
|
||||
return \Response::json($msg);
|
||||
}
|
||||
|
||||
|
@@ -1,19 +1,24 @@
|
||||
<?php namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\User;
|
||||
|
||||
// classes
|
||||
use DB;
|
||||
use View;
|
||||
use Auth;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* DashboardController
|
||||
*
|
||||
* This controlleris used to fetch dashboard in the agent panel
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
@@ -29,61 +34,76 @@ class DashboardController extends Controller {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return type Response
|
||||
* Get the dashboard page
|
||||
* @return type view
|
||||
*/
|
||||
public function index() {
|
||||
try {
|
||||
if(Auth::user()->role == "user"){
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
}
|
||||
// if(Auth::user()->role == "user"){
|
||||
// return \Redirect::route('home');
|
||||
// }
|
||||
try {
|
||||
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
|
||||
} catch (Exception $e) {
|
||||
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ChartData
|
||||
* @return type
|
||||
* Fetching dashboard graph data to implement graph
|
||||
* @return type Json
|
||||
*/
|
||||
public function ChartData()
|
||||
{
|
||||
$date2 = strtotime(Date('Y-m-d'));
|
||||
$date3 = Date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
|
||||
|
||||
$return = "";
|
||||
$last = "";
|
||||
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
|
||||
$thisDate = date( 'Y-m-d', $i );
|
||||
|
||||
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
|
||||
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities',$value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return,',');
|
||||
|
||||
return '['.$last.']';
|
||||
|
||||
// $date11 = strtotime(\Input::get('start_date'));
|
||||
// $date12 = strtotime(\Input::get('end_date'));
|
||||
// if($date11 && $date12){
|
||||
// $date2 = $date12;
|
||||
// $date1 = $date11;
|
||||
// } else {
|
||||
// generating current date
|
||||
$date2 = strtotime(Date('Y-m-d'));
|
||||
$date3 = Date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
|
||||
// }
|
||||
|
||||
$return = "";
|
||||
$last = "";
|
||||
// fetching dashboard data for each day on a 1 month fixed range
|
||||
// this range can also be fetched on a requested rannge of date
|
||||
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
|
||||
$thisDate = date( 'Y-m-d', $i );
|
||||
// created tickets
|
||||
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
|
||||
// closed tickets
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
|
||||
// reopened tickets
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
|
||||
// storing in array format
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities',$value);
|
||||
// encoding the values in jsom format
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
// combining all the values in a single variable and returning that variable in Json.
|
||||
$last = rtrim($return,',');
|
||||
return '['.$last.']';
|
||||
// $ticketlist = DB::table('tickets')
|
||||
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
|
||||
// DB::raw('count(*) as totaltickets'))
|
||||
// ->groupBy('month')
|
||||
// ->orderBy('month', 'asc')
|
||||
// ->get();
|
||||
|
||||
// return $ticketlist;
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
|
||||
// models
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
@@ -9,6 +10,12 @@ use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
|
||||
// classes
|
||||
use PhpImap\Mailbox as ImapMailbox;
|
||||
use PhpImap\IncomingMail;
|
||||
@@ -20,6 +27,7 @@ use Crypt;
|
||||
use Schedule;
|
||||
use File;
|
||||
use Artisan;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* MailController
|
||||
@@ -45,53 +53,55 @@ class MailController extends Controller {
|
||||
*/
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system)
|
||||
{
|
||||
$path_url = $system->first()->url;
|
||||
// $path_url = $system->first()->url;
|
||||
if($settings_email->first()->email_fetching == 1)
|
||||
{
|
||||
if($settings_email->first()->all_emails == 1)
|
||||
{
|
||||
$helptopic = $this->TicketController->default_helptopic();
|
||||
$sla = $this->TicketController->default_sla();
|
||||
// $helptopic = $this->TicketController->default_helptopic();
|
||||
// $sla = $this->TicketController->default_sla();
|
||||
$email = $emails->get();
|
||||
foreach($email as $e_mail)
|
||||
{
|
||||
$helptopic = $e_mail->help_topic;
|
||||
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
|
||||
$sla = $get_helptopic->sla_plan;
|
||||
$dept = $e_mail->department;
|
||||
$host = $e_mail->fetching_host;
|
||||
$port = $e_mail->fetching_port;
|
||||
$protocol = $e_mail->mailbox_protocol;
|
||||
$get_mailboxprotocol = MailboxProtocol::where('id','=',$protocol)->first();
|
||||
$protocol = $get_mailboxprotocol->value;
|
||||
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
|
||||
|
||||
$password = Crypt::decrypt($e_mail->password);
|
||||
$mailbox = new ImapMailbox($imap_config, $e_mail->user_name, $password, __DIR__);
|
||||
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
|
||||
$mails = array();
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE '. date('d-M-Y', strtotime("-1 day")));
|
||||
if(!$mailsIds) {
|
||||
die('Mailbox is empty');
|
||||
}
|
||||
// dd($mailsIds);
|
||||
foreach($mailsIds as $mailId) {
|
||||
$overview = $mailbox->get_overview($mailId);
|
||||
$var = $overview[0]->seen ? 'read' : 'unread';
|
||||
if ($var == 'unread') {
|
||||
$mail = $mailbox->getMail($mailId);
|
||||
if($settings_email->email_collaborator == 1) {
|
||||
if($settings_email->first()->email_collaborator == 1) {
|
||||
$collaborator = $mail->cc;
|
||||
} else {
|
||||
$collaborator = null;
|
||||
}
|
||||
$body = $mail->textHtml;
|
||||
// dd($mailId);
|
||||
if($body == null) {
|
||||
$body = $mailbox->backup_getmail($mailId);
|
||||
$body = str_replace('\r\n', '<br/>', $body);
|
||||
// var_dump($body);
|
||||
}
|
||||
// dd($body);
|
||||
$date = $mail->date;
|
||||
$datetime = $overview[0]->date;
|
||||
$date_time = explode(" ", $datetime);
|
||||
$date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
|
||||
$date = date('Y-m-d H:i:s', strtotime($date));
|
||||
// dd($date);
|
||||
|
||||
if(isset($mail->subject)){
|
||||
$subject = $mail->subject;
|
||||
@@ -99,27 +109,36 @@ class MailController extends Controller {
|
||||
$subject = "No Subject";
|
||||
}
|
||||
|
||||
// dd($subject);
|
||||
$fromname = $mail->fromName;
|
||||
$fromaddress = $mail->fromAddress;
|
||||
$source = "2";
|
||||
$ticket_source = Ticket_source::where('name','=','email')->first();
|
||||
$source = $ticket_source->id;
|
||||
$phone = "";
|
||||
$priority = '1';
|
||||
$assign = "";
|
||||
$priority = $get_helptopic->priority;
|
||||
// Ticket_Priority::where('')
|
||||
|
||||
$assign = $get_helptopic->auto_assign;
|
||||
$form_data = null;
|
||||
if ($this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data) == true) {
|
||||
$thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
|
||||
$thread_id = $thread_id->id;
|
||||
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
|
||||
// dd($result);
|
||||
if ($result[1] == true) {
|
||||
$ticket_table = Tickets::where('ticket_number', '=' , $result[0])->first();
|
||||
$thread_id = Ticket_Thread::where('ticket_id','=',$ticket_table->id)->max('id');
|
||||
// $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
|
||||
$thread_id = $thread_id;
|
||||
|
||||
foreach($mail->getAttachments() as $attachment) {
|
||||
// dd($attachment);
|
||||
$support = "support";
|
||||
// echo $_SERVER['DOCUMENT_ROOT'];
|
||||
$dir_img_paths = __DIR__;
|
||||
$dir_img_path = explode('/code', $dir_img_paths);
|
||||
$filepath = explode('../../../../../../public',$attachment->filePath);
|
||||
// dd($attachment->filePath);
|
||||
$filepath = explode('../../../../../public',$attachment->filePath);
|
||||
// var_dump($attachment->filePath);
|
||||
// dd($filepath);
|
||||
// $path = $dir_img_path[0]."/public/".$filepath[1];
|
||||
$path = public_path().'/'.$filepath[1];
|
||||
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
|
||||
$path = public_path().$filepath[1];
|
||||
// dd($path);
|
||||
$filesize = filesize($path);
|
||||
$file_data = file_get_contents($path);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// Model
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
@@ -10,8 +11,12 @@ use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Utility\Log_notification;
|
||||
use App\Model\helpdesk\settings\Email;
|
||||
|
||||
// classes
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* UserController
|
||||
* NotificationController
|
||||
* This controller is used to send daily notifications
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
@@ -21,20 +26,27 @@ class NotificationController extends Controller {
|
||||
|
||||
/**
|
||||
* This function is for sending daily report/notification about the system
|
||||
* @return mail
|
||||
**/
|
||||
public function send_notification() {
|
||||
//fetching email settings
|
||||
$email = Email::where('id','=','1')->first();
|
||||
// checking if the daily notification is enabled or not
|
||||
if($email->notification_cron == 1){
|
||||
// checking if current date is equal to the last entered daily notification log
|
||||
$notification = Log_notification::where('log','=','NOT-1')->orderBy('id','DESC')->first();
|
||||
$date = explode(" " , $notification->created_at);
|
||||
if(Date('Y-m-d') == $date[0]){
|
||||
} else {
|
||||
// creating a daily notification log
|
||||
Log_notification::create(['log'=>'NOT-1']);
|
||||
$company = $this->company();
|
||||
// Send notification details to admin
|
||||
$this->send_notification_to_admin($company);
|
||||
// Send notification details to team lead
|
||||
$this->send_notification_to_team_lead($company);
|
||||
// Send notification details to manager of a department
|
||||
$this->send_notification_to_manager($company);
|
||||
// Send notification details to all the agents
|
||||
$this->send_notification_to_agent($company);
|
||||
}
|
||||
}
|
||||
@@ -49,6 +61,7 @@ class NotificationController extends Controller {
|
||||
// get all admin users
|
||||
$users = User::where('role','=','admin')->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to admin
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name . " " . $user->last_name;
|
||||
\Mail::send('emails.notifications.admin', ['company' => $company, 'name'=>$user_name], function ($message)use ($email, $user_name, $company) {
|
||||
@@ -62,12 +75,14 @@ class NotificationController extends Controller {
|
||||
* @return mail
|
||||
**/
|
||||
public function send_notification_to_manager($company) {
|
||||
// get all department managers
|
||||
$depts = Department::all();
|
||||
foreach ($depts as $dept) {
|
||||
if(isset($dept->manager)) {
|
||||
$dept_name = $dept->name;
|
||||
$users = User::where('id','=',$dept->manager)->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to manager of a department
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name . " " . $user->last_name;
|
||||
\Mail::send('emails.notifications.manager', ['company' => $company, 'name'=>$user_name,'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) {
|
||||
@@ -83,12 +98,14 @@ class NotificationController extends Controller {
|
||||
* @return mail
|
||||
**/
|
||||
public function send_notification_to_team_lead($company) {
|
||||
// get all Team leads
|
||||
$teams = Teams::all();
|
||||
foreach ($teams as $team) {
|
||||
if(isset($team->team_lead)) {
|
||||
$team_name = $team->name;
|
||||
$users = User::where('id','=',$team->team_lead)->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to team lead
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name . " " . $user->last_name;
|
||||
\Mail::send('emails.notifications.lead', ['company' => $company, 'name'=>$user_name,'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) {
|
||||
@@ -107,6 +124,7 @@ class NotificationController extends Controller {
|
||||
// get all agents users
|
||||
$users = User::where('role','=','agent')->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to all the agents
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name . " " . $user->last_name;
|
||||
\Mail::send('emails.notifications.agent', ['company' => $company, 'name'=>$user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) {
|
||||
@@ -116,12 +134,13 @@ class NotificationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* company
|
||||
* @return type
|
||||
* Fetching company name
|
||||
* @return type variable
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
public function company() {
|
||||
// fetching comapny model
|
||||
$company = Company::Where('id','=','1')->first();
|
||||
// fetching company name
|
||||
if($company->company_name == null){
|
||||
$company = "Support Center";
|
||||
}else{
|
||||
@@ -130,12 +149,13 @@ class NotificationController extends Controller {
|
||||
return $company;
|
||||
}
|
||||
|
||||
public function test(){
|
||||
$email = "sujit.prasad@ladybirdweb.com";
|
||||
$user_name = "sujit prasad";
|
||||
\Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
|
||||
$message->to($email, $user_name)->subject('testing reporting');
|
||||
});
|
||||
}
|
||||
// // testing
|
||||
// public function test(){
|
||||
// $email = "sujit.prasad@ladybirdweb.com";
|
||||
// $user_name = "sujit prasad";
|
||||
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
|
||||
// $message->to($email, $user_name)->subject('testing reporting');
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
@@ -1,18 +1,25 @@
|
||||
<?php namespace App\Http\Controllers\Agent\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\OrganizationRequest;
|
||||
|
||||
/* include organization model */
|
||||
use App\Http\Requests\helpdesk\OrganizationUpdate;
|
||||
|
||||
// models
|
||||
/* Define OrganizationRequest to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\User_org_head;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
// classes
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* OrganizationController
|
||||
* This controller is used to CRUD organization detail.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
@@ -26,13 +33,13 @@ class OrganizationController extends Controller {
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
$this->middleware('role.agent');
|
||||
// $this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,47 +61,54 @@ class OrganizationController extends Controller {
|
||||
* @return datatable
|
||||
*/
|
||||
public function org_list() {
|
||||
// chumper datable package call to display Advance datatable
|
||||
return \Datatable::collection(Organization::all())
|
||||
/* searchable name */
|
||||
->searchColumns('name')
|
||||
/* order by name and website */
|
||||
->orderColumns('name', 'website')
|
||||
/* column name */
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
/* column website */
|
||||
->addColumn('website', function ($model) {
|
||||
$website = $model->website;
|
||||
return $website;
|
||||
})
|
||||
/* column phone number */
|
||||
->addColumn('phone', function ($model) {
|
||||
$phone = $model->phone;
|
||||
return $phone;
|
||||
})
|
||||
/* column action buttons */
|
||||
->addColumn('Actions', function ($model) {
|
||||
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
// displaying action buttons
|
||||
// modal popup to delete data
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="'.route('organizations.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id .'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->user_name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="'.route('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->user_name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="'.route('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* Show the form for creating a new organization.
|
||||
* @return type Response
|
||||
*/
|
||||
public function create() {
|
||||
@@ -106,10 +120,10 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* Store a newly created organization in storage.
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationRequest $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(Organization $org, OrganizationRequest $request) {
|
||||
try {
|
||||
@@ -129,11 +143,10 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* Display the specified organization.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, Organization $org) {
|
||||
try {
|
||||
@@ -142,16 +155,15 @@ class OrganizationController extends Controller {
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* Show the form for editing the specified organization.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($id, Organization $org) {
|
||||
try {
|
||||
@@ -165,63 +177,69 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* Update the specified organization in storage.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationUpdate $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function update($id, Organization $org, OrganizationUpdate $request) {
|
||||
try {
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
} else {
|
||||
try {
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* Delete a specified organization from storage.
|
||||
* @param type int $id
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Organization $org) {
|
||||
try {
|
||||
// User_org
|
||||
public function destroy($id, Organization $org, User_org $user_org) {
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id','=',$id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->delete() == true) {
|
||||
try {
|
||||
$orgs->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
|
||||
} else {
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Delete');
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Soring an organization head
|
||||
* @param type $id
|
||||
* @return type boolean
|
||||
*/
|
||||
public function Head_Org($id){
|
||||
|
||||
// get the user to make organization head
|
||||
$head_user = \Input::get('user');
|
||||
|
||||
// get an instance of the selected organization
|
||||
$org_head = Organization::where('id','=',$id)->first();
|
||||
$org_head->head = $head_user;
|
||||
// save the user to organization head
|
||||
$org_head->save();
|
||||
return 1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
<?php namespace App\Http\Controllers\Agent\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
// requests
|
||||
/* Include Sys_user Model */
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
@@ -10,26 +11,22 @@ use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
use App\Http\Requests\helpdesk\Sys_userRequest;
|
||||
/* include guest_note model */
|
||||
use App\Http\Requests\helpdesk\Sys_userUpdate;
|
||||
|
||||
// models
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
/* include User Model */
|
||||
/* include Help_topic Model */
|
||||
/* Profile validator */
|
||||
/* Profile Password validator */
|
||||
use App\User;
|
||||
|
||||
// classes
|
||||
/* include ticket_thred model */
|
||||
use Auth;
|
||||
/* include tickets model */
|
||||
use Hash;
|
||||
/* TicketRequest to validate the ticket response */
|
||||
/* Validate post check ticket */
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* UserController
|
||||
* This controller is used to CRUD an User details, and proile management of an agent
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
@@ -43,45 +40,50 @@ class UserController extends Controller {
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
$this->middleware('role.agent');
|
||||
// $this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Display all list of the users.
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function index() {
|
||||
try {
|
||||
/* get all values in Sys_user */
|
||||
return view('themes.default1.agent.helpdesk.user.index');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display the list of users
|
||||
* This function is used to display the list of users using chumper datatables
|
||||
* @return datatable
|
||||
*/
|
||||
public function user_list() {
|
||||
|
||||
// displaying list of users with chumper datatables
|
||||
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get())
|
||||
/* searchable column username */
|
||||
->searchColumns('user_name')
|
||||
/* order column username and email */
|
||||
->orderColumns('user_name', 'email')
|
||||
/* column username */
|
||||
->addColumn('user_name', function ($model) {
|
||||
return $model->user_name;
|
||||
})
|
||||
/* column email */
|
||||
->addColumn('email', function ($model) {
|
||||
$email = $model->email;
|
||||
return $email;
|
||||
})
|
||||
/* column phone */
|
||||
->addColumn('phone', function ($model) {
|
||||
$phone = "";
|
||||
if($model->phone_number) {
|
||||
@@ -94,6 +96,7 @@ class UserController extends Controller {
|
||||
$phone = $phone ." ". $mobile;
|
||||
return $phone;
|
||||
})
|
||||
/* column status */
|
||||
->addColumn('status', function ($model) {
|
||||
$status = $model->active;
|
||||
if($status == 1) {
|
||||
@@ -103,55 +106,37 @@ class UserController extends Controller {
|
||||
}
|
||||
return $stat;
|
||||
})
|
||||
/* column last login date */
|
||||
->addColumn('lastlogin', function ($model) {
|
||||
$t = $model->updated_at;
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* column actions */
|
||||
->addColumn('Actions', function ($model) {
|
||||
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id .'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->user_name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="'.route('user.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return type Response
|
||||
* Show the form for creating a new users.
|
||||
* @return type view
|
||||
*/
|
||||
public function create() {
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.create');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* Store a newly created users in storage.
|
||||
* @param type User $user
|
||||
* @param type Sys_userRequest $request
|
||||
* @return type Response
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(User $user, Sys_userRequest $request) {
|
||||
try {
|
||||
/* insert the input request to sys_user table */
|
||||
/* Check whether function success or not */
|
||||
$user->email = $request->input('email');
|
||||
@@ -162,24 +147,21 @@ class UserController extends Controller {
|
||||
$user->active = $request->input('active');
|
||||
$user->internal_note = $request->input('internal_note');
|
||||
$user->role = 'user';
|
||||
if ($user->save() == true) {
|
||||
try {
|
||||
$user->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Created Successfully');
|
||||
} else {
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Create');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Create');
|
||||
}
|
||||
return redirect('user')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
* Display the specified users.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, User $user) {
|
||||
try {
|
||||
@@ -203,89 +185,71 @@ class UserController extends Controller {
|
||||
$users = $user->whereId($id)->first();
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* Update the specified user in storage.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @param type Sys_userUpdate $request
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, User $user, Sys_userUpdate $request) {
|
||||
try {
|
||||
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
/* Update the value by selected field */
|
||||
/* Check whether function success or not */
|
||||
if ($users->fill($request->input())->save() == true) {
|
||||
try{
|
||||
$users->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Updated Successfully');
|
||||
} else {
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Update');
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Update');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @return type Response
|
||||
*/
|
||||
public function destroy($id, User $user) {
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
/* delete the selected field */
|
||||
/* Check whether function success or not */
|
||||
if ($users->delete() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Deleted Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Delete');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', 'User can not Delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile page
|
||||
* @return type Response
|
||||
* get agent profile page
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfile() {
|
||||
$user = Auth::user();
|
||||
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
|
||||
}
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
|
||||
} catch(Exception $e) {
|
||||
return redirect()->back()->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile edit page
|
||||
* @return type Response
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfileedit() {
|
||||
$user = Auth::user();
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails',$e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* post profile page
|
||||
* post profile edit
|
||||
* @param type int $id
|
||||
* @param type ProfileRequest $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfileedit(ProfileRequest $request) {
|
||||
// geet authenticated user details
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
// checking availability of agent profile ppicture
|
||||
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
|
||||
if ($request->input('gender') == 1) {
|
||||
$name = 'avatar5.png';
|
||||
@@ -297,17 +261,26 @@ class UserController extends Controller {
|
||||
$user->profile_pic = $name;
|
||||
}
|
||||
}
|
||||
// checking if the post system includes agent profile picture upload
|
||||
if (Input::file('profile_pic')) {
|
||||
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
|
||||
// fetching picture name
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
// fetching upload destination path
|
||||
$destinationPath = 'lb-faveo/profilepic';
|
||||
// adding a random value to profile picture filename
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
//echo $fileName;
|
||||
// moving the picture to a destination folder
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
// saving filename to database
|
||||
$user->profile_pic = $fileName;
|
||||
} else {
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
try{
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
} catch (Exception $e){
|
||||
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
|
||||
}
|
||||
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
@@ -318,22 +291,27 @@ class UserController extends Controller {
|
||||
* Post profile password
|
||||
* @param type int $id
|
||||
* @param type ProfilePassword $request
|
||||
* @return type Response
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfilePassword($id, ProfilePassword $request) {
|
||||
// get authenticated user
|
||||
$user = Auth::user();
|
||||
//echo $user->password;
|
||||
// checking if the old password matches the new password
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
$user->password = Hash::make($request->input('new_password'));
|
||||
$user->save();
|
||||
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
|
||||
try{
|
||||
$user->save();
|
||||
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} else {
|
||||
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User Assign Org
|
||||
* Assigning an user to an organization
|
||||
* @param type $id
|
||||
* @return type boolean
|
||||
*/
|
||||
@@ -347,21 +325,21 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* user create organisation
|
||||
* @return type value
|
||||
* creating an organization in user profile page via modal popup
|
||||
* @param type $id
|
||||
* @return type
|
||||
*/
|
||||
public function User_Create_Org($id) {
|
||||
|
||||
// checking if the entered value for website is available in database
|
||||
if(Input::get('website')!=null) {
|
||||
// checking website
|
||||
$check = Organization::where('website','=',Input::get('website'))->first();
|
||||
} else {
|
||||
$check = null;
|
||||
}
|
||||
|
||||
// checking name
|
||||
// checking if the name is unique
|
||||
$check2 = Organization::where('name','=',Input::get('name'))->first();
|
||||
|
||||
// if any of the fields is not available then return false
|
||||
if (\Input::get('name') == null) {
|
||||
return "Name is required";
|
||||
} elseif($check2 != null) {
|
||||
@@ -369,6 +347,7 @@ class UserController extends Controller {
|
||||
} elseif($check != null) {
|
||||
return "Website should be Unique";
|
||||
} else {
|
||||
// storing organization details and assigning the current user to that organization
|
||||
$org = new Organization;
|
||||
$org->name = Input::get('name');
|
||||
$org->phone = Input::get('phone');
|
||||
@@ -381,7 +360,7 @@ class UserController extends Controller {
|
||||
$user_org->org_id = $org->id;
|
||||
$user_org->user_id = $id;
|
||||
$user_org->save();
|
||||
|
||||
// for success return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user