update for version 1.0.2
This commit is contained in:
@@ -69,8 +69,7 @@ class MailController extends Controller {
|
||||
die('Mailbox is empty');
|
||||
}
|
||||
// dd($mailsIds);
|
||||
foreach($mailsIds as $mailId)
|
||||
{
|
||||
foreach($mailsIds as $mailId) {
|
||||
$overview = $mailbox->get_overview($mailId);
|
||||
$var = $overview[0]->seen ? 'read' : 'unread';
|
||||
if ($var == 'unread') {
|
||||
@@ -82,8 +81,7 @@ class MailController extends Controller {
|
||||
}
|
||||
$body = $mail->textHtml;
|
||||
// dd($mailId);
|
||||
if($body == null)
|
||||
{
|
||||
if($body == null) {
|
||||
$body = $mailbox->backup_getmail($mailId);
|
||||
$body = str_replace('\r\n', '<br/>', $body);
|
||||
// var_dump($body);
|
||||
@@ -112,8 +110,7 @@ class MailController extends Controller {
|
||||
$thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
|
||||
$thread_id = $thread_id->id;
|
||||
|
||||
foreach($mail->getAttachments() as $attachment)
|
||||
{
|
||||
foreach($mail->getAttachments() as $attachment) {
|
||||
$support = "support";
|
||||
// echo $_SERVER['DOCUMENT_ROOT'];
|
||||
$dir_img_paths = __DIR__;
|
||||
@@ -132,7 +129,6 @@ class MailController extends Controller {
|
||||
$pos = strpos($body, $filepath[1]);
|
||||
|
||||
if($pos == false) {
|
||||
|
||||
if($settings_email->first()->attachment == 1) {
|
||||
$upload = new Ticket_attachments;
|
||||
$upload->file = $file_data;
|
||||
|
@@ -13,6 +13,7 @@ use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
@@ -56,6 +57,135 @@ class TicketController extends Controller {
|
||||
return view('themes.default1.agent.helpdesk.ticket.inbox');
|
||||
}
|
||||
|
||||
public function get_inbox() {
|
||||
return \Datatable::collection(Tickets::where('status', '=', 1)->orderBy('id', 'DESC')->get())
|
||||
->searchColumns('subject')
|
||||
->orderColumns('ticket_number')
|
||||
|
||||
->addColumn('checkbox', function ($ticket) {
|
||||
return "<input type='checkbox' class='icheckbox_flat-blue' name='select_all' value=".$ticket->id."/>";
|
||||
})
|
||||
|
||||
->addColumn('name', function ($ticket) {
|
||||
$title = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
|
||||
$string = strip_tags($title->title);
|
||||
if($title)
|
||||
if($title == null){
|
||||
} else {
|
||||
$collaborators = Ticket_Collaborator::where('ticket_id','=',$ticket->id)->get();
|
||||
$collab = count($collaborators);
|
||||
// check atatchments
|
||||
$attachments = Ticket_attachments::where('thread_id','=',$title->id)->first();
|
||||
$attach = count($attachments);
|
||||
if (strlen($string) > 40) {
|
||||
$stringCut = substr($string, 0, 40);
|
||||
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
|
||||
}
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
|
||||
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
|
||||
if($LastResponse->role == "user") {
|
||||
$rep = "#F39C12";
|
||||
$username = $LastResponse->user_name;
|
||||
} else { $rep = "#000"; $username = $LastResponse->first_name ." ". $LastResponse->last_name;
|
||||
if($LastResponse->first_name==null || $LastResponse->last_name==null) {
|
||||
$username = $LastResponse->user_name;
|
||||
}
|
||||
}
|
||||
$titles = Ticket_Thread::where('ticket_id', '=', $ticket->id)->get();
|
||||
$count = count($titles);
|
||||
foreach($titles as $title) {
|
||||
$title = $title;
|
||||
}
|
||||
$assigned_to = User::where('id','=',$ticket->assigned_to)->first();
|
||||
if($assigned_to == null) {
|
||||
$assigned = "Unassigned";
|
||||
} else {
|
||||
$assigned = $assigned_to->first_name ." ". $assigned_to->last_name;
|
||||
}
|
||||
if($collab > 0) {
|
||||
$collabs = " <i class='fa fa-users'></i>";
|
||||
}
|
||||
if($attach > 0) {
|
||||
$attachs = " <i class='fa fa-paperclip'></i>";
|
||||
if($collab > 0) {
|
||||
$collabs = $collabs . $attachs;
|
||||
} else {
|
||||
$collabs = $attachs;
|
||||
}
|
||||
}
|
||||
return "<a href=".route('ticket.thread',[$ticket->id])." title=". $title->title .">".$string."</a> (".$count.") <i class='fa fa-comment'></i>
|
||||
".$collab;
|
||||
}
|
||||
})
|
||||
|
||||
->addColumn('Ticket ID', function ($ticket) {
|
||||
$ticket_number = "<a href='". route('ticket.thread',[$ticket->id]) ."' title=''># ".$ticket->ticket_number."</a>";
|
||||
return $ticket_number;
|
||||
})
|
||||
|
||||
->addColumn('Priority', function ($ticket) {
|
||||
$priority = Ticket_Priority::where('priority_id', '=', $ticket->priority_id)->first();
|
||||
return "<td class='mailbox-priority'><spam style='color:green;'>".$priority->priority_desc."</spam></td>";
|
||||
// return TicketController::usertimezone($st);
|
||||
})
|
||||
|
||||
->addColumn('From', function ($ticket) {
|
||||
$from = User::where('id','=',$ticket->user_id)->first();
|
||||
if($from->role == "user") {
|
||||
return $from->user_name;
|
||||
} else {
|
||||
return $from->first_name." ".$from->last_name;
|
||||
}
|
||||
})
|
||||
|
||||
->addColumn('Last Replier', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
|
||||
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
|
||||
if($LastResponse->role == "user") {
|
||||
$rep = "#F39C12";
|
||||
$username = $LastResponse->user_name;
|
||||
} else { $rep = "#000"; $username = $LastResponse->first_name ." ". $LastResponse->last_name;
|
||||
if($LastResponse->first_name==null || $LastResponse->last_name==null) {
|
||||
$username = $LastResponse->user_name;
|
||||
}}
|
||||
return $username;
|
||||
})
|
||||
|
||||
->addColumn('Assigned To', function ($ticket) {
|
||||
$assigned_to = User::where('id','=',$ticket->assigned_to)->first();
|
||||
if($assigned_to == null) {
|
||||
$assigned = "Unassigned";
|
||||
} else {
|
||||
$assigned = $assigned_to->first_name ." ". $assigned_to->last_name;
|
||||
}
|
||||
return $assigned;
|
||||
})
|
||||
|
||||
->addColumn('Last Activity', function ($ticket) {
|
||||
$assigned_to = User::where('id','=',$ticket->assigned_to)->first();
|
||||
if($assigned_to == null) {
|
||||
$assigned = "Unassigned";
|
||||
} else {
|
||||
$assigned = $assigned_to->first_name ." ". $assigned_to->last_name;
|
||||
}
|
||||
return $assigned;
|
||||
})
|
||||
|
||||
->addColumn('Last Activity', function ($ticket) {
|
||||
$titles = Ticket_Thread::where('ticket_id', '=', $ticket->id)->get();
|
||||
$count = count($titles);
|
||||
foreach($titles as $title) {
|
||||
$title = $title;
|
||||
}
|
||||
return TicketController::usertimezone($title->created_at);
|
||||
})
|
||||
|
||||
->make();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Open ticket list page
|
||||
* @return type response
|
||||
@@ -429,8 +559,8 @@ class TicketController extends Controller {
|
||||
// mail user his/her password
|
||||
if ($user->save()) {
|
||||
$user_id = $user->id;
|
||||
if (Mail::send('emails.pass', ['password' => $password, 'name' => $username, 'from'=>$company], function ($message) use ($emailadd, $username) {
|
||||
$message->to($emailadd, $username)->subject('password');
|
||||
if (Mail::send('emails.pass', ['password' => $password, 'name' => $username, 'from'=>$company], function ($message) use ($emailadd, $username,$company) {
|
||||
$message->to($emailadd, $username)->subject('Welcome to '.$company.' helpdesk');
|
||||
})) {
|
||||
// need to do something here....
|
||||
}
|
||||
|
270
code/app/Http/Controllers/Agent/kb/ArticleController.php
Normal file
270
code/app/Http/Controllers/Agent/kb/ArticleController.php
Normal file
@@ -0,0 +1,270 @@
|
||||
<?php namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Controllers\Client\kb\UserController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Requests\kb\ArticleRequest;
|
||||
use App\Model\kb\Article;
|
||||
use App\Model\kb\Category;
|
||||
use App\Model\kb\Relationship;
|
||||
use App\Model\kb\Settings;
|
||||
use Auth;
|
||||
use Chumper\Datatable\Table;
|
||||
use Datatable;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Model\kb\Comment;
|
||||
|
||||
/* include the article model to access the article table */
|
||||
use Redirect;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* ArticleController
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
|
||||
class ArticleController extends Controller {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
SettingsController::language();
|
||||
}
|
||||
public function test() {
|
||||
//$table = $this->setDatatable();
|
||||
return view('themes.default1.agent.kb.article.test');
|
||||
|
||||
}
|
||||
public function getData() {
|
||||
|
||||
//return 'kfjhje';
|
||||
|
||||
return Datatable::collection(Article::All())
|
||||
->searchColumns('name')
|
||||
->orderColumns('name', 'description')
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
->addColumn('Created', function ($model) {
|
||||
$t = $model->created_at;
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
|
||||
return '<span data-toggle="modal" data-target="#banemail"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href=article/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=show/'.$model->slug .' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="banemail">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="article/delete/'.$model->slug.'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Index for Articles
|
||||
* @param type Article $article
|
||||
* @return type Response
|
||||
*/
|
||||
public function index() {
|
||||
/* show the index page with article list */
|
||||
return view('themes.default1.agent.kb.article.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating a Article
|
||||
* @param type Category $category
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Category $category) {
|
||||
//$cat = $category->whereId(33)->first();
|
||||
//$tm = $cat->created_at;
|
||||
//$this->usertimezone($tm);
|
||||
// // /* get the attributes of the category */
|
||||
$category = $category->lists('id', 'name');
|
||||
/* get the create page */
|
||||
return view('themes.default1.agent.kb.article.create', compact('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the values to the article table
|
||||
* @param type Article $article
|
||||
* @param type ArticleRequest $request
|
||||
* @return type
|
||||
*/
|
||||
public function store(Article $article, ArticleRequest $request) {
|
||||
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$article->slug = $slug;
|
||||
$article->fill($request->except('created_at','slug'))->save();
|
||||
$requests = $request->input('category_id');
|
||||
$id = $article->id;
|
||||
foreach ($requests as $req) {
|
||||
DB::insert('insert into article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
|
||||
}
|
||||
/* insert the values to the article table */
|
||||
if ($article->fill($request->except('slug'))->save()) //true: redirect to index page with success message
|
||||
{
|
||||
return redirect('article')->with('success', 'Article Inserted Successfully');
|
||||
} else //redirect to index page with fail message
|
||||
{
|
||||
return redirect('article')->with('fails', 'Article Not Inserted');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an Article by id
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* @param type Relationship $relation
|
||||
* @param type Category $category
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($slug, Article $article, Relationship $relation, Category $category) {
|
||||
|
||||
$aid = $article->where('slug', $slug)->first();
|
||||
$id = $aid->id;
|
||||
|
||||
/* define the selected fields */
|
||||
$assign = $relation->where('article_id', $id)->lists('category_id');
|
||||
/* get the attributes of the category */
|
||||
$category = $category->lists('id', 'name');
|
||||
/* get the selected article and display it at edit page */
|
||||
/* Get the selected article with id */
|
||||
$article = $article->whereId($id)->first();
|
||||
/* send to the edit page */
|
||||
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an Artile by id
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* @param type Relationship $relation
|
||||
* @param type ArticleRequest $request
|
||||
* @return Response
|
||||
*/
|
||||
public function update($slug, Article $article, Relationship $relation,
|
||||
ArticleRequest $request) {
|
||||
$aid = $article->where('slug', $slug)->first();
|
||||
$id = $aid->id;
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$article->slug = $slug;
|
||||
/* get the attribute of relation table where id==$id */
|
||||
$relation = $relation->where('article_id', $id);
|
||||
$relation->delete();
|
||||
/* get the request of the current articles */
|
||||
$article = $article->whereId($id)->first();
|
||||
$requests = $request->input('category_id');
|
||||
$id = $article->id;
|
||||
foreach ($requests as $req) {
|
||||
DB::insert('insert into article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
|
||||
}
|
||||
/* update the value to the table */
|
||||
if ($article->fill($request->except('slug'))->save()) //true: redirect to index page with success message
|
||||
{
|
||||
return redirect('article')->with('success', 'Article Updated Successfully');
|
||||
} else // redirect to index page with fails message
|
||||
{
|
||||
return redirect('article')->with('fails', 'Article Not Updated');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an Agent by id
|
||||
* @param type $id
|
||||
* @param type Article $article
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
|
||||
|
||||
/* delete the selected article from the table */
|
||||
$article = $article->where('slug',$slug)->first(); //get the selected article via id
|
||||
//dd($article);
|
||||
$id = $article->id;
|
||||
$comments = $comment->where('article_id',$id)->get();
|
||||
|
||||
if($comments)
|
||||
{
|
||||
foreach($comments as $comment)
|
||||
$comment->delete();
|
||||
}
|
||||
|
||||
$relation = $relation->where('article_id', $id)->first();
|
||||
if($relation)
|
||||
{
|
||||
$relation->delete();
|
||||
}
|
||||
if($article)
|
||||
{
|
||||
if ($article->delete()) //true:redirect to index page with success message
|
||||
{
|
||||
return Redirect::back()->with('success', 'Article Deleted Successfully');
|
||||
} else //redirect to index page with fails message
|
||||
{
|
||||
return Redirect::back()->with('fails', 'Article Not Deleted');
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return Redirect::back()->with('fails', 'Article can Not Deleted');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static function usertimezone($utc) {
|
||||
$user = Auth::user();
|
||||
$tz = $user->timezone;
|
||||
$set = Settings::whereId('1')->first();
|
||||
$format = $set->dateformat;
|
||||
//$utc = date('M d Y h:i:s A');
|
||||
//echo 'UTC : ' . $utc;
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
$offset = date('Z', strtotime($utc));
|
||||
//print "offset: $offset \n";
|
||||
$date = date($format, strtotime($utc) + $offset);
|
||||
echo $date;
|
||||
//return substr($date, 0, -6);
|
||||
|
||||
}
|
||||
|
||||
}
|
194
code/app/Http/Controllers/Agent/kb/CategoryController.php
Normal file
194
code/app/Http/Controllers/Agent/kb/CategoryController.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php namespace App\Http\Controllers\Agent\kb;
|
||||
use App\Http\Controllers\client\kb\UserController;
|
||||
use App\Http\Controllers\admin\kb\ArticleController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Requests\kb\CategoryRequest;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Model\kb\Category;
|
||||
use App\Model\kb\Relationship;
|
||||
use Datatable;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* CategoryController
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
|
||||
class CategoryController extends Controller {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
SettingsController::language();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indexing all Category
|
||||
* @param type Category $category
|
||||
* @return Response
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
/* get the view of index of the catogorys with all attributes
|
||||
of category model */
|
||||
return view('themes.default1.agent.kb.category.index');
|
||||
}
|
||||
public function getData() {
|
||||
|
||||
//return 'kfjhje';
|
||||
|
||||
return Datatable::collection(Category::All())
|
||||
->searchColumns('name')
|
||||
->orderColumns('name', 'description')
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
|
||||
->addColumn('Created', function ($model) {
|
||||
|
||||
$t = $model->created_at;
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
//return '<a href=category/delete/' . $model->id . ' class="btn btn-danger btn-flat">Delete</a> <a href=category/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=article-list class="btn btn-warning btn-flat">View</a>';
|
||||
return '<span data-toggle="modal" data-target="#banemail"><a href="#" ><button class="btn btn-danger btn-xs"></a>'. \Lang::get("lang.delete") .'</button></span> <a href=category/' . $model->slug . '/edit class="btn btn-warning btn-xs">'. \Lang::get("lang.edit") .'</a> <a href=article-list class="btn btn-primary btn-xs">'. \Lang::get("lang.view") .'</a>
|
||||
<div class="modal fade" id="banemail">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="category/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
})
|
||||
->make();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Category
|
||||
* @param type Category $category
|
||||
* @return Response
|
||||
*/
|
||||
public function create(Category $category) {
|
||||
/* Get the all attributes in the category model */
|
||||
$category = $category->get();
|
||||
/* get the view page to create new category with all attributes
|
||||
of category model*/
|
||||
return view('themes.default1.agent.kb.category.create', compact('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Category $category, CategoryRequest $request) {
|
||||
/* Get the whole request from the form and insert into table via model */
|
||||
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
|
||||
$category->slug = $slug;
|
||||
//$category->save();
|
||||
|
||||
if ($category->fill($request->except('slug'))->save()) //True: send success message to index page
|
||||
{
|
||||
return Redirect::back()->with('success', 'Category Inserted Successfully');
|
||||
} else //send fail to index page
|
||||
{
|
||||
return Redirect::back()->with('fails', 'Category Not Inserted');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($slug, Category $category) {
|
||||
|
||||
$cid = $category->where('slug', $slug)->first();
|
||||
$id = $cid->id;
|
||||
/* get the atributes of the category model whose id == $id */
|
||||
$category = $category->whereId($id)->first();
|
||||
/* get the Edit page the selected category via id */
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update($slug, Category $category, CategoryRequest $request) {
|
||||
|
||||
/* Edit the selected category via id */
|
||||
$category = $category->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
|
||||
$category->slug = $slug;
|
||||
/* update the values at the table via model according with the request */
|
||||
if ($category->fill($request->except('slug'))->save()) //True: redirct to index page with success message
|
||||
{
|
||||
return redirect('category')->with('success', 'Category Updated Successfully');
|
||||
} else //redirect to index with fails message
|
||||
{
|
||||
return redirect('category')->with('fails', 'Category Not Updated');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id, Category $category, Relationship $relation) {
|
||||
$relation = $relation->where('category_id', $id)->delete();
|
||||
// $relation->delete();
|
||||
/* delete the category selected, id == $id */
|
||||
$category = $category->whereId($id)->first();
|
||||
if ($category->delete()) //True: redirect to index with success message
|
||||
{
|
||||
return Redirect::back()->with('success', 'Category Deleted Successfully');
|
||||
} else //redirect to index page fails message
|
||||
{
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
154
code/app/Http/Controllers/Agent/kb/PageController.php
Normal file
154
code/app/Http/Controllers/Agent/kb/PageController.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
use App\Http\Controllers\client\kb\UserController;
|
||||
use App\Http\Controllers\Agent\kb\ArticleController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Requests\kb\PageRequest;
|
||||
use App\Model\kb\Page;
|
||||
use Datatable;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PageController extends Controller {
|
||||
|
||||
/**
|
||||
* Contructor for both Authentication and Model Injecting
|
||||
* @param type Page $page
|
||||
* @return type
|
||||
*/
|
||||
public function __construct(Page $page) {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
$this->page = $page;
|
||||
SettingsController::language();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
$pages = $this->page->paginate(3);
|
||||
$pages->setPath('page');
|
||||
return view('themes.default1.agent.kb.pages.index', compact('pages'));
|
||||
|
||||
}
|
||||
|
||||
public function getData() {
|
||||
|
||||
//return 'kfjhje';
|
||||
|
||||
return Datatable::collection(Page::All())
|
||||
->searchColumns('name')
|
||||
->orderColumns('name', 'description', 'created')
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
|
||||
->addColumn('Created', function ($model) {
|
||||
|
||||
$t = $model->created_at;
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
|
||||
//return '<a href=page/delete/' . $model->id . ' class="btn btn-danger btn-flat">Delete</a> <a href=page/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=article-list class="btn btn-warning btn-flat">View</a>';
|
||||
return '<span data-toggle="modal" data-target="#banemail"><a href="#" ><button class="btn btn-danger btn-xs"></a> '. \Lang::get('lang.delete') .'</button></span> <a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">'. \Lang::get('lang.edit') .'</a> <a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">'. \Lang::get('lang.view') .'</a>
|
||||
<div class="modal fade" id="banemail">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="page/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create() {
|
||||
return view('themes.default1.agent.kb.pages.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* To insert a value to the table Page
|
||||
* @param type Request $request
|
||||
* @return type
|
||||
*/
|
||||
public function store(PageRequest $request) {
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
|
||||
$this->page->slug = $slug;
|
||||
|
||||
$this->page->fill($request->except('slug'))->save();
|
||||
return redirect('page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* To edit a page
|
||||
* @param type $id
|
||||
* @return type
|
||||
*/
|
||||
public function edit($slug) {
|
||||
$page = $this->page->where('slug', $slug)->first();
|
||||
return view('themes.default1.agent.kb.pages.edit', compact('page'));
|
||||
}
|
||||
|
||||
/**
|
||||
* To update a page
|
||||
* @param type $id
|
||||
* @param type Request $request
|
||||
* @return type
|
||||
*/
|
||||
public function update($slug, PageRequest $request) {
|
||||
$pages = $this->page->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
|
||||
$this->page->slug = $slug;
|
||||
//$id = $page->id;
|
||||
$pages->fill($request->except('slug'))->save();
|
||||
return redirect('page')->with('success', 'Your Page Updated Successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* To Delete one Page
|
||||
* @param type $id
|
||||
* @return type
|
||||
*/
|
||||
public function destroy($id) {
|
||||
$page = $this->page->whereId($id)->first();
|
||||
$page->delete();
|
||||
return redirect('page')->with('success', 'Page Deleted Successfully');
|
||||
}
|
||||
|
||||
}
|
384
code/app/Http/Controllers/Agent/kb/SettingsController.php
Normal file
384
code/app/Http/Controllers/Agent/kb/SettingsController.php
Normal file
@@ -0,0 +1,384 @@
|
||||
<?php namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
use App\Http\Controllers\Agent\kb\ArticleController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\kb\FooterRequest;
|
||||
use App\Http\Requests\kb\ProfilePassword;
|
||||
use App\Http\Requests\kb\ProfileRequest;
|
||||
use App\Http\Requests\kb\SettingsRequests;
|
||||
use App\Http\Requests\kb\SocialRequest;
|
||||
use App\Model\kb\Comment;
|
||||
use App\Model\kb\DateFormat;
|
||||
use App\Model\kb\Faq;
|
||||
use App\Model\kb\Settings;
|
||||
use App\Model\kb\Side1;
|
||||
use App\Model\kb\Side2;
|
||||
use App\Model\kb\Social;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use Auth;
|
||||
use Config;
|
||||
use Datatable;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Image;
|
||||
use Input;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
$this->language();
|
||||
}
|
||||
|
||||
/**
|
||||
* to get the settings page
|
||||
* @return response
|
||||
* @package default
|
||||
*/
|
||||
public function settings(Settings $settings, Timezones $time, DateFormat $date) {
|
||||
|
||||
/* get the setting where the id == 1 */
|
||||
$settings = $settings->whereId('1')->first();
|
||||
$time = $time->get();
|
||||
//$date = $date->get();
|
||||
return view('themes.default1.agent.kb.settings.settings', compact('date', 'settings', 'time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function postSettings($id, Settings $settings, SettingsRequests $request) {
|
||||
try
|
||||
{
|
||||
/* fetch the values of company request */
|
||||
$settings = $settings->whereId('1')->first();
|
||||
|
||||
if (Input::file('logo')) {
|
||||
$name = Input::file('logo')->getClientOriginalName();
|
||||
|
||||
$destinationPath = 'lb-faveo/dist/image';
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
//echo $fileName;
|
||||
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
|
||||
$settings->logo = $fileName;
|
||||
//$thDestinationPath = 'dist/th';
|
||||
|
||||
Image::make($destinationPath . '/' . $fileName, array(
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'grayscale' => false,
|
||||
))->save('lb-faveo/dist/image/' . $fileName);
|
||||
}
|
||||
if (Input::file('background')) {
|
||||
$name = Input::file('background')->getClientOriginalName();
|
||||
|
||||
$destinationPath = 'lb-faveo/dist/image';
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
echo $fileName;
|
||||
|
||||
Input::file('background')->move($destinationPath, $fileName);
|
||||
|
||||
$settings->background = $fileName;
|
||||
//$thDestinationPath = 'dist/th';
|
||||
|
||||
Image::make($destinationPath . '/' . $fileName, array(
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'grayscale' => false,
|
||||
))->save('lb-faveo/dist/image/' . $fileName);
|
||||
}
|
||||
|
||||
/* Check whether function success or not */
|
||||
|
||||
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('settings')->with('fails', 'Settings can not Updated');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('settings')->with('fails', 'Settings can not Updated');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to get the faq view page
|
||||
* @return response
|
||||
*/
|
||||
public function Faq(Faq $faq) {
|
||||
/* fetch the values of faq */
|
||||
$faq = $faq->whereId('1')->first();
|
||||
return view('themes.default1.agent.settings.faq', compact('faq'));
|
||||
|
||||
}
|
||||
public function postfaq($id, Faq $faq, Request $request) {
|
||||
$faq = $faq->whereId('1')->first();
|
||||
if ($faq->fill($request->input())->save()) {
|
||||
return redirect('create-faq')->with('success', 'Faq updated Successfully');
|
||||
} else {
|
||||
return redirect('craete-faq')->with('fails', 'Faq not updated');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the create page to insert the values to database
|
||||
* @return type response
|
||||
*/
|
||||
public function CreateSocialLink(Social $social) {
|
||||
$social = $social->whereId('1')->first();
|
||||
return view('themes.default1.agent.kb.settings.social', compact('social'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type Social $social
|
||||
* @param type Request $request
|
||||
* @return type resonse
|
||||
*/
|
||||
public function PostSocial(Social $social, SocialRequest $request) {
|
||||
$social = $social->whereId('1')->first();
|
||||
if ($social->fill($request->input())->save()) {
|
||||
return redirect('social')->with('success', 'Your Social Links Stored');
|
||||
} else {
|
||||
return redirect('social')->with('fails', 'Sorry Can not Performe');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To Moderate the commenting
|
||||
* @param type Comment $comment
|
||||
* @return Response
|
||||
*/
|
||||
public function comment(Comment $comment) {
|
||||
return view('themes.default1.agent.kb.settings.comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* getdata
|
||||
* @return type
|
||||
*/
|
||||
public function getData() {
|
||||
return \Datatable::collection(Comment::All())
|
||||
->searchColumns('name', 'email', 'comment', 'created')
|
||||
->orderColumns('name')
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
->addColumn('email', function ($model) {
|
||||
return $model->email;
|
||||
})
|
||||
->addColumn('website', function ($model) {
|
||||
return $model->website;
|
||||
})
|
||||
->addColumn('comment', function ($model) {
|
||||
return $model->comment;
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
$status = $model->status;
|
||||
if ($status == 1) {
|
||||
return '<p style="color:blue"">'.\Lang::get('lang.published');
|
||||
} else {
|
||||
return '<p style="color:red"">'.\Lang::get('lang.not_published');
|
||||
}
|
||||
})
|
||||
->addColumn('Created', function ($model) {
|
||||
return TicketController::usertimezone(date($model->created_at));
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href=comment/delete/' . $model->id . ' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a> <a href=published/' . $model->id . ' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin can publish the comment
|
||||
* @param type $id
|
||||
* @param type Comment $comment
|
||||
* @return bool
|
||||
*/
|
||||
public function publish($id, Comment $comment) {
|
||||
$comment = $comment->whereId($id)->first();
|
||||
$comment->status = 1;
|
||||
if ($comment->save()) {
|
||||
return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published');
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the comment
|
||||
* @param type $id
|
||||
* @param type Comment $comment
|
||||
* @return type
|
||||
*/
|
||||
public function delete($id, Comment $comment) {
|
||||
$comment = $comment->whereId($id)->first();
|
||||
if ($comment->delete()) {
|
||||
return redirect('comment')->with('success', $comment->name . "'s!" . 'Comment Deleted');
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
}
|
||||
}
|
||||
|
||||
public function getProfile() {
|
||||
$time = Timezone::all();
|
||||
$user = Auth::user();
|
||||
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
|
||||
}
|
||||
|
||||
public function postProfile(ProfileRequest $request) {
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
|
||||
if (is_null($user->profile_pic)) {
|
||||
if ($request->input('gender') == 1) {
|
||||
|
||||
$name = 'avatar5.png';
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$user->profile_pic = $name;
|
||||
} elseif ($request->input('gender') == 0) {
|
||||
|
||||
$name = 'avatar2.png';
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$user->profile_pic = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if (Input::file('profile_pic')) {
|
||||
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
//echo $fileName;
|
||||
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
|
||||
$user->profile_pic = $fileName;
|
||||
|
||||
} else {
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
|
||||
|
||||
}
|
||||
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return redirect('profile')->with('success1', 'Profile Updated sucessfully');
|
||||
} else {
|
||||
return redirect('profile')->with('fails1', 'Profile Not Updated sucessfully');
|
||||
}
|
||||
|
||||
}
|
||||
public function postProfilePassword($id, ProfilePassword $request) {
|
||||
$user = Auth::user();
|
||||
//echo $user->password;
|
||||
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
$user->password = Hash::make($request->input('new_password'));
|
||||
$user->save();
|
||||
return redirect('profile')->with('success2', 'Password Updated sucessfully');
|
||||
} else {
|
||||
return redirect('profile')->with('fails2', 'Old password Wrong');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* To delete the logo
|
||||
* @param type $id
|
||||
* @param type Settings $setting
|
||||
* @return type
|
||||
*/
|
||||
public function deleteLogo($id, Settings $setting) {
|
||||
$setting = $setting->whereId($id)->first();
|
||||
$setting->logo = '';
|
||||
$setting->save();
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
|
||||
}
|
||||
|
||||
public function deleteBackground($id, Settings $setting) {
|
||||
$setting = $setting->whereId($id)->first();
|
||||
$setting->background = '';
|
||||
$setting->save();
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the View of create Side widget page
|
||||
* @param type Side1 $side
|
||||
* @return View
|
||||
*/
|
||||
public function side1(Side1 $side) {
|
||||
$side = $side->where('id', '1')->first();
|
||||
return view('themes.default1.agent.kb.settings.side1', compact('side'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post function of Side1 Page
|
||||
* @param type $id
|
||||
* @param type Side1 $side
|
||||
* @param type Request $request
|
||||
* @return view
|
||||
*/
|
||||
public function postside1($id, Side1 $side, Request $request) {
|
||||
$side = $side->whereId($id)->first();
|
||||
if ($side->fill($request->input())->save()) {
|
||||
return redirect('side1')->with('success', 'Side Widget 1 Created !');
|
||||
} else {
|
||||
return redirect('side1')->with('fails', 'Whoops ! Something went Wrong ! ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the View for side widget creat
|
||||
* @param type Side2 $side
|
||||
* @return type
|
||||
*/
|
||||
public function side2(Side2 $side) {
|
||||
$side = $side->where('id', '1')->first();
|
||||
return view('themes.default1.agent.kb.settings.side2', compact('side'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post functio for side
|
||||
* @param type $id
|
||||
* @param type Side2 $side
|
||||
* @param type Request $request
|
||||
* @return response
|
||||
*/
|
||||
public function postside2($id, Side2 $side, Request $request) {
|
||||
$side = $side->whereId($id)->first();
|
||||
if ($side->fill($request->input())->save()) {
|
||||
return redirect('side2')->with('success', 'Side Widget 2 Created !');
|
||||
} else {
|
||||
return redirect('side2')->with('fails', 'Whoops ! Something went Wrong ! ');
|
||||
}
|
||||
}
|
||||
|
||||
static function language() {
|
||||
// $set = Settings::whereId(1)->first();
|
||||
// $lang = $set->language;
|
||||
Config::set('app.locale', 'en');
|
||||
Config::get('app');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user