This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -0,0 +1,325 @@
<?php
namespace App\Http\Controllers\Agent\helpdesk\Filter;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Filters\Label;
use App\Model\helpdesk\Filters\Filter;
use App\Model\helpdesk\Ticket\Tickets;
use DB;
use Auth;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use Datatables;
class FilterController extends Controller {
protected $request;
public function __construct(Request $req) {
$this->middleware(['auth', 'role.agent']);
$this->request = $req;
}
public function getFilter(Request $request) {
$labels = $this->request->input('labels');
$tags = $this->request->input('tags');
if($request->has('department')) {
$table = $this->departmentTickets($request->input('department'), $request->input('status'));
} else {
$segment = $this->request->input('segment');
$table = $this->segments($segment);
}
$tickets = [];
$render = false;
if (is_array($labels) && count($labels) > 0) {
$table = $table
->leftJoin('filters as label',function($join){
$join->on('tickets.id', '=', 'label.ticket_id')
->where('label.key','=','label');
})
->whereIn('label.value',$labels);
}
if (is_array($tags) && count($tags) > 0) {
$table = $table
->leftJoin('filters as tag',function($join){
$join->on('tickets.id', '=', 'tag.ticket_id')
->where('tag.key','=','tag');
})
->whereIn('tag.value',$tags);
}
if((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)){
$render = true;
}
// return \Datatables::of($table)->make();
return \Ttable::getTable($table);
}
public function filterByKey($key,$labels = []) {
$filter = new Filter();
$query = $filter->where('key', $key)
->where(function($query) use($labels) {
if (is_array($labels) && count($labels) > 0) {
for ($i = 0; $i < count($labels); $i++) {
$query->orWhere('value', 'LIKE', '%' . $labels[$i] . '%');
}
}
})
->lists('ticket_id')
->toArray();
return $query;
}
public function segments($segment){
if (strpos($segment, "user") !== false) {
return $this->formatUserTickets($segment);
}
$table = $this->table();
switch($segment){
case "/ticket/inbox":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.id', [1, 7]);
});
case "/ticket/closed":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status')
->whereIn('ticket_status.state',['closed']);
});
case "/ticket/myticket":
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->orWhere('tickets.assigned_to', '=', Auth::user()->id)
->where('tickets.status','=',1 );
case "/unassigned":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.assigned_to', '=', null)
->where('tickets.status','=',1 );
case "/ticket/overdue":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0)
->whereNotNull('tickets.duedate')
->where('tickets.duedate','!=', '00-00-00 00:00:00')
// ->where('duedate','>',\Carbon\Carbon::now());
->where('tickets.duedate','<', \Carbon\Carbon::now());
case "/ticket/approval/closed":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status')
->where('tickets.status','=',7 );
});
case "/trash":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status')
->where('tickets.status','=',5 );
});
case "/ticket/answered":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status')
->where('tickets.status','=',1 )
->where('tickets.isanswered', '=', 1);
});
case "/ticket/assigned":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.assigned_to', '>', 0)
->where('tickets.status','=',1 );
case "/ticket/open":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.status','=',1 );
case "/duetoday":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.status','=',1 )
->whereNotNull('tickets.duedate')
->whereDate('tickets.duedate','=', \Carbon\Carbon::now()->format('Y-m-d'));
case "/ticket/followup":
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0)
->where('tickets.follow_up', '=', 1);
}
}
public function table(){
// if (Auth::user()->role == 'admin') {
$ticket = new Tickets();
$tickets = $ticket
->leftJoin('ticket_thread', function ($join) {
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
->whereNotNull('title')
->where('ticket_thread.is_internal', '<>', 1);
})
->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source')
->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->leftJoin('users as u', 'u.id', '=', 'tickets.user_id')
->leftJoin('users as u1', 'u1.id', '=', 'tickets.assigned_to')
->leftJoin('ticket_attachment', 'ticket_attachment.thread_id', '=', 'ticket_thread.id')
->leftJoin('ticket_collaborator', 'ticket_collaborator.ticket_id', '=', 'tickets.id')
->select(
'tickets.id',
'ticket_thread.title',
'tickets.ticket_number',
'ticket_priority.priority',
'u.user_name as user_name',
'u1.user_name as assign_user_name',
\DB::raw('max(ticket_thread.updated_at) as updated_at'),
\DB::raw('min(ticket_thread.updated_at) as created_at'),
'tickets.priority_id', 'tickets.assigned_to',
DB::raw('COUNT(ticket_thread.updated_at) as countthread'),
'ticket_priority.priority_color',
'u.first_name as first_name',
'u.last_name as last_name',
'u1.first_name as assign_first_name',
'u1.last_name as assign_last_name',
'tickets.status',
'tickets.user_id',
DB::raw('COUNT(ticket_attachment.thread_id) as countattachment'),
DB::raw('COUNT(ticket_collaborator.ticket_id) as countcollaborator'),
'ticket_status.name as tickets_status',
'ticket_source.css_class as css',
DB::raw('substring_index(group_concat(ticket_thread.poster order by ticket_thread.id desc) , ",", 1) as last_replier'),
DB::raw('substring_index(group_concat(ticket_thread.title order by ticket_thread.id asc) , ",", 1) as ticket_title'),
'u.active as verified')
->groupby('tickets.id');
return $tickets;
}
public function filter($render,$ticket_id=[]){
if (Auth::user()->role == 'admin') {
$tickets = Tickets::whereIn('status', array(1, 7));
} else {
$dept = DB::table('department')->where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::whereIn('status', array(1, 7))->where('dept_id', '=', $dept->id);
}
if($render==true){
$tickets = $tickets->whereIn('id',$ticket_id);
}
return $tickets;
}
public function ticketController(){
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket_controller = new TicketController($PhpMailController, $NotificationController);
return $ticket_controller;
}
public function departmentTickets($dept, $status)
{
$table = $this->table();
return $table->leftJoin('department as dep', 'tickets.dept_id', '=', 'dep.id')
->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('dep.name',$dept)
->where('ticket_status.name',$status);
}
/**
*@category function to format and return user tickets
*@param string $segment
*@return builder
*/
public function formatUserTickets($segment)
{
$convert_to_array = explode("/",$segment);
$user_id = $convert_to_array[2];
$user = \DB::table('users')->select('role', 'id')->where('id', '=', $user_id)->first();
$table = $this->table();
if ($user->role == 'user') {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.user_id', '=', $user->id)
->where('ticket_status.name',$convert_to_array[3]);
} else {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.assigned_to', '=', $user->id)
->where('ticket_status.name',$convert_to_array[3]);
}
return $table;
}
}

View File

@@ -4,12 +4,10 @@ namespace App\Http\Controllers\Agent\helpdesk;
use PhpImap\Mailbox;
class ImapMail extends Mailbox
{
public function get_overview($mailId)
{
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
class ImapMail extends Mailbox {
public function get_overview($mailId) {
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
return $overview;
}
@@ -18,14 +16,13 @@ class ImapMail extends Mailbox
* For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom".
*
* @param string $criteria See http://php.net/imap_search for a complete list of available criteria
*
* @return array mailsIds (or empty array)
*/
public function searchMailbox($criteria = 'ALL')
{
public function searchMailbox($criteria = 'ALL') {
//dd($this->getImapStream());
$mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID);
//dd($mailsIds);
return $mailsIds ? $mailsIds : [];
return $mailsIds ? $mailsIds : array();
}
}

View File

@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Agent\helpdesk;
// models
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic;
@@ -13,24 +12,24 @@ use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Thread;
// classes
use App\Model\helpdesk\Ticket\Tickets;
// classes
use App\Http\Controllers\Admin\MailFetch as Fetch;
/**
* MailController.
*
* @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(TicketWorkflowController $TicketWorkflowController)
{
public function __construct(TicketWorkflowController $TicketWorkflowController) {
$this->middleware('board');
$this->TicketWorkflowController = $TicketWorkflowController;
}
@@ -40,8 +39,7 @@ class MailController extends Controller
*
* @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) {
//dd($emails);
if ($settings_email->first()->email_fetching == 1) {
if ($settings_email->first()->all_emails == 1) {
@@ -62,8 +60,7 @@ class MailController extends Controller
*
* @return type string
*/
public function separate_reply($body)
{
public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
@@ -71,64 +68,51 @@ class MailController extends Controller
}
/**
*
* @param object $email
*
* @return int
* @return integer
*/
public function priority($email)
{
public function priority($email) {
$priority = $email->priority;
if (!$priority) {
$priority = $this->ticketController()->getSystemDefaultPriority();
}
return $priority;
}
/**
* get department.
*
* get department
* @param object $email
*
* @return int
* @return integer
*/
public function department($email)
{
public function department($email) {
$department = $email->department;
if (!$department) {
$department = $this->ticketController()->getSystemDefaultDepartment();
}
return $department;
}
/**
* get help topic.
*
* get help topic
* @param object $email
*
* @return int
* @return integer
*/
public function helptopic($email)
{
public function helptopic($email) {
//dd($email);
$helptopic = $email->help_topic;
if (!$helptopic) {
$helptopic = $this->ticketController()->getSystemDefaultHelpTopic();
}
return $helptopic;
}
/**
* get sla.
*
* get sla
* @param object $email
*
* @return int
* @return integer
*/
public function sla($email)
{
public function sla($email) {
$helptopic = $this->helptopic($email);
$help = Help_topic::where('id', '=', $helptopic)->first();
if ($help) {
@@ -137,26 +121,21 @@ class MailController extends Controller
if (!$sla) {
$sla = $this->ticketController()->getSystemDefaultSla();
}
return $sla;
}
/**
* get ticket controller.
*
* get ticket controller
* @return \App\Http\Controllers\Agent\helpdesk\TicketController
*/
public function ticketController()
{
public function ticketController() {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$controller = new TicketController($PhpMailController, $NotificationController);
return $controller;
}
public function fetch($email)
{
public function fetch($email) {
// dd($email);
if ($email) {
$username = $email->email_address;
@@ -167,30 +146,31 @@ class MailController extends Controller
$encryption = $email->fetching_encryption;
$cert = $email->mailbox_protocol;
$server = new Fetch($host, $port, $service);
if ($encryption != null || $encryption != '') {
if ($encryption != null || $encryption != "") {
$server->setFlag($encryption);
}
$server->setFlag($cert);
$server->setAuthentication($username, $password);
$date = date('d M Y', strtotime('-1 days'));
$date = date("d M Y", strToTime("-1 days"));
$messages = $server->search("SINCE \"$date\" UNSEEN");
$this->message($messages, $email);
}
}
public function message($messages, $email)
{
foreach ($messages as $message) {
$this->getMessageContent($message, $email);
public function message($messages, $email) {
if (count($messages) > 0) {
foreach ($messages as $message) {
$this->getMessageContent($message, $email);
}
}
}
public function getMessageContent($message, $email)
{
public function getMessageContent($message, $email) {
$body = $message->getMessageBody(true);
if (!$body) {
$body = $message->getMessageBody();
}
$body = $this->separateReply($body);
$subject = $message->getSubject();
$address = $message->getAddresses('reply-to');
if (!$address) {
@@ -202,8 +182,7 @@ class MailController extends Controller
$this->workflow($address, $subject, $body, $collaborators, $attachments, $email);
}
public function workflow($address, $subject, $body, $collaborator, $attachments, $email)
{
public function workflow($address, $subject, $body, $collaborator, $attachments, $email) {
$fromaddress = checkArray('address', $address[0]);
$fromname = checkArray('name', $address[0]);
$helptopic = $this->helptopic($email);
@@ -224,39 +203,49 @@ class MailController extends Controller
}
}
public function updateThread($ticket_number, $body, $attachments)
{
public function updateThread($ticket_number, $body, $attachments) {
$ticket_table = Tickets::where('ticket_number', '=', $ticket_number)->first();
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
$thread->body = $this->separate_reply($body);
$thread->save();
$this->saveAttachments($thread->id, $attachments);
\Log::info('Ticket has created : ', ['id' => $thread->ticket_id]);
if (file_exists(app_path('/FaveoStorage/Controllers/StorageController.php'))) {
try {
$storage = new \App\FaveoStorage\Controllers\StorageController();
$storage->saveAttachments($thread->id, $attachments);
} catch (\Exception $ex) {
loging('attachment', $ex->getMessage());
}
} else {
loging('attachment', 'FaveoStorage not installed');
}
\Log::info("Ticket has created : ", ['id' => $thread->ticket_id]);
}
public function saveAttachments($thread_id, $attachments = [])
{
public function saveAttachments($thread_id, $attachments = []) {
if (is_array($attachments) && count($attachments) > 0) {
foreach ($attachments as $attachment) {
$structure = $attachment->getStructure();
$disposition = 'ATTACHMENT';
if (isset($structure->disposition)) {
$disposition = $structure->disposition;
}
$filename = str_random(16).'-'.$attachment->getFileName();
$filename = str_random(16) . '-' . $attachment->getFileName();
$type = $attachment->getMimeType();
$size = $attachment->getSize();
$data = $attachment->getData();
//$path = storage_path('/');
//$attachment->saveToDirectory($path);
$this->manageAttachment($data, $filename, $type, $size, $disposition, $thread_id);
$this->updateBody($attachment, $thread_id, $filename);
}
}
}
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id)
{
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id) {
$upload = new Ticket_attachments();
$upload->file = $data;
$upload->thread_id = $thread_id;
@@ -269,30 +258,25 @@ class MailController extends Controller
}
}
public function updateBody($attachment, $thread_id, $filename)
{
public function updateBody($attachment, $thread_id, $filename) {
$structure = $attachment->getStructure();
$disposition = 'ATTACHMENT';
if (isset($structure->disposition)) {
$disposition = $structure->disposition;
}
if ($disposition == 'INLINE') {
$id = str_replace('>', '', str_replace('<', '', $structure->id));
if ($disposition == 'INLINE' || $disposition == 'inline') {
$id = str_replace(">", "", str_replace("<", "", $structure->id));
//$filename = $attachment->getFileName();
$path = public_path('attachments');
$filepath = asset('attachments/'.$filename);
$threads = new Ticket_Thread();
$thread = $threads->find($thread_id);
$body = $thread->body;
$body = str_replace('cid:'.$id, $filename, $body);
$body = str_replace('cid:' . $id, $filename, $body);
$thread->body = $body;
$thread->save();
$attachment->saveToDirectory($path);
}
}
public function collaburators($message, $email)
{
public function collaburators($message, $email) {
$this_address = $email->email_address;
$collaborator_cc = $message->getAddresses('cc');
//dd($collaborator_cc);
@@ -327,7 +311,6 @@ class MailController extends Controller
if (array_key_exists($this_address, $array)) {
unset($array[$this_address]);
}
return $array;
}
@@ -338,21 +321,35 @@ class MailController extends Controller
*
* @return type file
*/
public function get_data($id)
{
public function get_data($id) {
$attachment = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->first();
if (mime($attachment->type) == true) {
echo "<img src=data:$attachment->type;base64,".$attachment->file.'>';
echo "<img src=data:$attachment->type;base64," . $attachment->file . ">";
} else {
$file = base64_decode($attachment->file);
return response($file)
->header('Cache-Control', 'no-cache private')
->header('Content-Description', 'File Transfer')
->header('Content-Type', $attachment->type)
->header('Content-length', strlen($file))
->header('Content-Disposition', 'attachment; filename='.$attachment->name)
->header('Content-Disposition', 'attachment; filename=' . $attachment->name)
->header('Content-Transfer-Encoding', 'binary');
}
}
/**
* separate reply.
*
* @param type $body
*
* @return type string
*/
public function separateReply($body) {
$body2 = explode('---Reply above this line---', $body);
if (is_array($body2) && array_key_exists(0, $body2)) {
$body = $body2[0];
}
return $body;
}
}

View File

@@ -22,25 +22,23 @@ use View;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class NotificationController extends Controller
{
public function __construct(PhpMailController $PhpMailController)
{
class NotificationController extends Controller {
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
}
/**
* This function is for sending daily report/notification about the system.
* */
public function send_notification()
{
// dd('sdckjdsc');
public function send_notification() {
// dd('sdckjdsc');
//fetching email settings
$email = Email::where('id', '=', '1')->first();
//dd('yes');
$send = 0;
$date = [0];
// dd($date);
// dd($date);
// 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
@@ -48,22 +46,21 @@ class NotificationController extends Controller
if ($notification) {
$date = explode(' ', $notification->created_at);
}
// if (date('Y-m-d') !== $date[0]) {
// creating a daily notification log
// if (date('Y-m-d') !== $date[0]) {
// creating a daily notification log
$company = $this->company();
// Send notification details to admin
$send += $this->send_notification_to_admin($company);
// Send notification details to team lead
$send += $this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$send += $this->send_notification_to_manager($company);
// Send notification details to all the agents
$send += $this->send_notification_to_agent($company);
$company = $this->company();
// Send notification details to admin
$send += $this->send_notification_to_admin($company);
// Send notification details to team lead
$send += $this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$send += $this->send_notification_to_manager($company);
// Send notification details to all the agents
$send += $this->send_notification_to_agent($company);
//}
Log_notification::create(['log' => 'NOT-1']);
Log_notification::create(['log' => 'NOT-1']);
}
return $send;
}
@@ -74,31 +71,27 @@ class NotificationController extends Controller
*
* @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;
$user_name = $user->first_name . ' ' . $user->last_name;
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0');
$to = [
'name' => $user_name,
'email' => $email,
'name' => $user_name,
'email' => $email
];
$message = [
'subject' => 'Daily Report',
'subject' => 'Daily Report',
'scenario' => null,
'body' => $contents,
'body' => $contents
];
$job = new \App\Jobs\SendEmail($from, $to, $message);
$dispatch = $this->dispatch($job);
return $dispatch;
//return $this->PhpMailController->sendEmail($from,$to,$message);
return $this->PhpMailController->sendEmail($from, $to, $message);
}
}
@@ -107,8 +100,7 @@ class NotificationController extends Controller
*
* @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) {
@@ -118,22 +110,20 @@ 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;
$user_name = $user->first_name . ' ' . $user->last_name;
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0');
$to = [
'name' => $user_name,
'email' => $email,
'name' => $user_name,
'email' => $email
];
$message = [
'subject' => 'Daily Report',
'subject' => 'Daily Report',
'scenario' => null,
'body' => $contents,
'body' => $contents
];
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
return $this->PhpMailController->sendEmail($from, $to, $message);
}
}
}
@@ -144,8 +134,7 @@ class NotificationController extends Controller
*
* @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) {
@@ -155,22 +144,20 @@ 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;
$user_name = $user->first_name . ' ' . $user->last_name;
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]);
$contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0');
$to = [
'name' => $user_name,
'email' => $email,
'name' => $user_name,
'email' => $email
];
$message = [
'subject' => 'Daily Report',
'subject' => 'Daily Report',
'scenario' => null,
'body' => $contents,
'body' => $contents
];
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
return $this->PhpMailController->sendEmail($from, $to, $message);
}
}
}
@@ -181,29 +168,26 @@ class NotificationController extends Controller
*
* @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;
$user_name = $user->first_name . ' ' . $user->last_name;
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
$contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0');
$to = [
'name' => $user_name,
'email' => $email,
];
'name' => $user_name,
'email' => $email
];
$message = [
'subject' => 'Daily Report',
'subject' => 'Daily Report',
'scenario' => null,
'body' => $contents,
];
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
'body' => $contents
];
return $this->PhpMailController->sendEmail($from,$to,$message);
}
}
@@ -212,8 +196,7 @@ class NotificationController extends Controller
*
* @return type variable
*/
public function company()
{
public function company() {
// fetching comapny model
$company = Company::Where('id', '=', '1')->first();
// fetching company name
@@ -225,4 +208,5 @@ class NotificationController extends Controller
return $company;
}
}

View File

@@ -16,8 +16,8 @@ use App\Model\helpdesk\Agent_panel\User_org;
use App\User;
// classes
use Exception;
use Illuminate\Http\Request;
use Lang;
use Illuminate\Http\Request;
/**
* OrganizationController
@@ -61,16 +61,6 @@ class OrganizationController extends Controller
}
}
/**
* This function is used autofill organizations name .
*
* @return datatable
*/
public function organizationAutofill()
{
return view('themes.default1.agent.helpdesk.organization.getautocomplete');
}
/**
* This function is used to display the list of Organizations.
*
@@ -339,16 +329,24 @@ class OrganizationController extends Controller
return '['.$last.']';
}
public function getOrgAjax(Request $request)
{
public function getOrgAjax(Request $request){
$org = new Organization();
$q = $request->input('term');
$orgs = $org->where('name', 'LIKE', '%'.$q.'%')
->select('name as label', 'id as value')
$orgs = $org->where('name','LIKE','%'.$q.'%')
->select('name as label','id as value')
->get()
->toJson();
return $orgs;
}
/**
* This function is used autofill organizations name .
*
* @return datatable
*/
public function organizationAutofill()
{
return view('themes.default1.agent.helpdesk.organization.getautocomplete');
}
}

View File

@@ -6,9 +6,9 @@ namespace App\Http\Controllers\Agent\helpdesk;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Manage\Help_topic;
// request
use App\Model\helpdesk\Ticket\Tickets;
// Model
use Illuminate\Http\Request;
// Model
use App\Model\helpdesk\Ticket\Tickets;
// classes
use PDF;
@@ -18,8 +18,8 @@ use PDF;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class ReportController extends Controller
{
class ReportController extends Controller {
/**
* Create a new controller instance.
* constructor to check
@@ -29,8 +29,7 @@ class ReportController extends Controller
*
* @return void
*/
public function __construct()
{
public function __construct() {
// checking for authentication
$this->middleware('auth');
// checking if the role is agent
@@ -39,26 +38,23 @@ class ReportController extends Controller
/**
* Get the Report page.
*
* @return type view
*/
public function index()
{
public function index() {
try {
return view('themes.default1.agent.helpdesk.report.index');
} catch (Exception $e) {
}
}
/**
* function to get help_topic graph.
*
* function to get help_topic graph
* @param type $date111
* @param type $date122
* @param type $helptopic
*/
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '')
{
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '') {
$date11 = strtotime($date122);
$date12 = strtotime($date111);
$help_topic = $helptopic;
@@ -77,24 +73,25 @@ class ReportController extends Controller
$format = 'Y-m-d';
// generating a date range of 1 month
if ($request->input('duration') == 'day') {
$date1 = strtotime(date($format, strtotime('-15 day'.$date3)));
$date1 = strtotime(date($format, strtotime('-15 day' . $date3)));
} elseif ($request->input('duration') == 'week') {
$date1 = strtotime(date($format, strtotime('-69 days'.$date3)));
$date1 = strtotime(date($format, strtotime('-69 days' . $date3)));
} elseif ($request->input('duration') == 'month') {
$date1 = strtotime(date($format, strtotime('-179 days'.$date3)));
$date1 = strtotime(date($format, strtotime('-179 days' . $date3)));
} else {
$date1 = strtotime(date($format, strtotime('-30 days'.$date3)));
$date1 = strtotime(date($format, strtotime('-30 days' . $date3)));
}
// $help_topic = Help_topic::where('status', '=', '1')->min('id');
}
$return = '';
$last = '';
$j = 0;
$created1 = '';
$closed1 = '';
$reopened1 = '';
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status', '=', 1)->count();
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status','=',1)->count();
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
$j++;
@@ -106,15 +103,15 @@ class ReportController extends Controller
if ($request->input('open') || $request->input('closed') || $request->input('reopened')) {
if ($request->input('open') && $request->input('open') == 'on') {
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$open_array = ['open' => $created];
}
if ($request->input('closed') && $request->input('closed') == 'on') {
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed_array = ['closed' => $closed];
}
if ($request->input('reopened') && $request->input('reopened') == 'on') {
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened_array = ['reopened' => $reopened];
}
// if ($request->input('overdue') && $request->input('overdue') == 'on') {
@@ -134,14 +131,14 @@ class ReportController extends Controller
// }
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
$return .= $json . ',';
} else {
if ($duration == 'week') {
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$created1 += $created;
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed1 += $closed;
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened1 += $reopened;
if ($j % 7 == 0) {
$open_array = ['open' => $created1];
@@ -161,14 +158,14 @@ class ReportController extends Controller
// }
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
$return .= $json . ',';
}
} elseif ($duration == 'month') {
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$created1 += $created_month;
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed1 += $closed_month;
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened1 += $reopened_month;
if ($j % 30 == 0) {
$open_array = ['open' => $created1];
@@ -186,17 +183,17 @@ class ReportController extends Controller
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
$return .= $json . ',';
}
} else {
if ($request->input('default') == null) {
$help_topic = Help_topic::where('status', '=', '1')->min('id');
}
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$open_array = ['open' => $created];
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed_array = ['closed' => $closed];
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened_array = ['reopened' => $reopened];
if ($j % 1 == 0) {
$open_array = ['open' => $created];
@@ -235,7 +232,7 @@ class ReportController extends Controller
// }
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
$return .= $json . ',';
}
}
}
@@ -250,19 +247,20 @@ class ReportController extends Controller
// if($reopened_array) {
// $value = array_merge($value,$reopened_array);
// }
}
$last = rtrim($return, ',');
return '['.$last.']';
return '[' . $last . ']';
}
public function helptopicPdf(Request $request)
{
public function helptopicPdf(Request $request){
$table_datas = json_decode($request->input('pdf_form'));
$table_help_topic = json_decode($request->input('pdf_form_help_topic'));
$html = view('themes.default1.agent.helpdesk.report.pdf', compact('table_datas', 'table_help_topic'))->render();
$html1 = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
return PDF::load($html1)->show();
}
}

View File

@@ -1,146 +0,0 @@
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
// models
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Ticket\Tickets;
use App\User;
use Auth;
// classes
use Ttable;
/**
* TicketController2.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class Ticket2Controller extends Controller
{
/**
* Create a new controller instance.
*
* @return type response
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the Inbox ticket list page.
*
* @return type response
*/
public function deptopen($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
}
}
/**
* this function returns the list of open tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function getOpenTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->get();
}
return Ttable::getTable($tickets);
}
/**
* Show the Inbox ticket list page.
*
* @return type response
*/
public function deptclose($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
}
}
/**
* this function returns the list of close tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function getCloseTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', '2')->where('status', '=', '3')->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', '2')->where('status', '=', '3')->where('dept_id', '=', $dept->id)->get();
}
return Ttable::getTable($tickets);
}
/**
* this function returns the list of close tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function deptinprogress($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
}
}
/**
*Show the list of In process tickets.
*
*@param $id int
*/
public function getInProcessTickets($id)
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $id)->get();
} else {
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $dept->id)->get();
}
return Ttable::getTable($tickets);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -166,7 +166,7 @@ class TicketWorkflowController extends Controller
}
}
}
//dd($form_data);
if ($ticket_settings_details['reject'] == true) {
return ['0' => false, '1' => false];
@@ -287,7 +287,7 @@ class TicketWorkflowController extends Controller
*/
public function checkStarts($statement, $to_check)
{
if (substr($to_check, 0, strlen($statement)) == $statement) {
if (substr($to_check, 0, strlen($statement)) == $statement) {
return true;
} else {
return false;
@@ -305,7 +305,7 @@ class TicketWorkflowController extends Controller
public function checkEnds($statement, $to_check)
{
$to_check = strip_tags($to_check);
if (substr($to_check, -strlen($statement)) == $statement) {
if (substr($to_check, -strlen($statement)) == $statement) {
return true;
} else {
return false;
@@ -352,7 +352,6 @@ class TicketWorkflowController extends Controller
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
}
}
return $ticket_settings_details;
}

File diff suppressed because it is too large Load Diff

View File

@@ -65,7 +65,7 @@ class ArticleController extends Controller
$article = new Article();
$articles = $article
->select('id', 'name', 'description', 'publish_time', 'slug')
->orderBy('publish_time', 'desc')
->orderBy('publish_time','desc')
->get();
// returns chumper datatable
return Datatable::Collection($articles)

View File

@@ -77,7 +77,6 @@ class CategoryController extends Controller
/* add column name */
->addColumn('name', function ($model) {
$string = strip_tags($model->name);
return str_limit($string, 20);
})
/* add column Created */
@@ -121,7 +120,7 @@ class CategoryController extends Controller
public function create(Category $category)
{
/* Get the all attributes in the category model */
$category = $category->lists('name', 'id')->toArray();
$category = $category->lists('name','id')->toArray();
/* get the view page to create new category with all attributes
of category model */
try {
@@ -148,7 +147,6 @@ class CategoryController extends Controller
// send success message to index page
try {
$category->fill($request->input())->save();
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
} catch (Exception $e) {
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>');
@@ -167,9 +165,9 @@ class CategoryController extends Controller
{
/* get the atributes of the category model whose id == $id */
$category = Category::whereId($id)->first();
$categories = Category::lists('name', 'id')->toArray();
$categories = Category::lists('name','id')->toArray();
/* get the Edit page the selected category via id */
return view('themes.default1.agent.kb.category.edit', compact('category', 'categories'));
return view('themes.default1.agent.kb.category.edit', compact('category','categories'));
}
/**
@@ -193,7 +191,6 @@ class CategoryController extends Controller
try {
$category->slug = $slug;
$category->fill($request->input())->save();
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
} catch (Exception $e) {
//redirect to index with fails message

View File

@@ -144,13 +144,11 @@ class SettingsController extends Controller
$name = "<p>$model->name</p><br>";
$email = "<p>$model->email</p><br>";
$website = "<p>$model->website</p><br>";
return $name.$email.$website;
})
->addColumn('comment', function ($model) {
$created = TicketController::usertimezone(date($model->created_at));
$created = TicketController::usertimezone(date($model->created_at));
return $model->comment."<p>$created</p>";
})
->addColumn('status', function ($model) {
@@ -161,7 +159,7 @@ class SettingsController extends Controller
return '<p style="color:red"">'.\Lang::get('lang.not_published');
}
})
->addColumn('Actions', function ($model) {
return '<div class="row"><div class="col-md-12"><a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a></div><div class="col-md-12"><a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a></div></div>';
})