Applied fixes from StyleCI

This commit is contained in:
Sujit Prasad
2016-02-19 02:20:12 -05:00
committed by StyleCI Bot
parent be5df5334f
commit d637c2b23f
439 changed files with 19063 additions and 19210 deletions

View File

@@ -14,25 +14,25 @@ use App\User;
use Exception;
/**
* CannedController
* CannedController.
*
* This controller is for all the functionalities of Canned response for Agents in the Agent Panel
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class CannedController extends Controller {
class CannedController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* 3. roles must be agent.
*
* @return void
*/
public function __construct() {
public function __construct()
{
// checking authentication
$this->middleware('auth');
// checking if role is agent
@@ -41,27 +41,34 @@ class CannedController extends Controller {
/**
* Display a listing of the Canned Responses.
*
* @return type View
*/
public function index() {
public function index()
{
return view('themes.default1.agent.helpdesk.canned.index');
}
/**
* Show the form for creating a new Canned Response
* Show the form for creating a new Canned Response.
*
* @return type View
*/
public function create() {
public function create()
{
return view('themes.default1.agent.helpdesk.canned.create');
}
/**
* Store a newly created Canned Response.
* @param type CannedRequest $request
* @param type Canned $canned
*
* @param type CannedRequest $request
* @param type Canned $canned
*
* @return type Redirect
*/
public function store(CannedRequest $request, Canned $canned) {
public function store(CannedRequest $request, Canned $canned)
{
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
@@ -69,6 +76,7 @@ class CannedController extends Controller {
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]);
@@ -77,24 +85,31 @@ class CannedController extends Controller {
/**
* Show the form for editing the Canned Response.
* @param type $id
* @param type Canned $canned
*
* @param type $id
* @param type Canned $canned
*
* @return type View
*/
public function edit($id, Canned $canned) {
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 Canned Response in database.
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
*
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
*
* @return type Redirect
*/
public function update($id, CannedUpdateRequest $request, Canned $canned) {
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
@@ -104,6 +119,7 @@ class CannedController extends Controller {
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]);
@@ -112,11 +128,14 @@ class CannedController extends Controller {
/**
* Delete the Canned Response from storage.
* @param type $id
* @param type Canned $canned
*
* @param type $id
* @param type Canned $canned
*
* @return type Redirect
*/
public function destroy($id, Canned $canned) {
public function destroy($id, Canned $canned)
{
/* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first();
/* delete the selected field */
@@ -133,20 +152,22 @@ class CannedController extends Controller {
/**
* Fetch Canned Response in the ticket detail page.
* @param type $id
*
* @param type $id
*
* @return type json
*/
public function get_canned($id) {
public function get_canned($id)
{
// checking for the canned response with requested value
if ($id != "zzz") {
if ($id != 'zzz') {
// fetching canned response
$canned = Canned::where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
$msg = $canned->message;
} else {
$msg = "";
$msg = '';
}
// returning the canned response in JSON format
return \Response::json($msg);
}
}

View File

@@ -5,35 +5,32 @@ 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 DB;
use Exception;
use View;
/**
* DashboardController
* This controlleris used to fetch dashboard in the agent panel
* This controlleris used to fetch dashboard in the agent panel.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class DashboardController extends Controller {
class DashboardController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* 3. roles must be agent.
*
* @return void
*/
public function __construct() {
public function __construct()
{
// checking for authentication
$this->middleware('auth');
// checking if the role is agent
@@ -41,12 +38,14 @@ class DashboardController extends Controller {
}
/**
* Get the dashboard page
* Get the dashboard page.
*
* @return type view
*/
public function index() {
public function index()
{
// if(Auth::user()->role == "user"){
// return \Redirect::route('home');
// return \Redirect::route('home');
// }
try {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
@@ -56,10 +55,12 @@ class DashboardController extends Controller {
}
/**
* Fetching dashboard graph data to implement graph
* Fetching dashboard graph data to implement graph.
*
* @return type Json
*/
public function ChartData($date111 = "", $date122 = "") {
public function ChartData($date111 = '', $date122 = '')
{
$date11 = strtotime($date122);
$date12 = strtotime($date111);
if ($date11 && $date12) {
@@ -67,29 +68,29 @@ class DashboardController extends Controller {
$date1 = $date11;
} else {
// generating current date
$date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d');
$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)));
$date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
}
$return = "";
$last = "";
$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();
$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 . ',';
$return .= $json.',';
}
$last = rtrim($return, ',');
return '[' . $last . ']';
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'),
@@ -99,5 +100,4 @@ class DashboardController extends Controller {
// ->get();
// return $ticketlist;
}
}

View File

@@ -3,57 +3,50 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App;
// models
use App\User;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic;
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\Settings\Ticket;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
// classes
use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
use \ForceUTF8\Encoding;
use App;
use DB;
use App\Model\helpdesk\Utility\MailboxProtocol;
use Crypt;
use Schedule;
use File;
use Artisan;
use Exception;
use ForceUTF8\Encoding;
use PhpImap\Mailbox as ImapMailbox;
/**
* MailController
* MailController.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class MailController extends Controller {
class MailController extends Controller
{
/**
* constructor
* Create a new controller instance.
*
* @param type TicketController $TicketController
*/
public function __construct(TicketController $TicketController) {
public function __construct(TicketController $TicketController)
{
$this->TicketController = $TicketController;
}
/**
* Reademails
* Reademails.
*
* @return type
*/
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) {
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket)
{
// $path_url = $system->first()->url;
if ($settings_email->first()->email_fetching == 1) {
if ($settings_email->first()->all_emails == 1) {
@@ -86,11 +79,11 @@ class MailController extends Controller {
$protocol = $e_mail->mailbox_protocol;
$get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol)->first();
$protocol = $get_mailboxprotocol->value;
$imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
$password = Crypt::decrypt($e_mail->password);
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day")));
$mails = [];
$mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day')));
if (!$mailsIds) {
die('Mailbox is empty');
}
@@ -112,15 +105,15 @@ class MailController extends Controller {
}
$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_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;
} else {
$subject = "No Subject";
$subject = 'No Subject';
}
// dd($subject);
@@ -128,7 +121,7 @@ class MailController extends Controller {
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
$source = $ticket_source->id;
$phone = "";
$phone = '';
$assign = $get_helptopic->auto_assign;
$form_data = null;
@@ -141,7 +134,7 @@ class MailController extends Controller {
$thread_id = $thread_id;
foreach ($mail->getAttachments() as $attachment) {
$support = "support";
$support = 'support';
// echo $_SERVER['DOCUMENT_ROOT'];
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
@@ -150,7 +143,7 @@ class MailController extends Controller {
// var_dump($attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
$path = public_path() . $filepath[1];
$path = public_path().$filepath[1];
// dd($path);
$filesize = filesize($path);
$file_data = file_get_contents($path);
@@ -159,28 +152,28 @@ class MailController extends Controller {
$string = str_replace('-', '', $attachment->name);
$filename = explode('src', $attachment->filePath);
$filename = str_replace('\\', '', $filename);
$body = str_replace("cid:" . $imageid, $filepath[1], $body);
$body = str_replace('cid:'.$imageid, $filepath[1], $body);
$pos = strpos($body, $filepath[1]);
if ($pos == false) {
if ($settings_email->first()->attachment == 1) {
$upload = new Ticket_attachments;
$upload = new Ticket_attachments();
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "ATTACHMENT";
$upload->poster = 'ATTACHMENT';
$upload->save();
}
} else {
$upload = new Ticket_attachments;
$upload = new Ticket_attachments();
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "INLINE";
$upload->poster = 'INLINE';
$upload->save();
}
unlink($path);
@@ -198,35 +191,45 @@ class MailController extends Controller {
}
/**
* separate reply
* @param type $body
* separate reply.
*
* @param type $body
*
* @return type string
*/
public function separate_reply($body) {
public function separate_reply($body)
{
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
return $body3;
}
/**
* Decode Imap text
* Decode Imap text.
*
* @param type $str
*
* @return type string
*/
public function decode_imap_text($str) {
public function decode_imap_text($str)
{
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) {
foreach ($decode_header as $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
/**
* fetch_attachments
* fetch_attachments.
*
* @return type
*/
public function fetch_attachments() {
public function fetch_attachments()
{
$uploads = Upload::all();
foreach ($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file);
@@ -234,24 +237,26 @@ class MailController extends Controller {
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
}
}
/**
* function to load data
* @param type $id
* function to load data.
*
* @param type $id
*
* @return type file
*/
public function get_data($id) {
public function get_data($id)
{
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
foreach ($attachments as $attachment) {
header('Content-type: application/' . $attachment->type . '');
header('Content-Disposition: inline; filename=' . $attachment->name . '');
header('Content-type: application/'.$attachment->type.'');
header('Content-Disposition: inline; filename='.$attachment->name.'');
header('Content-Transfer-Encoding: binary');
echo $attachment->file;
}
}
}

View File

@@ -5,38 +5,35 @@ namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// Model
use App\User;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Utility\Log_notification;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\settings\Email;
use App\Model\helpdesk\Utility\Log_notification;
use App\User;
// classes
use Exception;
/**
* NotificationController
* This controller is used to send daily notifications
* This controller is used to send daily notifications.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class NotificationController extends Controller {
class NotificationController extends Controller
{
/**
* This function is for sending daily report/notification about the system
* This function is for sending daily report/notification about the system.
* */
public function send_notification() {
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]) {
$date = explode(' ', $notification->created_at);
if (date('Y-m-d') == $date[0]) {
} else {
// creating a daily notification log
Log_notification::create(['log' => 'NOT-1']);
@@ -54,28 +51,33 @@ class NotificationController extends Controller {
}
/**
* Admin Notification/Report
* Admin Notification/Report.
*
* @param company
*
* @return mail
* */
public function send_notification_to_admin($company) {
public function send_notification_to_admin($company)
{
// 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) {
$message->to($email, $user_name)->subject($company . ' Daily Report ');
$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) {
$message->to($email, $user_name)->subject($company.' Daily Report ');
});
}
}
/**
* Department Manager Notification/Report
* Department Manager Notification/Report.
*
* @return mail
* */
public function send_notification_to_manager($company) {
public function send_notification_to_manager($company)
{
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
@@ -85,9 +87,9 @@ class NotificationController extends Controller {
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) {
$message->to($email, $user_name)->subject($company . ' Daily Report for department manager of ' . $dept_name . ' department.');
$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) {
$message->to($email, $user_name)->subject($company.' Daily Report for department manager of '.$dept_name.' department.');
});
}
}
@@ -95,10 +97,12 @@ class NotificationController extends Controller {
}
/**
* Team Lead Notification/Report
* Team Lead Notification/Report.
*
* @return mail
* */
public function send_notification_to_team_lead($company) {
public function send_notification_to_team_lead($company)
{
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
@@ -108,9 +112,9 @@ class NotificationController extends Controller {
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) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team ' . $team_name);
$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) {
$message->to($email, $user_name)->subject($company.' Daily Report for Team Lead of team '.$team_name);
});
}
}
@@ -118,35 +122,40 @@ class NotificationController extends Controller {
}
/**
* Agent Notification/Report
* Agent Notification/Report.
*
* @return mail
* */
public function send_notification_to_agent($company) {
public function send_notification_to_agent($company)
{
// 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) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Agents');
$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) {
$message->to($email, $user_name)->subject($company.' Daily Report for Agents');
});
}
}
/**
* Fetching company name
* 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";
$company = 'Support Center';
} else {
$company = $company->company_name;
}
return $company;
}

View File

@@ -6,13 +6,11 @@ namespace App\Http\Controllers\Agent\helpdesk;
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;
// classes
@@ -22,21 +20,21 @@ use Exception;
* OrganizationController
* This controller is used to CRUD organization detail.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class OrganizationController extends Controller {
class OrganizationController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* 3. roles must be agent.
*
* @return void
*/
public function __construct() {
public function __construct()
{
// checking for authentication
$this->middleware('auth');
// checking if the role is agent
@@ -45,10 +43,13 @@ class OrganizationController extends Controller {
/**
* Display a listing of the resource.
*
* @param type Organization $org
*
* @return type Response
*/
public function index() {
public function index()
{
try {
/* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index');
@@ -58,10 +59,12 @@ class OrganizationController extends Controller {
}
/**
* This function is used to display the list of Organizations
* This function is used to display the list of Organizations.
*
* @return datatable
*/
public function org_list() {
public function org_list()
{
// chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all())
/* searchable name */
@@ -73,28 +76,31 @@ class OrganizationController extends Controller {
// return $model->name;
if (strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')) . ' ...';
$orgname = substr($orgname, 0, strrpos($orgname, ' ')).' ...';
} else {
$orgname = $model->name;
}
return $orgname;
})
/* 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) {
// displaying action buttons
// 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>&nbsp;<a href="' . route('organizations.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<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 . '">
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>&nbsp;<a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp;<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">
@@ -102,11 +108,11 @@ class OrganizationController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
' . $model->user_name . '
'.$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>
<a href="'.route('org.delete', $model->id).'"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
@@ -117,9 +123,11 @@ class OrganizationController extends Controller {
/**
* Show the form for creating a new organization.
*
* @return type Response
*/
public function create() {
public function create()
{
try {
return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) {
@@ -129,11 +137,14 @@ class OrganizationController extends Controller {
/**
* Store a newly created organization in storage.
* @param type Organization $org
*
* @param type Organization $org
* @param type OrganizationRequest $request
*
* @return type Redirect
*/
public function store(Organization $org, OrganizationRequest $request) {
public function store(Organization $org, OrganizationRequest $request)
{
try {
/* Insert the all input request to organization table */
/* Check whether function success or not */
@@ -152,11 +163,14 @@ class OrganizationController extends Controller {
/**
* Display the specified organization.
* @param type $id
*
* @param type $id
* @param type Organization $org
*
* @return type view
*/
public function show($id, Organization $org) {
public function show($id, Organization $org)
{
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
@@ -169,11 +183,14 @@ class OrganizationController extends Controller {
/**
* Show the form for editing the specified organization.
* @param type $id
*
* @param type $id
* @param type Organization $org
*
* @return type view
*/
public function edit($id, Organization $org) {
public function edit($id, Organization $org)
{
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
@@ -186,12 +203,15 @@ class OrganizationController extends Controller {
/**
* Update the specified organization in storage.
* @param type $id
* @param type Organization $org
*
* @param type $id
* @param type Organization $org
* @param type OrganizationUpdate $request
*
* @return type Redirect
*/
public function update($id, Organization $org, OrganizationUpdate $request) {
public function update($id, Organization $org, OrganizationUpdate $request)
{
/* select the field by id */
$orgs = $org->whereId($id)->first();
@@ -213,10 +233,13 @@ class OrganizationController extends Controller {
/**
* Delete a specified organization from storage.
*
* @param type int $id
*
* @return type Redirect
*/
public function destroy($id, Organization $org, User_org $user_org) {
public function destroy($id, Organization $org, User_org $user_org)
{
/* select the field by id */
$orgs = $org->whereId($id)->first();
@@ -237,11 +260,14 @@ class OrganizationController extends Controller {
}
/**
* Soring an organization head
* @param type $id
* Soring an organization head.
*
* @param type $id
*
* @return type boolean
*/
public function Head_Org($id) {
public function Head_Org($id)
{
// get the user to make organization head
$head_user = \Input::get('user');
// get an instance of the selected organization
@@ -249,7 +275,7 @@ class OrganizationController extends Controller {
$org_head->head = $head_user;
// save the user to organization head
$org_head->save();
return 1;
}
}

View File

@@ -3,56 +3,39 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\SettingsController;use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CreateTicketRequest;
use App\Http\Requests\helpdesk\TicketRequest;
use App\Http\Requests\helpdesk\TicketEditRequest;
// models
use App\Model\helpdesk\Email\Banlist;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Agent\Department;
use App\User;
// classes
use Auth;
use Hash;
use Input;
use Mail;
use PDF;
/**
* TicketController2
* TicketController2.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class Ticket2Controller extends Controller {
class Ticket2Controller extends Controller
{
/**
* Create a new controller instance.
*
* @return type response
*/
public function __construct() {
public function __construct()
{
SettingsController::smtp();
$this->middleware('auth');
}
/**
* Show the Inbox ticket list page
* Show the Inbox ticket list page.
*
* @return type response
*/
public function deptopen($id) {
public function deptopen($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
@@ -66,10 +49,12 @@ class Ticket2Controller extends Controller {
}
/**
* Show the Inbox ticket list page
* Show the Inbox ticket list page.
*
* @return type response
*/
public function deptclose($id) {
public function deptclose($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
@@ -83,10 +68,12 @@ class Ticket2Controller extends Controller {
}
/**
* Show the Inbox ticket list page
* Show the Inbox ticket list page.
*
* @return type response
*/
public function deptinprogress($id) {
public function deptinprogress($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
@@ -98,5 +85,4 @@ class Ticket2Controller extends Controller {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,30 +19,30 @@ use App\Model\helpdesk\Agent_panel\User_org;
use App\User;
// classes
use Auth;
use Exception;
use Hash;
use Input;
use Redirect;
use Exception;
/**
* UserController
* This controller is used to CRUD an User details, and proile management of an agent
* This controller is used to CRUD an User details, and proile management of an agent.
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class UserController extends Controller {
class UserController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* 3. roles must be agent.
*
* @return void
*/
public function __construct() {
public function __construct()
{
// checking authentication
$this->middleware('auth');
// checking if role is agent
@@ -51,10 +51,13 @@ class UserController extends Controller {
/**
* Display all list of the users.
*
* @param type User $user
*
* @return type view
*/
public function index() {
public function index()
{
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
@@ -64,10 +67,12 @@ class UserController extends Controller {
}
/**
* This function is used to display the list of users using chumper datatables
* This function is used to display the list of users using chumper datatables.
*
* @return datatable
*/
public function user_list() {
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 */
@@ -78,28 +83,31 @@ class UserController extends Controller {
->addColumn('user_name', function ($model) {
if (strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')) . ' ...';
$username = substr($username, 0, strrpos($username, ' ')).' ...';
} else {
$username = $model->user_name;
}
return $username;
})
/* column email */
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
/* column phone */
->addColumn('phone', function ($model) {
$phone = "";
$phone = '';
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
$phone = $model->ext.' '.$model->phone_number;
}
$mobile = "";
$mobile = '';
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
$phone = $phone.'&nbsp;&nbsp;&nbsp;'.$mobile;
return $phone;
})
/* column account status */
@@ -110,6 +118,7 @@ class UserController extends Controller {
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
/* column ban status */
@@ -120,25 +129,29 @@ class UserController extends Controller {
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
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="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp; <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 users.
*
* @return type view
*/
public function create() {
public function create()
{
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
@@ -148,11 +161,14 @@ class UserController extends Controller {
/**
* Store a newly created users in storage.
* @param type User $user
*
* @param type User $user
* @param type Sys_userRequest $request
*
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
public function store(User $user, Sys_userRequest $request)
{
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
@@ -175,14 +191,18 @@ class UserController extends Controller {
/**
* Display the specified users.
*
* @param type int $id
* @param type User $user
*
* @return type view
*/
public function show($id, User $user) {
public function show($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
@@ -191,14 +211,18 @@ class UserController extends Controller {
/**
* Show the form for editing the specified resource.
* @param type int $id
*
* @param type int $id
* @param type User $user
*
* @return type Response
*/
public function edit($id, User $user) {
public function edit($id, User $user)
{
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
@@ -207,12 +231,15 @@ class UserController extends Controller {
/**
* Update the specified user in storage.
* @param type int $id
* @param type User $user
*
* @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) {
public function update($id, User $user, Sys_userUpdate $request)
{
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -229,10 +256,12 @@ class UserController extends Controller {
}
/**
* get agent profile page
* get agent profile page.
*
* @return type view
*/
public function getProfile() {
public function getProfile()
{
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
@@ -242,10 +271,12 @@ class UserController extends Controller {
}
/**
* get profile edit page
* get profile edit page.
*
* @return type view
*/
public function getProfileedit() {
public function getProfileedit()
{
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
@@ -255,12 +286,15 @@ class UserController extends Controller {
}
/**
* post profile edit
* @param type int $id
* post profile edit.
*
* @param type int $id
* @param type ProfileRequest $request
*
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
public function postProfileedit(ProfileRequest $request)
{
// geet authenticated user details
$user = Auth::user();
$user->gender = $request->input('gender');
@@ -284,7 +318,7 @@ class UserController extends Controller {
// fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name;
$fileName = rand(0000, 9999).'.'.$name;
// moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database
@@ -292,6 +326,7 @@ class UserController extends Controller {
} else {
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]);
@@ -303,19 +338,23 @@ class UserController extends Controller {
}
/**
* Post profile password
* @param type int $id
* Post profile password.
*
* @param type int $id
* @param type ProfilePassword $request
*
* @return type Redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
// get authenticated user
public function postProfilePassword($id, ProfilePassword $request)
{
// get authenticated user
$user = Auth::user();
// 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'));
try {
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
@@ -326,25 +365,32 @@ class UserController extends Controller {
}
/**
* Assigning an user to an organization
* @param type $id
* Assigning an user to an organization.
*
* @param type $id
*
* @return type boolean
*/
public function UserAssignOrg($id) {
public function UserAssignOrg($id)
{
$org = Input::get('org');
$user_org = new User_org;
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* creating an organization in user profile page via modal popup
* @param type $id
* creating an organization in user profile page via modal popup.
*
* @param type $id
*
* @return type
*/
public function User_Create_Org($id) {
public function User_Create_Org($id)
{
// checking if the entered value for website is available in database
if (Input::get('website') != null) {
// checking website
@@ -356,14 +402,14 @@ class UserController extends Controller {
$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";
return 'Name is required';
} elseif ($check2 != null) {
return "Name should be Unique";
return 'Name should be Unique';
} elseif ($check != null) {
return "Website should be Unique";
return 'Website should be Unique';
} else {
// storing organization details and assigning the current user to that organization
$org = new Organization;
$org = new Organization();
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
@@ -371,7 +417,7 @@ class UserController extends Controller {
$org->internal_notes = Input::get('internal');
$org->save();
$user_org = new User_org;
$user_org = new User_org();
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
@@ -379,5 +425,4 @@ class UserController extends Controller {
return 0;
}
}
}