Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2016-12-13 13:14:54 +00:00
committed by StyleCI Bot
parent 857d3004eb
commit 88f3df2180
161 changed files with 4729 additions and 3879 deletions

View File

@@ -2,30 +2,30 @@
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;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Filters\Filter;
use App\Model\helpdesk\Filters\Label;
use App\Model\helpdesk\Ticket\Tickets;
use Auth;
use DB;
use Illuminate\Http\Request;
class FilterController extends Controller {
class FilterController extends Controller
{
protected $request;
public function __construct(Request $req) {
public function __construct(Request $req)
{
$this->middleware(['auth', 'role.agent']);
$this->request = $req;
}
public function getFilter(Request $request) {
public function getFilter(Request $request)
{
$labels = $this->request->input('labels');
$tags = $this->request->input('tags');
if($request->has('department')) {
if ($request->has('department')) {
$table = $this->departmentTickets($request->input('department'), $request->input('status'));
} else {
$segment = $this->request->input('segment');
@@ -35,212 +35,216 @@ class FilterController extends Controller {
$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);
->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){
->leftJoin('filters as tag', function ($join) {
$join->on('tickets.id', '=', 'tag.ticket_id')
->where('tag.key','=','tag');
->where('tag.key', '=', 'tag');
})
->whereIn('tag.value',$tags);
->whereIn('tag.value', $tags);
}
if((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)){
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 = []) {
public function filterByKey($key, $labels = [])
{
$filter = new Filter();
$query = $filter->where('key', $key)
->where(function($query) use($labels) {
->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] . '%');
$query->orWhere('value', 'LIKE', '%'.$labels[$i].'%');
}
}
})
->lists('ticket_id')
->toArray();
return $query;
}
public function segments($segment){
if (strpos($segment, "user") !== false) {
public function segments($segment)
{
if (strpos($segment, 'user') !== false) {
return $this->formatUserTickets($segment);
}
$table = $this->table();
switch($segment){
case "/ticket/inbox":
switch ($segment) {
case '/ticket/inbox':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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":
case '/ticket/closed':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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']);
$join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.state', ['closed']);
});
case "/ticket/myticket":
case '/ticket/myticket':
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status');
})
$join->on('ticket_status.id', '=', 'tickets.status');
})
->orWhere('tickets.assigned_to', '=', Auth::user()->id)
->where('tickets.status','=',1 );
case "/unassigned":
->where('tickets.status', '=', 1);
case '/unassigned':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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');
})
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.assigned_to', '=', null)
->where('tickets.status','=',1 );
case "/ticket/overdue":
->where('tickets.status', '=', 1);
case '/ticket/overdue':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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');
$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('tickets.duedate', '!=', '00-00-00 00:00:00')
// ->where('duedate','>',\Carbon\Carbon::now());
->where('tickets.duedate','<', \Carbon\Carbon::now());
case "/ticket/approval/closed":
->where('tickets.duedate', '<', \Carbon\Carbon::now());
case '/ticket/approval/closed':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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 );
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 7);
});
case "/trash":
case '/trash':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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 );
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 5);
});
case "/ticket/answered":
case '/ticket/answered':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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 )
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 1)
->where('tickets.isanswered', '=', 1);
});
case "/ticket/assigned":
case '/ticket/assigned':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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');
})
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.assigned_to', '>', 0)
->where('tickets.status','=',1 );
case "/ticket/open":
->where('tickets.status', '=', 1);
case '/ticket/open':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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":
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1);
case '/duetoday':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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');
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status','=',1 )
->where('tickets.status', '=', 1)
->whereNotNull('tickets.duedate')
->whereDate('tickets.duedate','=', \Carbon\Carbon::now()->format('Y-m-d'));
case "/ticket/followup":
->whereDate('tickets.duedate', '=', \Carbon\Carbon::now()->format('Y-m-d'));
case '/ticket/followup':
if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt;
$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');
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0)
->where('tickets.follow_up', '=', 1);
}
}
public function table(){
public function table()
{
// if (Auth::user()->role == 'admin') {
$ticket = new Tickets();
$tickets = $ticket
$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',
@@ -254,7 +258,7 @@ class FilterController extends Controller {
'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.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',
@@ -268,58 +272,67 @@ class FilterController extends Controller {
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=[]){
public function filter($render, $ticket_id = [])
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::whereIn('status', array(1, 7));
$tickets = Tickets::whereIn('status', [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);
$tickets = Tickets::whereIn('status', [1, 7])->where('dept_id', '=', $dept->id);
}
if($render==true){
$tickets = $tickets->whereIn('id',$ticket_id);
if ($render == true) {
$tickets = $tickets->whereIn('id', $ticket_id);
}
return $tickets;
}
public function ticketController(){
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);
->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);
$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]);
->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]);
->where('ticket_status.name', $convert_to_array[3]);
}
return $table;
}
}

View File

@@ -4,10 +4,12 @@ namespace App\Http\Controllers\Agent\helpdesk;
use PhpImap\Mailbox;
class ImapMail extends Mailbox {
public function get_overview($mailId) {
class ImapMail extends Mailbox
{
public function get_overview($mailId)
{
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
return $overview;
}
@@ -16,13 +18,14 @@ 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 : array();
return $mailsIds ? $mailsIds : [];
}
}

View File

@@ -3,6 +3,7 @@
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;
@@ -12,24 +13,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;
use App\Model\helpdesk\Ticket\Tickets;
// classes
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Model\helpdesk\Ticket\Tickets;
/**
* 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;
}
@@ -39,7 +40,8 @@ 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) {
@@ -60,7 +62,8 @@ 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];
@@ -68,51 +71,64 @@ class MailController extends Controller {
}
/**
*
* @param object $email
* @return integer
*
* @return int
*/
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 integer
*
* @return int
*/
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 integer
*
* @return int
*/
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 integer
*
* @return int
*/
public function sla($email) {
public function sla($email)
{
$helptopic = $this->helptopic($email);
$help = Help_topic::where('id', '=', $helptopic)->first();
if ($help) {
@@ -121,21 +137,26 @@ 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;
@@ -146,18 +167,19 @@ 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) {
public function message($messages, $email)
{
if (count($messages) > 0) {
foreach ($messages as $message) {
$this->getMessageContent($message, $email);
@@ -165,7 +187,8 @@ class MailController extends Controller {
}
}
public function getMessageContent($message, $email) {
public function getMessageContent($message, $email)
{
$body = $message->getMessageBody(true);
if (!$body) {
$body = $message->getMessageBody();
@@ -182,7 +205,8 @@ 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);
@@ -203,7 +227,8 @@ 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();
@@ -220,20 +245,20 @@ class MailController extends Controller {
loging('attachment', 'FaveoStorage not installed');
}
\Log::info("Ticket has created : ", ['id' => $thread->ticket_id]);
\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();
@@ -245,7 +270,8 @@ class MailController extends Controller {
}
}
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;
@@ -258,25 +284,27 @@ 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' || $disposition == 'inline') {
$id = str_replace(">", "", str_replace("<", "", $structure->id));
$id = str_replace('>', '', str_replace('<', '', $structure->id));
//$filename = $attachment->getFileName();
$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();
}
}
public function collaburators($message, $email) {
public function collaburators($message, $email)
{
$this_address = $email->email_address;
$collaborator_cc = $message->getAddresses('cc');
//dd($collaborator_cc);
@@ -311,6 +339,7 @@ class MailController extends Controller {
if (array_key_exists($this_address, $array)) {
unset($array[$this_address]);
}
return $array;
}
@@ -321,18 +350,20 @@ 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');
}
}
@@ -344,12 +375,13 @@ class MailController extends Controller {
*
* @return type string
*/
public function separateReply($body) {
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,17 +22,19 @@ 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');
@@ -61,6 +63,7 @@ class NotificationController extends Controller {
//}
Log_notification::create(['log' => 'NOT-1']);
}
return $send;
}
@@ -71,24 +74,25 @@ 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,
];
return $this->PhpMailController->sendEmail($from, $to, $message);
@@ -100,7 +104,8 @@ 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) {
@@ -110,19 +115,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->PhpMailController->sendEmail($from, $to, $message);
}
}
@@ -134,7 +140,8 @@ 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) {
@@ -144,19 +151,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->PhpMailController->sendEmail($from, $to, $message);
}
}
@@ -168,26 +176,28 @@ 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
'body' => $contents,
];
return $this->PhpMailController->sendEmail($from,$to,$message);
return $this->PhpMailController->sendEmail($from, $to, $message);
}
}
@@ -196,7 +206,8 @@ 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
@@ -208,5 +219,4 @@ 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 Lang;
use Illuminate\Http\Request;
use Lang;
/**
* OrganizationController
@@ -329,24 +329,26 @@ 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
*/
* This function is used autofill organizations name .
*
* @return datatable
*/
public function organizationAutofill()
{
return view('themes.default1.agent.helpdesk.organization.getautocomplete');
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 Illuminate\Http\Request;
// Model
use App\Model\helpdesk\Ticket\Tickets;
// Model
use Illuminate\Http\Request;
// 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,7 +29,8 @@ class ReportController extends Controller {
*
* @return void
*/
public function __construct() {
public function __construct()
{
// checking for authentication
$this->middleware('auth');
// checking if the role is agent
@@ -38,23 +39,26 @@ 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;
@@ -73,25 +77,24 @@ 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++;
@@ -103,15 +106,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') {
@@ -131,14 +134,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];
@@ -158,14 +161,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];
@@ -183,17 +186,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];
@@ -232,7 +235,7 @@ class ReportController extends Controller {
// }
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json . ',';
$return .= $json.',';
}
}
}
@@ -247,20 +250,19 @@ 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();
}
}

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,6 +352,7 @@ class TicketWorkflowController extends Controller
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
}
}
return $ticket_settings_details;
}

View File

@@ -3,49 +3,44 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// requests
/* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword;
/* For validation include Sys_userRequest in create */
use App\Http\Requests\helpdesk\ProfileRequest;
/* For validation include Sys_userUpdate in update */
use App\Http\Requests\helpdesk\Sys_userRequest;
/* include guest_note model */
use App\Http\Requests\helpdesk\Sys_userUpdate;
use App\Http\Requests\helpdesk\OtpVerifyRequest;
// change password request
use App\Http\Requests\helpdesk\ChangepasswordRequest;
/* For validation include Sys_userRequest in create */
use App\Http\Requests\helpdesk\OtpVerifyRequest;
/* For validation include Sys_userUpdate in update */
use App\Http\Requests\helpdesk\ProfilePassword;
/* include guest_note model */
use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest;
// change password request
use App\Http\Requests\helpdesk\Sys_userUpdate;
// models
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Otp;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\User;
// classes
use Auth;
use DateTime;
use DB;
use Exception;
use GeoIP;
use Hash;
use Illuminate\Http\Request;
use Input;
use Lang;
use Redirect;
use Illuminate\Http\Request;
use DateTime;
use DB;
/**
* UserController
@@ -53,8 +48,8 @@ use DB;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class UserController extends Controller {
class UserController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
@@ -64,7 +59,8 @@ class UserController extends Controller {
*
* @return void
*/
public function __construct(PhpMailController $PhpMailController) {
public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController;
// checking authentication
$this->middleware('auth');
@@ -79,7 +75,8 @@ class UserController extends Controller {
*
* @return type view
*/
public function index() {
public function index()
{
try {
/* get all values in Sys_user */
@@ -93,13 +90,15 @@ class UserController extends Controller {
Lang::get('lang.role'),
Lang::get('lang.action')) // these are the column headings to be shown
->noScript();
return view('themes.default1.agent.helpdesk.user.index',compact('table'));
return view('themes.default1.agent.helpdesk.user.index', compact('table'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
public function deletedUser() {
public function deletedUser()
{
try {
// dd('here');
/* get all values in Sys_user */
@@ -109,30 +108,20 @@ class UserController extends Controller {
}
}
/**
* This function is used to display the list of users using chumper datatables.
*
* @return datatable
*/
public function user_list(Request $request) {
$type = $request->input('profiletype');
if($type=="active"){
$users=User::where('role', "!=", "admin")->where('is_delete','=',0)->get();
}
else{
$users=User::where('role', "!=", "admin")->where('is_delete','=',1)->get();
}
public function user_list(Request $request)
{
$type = $request->input('profiletype');
if ($type == 'active') {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 0)->get();
} else {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 1)->get();
}
// displaying list of users with chumper datatables
// return \Datatable::collection(User::where('role', "!=", "admin")->get())
@@ -144,7 +133,7 @@ else{
/* column username */
->addColumn('user_name', function ($model) {
if ($model->first_name) {
$string = strip_tags($model->first_name . ' ' . $model->last_name);
$string = strip_tags($model->first_name.' '.$model->last_name);
} else {
$string = strip_tags($model->user_name);
}
@@ -154,11 +143,12 @@ else{
} else {
$stringCut = $string;
}
return "<a href='" . route('user.show', $model->id) . "' title='".$string."''>".$stringCut."</a>";
return "<a href='".route('user.show', $model->id)."' title='".$string."''>".$stringCut.'</a>';
})
/* column email */
->addColumn('email', function ($model) {
$email = "<a href='" . route('user.show', $model->id) . "'>" . $model->email . '</a>';
$email = "<a href='".route('user.show', $model->id)."'>".$model->email.'</a>';
return $email;
})
@@ -166,13 +156,13 @@ else{
->addColumn('phone', function ($model) {
$phone = '';
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
$phone = $model->ext.' '.$model->phone_number;
}
$mobile = '';
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . '&nbsp;&nbsp;&nbsp;' . $mobile;
$phone = $phone.'&nbsp;&nbsp;&nbsp;'.$mobile;
return $phone;
})
@@ -207,46 +197,42 @@ else{
/* column Role */
->addColumn('role', function ($model) {
$role = $model->role;
return $role;
})
/* column actions */
->addColumn('Actions', function ($model) {
if($model->is_delete==0){
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>';
if ($model->is_delete == 0) {
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>';
} else {
if (Auth::user()->role == 'admin') {
// @if(Auth::user()->role == 'admin')
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
if (Auth::user()->role == 'agent') {
// @if(Auth::user()->role == 'admin')
if ($model->role == 'user') {
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
}
}
else{
if(Auth::user()->role == 'admin'){
// @if(Auth::user()->role == 'admin')
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
if(Auth::user()->role == 'agent'){
// @if(Auth::user()->role == 'admin')
if($model->role=="user"){
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
}
}
})
->make();
}
public function restoreUser($id)
public function restoreUser($id)
{
// dd($id);
// $delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first();
$users->is_delete=0;
$users->active=1;
$users->ban=0;
$users->is_delete = 0;
$users->active = 1;
$users->ban = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
}
/**
@@ -254,13 +240,15 @@ else{
*
* @return type view
*/
public function create(CountryCode $code) {
public function create(CountryCode $code)
{
try {
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
$location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
$org = Organization::lists('name', 'id')->toArray();
return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
@@ -275,7 +263,8 @@ else{
*
* @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 */
if ($request->input('email') != '') {
@@ -310,9 +299,9 @@ else{
}
// save user credentails
if ($user->save() == true) {
if ($request->input('org_id') != "") {
if ($request->input('org_id') != '') {
$orgid = $request->input('org_id');
$this->storeUserOrgRelation($user->id, $orgid);
$this->storeUserOrgRelation($user->id, $orgid);
}
// fetch user credentails to send mail
$name = $user->first_name;
@@ -332,6 +321,7 @@ else{
if (($request->input('active') == '0' || $request->input('active') == 0) || ($email_mandatory->status == '0') || $email_mandatory->status == 0) {
\Event::fire(new \App\Events\LoginEvent($request));
}
return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully'));
}
// $user->save();
@@ -344,17 +334,18 @@ else{
}
/**
* Random Password Genetor for users
* Random Password Genetor for users.
*
* @param type int $id
* @param type User $user
*
* @return type view
*/
public function randomPassword() {
public function randomPassword()
{
try {
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*(){}[]';
$pass = array(); //remember to declare $pass as an array
$pass = []; //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 10; $i++) {
$n = rand(0, $alphaLength);
@@ -369,14 +360,15 @@ else{
}
/**
* Random Password Genetor for users
* Random Password Genetor for users.
*
* @param type int $id
* @param type User $user
*
* @return type view
*/
public function randomPostPassword($id, ChangepasswordRequest $request) {
public function randomPostPassword($id, ChangepasswordRequest $request)
{
try {
$changepassword = $request->change_password;
$user = User::whereId($id)->first();
@@ -391,24 +383,25 @@ else{
return redirect('user')->with('success', Lang::get('lang.password_change_successfully'));
} catch (Exception $e) {
return redirect('user')->with('fails', $e->getMessage());
}
}
/**
*
* @param type $id
* @param type $id
* @param Request $request
*
* @return type
*/
public function changeRoleAdmin($id, Request $request) {
public function changeRoleAdmin($id, Request $request)
{
try {
$user = User::whereId($id)->first();
$user->role = 'admin';
$user->assign_group = $request->group;
$user->primary_dpt = $request->primary_department;
$user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
@@ -417,14 +410,14 @@ else{
}
/**
*
* @param type $id
* @param type $id
* @param Request $request
*
* @return type
*/
public function changeRoleAgent($id, Request $request) {
public function changeRoleAgent($id, Request $request)
{
try {
$user = User::whereId($id)->first();
$user->role = 'agent';
$user->assign_group = $request->group;
@@ -439,22 +432,22 @@ else{
}
/**
*
* @param type $id
*
* @return type
*/
public function changeRoleUser($id) {
public function changeRoleUser($id)
{
try {
$ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get();
if ($ticket) {
$ticket = Tickets::where('assigned_to', '=', $id)->update(array("assigned_to" => NULL));
$ticket = Tickets::where('assigned_to', '=', $id)->update(['assigned_to' => null]);
}
$user = User::whereId($id)->first();
$user->role = 'user';
$user->assign_group = NULL;
$user->primary_dpt = NULL;
$user->remember_token = NULL;
$user->assign_group = null;
$user->primary_dpt = null;
$user->remember_token = null;
$user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
@@ -466,32 +459,28 @@ else{
}
/**
*
* @param type $id
*
* @return type
*/
public function deleteAgent($id)
{
// try {
$delete_all = Input::get('delete_all');
$delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first();
if ($users->role == 'user') {
if ($users->role == 'user') {
$users = User::where('id', '=', $id)->first();
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
$users = User::where('id', '=', $id)->first();
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
}
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
}
// }
if ($users->role == 'agent') {
if ($delete_all == null) {
$UserEmail = Input::get('assign_to');
@@ -524,68 +513,62 @@ else{
// Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]);
$tickets = Tickets::where('assigned_to', '=', $id)->get();
foreach ($tickets as $ticket ) {
# code...
foreach ($tickets as $ticket) {
// code...
$ticket->assigned_to = $assign_to[1];
$user_detail = User::where('id', '=', $assign_to[1])->first();
$assignee = $user_detail->first_name . ' ' . $user_detail->last_name;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$user_detail = User::where('id', '=', $assign_to[1])->first();
$assignee = $user_detail->first_name.' '.$user_detail->last_name;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been assigned to ' . $assignee;
$thread->save();
}
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been assigned to '.$assignee;
$thread->save();
}
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully_and_ticket_assign_to_another_agent'));
}
// if (User_org::where('user_id', '=', $id)) {
// DB::table('user_assign_organization')->where('user_id', '=', $id)->delete();
// }
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->save();
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
} elseif ($delete_all == 1) {
if ($delete_all) {
// dd('here');
if ($delete_all) {
// dd('here');
$tickets = Tickets::where('assigned_to', '=', $id)->get();
// dd($tickets);
foreach ($tickets as $ticket ) {
$ticket->assigned_to = NULL;
$ticket_number = $ticket->ticket_number;
$ticket->save();
foreach ($tickets as $ticket) {
$ticket->assigned_to = null;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been unassigned ';
$thread->save();
}
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been unassigned ';
$thread->save();
}
// $users = User::where('id', '=', $id)->get();
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->is_delete = 1;
$users->active = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -593,8 +576,8 @@ foreach ($tickets as $ticket ) {
// Assign_team_agent::where('agent_id', '=', $id)->delete();
// User_org::where('user_id', '=', $id)->delete();
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->is_delete = 1;
$users->active = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -616,10 +599,11 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function show($id) {
public function show($id)
{
try {
$users = User::where('id','=', $id)->first();
if (count($users)>0) {
$users = User::where('id', '=', $id)->first();
if (count($users) > 0) {
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} else {
return redirect()->back()->with('fails', Lang::get('lang.user-not-found'));
@@ -637,10 +621,10 @@ foreach ($tickets as $ticket ) {
*
* @return type Response
*/
public function edit($id, CountryCode $code) {
public function edit($id, CountryCode $code)
{
try {
// dd('here');
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
@@ -652,12 +636,12 @@ foreach ($tickets as $ticket ) {
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
$orgs = Organization::all();
// dd($org);
$organization_id=User_org::where('user_id','=',$id)->lists('org_id')->first();
$organization_id = User_org::where('user_id', '=', $id)->lists('org_id')->first();
// $org_name=Organization::where('id','=',$org_id)->lists('name')->first();
// dd($org_name);
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory','organization_id'))->with('phonecode', $phonecode->phonecode);
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory', 'organization_id'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -672,8 +656,8 @@ foreach ($tickets as $ticket ) {
*
* @return type Response
*/
public function update($id, Sys_userUpdate $request) {
public function update($id, Sys_userUpdate $request)
{
$user = new User();
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -693,10 +677,10 @@ foreach ($tickets as $ticket ) {
$users->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile');
$users->fill($request->except('mobile'));
$users->save();
if ($request->input('org_id') != "") {
if ($request->input('org_id') != '') {
$orgid = $request->input('org_id');
$this->storeUserOrgRelation($id, $orgid);
$this->storeUserOrgRelation($id, $orgid);
}
/* redirect to Index page with Success Message */
return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully'));
@@ -711,7 +695,8 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function getProfile() {
public function getProfile()
{
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
@@ -725,7 +710,8 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function getProfileedit(CountryCode $code) {
public function getProfileedit(CountryCode $code)
{
$user = Auth::user();
$location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
@@ -734,7 +720,7 @@ foreach ($tickets as $ticket ) {
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))
->with(['phonecode' => $phonecode->phonecode,
'verify' => $status]);
'verify' => $status, ]);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -748,7 +734,8 @@ foreach ($tickets as $ticket ) {
*
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
public function postProfileedit(ProfileRequest $request)
{
try {
// geet authenticated user details
$user = Auth::user();
@@ -758,14 +745,14 @@ foreach ($tickets as $ticket ) {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) {
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
}
}
$user->country_code = $request->country_code;
}
$user->fill($request->except('profile_pic', 'mobile'));
$user->gender = $request->input('gender');
$user->save();
if (Input::file('profile_pic')) {
// fetching picture name
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'uploads/profilepic';
@@ -782,11 +769,10 @@ foreach ($tickets as $ticket ) {
$user->mobile = null;
}
if ($user->save()) {
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
} else {
return Redirect::route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
}
} catch (Exception $e) {
return Redirect::route('profile')->with('fails', $e->getMessage());
}
@@ -826,49 +812,50 @@ foreach ($tickets as $ticket ) {
*
* @return type boolean
*/
public function UserAssignOrg($id) {
public function UserAssignOrg($id)
{
$org_name = Input::get('org');
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
} else {
return 0;
return 1;
} else {
return 0;
}
} else {
return 2;
} else {
return 2;
}
}
}
public function UsereditAssignOrg($id)
{
$org_name = Input::get('org');
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
public function UsereditAssignOrg($id)
{
$org_name = Input::get('org');
return 1;
} else {
return 0;
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
} else {
return 0;
}
} else {
return 2;
} else {
return 2;
}
}
}
public function orgAssignUser($id) {
public function orgAssignUser($id)
{
$org = Input::get('org');
$user_org = new User_org();
$user_org->org_id = $id;
@@ -878,7 +865,8 @@ if ($org_name) {
return 1;
}
public function removeUserOrg($id) {
public function removeUserOrg($id)
{
$user_org = User_org::where('org_id', '=', $id)->first();
$user_org->delete();
@@ -892,7 +880,8 @@ if ($org_name) {
*
* @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
@@ -935,7 +924,8 @@ if ($org_name) {
*
* @return string
*/
public function generateRandomString($length = 10) {
public function generateRandomString($length = 10)
{
// list of supported characters
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// character length checked
@@ -950,7 +940,8 @@ if ($org_name) {
return $randomString;
}
public function storeUserOrgRelation($userid, $orgid) {
public function storeUserOrgRelation($userid, $orgid)
{
$org_relations = new User_org();
$org_relation = $org_relations->where('user_id', $userid)->first();
if ($org_relation) {
@@ -958,11 +949,12 @@ if ($org_name) {
}
$org_relations->create([
'user_id' => $userid,
'org_id' => $orgid,
'org_id' => $orgid,
]);
}
public function getExportUser() {
public function getExportUser()
{
try {
return view('themes.default1.agent.helpdesk.user.export');
} catch (Exception $ex) {
@@ -970,30 +962,34 @@ if ($org_name) {
}
}
public function exportUser(Request $request) {
public function exportUser(Request $request)
{
try {
$date = $request->input('date');
$date = str_replace(' ', '', $date);
$date_array = explode(':', $date);
$first = $date_array[0] . " 00:00:00";
$second = $date_array[1] . " 23:59:59";
$first = $date_array[0].' 00:00:00';
$second = $date_array[1].' 23:59:59';
$first_date = $this->convertDate($first);
$second_date = $this->convertDate($second);
$users = $this->getUsers($first_date, $second_date);
$excel_controller = new \App\Http\Controllers\Common\ExcelController();
$filename = "users" . $date;
$filename = 'users'.$date;
$excel_controller->export($filename, $users);
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function convertDate($date) {
public function convertDate($date)
{
$converted_date = date('Y-m-d H:i:s', strtotime($date));
return $converted_date;
}
public function getUsers($first, $last) {
public function getUsers($first, $last)
{
$user = new User();
$users = $user->leftJoin('user_assign_organization', 'users.id', '=', 'user_assign_organization.user_id')
->leftJoin('organization', 'user_assign_organization.org_id', '=', 'organization.id')
@@ -1003,37 +999,42 @@ if ($org_name) {
->select('users.user_name as Username', 'users.email as Email', 'users.first_name as Fisrtname', 'users.last_name as Lastname', 'organization.name as Organization')
->get()
->toArray();
return $users;
}
public function resendOTP(OtpVerifyRequest $request) {
public function resendOTP(OtpVerifyRequest $request)
{
if (\Schema::hasTable('sms')) {
$sms = DB::table('sms')->get();
if (count($sms) > 0) {
\Event::fire(new \App\Events\LoginEvent($request));
return 1;
}
} else {
return "Plugin has not been setup successfully.";
return 'Plugin has not been setup successfully.';
}
}
public function verifyOTP() {
public function verifyOTP()
{
// dd(Input::all());
// $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first();
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id'))
->first();
if ($otp != null) {
$otp_length = strlen(Input::get('otp'));
if (($otp_length == 6 && !preg_match("/[a-z]/i", Input::get('otp')))) {
if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
$otp2 = Hash::make(Input::get('otp'));
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa");
$date2 = date("Y-m-d h:i:sa");
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
$date2 = date('Y-m-d h:i:sa');
$time1 = new DateTime($date2);
$time2 = new DateTime($date1);
$interval = $time1->diff($time2);
if ($interval->i > 10 || $interval->h > 0) {
$message = Lang::get('lang.otp-expired');
return $message;
} else {
if (Hash::check(Input::get('otp'), $otp->otp)) {
@@ -1045,26 +1046,27 @@ if ($org_name) {
return 1;
} else {
$message = Lang::get('lang.otp-not-matched');
return $message;
}
}
} else {
$message = Lang::get('lang.otp-invalid');
return $message;
}
} else {
$message = Lang::get('lang.otp-not-matched');
return $message;
}
}
/**
*/
public function getAgentDetails()
{
$users = User::where('role', '<>', 'user')->where('active', '=', 1)->get();
foreach ($users as $user) {
echo "<option value='user_$user->id'>".$user->name().'</option>';
echo "<option value='user_$user->id'>".$user->name().'</option>';
}
}
}

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,6 +77,7 @@ class CategoryController extends Controller
/* add column name */
->addColumn('name', function ($model) {
$string = strip_tags($model->name);
return str_limit($string, 20);
})
/* add column Created */
@@ -120,7 +121,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 {
@@ -147,6 +148,7 @@ 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>');
@@ -165,9 +167,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'));
}
/**
@@ -191,6 +193,7 @@ 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,11 +144,13 @@ 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) {
@@ -159,7 +161,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>';
})