update v1.0.6

This commit is contained in:
sujitprasad
2016-02-16 22:42:08 +05:30
parent e6b579d67b
commit 073a49a8af
587 changed files with 21487 additions and 22766 deletions

View File

@@ -1,92 +0,0 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// models
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Email\Emails;
use App\User;
// classes
use DB;
use View;
use Auth;
/**
* DashboardController
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class DashboardController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('role.agent');
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function index() {
try {
if(Auth::user()->role == "user"){
return \Redirect::route('home');
}
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} catch (Exception $e) {
return view('404');
}
}
/**
* ChartData
* @return type
*/
public function ChartData()
{
$date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d');
$format = 'Y-m-d';
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
$return = "";
$last = "";
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
$thisDate = date( 'Y-m-d', $i );
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities',$value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
}
$last = rtrim($return,',');
return '['.$last.']';
// $ticketlist = DB::table('tickets')
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),
// DB::raw('count(*) as totaltickets'))
// ->groupBy('month')
// ->orderBy('month', 'asc')
// ->get();
// return $ticketlist;
}
}

View File

@@ -1,234 +0,0 @@
@extends('themes.default1.agent.layout.agent')
@section('Dashboard')
class="active"
@stop
@section('dashboard-bar')
active
@stop
@section('dashboard')
class="active"
@stop
@section('content')
<div class="box box-info">
<?php
// $tickets = App\Model\Ticket\Tickets::where('created_at','>=',date('Y-m-d'))->get();
// echo count($tickets);
?>
<div class="box-header with-border">
<h3 class="box-title">{!! Lang::get('lang.line_chart') !!}</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
<div class="chart" >
<div id="legendDiv"></div>
<canvas class="chart-data" id="tickets-graph" width="1000" height="400"></canvas>
</div>
</div><!-- /.box-body -->
</div><!-- /.box -->
<hr/>
<div class="box">
<div class="box-header">
<h1>{!! Lang::get('lang.statistics') !!}</h1>
</div>
<div class="box-body">
<table class="table table-hover" style="overflow:hidden;">
<tr>
<th>{!! Lang::get('lang.department') !!}</th>
<th>{!! Lang::get('lang.opened') !!}</th>
<th>{!! Lang::get('lang.resolved') !!}</th>
<th>{!! Lang::get('lang.closed') !!}</th>
<th>{!! Lang::get('lang.deleted') !!}</th>
</tr>
<?php $departments = App\Model\helpdesk\Agent\Department::all(); ?>
@foreach($departments as $department)
<?php
$open = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',1)->count();
$resolve = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',2)->count();
$close = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',3)->count();
$delete = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',5)->count();
?>
<tr>
<td>{!! $department->name !!}</td>
<td>{!! $open !!}</td>
<td>{!! $resolve !!}</td>
<td>{!! $close !!}</td>
<td>{!! $delete !!}</td>
</tr>
@endforeach
</table>
</div>
</div>
<script src="{{asset("lb-faveo/plugins/chartjs/Chart.min.js")}}" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$.getJSON("agen", function (result) {
var labels = [],data=[],data2=[],data3=[],data4=[];
for (var i = 0; i < result.length; i++) {
$var12 = result[i].month;
if($var12 == 1){
$var13 = "January";
}
if($var12 == 2){
$var13 = "Febuary";
}
if($var12 == 3){
$var13 = "March";
}
if($var12 == 4){
$var13 = "April";
}
if($var12 == 5){
$var13 = "May";
}
if($var12 == 6){
$var13 = "June";
}
if($var12 == 7){
$var13 = "July";
}
if($var12 == 8){
$var13 = "August";
}
if($var12 == 9){
$var13 = "September";
}
if($var12 == 10){
$var13 = "October";
}
if($var12 == 11){
$var13 = "November";
}
if($var12 == 12){
$var13 = "December";
}
labels.push($var13);
data.push(result[i].totaltickets);
data2.push(result[i].closed);
data3.push(result[i].reopened);
data4.push(result[i].open);
}
var buyerData = {
labels : labels,
datasets : [
{
label : "Total Tickets" ,
fillColor : "rgba(240, 127, 110, 0.3)",
strokeColor : "#f56954",
pointColor : "#A62121",
pointStrokeColor : "#E60073",
data : data
}
,
{
label : "Open Tickets" ,
fillColor : "rgba(255, 102, 204, 0.4)",
strokeColor : "#f56954",
pointColor : "#FF66CC",
pointStrokeColor : "#fff",
pointHighlightFill : "#FF4DC3",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data4
}
,
{
label : "Closed Tickets",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#0000CC",
pointHighlightFill : "#0000E6",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data2
}
,
{
label : "Reopened Tickets",
fillColor : "rgba(102,255,51,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(46,184,0,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data3
}
]
};
var myLineChart = new Chart(document.getElementById("tickets-graph").getContext("2d")).Line(buyerData, {
showScale: true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines: false,
//String - Colour of the grid lines
scaleGridLineColor: "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth: 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines: true,
//Boolean - Whether the line is curved between points
bezierCurve: false,
//Number - Tension of the bezier curve between points
bezierCurveTension: 0.3,
//Boolean - Whether to show a dot for each point
pointDot: true,
//Number - Radius of each point dot in pixels
pointDotRadius: 4,
//Number - Pixel width of point dot stroke
pointDotStrokeWidth: 1,
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point
pointHitDetectionRadius: 20,
//Boolean - Whether to show a stroke for datasets
datasetStroke: true,
//Number - Pixel width of dataset stroke
datasetStrokeWidth: 1,
//Boolean - Whether to fill the dataset with a color
datasetFill: true,
//String - A legend template
//Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: false,
//Boolean - whether to make the chart responsive to window resizing
responsive: true,
legendTemplate : '<ul style="list-style-type: square;">'
+'<% for (var i=0; i<datasets.length; i++) { %>'
+'<li style="color: <%=datasets[i].pointColor%>;">'
+'<span style=\"background-color:<%=datasets[i].pointColor%>\"></span>'
+'<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
+'</li>'
+'<% } %>'
+'</ul>'
});
document.getElementById("legendDiv").innerHTML = myLineChart.generateLegend();
});
});
</script>
@stop

View File

@@ -1,16 +1,15 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CannedRequest;
use App\Http\Requests\helpdesk\CannedUpdateRequest;
// model
use App\Model\helpdesk\Agent_panel\Canned;
use App\User;
// classes
use Exception;
@@ -25,129 +24,129 @@ use Exception;
*/
class CannedController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Display a listing of the Canned Responses.
* @return type View
*/
public function index() {
return view('themes.default1.agent.helpdesk.canned.index');
}
/**
* Display a listing of the Canned Responses.
* @return type View
*/
public function index() {
return view('themes.default1.agent.helpdesk.canned.index');
}
/**
* Show the form for creating a new Canned Response
* @return type View
*/
public function create() {
return view('themes.default1.agent.helpdesk.canned.create');
}
/**
* Show the form for creating a new Canned Response
* @return type View
*/
public function create() {
return view('themes.default1.agent.helpdesk.canned.create');
}
/**
* Store a newly created Canned Response.
* @param type CannedRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function store(CannedRequest $request, Canned $canned) {
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success','Added Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
}
}
/**
* Store a newly created Canned Response.
* @param type CannedRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function store(CannedRequest $request, Canned $canned) {
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success', 'Added Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the Canned Response.
* @param type $id
* @param type Canned $canned
* @return type View
*/
public function edit($id, Canned $canned) {
// fetching requested canned response
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id','=',$id)->first();
return view('themes.default1.agent.helpdesk.canned.edit',compact('canned'));
}
/**
* Show the form for editing the Canned Response.
* @param type $id
* @param type Canned $canned
* @return type View
*/
public function edit($id, Canned $canned) {
// fetching requested canned response
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first();
return view('themes.default1.agent.helpdesk.canned.edit', compact('canned'));
}
/**
* Update the Canned Response in database.
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function update($id, CannedUpdateRequest $request, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->where('id','=',$id)->where('user_id', '=', \Auth::user()->id)->first();
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success','Updated Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
}
}
/**
* Update the Canned Response in database.
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function update($id, CannedUpdateRequest $request, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success', 'Updated Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Delete the Canned Response from storage.
* @param type $id
* @param type Canned $canned
* @return type Redirect
*/
public function destroy($id, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
try {
$canned->delete();
/* redirect to Index page with Success Message */
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Delete the Canned Response from storage.
* @param type $id
* @param type Canned $canned
* @return type Redirect
*/
public function destroy($id, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
try {
$canned->delete();
/* redirect to Index page with Success Message */
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Fetch Canned Response in the ticket detail page.
* @param type $id
* @return type json
*/
public function get_canned($id) {
// checking for the canned response with requested value
if($id != "zzz") {
// fetching canned response
$canned = Canned::where('id','=',$id)->where('user_id','=',\Auth::user()->id)->first();
$msg = $canned->message;
} else {
$msg = "";
}
// returning the canned response in JSON format
return \Response::json($msg);
}
/**
* Fetch Canned Response in the ticket detail page.
* @param type $id
* @return type json
*/
public function get_canned($id) {
// checking for the canned response with requested value
if ($id != "zzz") {
// fetching canned response
$canned = Canned::where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
$msg = $canned->message;
} else {
$msg = "";
}
// returning the canned response in JSON format
return \Response::json($msg);
}
}
}

View File

@@ -1,14 +1,14 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// models
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Email\Emails;
use App\User;
// classes
use DB;
use View;
@@ -25,81 +25,78 @@ use Exception;
*/
class DashboardController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking for authentication
$this->middleware('auth');
$this->middleware('auth');
// checking if the role is agent
$this->middleware('role.agent');
}
$this->middleware('role.agent');
}
/**
* Get the dashboard page
* @return type view
*/
public function index() {
// if(Auth::user()->role == "user"){
// return \Redirect::route('home');
// }
/**
* Get the dashboard page
* @return type view
*/
public function index() {
// if(Auth::user()->role == "user"){
// return \Redirect::route('home');
// }
try {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} catch (Exception $e) {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
}
}
}
/**
* Fetching dashboard graph data to implement graph
* @return type Json
*/
public function ChartData($date111 = "",$date122 = "")
{
$date11 = strtotime($date122);
$date12 = strtotime($date111);
if($date11 && $date12){
$date2 = $date12;
$date1 = $date11;
} else {
public function ChartData($date111 = "", $date122 = "") {
$date11 = strtotime($date122);
$date12 = strtotime($date111);
if ($date11 && $date12) {
$date2 = $date12;
$date1 = $date11;
} else {
// generating current date
$date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d');
$format = 'Y-m-d';
// generating a date range of 1 month
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
}
$return = "";
$last = "";
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
$thisDate = date( 'Y-m-d', $i );
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities',$value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
}
$last = rtrim($return,',');
$date1 = strtotime(Date($format, strtotime('-1 month' . $date3)));
}
$return = "";
$last = "";
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
$thisDate = date('Y-m-d', $i);
$created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array));
$return .= $json . ',';
}
$last = rtrim($return, ',');
return '[' . $last . ']';
return '['.$last.']';
// $ticketlist = DB::table('tickets')
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
// DB::raw('count(*) as totaltickets'))
// ->groupBy('month')
// ->orderBy('month', 'asc')
// ->get();
// return $ticketlist;
}

View File

@@ -1,8 +1,10 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// models
use App\User;
use App\Model\helpdesk\Email\Emails;
@@ -10,17 +12,17 @@ use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Tickets;
// classes
use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
use ForceUTF8\Encoding;
use \ForceUTF8\Encoding;
use App;
use DB;
use Crypt;
@@ -28,9 +30,7 @@ use Schedule;
use File;
use Artisan;
use Exception;
use Phpmailer\PHPMailerautoload;
//$root = realpath($_SERVER["DOCUMENT_ROOT"]);
//include_once($root.'\vendor\phpmailer\phpmailer\PHPMailerautoload.php');
/**
* MailController
*
@@ -40,211 +40,218 @@ use Phpmailer\PHPMailerautoload;
*/
class MailController extends Controller {
/**
* constructor
* Create a new controller instance.
* @param type TicketController $TicketController
*/
public function __construct(TicketController $TicketController) {
$this->TicketController = $TicketController;
}
/**
* constructor
* Create a new controller instance.
* @param type TicketController $TicketController
*/
public function __construct(TicketController $TicketController) {
$this->TicketController = $TicketController;
}
/**
* Reademails
* @return type
*/
public function readmails(Emails $emails, Email $settings_email, System $system)
{
// $path_url = $system->first()->url;
if($settings_email->first()->email_fetching == 1)
{
if($settings_email->first()->all_emails == 1)
{
// $helptopic = $this->TicketController->default_helptopic();
// $sla = $this->TicketController->default_sla();
$email = $emails->get();
foreach($email as $e_mail)
{
$helptopic = $e_mail->help_topic;
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
$sla = $get_helptopic->sla_plan;
$dept = $e_mail->department;
$host = $e_mail->fetching_host;
$port = $e_mail->fetching_port;
$protocol = $e_mail->mailbox_protocol;
$get_mailboxprotocol = MailboxProtocol::where('id','=',$protocol)->first();
$protocol = $get_mailboxprotocol->value;
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
$password = Crypt::decrypt($e_mail->password);
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('SINCE '. date('d-M-Y', strtotime("-1 day")));
if(!$mailsIds) {
die('Mailbox is empty');
}
foreach($mailsIds as $mailId) {
$overview = $mailbox->get_overview($mailId);
$var = $overview[0]->seen ? 'read' : 'unread';
if ($var == 'unread') {
$mail = $mailbox->getMail($mailId);
if($settings_email->first()->email_collaborator == 1) {
$collaborator = $mail->cc;
} else {
$collaborator = null;
}
$body = $mail->textHtml;
if($body == null) {
$body = $mailbox->backup_getmail($mailId);
$body = str_replace('\r\n', '<br/>', $body);
// var_dump($body);
}
$date = $mail->date;
$datetime = $overview[0]->date;
$date_time = explode(" ", $datetime);
$date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
$date = date('Y-m-d H:i:s', strtotime($date));
// dd($date);
if(isset($mail->subject)){
$subject = $mail->subject;
} else {
$subject = "No Subject";
}
// dd($subject);
$fromname = $mail->fromName;
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name','=','email')->first();
$source = $ticket_source->id;
$phone = "";
$priority = $get_helptopic->priority;
// Ticket_Priority::where('')
/**
* Reademails
* @return type
*/
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) {
// $path_url = $system->first()->url;
if ($settings_email->first()->email_fetching == 1) {
if ($settings_email->first()->all_emails == 1) {
// $helptopic = $this->TicketController->default_helptopic();
// $sla = $this->TicketController->default_sla();
$email = $emails->get();
foreach ($email as $e_mail) {
$priority = $e_mail->priority;
$dept = $e_mail->department;
$helptopic = $e_mail->help_topic;
$assign = $get_helptopic->auto_assign;
$form_data = null;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
// dd($result);
if ($result[1] == true) {
$ticket_table = Tickets::where('ticket_number', '=' , $result[0])->first();
$thread_id = Ticket_Thread::where('ticket_id','=',$ticket_table->id)->max('id');
// $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
$thread_id = $thread_id;
foreach($mail->getAttachments() as $attachment) {
$support = "support";
// echo $_SERVER['DOCUMENT_ROOT'];
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
// dd($attachment->filePath);
$filepath = explode('../../../../../public',$attachment->filePath);
// var_dump($attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
$path = public_path().$filepath[1];
// dd($path);
$filesize = filesize($path);
$file_data = file_get_contents($path);
$ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
$imageid = $attachment->id;
$string = str_replace('-', '', $attachment->name);
$filename = explode('src', $attachment->filePath);
$filename = str_replace('\\', '', $filename);
$body = str_replace("cid:".$imageid, $filepath[1], $body);
$pos = strpos($body, $filepath[1]);
if ($priority == null) {
$priority = $ticket->first()->priority;
}
if($pos == false) {
if($settings_email->first()->attachment == 1) {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "ATTACHMENT";
$upload->save();
if ($dept == null) {
$dept = $system->first()->department;
}
if ($helptopic == null) {
$helptopic = $ticket->first()->help_topic;
}
// dd($dept);
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
$sla = $get_helptopic->sla_plan;
// $dept = $e_mail->department;
$host = $e_mail->fetching_host;
$port = $e_mail->fetching_port;
$protocol = $e_mail->mailbox_protocol;
$get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol)->first();
$protocol = $get_mailboxprotocol->value;
$imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
$password = Crypt::decrypt($e_mail->password);
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day")));
if (!$mailsIds) {
die('Mailbox is empty');
}
foreach ($mailsIds as $mailId) {
$overview = $mailbox->get_overview($mailId);
$var = $overview[0]->seen ? 'read' : 'unread';
if ($var == 'unread') {
$mail = $mailbox->getMail($mailId);
if ($settings_email->first()->email_collaborator == 1) {
$collaborator = $mail->cc;
} else {
$collaborator = null;
}
$body = $mail->textHtml;
if ($body == null) {
$body = $mailbox->backup_getmail($mailId);
$body = str_replace('\r\n', '<br/>', $body);
// var_dump($body);
}
$date = $mail->date;
$datetime = $overview[0]->date;
$date_time = explode(" ", $datetime);
$date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
$date = date('Y-m-d H:i:s', strtotime($date));
// dd($date);
if (isset($mail->subject)) {
$subject = $mail->subject;
} else {
$subject = "No Subject";
}
// dd($subject);
$fromname = $mail->fromName;
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
$source = $ticket_source->id;
$phone = "";
$assign = $get_helptopic->auto_assign;
$form_data = null;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
// dd($result);
if ($result[1] == true) {
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
// $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
$thread_id = $thread_id;
foreach ($mail->getAttachments() as $attachment) {
$support = "support";
// echo $_SERVER['DOCUMENT_ROOT'];
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
// dd($attachment->filePath);
$filepath = explode('../../../../../public', $attachment->filePath);
// var_dump($attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
$path = public_path() . $filepath[1];
// dd($path);
$filesize = filesize($path);
$file_data = file_get_contents($path);
$ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
$imageid = $attachment->id;
$string = str_replace('-', '', $attachment->name);
$filename = explode('src', $attachment->filePath);
$filename = str_replace('\\', '', $filename);
$body = str_replace("cid:" . $imageid, $filepath[1], $body);
$pos = strpos($body, $filepath[1]);
if ($pos == false) {
if ($settings_email->first()->attachment == 1) {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "ATTACHMENT";
$upload->save();
}
} else {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "INLINE";
$upload->save();
}
unlink($path);
}
} else {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "INLINE";
$upload->save();
}
unlink($path);
}
$body = Encoding::fixUTF8($body);
$thread = Ticket_Thread::where('id','=',$thread_id)->first();
$thread->body = $this->separate_reply($body) ;
$thread->save();
}
}
}
}
}
}
}
$body = Encoding::fixUTF8($body);
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
$thread->body = $this->separate_reply($body);
$thread->save();
}
}
}
}
}
}
}
/**
* separate reply
* @param type $body
* @return type string
*/
public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
return $body3;
}
/**
* separate reply
* @param type $body
* @return type string
*/
public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
return $body3;
}
/**
* Decode Imap text
* @param type $str
* @return type string
*/
public function decode_imap_text($str) {
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
/**
* Decode Imap text
* @param type $str
* @return type string
*/
public function decode_imap_text($str) {
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
/**
* fetch_attachments
* @return type
*/
public function fetch_attachments(){
$uploads = Upload::all();
foreach($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file);
ob_start();
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
}
}
/**
* fetch_attachments
* @return type
*/
public function fetch_attachments() {
$uploads = Upload::all();
foreach ($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file);
ob_start();
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
}
}
/**
* function to load data
* @param type $id
* @return type file
*/
public function get_data($id){
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id','=',$id)->get();
foreach($attachments as $attachment)
{
header('Content-type: application/'.$attachment->type.'');
header('Content-Disposition: inline; filename='.$attachment->name.'');
header('Content-Transfer-Encoding: binary');
echo $attachment->file;
}
}
/**
* function to load data
* @param type $id
* @return type file
*/
public function get_data($id) {
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
foreach ($attachments as $attachment) {
header('Content-type: application/' . $attachment->type . '');
header('Content-Disposition: inline; filename=' . $attachment->name . '');
header('Content-Transfer-Encoding: binary');
echo $attachment->file;
}
}
}

View File

@@ -1,8 +1,9 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// Model
use App\User;
use App\Model\helpdesk\Settings\Company;
@@ -10,7 +11,6 @@ use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Utility\Log_notification;
use App\Model\helpdesk\settings\Email;
// classes
use Exception;
@@ -24,138 +24,138 @@ use Exception;
*/
class NotificationController extends Controller {
/**
* This function is for sending daily report/notification about the system
**/
public function send_notification() {
//fetching email settings
$email = Email::where('id','=','1')->first();
// checking if the daily notification is enabled or not
if($email->notification_cron == 1){
// checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log','=','NOT-1')->orderBy('id','DESC')->first();
$date = explode(" " , $notification->created_at);
if(Date('Y-m-d') == $date[0]){
} else {
// creating a daily notification log
Log_notification::create(['log'=>'NOT-1']);
$company = $this->company();
// Send notification details to admin
$this->send_notification_to_admin($company);
// Send notification details to team lead
$this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$this->send_notification_to_manager($company);
// Send notification details to all the agents
$this->send_notification_to_agent($company);
}
}
}
/**
* This function is for sending daily report/notification about the system
* */
public function send_notification() {
//fetching email settings
$email = Email::where('id', '=', '1')->first();
// checking if the daily notification is enabled or not
if ($email->notification_cron == 1) {
// checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first();
$date = explode(" ", $notification->created_at);
if (Date('Y-m-d') == $date[0]) {
} else {
// creating a daily notification log
Log_notification::create(['log' => 'NOT-1']);
$company = $this->company();
// Send notification details to admin
$this->send_notification_to_admin($company);
// Send notification details to team lead
$this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$this->send_notification_to_manager($company);
// Send notification details to all the agents
$this->send_notification_to_agent($company);
}
}
}
/**
* Admin Notification/Report
* @param company
* @return mail
**/
public function send_notification_to_admin($company) {
// get all admin users
$users = User::where('role','=','admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.admin', ['company' => $company, 'name'=>$user_name], function ($message)use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company . ' Daily Report ');
});
}
}
/**
* Admin Notification/Report
* @param company
* @return mail
* */
public function send_notification_to_admin($company) {
// get all admin users
$users = User::where('role', '=', 'admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message)use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company . ' Daily Report ');
});
}
}
/**
* Department Manager Notification/Report
* @return mail
**/
public function send_notification_to_manager($company) {
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
if(isset($dept->manager)) {
$dept_name = $dept->name;
$users = User::where('id','=',$dept->manager)->get();
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.manager', ['company' => $company, 'name'=>$user_name,'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for department manager of '. $dept_name.' department.');
});
}
}
}
}
/**
* Department Manager Notification/Report
* @return mail
* */
public function send_notification_to_manager($company) {
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
if (isset($dept->manager)) {
$dept_name = $dept->name;
$users = User::where('id', '=', $dept->manager)->get();
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for department manager of ' . $dept_name . ' department.');
});
}
}
}
}
/**
* Team Lead Notification/Report
* @return mail
**/
public function send_notification_to_team_lead($company) {
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
if(isset($team->team_lead)) {
$team_name = $team->name;
$users = User::where('id','=',$team->team_lead)->get();
foreach ($users as $user) {
// Send notification details to team lead
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.lead', ['company' => $company, 'name'=>$user_name,'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team '. $team_name);
});
}
}
}
}
/**
* Team Lead Notification/Report
* @return mail
* */
public function send_notification_to_team_lead($company) {
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
if (isset($team->team_lead)) {
$team_name = $team->name;
$users = User::where('id', '=', $team->team_lead)->get();
foreach ($users as $user) {
// Send notification details to team lead
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team ' . $team_name);
});
}
}
}
}
/**
* Agent Notification/Report
* @return mail
**/
public function send_notification_to_agent($company) {
// get all agents users
$users = User::where('role','=','agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.agent', ['company' => $company, 'name'=>$user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Agents');
});
}
}
/**
* Agent Notification/Report
* @return mail
* */
public function send_notification_to_agent($company) {
// get all agents users
$users = User::where('role', '=', 'agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Agents');
});
}
}
/**
* Fetching company name
* @return type variable
*/
public function company() {
// fetching comapny model
$company = Company::Where('id','=','1')->first();
// fetching company name
if($company->company_name == null){
$company = "Support Center";
}else{
$company = $company->company_name;
}
return $company;
}
/**
* Fetching company name
* @return type variable
*/
public function company() {
// fetching comapny model
$company = Company::Where('id', '=', '1')->first();
// fetching company name
if ($company->company_name == null) {
$company = "Support Center";
} else {
$company = $company->company_name;
}
return $company;
}
// // testing
// public function test(){
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// }
}
// // testing
// public function test(){
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// }
}

View File

@@ -1,13 +1,14 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\OrganizationRequest;
/* include organization model */
use App\Http\Requests\helpdesk\OrganizationUpdate;
// models
/* Define OrganizationRequest to validate the create form */
use App\Model\helpdesk\Agent_panel\Organization;
@@ -27,73 +28,73 @@ use Exception;
*/
class OrganizationController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking for authentication
$this->middleware('auth');
$this->middleware('auth');
// checking if the role is agent
$this->middleware('role.agent');
}
$this->middleware('role.agent');
}
/**
* Display a listing of the resource.
* @param type Organization $org
* @return type Response
*/
public function index() {
try {
/* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Organization $org
* @return type Response
*/
public function index() {
try {
/* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* This function is used to display the list of Organizations
* @return datatable
*/
public function org_list() {
// chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all())
/* searchable name */
->searchColumns('name')
/* order by name and website */
->orderColumns('name', 'website')
/* column name */
->addColumn('name', function ($model) {
// return $model->name;
if(strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')).' ...';
} else {
$orgname = $model->name;
}
return $orgname;
})
/* column website */
->addColumn('website', function ($model) {
$website = $model->website;
return $website;
})
/* column phone number */
->addColumn('phone', function ($model) {
$phone = $model->phone;
return $phone;
})
/* column action buttons */
->addColumn('Actions', function ($model) {
// displaying action buttons
// modal popup to delete data
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="'.route('organizations.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle'.$model->id .'">
/**
* This function is used to display the list of Organizations
* @return datatable
*/
public function org_list() {
// chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all())
/* searchable name */
->searchColumns('name')
/* order by name and website */
->orderColumns('name', 'website')
/* column name */
->addColumn('name', function ($model) {
// return $model->name;
if (strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')) . ' ...';
} else {
$orgname = $model->name;
}
return $orgname;
})
/* column website */
->addColumn('website', function ($model) {
$website = $model->website;
return $website;
})
/* column phone number */
->addColumn('phone', function ($model) {
$phone = $model->phone;
return $phone;
})
/* column action buttons */
->addColumn('Actions', function ($model) {
// displaying action buttons
// modal popup to delete data
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="' . route('organizations.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="' . route('organizations.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -101,154 +102,154 @@ class OrganizationController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->user_name.'
' . $model->user_name . '
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="'.route('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a>
<a href="' . route('org.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})
->make();
}
})
->make();
}
/**
* Show the form for creating a new organization.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new organization.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created organization in storage.
* @param type Organization $org
* @param type OrganizationRequest $request
* @return type Redirect
*/
public function store(Organization $org, OrganizationRequest $request) {
try {
/* Insert the all input request to organization table */
/* Check whether function success or not */
if ($org->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
}
/**
* Store a newly created organization in storage.
* @param type Organization $org
* @param type OrganizationRequest $request
* @return type Redirect
*/
public function store(Organization $org, OrganizationRequest $request) {
try {
/* Insert the all input request to organization table */
/* Check whether function success or not */
if ($org->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
}
/**
* Display the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function show($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Display the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function show($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function edit($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function edit($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified organization in storage.
* @param type $id
* @param type Organization $org
* @param type OrganizationUpdate $request
* @return type Redirect
*/
public function update($id, Organization $org, OrganizationUpdate $request) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* update the organization table */
/* Check whether function success or not */
try {
if ($orgs->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified organization in storage.
* @param type $id
* @param type Organization $org
* @param type OrganizationUpdate $request
* @return type Redirect
*/
public function update($id, Organization $org, OrganizationUpdate $request) {
/**
* Delete a specified organization from storage.
* @param type int $id
* @return type Redirect
*/
public function destroy($id, Organization $org, User_org $user_org) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
$user_orgs = $user_org->where('org_id','=',$id)->get();
foreach ($user_orgs as $user_org) {
$user_org->delete();
}
/* Delete the field selected from the table */
/* Check whether function success or not */
try {
$orgs->delete();
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* update the organization table */
/* Check whether function success or not */
try {
if ($orgs->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Soring an organization head
* @param type $id
* @return type boolean
*/
public function Head_Org($id){
// get the user to make organization head
$head_user = \Input::get('user');
// get an instance of the selected organization
$org_head = Organization::where('id','=',$id)->first();
$org_head->head = $head_user;
// save the user to organization head
$org_head->save();
return 1;
}
/**
* Delete a specified organization from storage.
* @param type int $id
* @return type Redirect
*/
public function destroy($id, Organization $org, User_org $user_org) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
$user_orgs = $user_org->where('org_id', '=', $id)->get();
foreach ($user_orgs as $user_org) {
$user_org->delete();
}
/* Delete the field selected from the table */
/* Check whether function success or not */
try {
$orgs->delete();
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Soring an organization head
* @param type $id
* @return type boolean
*/
public function Head_Org($id) {
// get the user to make organization head
$head_user = \Input::get('user');
// get an instance of the selected organization
$org_head = Organization::where('id', '=', $id)->first();
$org_head->head = $head_user;
// save the user to organization head
$org_head->save();
return 1;
}
}

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
@@ -36,64 +39,64 @@ use PDF;
*/
class Ticket2Controller extends Controller {
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
$this->middleware('auth');
}
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
$this->middleware('auth');
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptopen($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptopen($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptclose($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptclose($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptinprogress($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptinprogress($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
/* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword;
@@ -11,12 +13,10 @@ use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest;
/* include guest_note model */
use App\Http\Requests\helpdesk\Sys_userUpdate;
// models
use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org;
use App\User;
// classes
use Auth;
use Hash;
@@ -34,350 +34,350 @@ use Exception;
*/
class UserController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Display all list of the users.
* @param type User $user
* @return type view
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Display all list of the users.
* @param type User $user
* @return type view
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* This function is used to display the list of users using chumper datatables
* @return datatable
*/
public function user_list() {
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get())
/* searchable column username */
->searchColumns('user_name')
/* order column username and email */
->orderColumns('user_name', 'email')
/* column username */
->addColumn('user_name', function ($model) {
if(strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')).' ...';
} else {
$username = $model->user_name;
}
return $username;
})
/* column email */
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
/* column phone */
->addColumn('phone', function ($model) {
$phone = "";
if($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone ."&nbsp;&nbsp;&nbsp;". $mobile;
return $phone;
})
/* column account status */
->addColumn('status', function ($model) {
$status = $model->active;
if($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
/* column ban status */
->addColumn('ban', function ($model) {
$status = $model->ban;
if($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
return $stat;
})
/* column last login date */
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
/* column actions */
->addColumn('Actions', function ($model) {
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
})
->make();
}
/**
* This function is used to display the list of users using chumper datatables
* @return datatable
*/
public function user_list() {
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
/* searchable column username */
->searchColumns('user_name')
/* order column username and email */
->orderColumns('user_name', 'email')
/* column username */
->addColumn('user_name', function ($model) {
if (strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')) . ' ...';
} else {
$username = $model->user_name;
}
return $username;
})
/* column email */
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
/* column phone */
->addColumn('phone', function ($model) {
$phone = "";
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
return $phone;
})
/* column account status */
->addColumn('status', function ($model) {
$status = $model->active;
if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
/* column ban status */
->addColumn('ban', function ($model) {
$status = $model->ban;
if ($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
return $stat;
})
/* column last login date */
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
/* column actions */
->addColumn('Actions', function ($model) {
return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
})
->make();
}
/**
* Show the form for creating a new users.
* @return type view
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Show the form for creating a new users.
* @return type view
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created users in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
try {
$user->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created users in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
try {
$user->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', $e->errorInfo[2]);
}
}
/**
* Display the specified users.
* @param type int $id
* @param type User $user
* @return type view
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display the specified users.
* @param type int $id
* @param type User $user
* @return type view
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified user in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
/**
* Update the specified user in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
try{
$users->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
try {
$users->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* get agent profile page
* @return type view
*/
public function getProfile() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get agent profile page
* @return type view
*/
public function getProfile() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* get profile edit page
* @return type view
*/
public function getProfileedit() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get profile edit page
* @return type view
*/
public function getProfileedit() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* post profile edit
* @param type int $id
* @param type ProfileRequest $request
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
// geet authenticated user details
$user = Auth::user();
$user->gender = $request->input('gender');
$user->save();
// checking availability of agent profile ppicture
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
}
}
// checking if the post system includes agent profile picture upload
if (Input::file('profile_pic')) {
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name;
// moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database
$user->profile_pic = $fileName;
} else {
try{
$user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} catch (Exception $e){
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
}
}
if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
}
/**
* post profile edit
* @param type int $id
* @param type ProfileRequest $request
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
// geet authenticated user details
$user = Auth::user();
$user->gender = $request->input('gender');
$user->save();
// checking availability of agent profile ppicture
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
}
}
// checking if the post system includes agent profile picture upload
if (Input::file('profile_pic')) {
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name;
// moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database
$user->profile_pic = $fileName;
} else {
try {
$user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} catch (Exception $e) {
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
}
}
if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
}
/**
* Post profile password
* @param type int $id
* @param type ProfilePassword $request
* @return type Redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
// get authenticated user
$user = Auth::user();
// checking if the old password matches the new password
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
try{
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
}
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/**
* Post profile password
* @param type int $id
* @param type ProfilePassword $request
* @return type Redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
// get authenticated user
$user = Auth::user();
// checking if the old password matches the new password
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
try {
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
}
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/**
* Assigning an user to an organization
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* Assigning an user to an organization
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* creating an organization in user profile page via modal popup
* @param type $id
* @return type
*/
public function User_Create_Org($id) {
// checking if the entered value for website is available in database
if(Input::get('website')!=null) {
// checking website
$check = Organization::where('website','=',Input::get('website'))->first();
} else {
$check = null;
}
// checking if the name is unique
$check2 = Organization::where('name','=',Input::get('name'))->first();
// if any of the fields is not available then return false
if (\Input::get('name') == null) {
return "Name is required";
} elseif($check2 != null) {
return "Name should be Unique";
} elseif($check != null) {
return "Website should be Unique";
} else {
// storing organization details and assigning the current user to that organization
$org = new Organization;
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
$org->address = Input::get('address');
$org->internal_notes = Input::get('internal');
$org->save();
/**
* creating an organization in user profile page via modal popup
* @param type $id
* @return type
*/
public function User_Create_Org($id) {
// checking if the entered value for website is available in database
if (Input::get('website') != null) {
// checking website
$check = Organization::where('website', '=', Input::get('website'))->first();
} else {
$check = null;
}
// checking if the name is unique
$check2 = Organization::where('name', '=', Input::get('name'))->first();
// if any of the fields is not available then return false
if (\Input::get('name') == null) {
return "Name is required";
} elseif ($check2 != null) {
return "Name should be Unique";
} elseif ($check != null) {
return "Website should be Unique";
} else {
// storing organization details and assigning the current user to that organization
$org = new Organization;
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
$org->address = Input::get('address');
$org->internal_notes = Input::get('internal');
$org->save();
$user_org = new User_org;
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
// for success return 0
return 0;
}
}
}
$user_org = new User_org;
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
// for success return 0
return 0;
}
}
}

View File

@@ -1,22 +1,21 @@
<?php namespace App\Http\Controllers\Agent\kb;
<?php
namespace App\Http\Controllers\Agent\kb;
// Controllers
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;
// Requests
use App\Http\Requests\kb\ArticleRequest;
use App\Http\Requests\kb\ArticleUpdate;
// Models
use App\Model\kb\Article;
use App\Model\kb\Category;
use App\Model\kb\Relationship;
use App\Model\kb\Settings;
use App\Model\kb\Comment;
// Classes
use Auth;
use Chumper\Datatable\Table;
@@ -36,52 +35,52 @@ use Exception;
*/
class ArticleController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
public function test() {
//$table = $this->setDatatable();
return view('themes.default1.agent.kb.article.test');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
/**
* Fetching all the list of articles in a chumper datatable format
* @return type void
*/
public function getData() {
// returns chumper datatable
return Datatable::collection(Article::All())
/* searcable column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column action */
->addColumn('Actions', function ($model) {
/* here are all the action buttons and modal popup to delete articles with confirmations */
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=show/'.$model->slug .' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle'.$model->id .'">
public function test() {
//$table = $this->setDatatable();
return view('themes.default1.agent.kb.article.test');
}
/**
* Fetching all the list of articles in a chumper datatable format
* @return type void
*/
public function getData() {
// returns chumper datatable
return Datatable::collection(Article::All())
/* searcable column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column action */
->addColumn('Actions', function ($model) {
/* here are all the action buttons and modal popup to delete articles with confirmations */
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=show/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -89,188 +88,192 @@ class ArticleController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $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>
<a href="article/delete/' . $model->slug . '"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})
->make();
}
})
->make();
}
/**
* List of Articles
* @return type view
*/
public function index() {
/* show article list */
try{
return view('themes.default1.agent.kb.article.index');
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* List of Articles
* @return type view
*/
public function index() {
/* show article list */
try {
return view('themes.default1.agent.kb.article.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Creating a Article
* @param type Category $category
* @return type view
*/
public function create(Category $category) {
/* get the attributes of the category */
$category = $category->lists('id', 'name');
/* get the create page */
try{
return view('themes.default1.agent.kb.article.create', compact('category'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Creating a Article
* @param type Category $category
* @return type view
*/
public function create(Category $category) {
/* get the attributes of the category */
$category = $category->lists('id', 'name');
/* get the create page */
try {
return view('themes.default1.agent.kb.article.create', compact('category'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Insert the values to the article
* @param type Article $article
* @param type ArticleRequest $request
* @return type redirect
*/
public function store(Article $article, ArticleRequest $request) {
// requesting the values to store article data
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$article->slug = $slug;
$article->fill($request->except('created_at','slug'))->save();
// creating article category relationship
$requests = $request->input('category_id');
$id = $article->id;
foreach ($requests as $req) {
DB::insert('insert into kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
}
/* insert the values to the article table */
try{
$article->fill($request->except('slug'))->save();
return redirect('article')->with('success', 'Article Inserted Successfully');
} catch (Exception $e) {
return redirect('article')->with('fails', 'Article Not Inserted'. '<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Insert the values to the article
* @param type Article $article
* @param type ArticleRequest $request
* @return type redirect
*/
public function store(Article $article, ArticleRequest $request) {
// requesting the values to store article data
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
/**
* Edit an Article by id
* @param type Integer $id
* @param type Article $article
* @param type Relationship $relation
* @param type Category $category
* @return view
*/
public function edit($slug, Article $article, Relationship $relation, Category $category) {
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$article->slug = $slug;
$article->publish_time = $publishTime;
$article->fill($request->except('created_at', 'slug'))->save();
// creating article category relationship
$requests = $request->input('category_id');
$id = $article->id;
$aid = $article->where('id', $slug)->first();
$id = $aid->id;
foreach ($requests as $req) {
DB::insert('insert into kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
}
/* insert the values to the article table */
try {
$article->fill($request->except('slug'))->save();
return redirect('article')->with('success', 'Article Inserted Successfully');
} catch (Exception $e) {
return redirect('article')->with('fails', 'Article Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/* 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 */
try {
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
} catch(Exception $e){
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Edit an Article by id
* @param type Integer $id
* @param type Article $article
* @param type Relationship $relation
* @param type Category $category
* @return view
*/
public function edit($slug, Article $article, Relationship $relation, Category $category) {
$aid = $article->where('id', $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 */
try {
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* 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, ArticleUpdate $request) {
$aid = $article->where('id', $slug)->first();
$id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$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 */
try{
$article->fill($request->all())->save();
$article->slug = $slug;
$article->save();
return redirect('article')->with('success', 'Article Updated Successfully');
} catch(Exception $e){
return redirect('article')->with('fails', 'Article Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* 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, ArticleUpdate $request) {
$aid = $article->where('id', $slug)->first();
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
/**
* 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
$id = $article->id;
$comments = $comment->where('article_id',$id)->get();
if($comments) {
foreach($comments as $comment)
$comment->delete();
$id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$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 kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
}
/* update the value to the table */
try {
$article->fill($request->all())->save();
$article->slug = $slug;
$article->publish_time = $publishTime;
$article->save();
return redirect('article')->with('success', 'Article Updated Successfully');
} catch (Exception $e) {
return redirect('article')->with('fails', 'Article Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* 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
$id = $article->id;
$comments = $comment->where('article_id', $id)->get();
if ($comments) {
foreach ($comments as $comment)
$comment->delete();
}
// deleting relationship
$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');
}
}
$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');
}
}
/**
* user time zone
* fetching timezone
* @param type $utc
* @return type
*/
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');
date_default_timezone_set($tz);
$offset = date('Z', strtotime($utc));
$date = date($format, strtotime($utc) + $offset);
echo $date;
}
/**
* user time zone
* fetching timezone
* @param type $utc
* @return type
*/
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');
date_default_timezone_set($tz);
$offset = date('Z', strtotime($utc));
$date = date($format, strtotime($utc) + $offset);
echo $date;
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Agent\kb;
<?php
namespace App\Http\Controllers\Agent\kb;
// Controllers
use App\Http\Controllers\client\kb\UserController;
@@ -6,15 +8,12 @@ use App\Http\Controllers\admin\kb\ArticleController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// Requests
use App\Http\Requests\kb\CategoryRequest;
use App\Http\Requests\kb\CategoryUpdate;
// Model
use App\Model\kb\Category;
use App\Model\kb\Relationship;
// Classes
use Datatable;
use Redirect;
@@ -30,61 +29,61 @@ use Exception;
*/
class CategoryController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$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 */
try{
return view('themes.default1.agent.kb.category.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* 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 */
try {
return view('themes.default1.agent.kb.category.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* fetching category list in chumper datatables
* @return type chumper datatable
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Category::All())
/* search column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>'. \Lang::get("lang.delete") .'</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">'. \Lang::get("lang.edit") .'</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">'. \Lang::get("lang.view") .'</a>
/**
* fetching category list in chumper datatables
* @return type chumper datatable
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Category::All())
/* search column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get("lang.delete") . '</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get("lang.edit") . '</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">' . \Lang::get("lang.view") . '</a>
<div class="modal fade" id="deletecategory' . $model->slug . '">
<div class="modal-dialog">
<div class="modal-content">
@@ -93,7 +92,7 @@ class CategoryController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $model->name . '
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
@@ -102,116 +101,114 @@ class CategoryController extends Controller {
</div>
</div>
</div>';
})
->make();
})
->make();
}
}
/**
* Create a Category
* @param type Category $category
* @return type view
*/
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 */
try {
return view('themes.default1.agent.kb.category.create', compact('category'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Create a Category
* @param type Category $category
* @return type view
*/
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*/
try {
return view('themes.default1.agent.kb.category.create', compact('category'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* To store the selected category
* @param type Category $category
* @param type CategoryRequest $request
* @return type Redirect
*/
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;
// send success message to index page
try {
$category->fill($request->except('slug'))->save();
return Redirect::back()->with('success', 'Category Inserted Successfully');
} catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* To store the selected category
* @param type Category $category
* @param type CategoryRequest $request
* @return type Redirect
*/
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;
// send success message to index page
try{
$category->fill($request->except('slug'))->save();
return Redirect::back()->with('success', 'Category Inserted Successfully');
} catch(Exception $e) {
return Redirect::back()->with('fails', 'Category Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Show the form for editing the specified category.
* @param type $slug
* @param type Category $category
* @return type view
*/
public function edit($slug, Category $category) {
// fetch the category
$cid = $category->where('id', $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'));
}
/**
* Show the form for editing the specified category.
* @param type $slug
* @param type Category $category
* @return type view
*/
public function edit($slug, Category $category) {
// fetch the category
$cid = $category->where('id', $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 Category in storage.
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
* @return type redirect
*/
public function update($slug, Category $category, CategoryUpdate $request) {
/**
* Update the specified Category in storage.
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
* @return type redirect
*/
public function update($slug, Category $category, CategoryUpdate $request) {
/* Edit the selected category via id */
$category = $category->where('id', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$category->slug = $slug;
/* update the values at the table via model according with the request */
//redirct to index page with success message
try{
$category->fill($request->all())->save();
$category->slug = $slug;
$category->save();
return redirect('category')->with('success', 'Category Updated Successfully');
} catch(Exception $e) {
//redirect to index with fails message
return redirect('category')->with('fails', 'Category Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/* Edit the selected category via id */
$category = $category->where('id', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$category->slug = $slug;
/* update the values at the table via model according with the request */
//redirct to index page with success message
try {
$category->fill($request->all())->save();
$category->slug = $slug;
$category->save();
return redirect('category')->with('success', 'Category Updated Successfully');
} catch (Exception $e) {
//redirect to index with fails message
return redirect('category')->with('fails', 'Category Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified category from storage.
* @param type $id
* @param type Category $category
* @param type Relationship $relation
* @return type Redirect
*/
public function destroy($id, Category $category, Relationship $relation) {
/**
* Remove the specified category from storage.
* @param type $id
* @param type Category $category
* @param type Relationship $relation
* @return type Redirect
*/
public function destroy($id, Category $category, Relationship $relation) {
$relation = $relation->where('category_id', $id)->first();
if($relation != null){
return Redirect::back()->with('fails', 'Category Not Deleted');
}
else {
/* delete the category selected, id == $id */
$category = $category->whereId($id)->first();
// redirect to index with success message
try{
$category->delete();
return Redirect::back()->with('success', 'Category Deleted Successfully');
} catch(Exception $e){
return Redirect::back()->with('fails', 'Category Not Deleted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
}
$relation = $relation->where('category_id', $id)->first();
if ($relation != null) {
return Redirect::back()->with('fails', 'Category Not Deleted');
} else {
/* delete the category selected, id == $id */
$category = $category->whereId($id)->first();
// redirect to index with success message
try {
$category->delete();
return Redirect::back()->with('success', 'Category Deleted Successfully');
} catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Deleted' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Agent\kb;
<?php
namespace App\Http\Controllers\Agent\kb;
// controllers
use App\Http\Controllers\client\kb\UserController;
@@ -6,15 +8,12 @@ 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;
// request
use App\Http\Requests\kb\PageRequest;
use App\Http\Requests\kb\PageUpdate;
use Illuminate\Http\Request;
// Model
use App\Model\kb\Page;
// classes
use Datatable;
use Exception;
@@ -29,61 +28,61 @@ use Exception;
*/
class PageController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct(Page $page) {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->page = $page;
SettingsController::language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct(Page $page) {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->page = $page;
SettingsController::language();
}
/**
* Display the list of pages
* @return type
*/
public function index() {
$pages = $this->page->paginate(3);
$pages->setPath('page');
try{
return view('themes.default1.agent.kb.pages.index', compact('pages'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Display the list of pages
* @return type
*/
public function index() {
$pages = $this->page->paginate(3);
$pages->setPath('page');
try {
return view('themes.default1.agent.kb.pages.index', compact('pages'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* fetching pages list in chumper datatables
* @return type
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Page::All())
/* search column name */
->searchColumns('name')
/* order column name, description and created */
->orderColumns('name', 'description', 'created')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> '. \Lang::get('lang.delete') .'</button></span>&nbsp;<a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">'. \Lang::get('lang.edit') .'</a>&nbsp;<a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">'. \Lang::get('lang.view') .'</a>
/**
* fetching pages list in chumper datatables
* @return type
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Page::All())
/* search column name */
->searchColumns('name')
/* order column name, description and created */
->orderColumns('name', 'description', 'created')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . '</button></span>&nbsp;<a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletepage' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
@@ -92,7 +91,7 @@ class PageController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $model->name . '
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
@@ -101,85 +100,85 @@ class PageController extends Controller {
</div>
</div>
</div>';
})
->make();
}
})
->make();
}
/**
* Show the form for creating a new resource.
* @return type view
*/
public function create() {
return view('themes.default1.agent.kb.pages.create');
}
/**
* Show the form for creating a new resource.
* @return type view
*/
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;
try{
$this->page->fill($request->except('slug'))->save();
return redirect('page')->with('success','Page created successfully');
} catch(Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]);
}
}
/**
* 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;
try {
$this->page->fill($request->except('slug'))->save();
return redirect('page')->with('success', 'Page created successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To edit a page
* @param type $slug
* @return type view
*/
public function edit($slug) {
try{
$page = $this->page->where('slug', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]);
}
}
/**
* To edit a page
* @param type $slug
* @return type view
*/
public function edit($slug) {
try {
$page = $this->page->where('slug', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To update a page
* @param type $slug
* @param type PageUpdate $request
* @return type redirect
*/
public function update($slug, PageUpdate $request) {
// get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try{
$pages->fill($request->all())->save();
$pages->slug = $slug;
$pages->save();
return redirect('page')->with('success', 'Your Page Updated Successfully');
} catch(Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To update a page
* @param type $slug
* @param type PageUpdate $request
* @return type redirect
*/
public function update($slug, PageUpdate $request) {
// get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try {
$pages->fill($request->all())->save();
$pages->slug = $slug;
$pages->save();
return redirect('page')->with('success', 'Your Page Updated Successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To Delete a Page
* @param type $id
* @return type redirect
*/
public function destroy($id) {
try{
// get the page to be deleted
$page = $this->page->whereId($id)->first();
$page->delete();
return redirect('page')->with('success', 'Page Deleted Successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To Delete a Page
* @param type $id
* @return type redirect
*/
public function destroy($id) {
try {
// get the page to be deleted
$page = $this->page->whereId($id)->first();
$page->delete();
return redirect('page')->with('success', 'Page Deleted Successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
}
}

View File

@@ -1,10 +1,11 @@
<?php namespace App\Http\Controllers\Agent\kb;
<?php
namespace App\Http\Controllers\Agent\kb;
// Controllers
use App\Http\Controllers\Agent\kb\ArticleController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
// Request
use App\Http\Requests\kb\FooterRequest;
use App\Http\Requests\kb\ProfilePassword;
@@ -12,7 +13,6 @@ use App\Http\Requests\kb\ProfileRequest;
use App\Http\Requests\kb\SettingsRequests;
use App\Http\Requests\kb\SocialRequest;
use Illuminate\Http\Request;
// Model
use App\Model\kb\Comment;
use App\Model\kb\Faq;
@@ -22,7 +22,6 @@ use App\Model\kb\Side2;
use App\Model\kb\Social;
use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Utility\Date_format;
// Classes
use Auth;
use Config;
@@ -42,244 +41,241 @@ use Exception;
*/
class SettingsController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->language();
}
/**
* to get the settings page
* @return response
* @package default
*/
public function settings(Settings $settings, Timezones $time, Date_format $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'));
}
/**
* to get the settings page
* @return response
* @package default
*/
public function settings(Settings $settings, Timezones $time, Date_format $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');
}
/**
* 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 Moderate the commenting
* @param type Comment $comment
* @return Response
*/
public function comment(Comment $comment) {
return view('themes.default1.agent.kb.settings.comment');
}
/**
* 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>&nbsp;<a href=published/' . $model->id . ' class="btn btn-warning btn-xs">' . \Lang::get('lang.publish') . '</a>';
})
->make();
}
/**
* 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>&nbsp;<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');
}
}
/**
* 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');
}
}
/**
* 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');
}
}
/**
* get profile page
* @return type view
*/
public function getProfile() {
$time = Timezone::all();
$user = Auth::user();
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
}
/**
* get profile page
* @return type view
*/
public function getProfile() {
$time = Timezone::all();
$user = Auth::user();
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
}
/**
* Post profile page
* @param type ProfileRequest $request
* @return type redirect
*/
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');
}
}
/**
* Post profile page
* @param type ProfileRequest $request
* @return type redirect
*/
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');
}
}
/**
* post profile password
* @param type $id
* @param type ProfilePassword $request
* @return type redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
$user = Auth::user();
//echo $user->password;
/**
* post profile password
* @param type $id
* @param type ProfilePassword $request
* @return type redirect
*/
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');
}
}
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');
}
}
/**
* het locale for language
* @return type config set
*/
static function language() {
// $set = Settings::whereId(1)->first();
// $lang = $set->language;
Config::set('app.locale', 'en');
Config::get('app');
}
/**
* het locale for language
* @return type config set
*/
static function language() {
// $set = Settings::whereId(1)->first();
// $lang = $set->language;
Config::set('app.locale', 'en');
Config::get('app');
}
}