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

View File

@@ -1,13 +1,10 @@
<?php
namespace App\Http\Controllers\Admin;
use Fetch\Server as Server;
class MailFetch extends Server
{
public function __construct($serverPath, $port = 143, $service = 'imap')
{
class MailFetch extends Server{
public function __construct($serverPath, $port = 143, $service = 'imap') {
$this->serverPath = $serverPath;
$this->port = $port;

View File

@@ -3,8 +3,8 @@
namespace App\Http\Controllers\Admin\helpdesk;
// controller
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController;
// request
use App\Http\Requests\helpdesk\AgentRequest;
use App\Http\Requests\helpdesk\AgentUpdate;
@@ -79,11 +79,11 @@ class AgentController extends Controller
{
try {
// gte all the teams
$team = $team_all->get();
$team = $team_all->where('status', '=', 1)->get();
// get all the timezones
$timezones = $timezone->get();
// get all the groups
$groups = $group->get();
$groups = $group->where('group_status', '=', 1)->get();
// get all department
$departments = $department->get();
// list all the teams in a single variable
@@ -92,7 +92,6 @@ class AgentController extends Controller
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
// returns to the page with all the variables and their datas
$send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first();
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team', 'send_otp'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
// returns if try fails with exception meaagse
@@ -121,9 +120,10 @@ class AgentController extends Controller
}
// fixing the user role to agent
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone', 'mobile']))->save();
if ($request->get('mobile')) {
if ($request->get('mobile'))
{
$user->mobile = $request->get('mobile');
} else {
} else{
$user->mobile = null;
}
$user->assign_group = $request->group;
@@ -146,7 +146,7 @@ class AgentController extends Controller
// fetch user credentails to send mail
$name = $user->first_name;
$email = $user->email;
if ($request->input('send_email')) {
if($request->input('send_email')) {
try {
// send mail on registration
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
@@ -159,7 +159,6 @@ class AgentController extends Controller
if ($request->input('active') == '0' || $request->input('active') == 0) {
\Event::fire(new \App\Events\LoginEvent($request));
}
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
} else {
// returns if fails
@@ -186,10 +185,10 @@ class AgentController extends Controller
$location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
$user = $user->whereId($id)->first();
$team = $team->get();
$team = $team->where('status', '=', 1)->get();
$teams1 = $team->lists('name', 'id');
$timezones = $timezone->get();
$groups = $group->get();
$groups = $group->where('group_status', '=', 1)->get();
$departments = $department->get();
$table = $team_assign_agent->where('agent_id', $id)->first();
$teams = $team->lists('id', 'name')->toArray();
@@ -276,6 +275,7 @@ class AgentController extends Controller
$user->id;
$user->delete();
throw new \Exception($error);
return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully'));
} catch (\Exception $e) {
return redirect('agents')->with('fails', $error);

View File

@@ -29,15 +29,14 @@ use Lang;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class DepartmentController extends Controller
{
class DepartmentController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
@@ -49,11 +48,9 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function index(Department $department)
{
public function index(Department $department) {
try {
$departments = $department->get();
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
} catch (Exception $e) {
return view('404');
@@ -73,14 +70,14 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group)
{
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) {
try {
$slas = $sla->get();
$slas = $sla->where('status', '=', 1)
->select('grace_period','id')->get();
$user = $user->where('role', '<>', 'user')
->where('active', '=', 1)
->get();
$emails = $email->get();
$emails = $email->select('email_name','id')->get();
$templates = $template->get();
$department = $department->get();
$groups = $group->lists('id', 'name');
@@ -99,8 +96,7 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function store(Department $department, DepartmentRequest $request)
{
public function store(Department $department, DepartmentRequest $request) {
try {
$department->fill($request->except('group_id', 'manager', 'sla'))->save();
if ($request->sla) {
@@ -123,7 +119,6 @@ class DepartmentController extends Controller
->where('id', 1)
->update(['department' => $department->id]);
}
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
} else {
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
@@ -148,24 +143,24 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group)
{
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) {
try {
$sys_department = \DB::table('settings_system')
->select('department')
->where('id', '=', 1)
->first();
$slas = $sla->get();
$slas = $sla->where('status', '=', 1)
->select('grace_period','id')->get();
$user = $user->where('primary_dpt', $id)
->where('active', '=', 1)
->get();
$emails = $email->get();
->get();
$emails = $email->select('email_name','id')->get();
$templates = $template->get();
$departments = $department->whereId($id)->first();
$groups = $group->lists('id', 'name');
//$groups = $group->lists('id', 'name');
$assign = $group_assign_department->where('department_id', $id)->lists('group_id');
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups', 'sys_department'));
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'sys_department'));
} catch (Exception $e) {
return redirect('departments')->with('fails', $e->getMessage());
}
@@ -181,8 +176,7 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
{
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
// dd($id);
try {
$table = $group_assign_department->where('department_id', $id);
@@ -230,10 +224,9 @@ class DepartmentController extends Controller
*
* @return type Response
*/
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets)
{
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
// try {
$system = $system->where('id', '=', '1')->first();
if ($system->department == $id) {
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
@@ -245,7 +238,7 @@ class DepartmentController extends Controller
} else {
$text_tickets = 'Ticket';
}
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
$ticket = '<li>' . $tickets . ' ' . $text_tickets . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
} else {
$ticket = '';
}
@@ -256,7 +249,7 @@ class DepartmentController extends Controller
} else {
$text_user = 'User';
}
$user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
$user = '<li>' . $users . ' ' . $text_user . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
} else {
$user = '';
}
@@ -267,27 +260,28 @@ class DepartmentController extends Controller
} else {
$text_emails = 'Email';
}
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_department').' </li>';
$email = '<li>' . $emails . ' System ' . $text_emails . Lang::get('lang.have_been_moved_to_default_department') . ' </li>';
} else {
$email = '';
}
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
if ($helptopic > 0) {
$helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
$helptopic = '<li>' . Lang::get('lang.the_associated_helptopic_has_been_deactivated') . '</li>';
} else {
$helptopic = '';
}
$message = $ticket.$user.$email.$helptopic;
$message = $ticket . $user . $email . $helptopic;
/* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete();
$departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */
if ($departments->delete() == true) {
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully') . $message);
} else {
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
}
}
}
}

View File

@@ -3,21 +3,21 @@
namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\EmailsRequest;
// model
use App\Http\Requests\helpdesk\Mail\MailRequest;
use App\Model\helpdesk\Agent\Department;
// model
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Priority;
// classes
use App\Model\helpdesk\Utility\MailboxProtocol;
use Crypt;
// classes
use Exception;
use Lang;
use App\Http\Requests\helpdesk\Mail\MailRequest;
use App\Http\Controllers\Admin\MailFetch as Fetch;
/**
* ======================================
@@ -27,15 +27,14 @@ use Lang;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class EmailsController extends Controller
{
class EmailsController extends Controller {
/**
* Defining constructor variables.
*
* @return type
*/
public function __construct()
{
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
@@ -47,8 +46,7 @@ class EmailsController extends Controller
*
* @return type view
*/
public function index(Emails $email)
{
public function index(Emails $email) {
try {
// fetch all the emails from emails table
$emails = $email->get();
@@ -69,14 +67,13 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
try {
// fetch all the departments from the department table
$departments = $department->get();
// fetch all the helptopics from the helptopic table
$helps = $help->where('status', '=', 1)->get();
// fetch all the types of active priority from the ticket_priority table
// fetch all the types of priority from the ticket_priority table
$priority = $ticket_priority->where('status', '=', 1)->get();
// fetch all the types of mailbox protocols from the mailbox_protocols table
$mailbox_protocols = $mailbox_protocol->get();
@@ -99,8 +96,7 @@ class EmailsController extends Controller
*
* @return int
*/
public function validatingEmailSettings(MailRequest $request, $id = '')
{
public function validatingEmailSettings(MailRequest $request, $id = "") {
//dd($request->all());
try {
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
@@ -118,10 +114,8 @@ class EmailsController extends Controller
}
if ($send == 1 && $fetch == 1) {
$this->store($request, $service_request, $id);
return $this->jsonResponse('success', Lang::get('lang.success'));
}
return $this->validateEmailError($send, $fetch);
} catch (Exception $ex) {
$message = $ex->getMessage();
@@ -129,13 +123,11 @@ class EmailsController extends Controller
$message = imap_last_error();
}
loging('mail-config', $message);
return $this->jsonResponse('fails', $message);
}
}
public function validateEmailError($out, $in)
{
public function validateEmailError($out, $in) {
if ($out !== 1) {
return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed'));
}
@@ -144,15 +136,13 @@ class EmailsController extends Controller
}
}
public function jsonResponse($type, $message)
{
public function jsonResponse($type, $message) {
if ($type == 'fails') {
$result = ['fails' => $message];
}
if ($type == 'success') {
$result = ['success' => $message];
}
return response()->json(compact('result'));
}
@@ -164,10 +154,9 @@ class EmailsController extends Controller
*
* @return type Redirect
*/
public function store($request, $service_request = [], $id = '')
{
public function store($request, $service_request = [], $id = "") {
$email = new Emails();
if ($id !== '') {
if ($id !== "") {
$email = $email->find($id);
}
@@ -219,7 +208,7 @@ class EmailsController extends Controller
if ($request->input('fetching_status')) {
$this->fetch($email);
}
if ($id === '') {
if ($id === "") {
// Creating a default system email as the first email is inserted to the system
$email_settings = Email::where('id', '=', '1')->first();
$email_settings->sys_email = $email->id;
@@ -233,12 +222,31 @@ class EmailsController extends Controller
if ($request->input('fetching_status')) {
$this->fetch($email);
}
return 1;
}
public function sendDiagnoEmail($request)
{
public function checkMail($request) {
$mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address');
$password = $request->input('password');
$name = $request->input('email_name');
$host = $request->input('sending_host');
$port = $request->input('sending_port');
$enc = $request->input('sending_encryption');
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
$this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$transport = \Swift_SmtpTransport::newInstance($host, $port, $enc);
$transport->setUsername($username);
$transport->setPassword($password);
$mailer = \Swift_Mailer::newInstance($transport);
$mailer->getTransport()->start();
return 1;
}
public function sendDiagnoEmail($request) {
$mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address');
@@ -252,45 +260,41 @@ class EmailsController extends Controller
$this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$controller = new \App\Http\Controllers\Common\PhpMailController();
$subject = 'test';
$data = 'test';
$subject = "test";
$data = "test";
//dd(\Config::get('mail'),\Config::get('services'));
$send = $controller->laravelMail($username, $name, $subject, $data, [], []);
return $send;
}
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
{
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port) {
$configs = [
'username' => $username,
'from' => ['address' => $username, 'name' => $name],
'password' => $password,
'username' => $username,
'from' => ['address' => $username, 'name' => $name,],
'password' => $password,
'encryption' => $enc,
'host' => $host,
'port' => $port,
'driver' => $driver,
'host' => $host,
'port' => $port,
'driver' => $driver,
];
foreach ($configs as $key => $config) {
if (is_array($config)) {
foreach ($config as $from) {
\Config::set('mail.'.$key, $config);
\Config::set('mail.' . $key, $config);
}
} else {
\Config::set('mail.'.$key, $config);
\Config::set('mail.' . $key, $config);
}
}
}
public function getDriver($driver_id)
{
$short = '';
public function getDriver($driver_id) {
$short = "";
$email_drivers = new \App\Model\MailJob\MailService();
$email_driver = $email_drivers->find($driver_id);
if ($email_driver) {
$short = $email_driver->short_name;
}
return $short;
}
@@ -306,8 +310,7 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
try {
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
// dd($sys_email);
@@ -319,8 +322,8 @@ class EmailsController extends Controller
$count = $email->count();
// get all the helptopic
$helps = $help->where('status', '=', 1)->get();
// get all active the priority
$priority = $ticket_priority->where('status', '=', 1)->get();
// get all the priority
$priority = $ticket_priority->where('status', '=', 1)->get();
// get all the mailbox protocols
$mailbox_protocols = $mailbox_protocol->get();
@@ -342,8 +345,7 @@ class EmailsController extends Controller
*
* @return int
*/
public function validatingEmailSettingsUpdate($id, MailRequest $request)
{
public function validatingEmailSettingsUpdate($id, MailRequest $request) {
try {
return $this->validatingEmailSettings($request, $id);
} catch (Exception $ex) {
@@ -367,9 +369,9 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function update($id, $request)
{
public function update($id, $request) {
try {
if ($request->sys_email == 'on') {
$system = \DB::table('settings_email')
->where('id', '=', 1)
@@ -395,8 +397,7 @@ class EmailsController extends Controller
*
* @return type Redirect
*/
public function destroy($id, Emails $email)
{
public function destroy($id, Emails $email) {
// fetching the details on the basis of the $id passed to the function
$default_system_email = Email::where('id', '=', '1')->first();
if ($default_system_email->sys_email) {
@@ -410,7 +411,6 @@ class EmailsController extends Controller
$emails = $email->whereId($id)->first();
// checking if deleting the email is success or if it's carrying any dependencies
$emails->delete();
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
} catch (Exception $e) {
// returns if the try fails
@@ -425,8 +425,7 @@ class EmailsController extends Controller
*
* @return type int
*/
public function getImapStream($request)
{
public function getImapStream($request) {
$host = $request->input('fetching_host');
$port = $request->input('fetching_port');
$service = $request->input('fetching_protocol');
@@ -436,7 +435,7 @@ class EmailsController extends Controller
$password = $request->input('password');
$server = new Fetch($host, $port, $service);
//$server->setFlag('novalidate-cert');
if ($encryption != '') {
if ($encryption != "") {
$server->setFlag($encryption);
}
if (!$validate) {
@@ -447,7 +446,6 @@ class EmailsController extends Controller
$server->setAuthentication($username, $password);
$server->getImapStream();
return 1;
}
@@ -458,8 +456,7 @@ class EmailsController extends Controller
*
* @return type int
*/
public function checkImapStream($imap_stream)
{
public function checkImapStream($imap_stream) {
$check_imap_stream = imap_check($imap_stream);
if ($check_imap_stream) {
$imap_stream = 1;
@@ -477,8 +474,7 @@ class EmailsController extends Controller
*
* @return int
*/
public function getSmtp($request)
{
public function getSmtp($request) {
$sending_status = $request->input('sending_status');
// cheking for the sending protocol
if ($request->input('sending_protocol') == 'smtp') {
@@ -494,8 +490,8 @@ class EmailsController extends Controller
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
];
@@ -527,8 +523,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function departmentValue($dept)
{
public function departmentValue($dept) {
if ($dept) {
$email_department = $dept;
} else {
@@ -545,8 +540,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function priorityValue($priority)
{
public function priorityValue($priority) {
if ($priority) {
$email_priority = $priority;
} else {
@@ -563,8 +557,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function helpTopicValue($help_topic)
{
public function helpTopicValue($help_topic) {
if ($help_topic) {
$email_help_topic = $help_topic;
} else {
@@ -574,20 +567,18 @@ class EmailsController extends Controller
return $email_help_topic;
}
public function emailService($service, $value = [])
{
public function emailService($service, $value = []) {
switch ($service) {
case 'mailgun':
case "mailgun":
$this->setServiceConfig($service, $value);
case 'mandrill':
case "mandrill":
$this->setServiceConfig($service, $value);
case 'ses':
case "ses":
$this->setServiceConfig($service, $value);
}
}
public function setServiceConfig($service, $value)
{
public function setServiceConfig($service, $value) {
//dd($service);
if (count($value) > 0) {
foreach ($value as $k => $v) {
@@ -596,8 +587,7 @@ class EmailsController extends Controller
}
}
public function saveMailService($emailid, $request, $driver)
{
public function saveMailService($emailid, $request, $driver) {
$mail_service = new \App\Model\MailJob\FaveoMail();
$mails = $mail_service->where('email_id', $emailid)->get();
if (count($request) > 0) {
@@ -606,17 +596,16 @@ class EmailsController extends Controller
}
foreach ($request as $key => $value) {
$mail_service->create([
'drive' => $driver,
'key' => $key,
'value' => $value,
'drive' => $driver,
'key' => $key,
'value' => $value,
'email_id' => $emailid,
]);
}
}
}
public function readMails()
{
public function readMails() {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
@@ -629,8 +618,7 @@ class EmailsController extends Controller
$controller->readmails($emails, $settings_email, $system, $ticket);
}
public function fetch($email)
{
public function fetch($email) {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
@@ -639,26 +627,4 @@ class EmailsController extends Controller
$controller->fetch($email);
}
public function checkMail($request)
{
$mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address');
$password = $request->input('password');
$name = $request->input('email_name');
$host = $request->input('sending_host');
$port = $request->input('sending_port');
$enc = $request->input('sending_encryption');
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
$this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$transport = \Swift_SmtpTransport::newInstance($host, $port, $enc);
$transport->setUsername($username);
$transport->setPassword($password);
$mailer = \Swift_Mailer::newInstance($transport);
$mailer->getTransport()->start();
return 1;
}
}

View File

@@ -1,637 +0,0 @@
<?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// request
use App\Http\Requests\helpdesk\EmailsEditRequest;
use App\Http\Requests\helpdesk\EmailsRequest;
use App\Http\Requests\helpdesk\Mail\MailRequest;
// model
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Utility\MailboxProtocol;
// classes
use Crypt;
use Exception;
use Illuminate\Http\Request;
use Lang;
/**
* ======================================
* EmailsController.
* ======================================
* This Controller is used to define below mentioned set of functions applied to the Emails in the system.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class EmailsControllerOld extends Controller
{
/**
* Defining constructor variables.
*
* @return type
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the Emails.
*
* @param type Emails $emails
*
* @return type view
*/
public function index(Emails $email)
{
try {
// fetch all the emails from emails table
$emails = $email->get();
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Show the form for creating a new resource.
*
* @param type Department $department
* @param type Help_topic $help
* @param type Priority $priority
* @param type MailboxProtocol $mailbox_protocol
*
* @return type Response
*/
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
try {
// fetch all the departments from the department table
$departments = $department->get();
// fetch all the helptopics from the helptopic table
$helps = $help->get();
// fetch all the types of priority from the ticket_priority table
$priority = $ticket_priority->get();
// fetch all the types of mailbox protocols from the mailbox_protocols table
$mailbox_protocols = $mailbox_protocol->get();
$service = new \App\Model\MailJob\MailService();
$services = $service->lists('name', 'id')->toArray();
// return with all the table data
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'services'));
} catch (Exception $e) {
// return error messages if any
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Check for email input validation.
*
* @param EmailsRequest $request
*
* @return int
*/
public function validatingEmailSettings(MailRequest $request, $id = '')
{
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
$service = $request->input('sending_protocol');
$send = 0;
$imap_check[0] = 0;
if ($request->input('imap_validate') == 'on') {
$validate = '/validate-cert';
} elseif (!$request->input('imap_validate')) {
$validate = '/novalidate-cert';
}
if ($request->input('fetching_status') == 'on') {
try {
$imap_check = $this->getImapStream($request, $validate);
} catch (Exception $ex) {
\Log::error($ex->getMessage());
$result = ['fails' => $ex->getMessage()];
return response()->json(compact('result'));
}
if ($imap_check[0] == 0) {
$response = Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
}
} else {
$imap_check[0] = 1;
}
if ($request->input('sending_status') == 'on') {
$this->emailService($service, $service_request);
try {
$send = $this->sendDiagnoEmail($request);
} catch (Exception $ex) {
\Log::error($ex->getMessage());
$result = ['fails' => $ex->getMessage()];
return response()->json(compact('result'));
}
if ($send === 0) {
$response = Lang::get('lang.outgoing_email_connection_failed');
}
} else {
$send = 1;
}
if ($send === 1 && $imap_check[0] === 1) {
$this->store($request, $imap_check, $service_request, $id);
}
return $this->jsonResponse($send, $imap_check);
}
public function sendDiagnoEmail($request)
{
try {
$mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address');
$password = $request->input('password');
$name = $request->input('email_name');
$host = $request->input('sending_host');
$port = $request->input('sending_port');
$enc = $request->input('sending_encryption');
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
$this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$controller = new \App\Http\Controllers\Common\PhpMailController();
$to = 'example@ladybirdweb.com';
$toname = 'test';
$subject = 'test';
$data = 'test';
//dd(\Config::get('mail'),\Config::get('services'));
$send = $controller->laravelMail($to, $toname, $subject, $data, [], []);
} catch (Exception $e) {
\Log::error($e->getMessage());
//dd($e);
}
return $send;
}
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
{
$configs = [
'username' => $username,
'from' => ['address' => $username, 'name' => $name],
'password' => $password,
'encryption' => $enc,
'host' => $host,
'port' => $port,
'driver' => $driver,
];
foreach ($configs as $key => $config) {
if (is_array($config)) {
foreach ($config as $from) {
\Config::set('mail.'.$key, $config);
}
} else {
\Config::set('mail.'.$key, $config);
}
}
}
public function getDriver($driver_id)
{
$short = '';
$email_drivers = new \App\Model\MailJob\MailService();
$email_driver = $email_drivers->find($driver_id);
if ($email_driver) {
$short = $email_driver->short_name;
}
return $short;
}
/**
* Store a newly created resource in storage.
*
* @param type Emails $email
* @param type EmailsRequest $request
*
* @return type Redirect
*/
public function store($request, $imap_check, $service_request = [], $id = '')
{
$email = new Emails();
if ($id !== '') {
$email = $email->find($id);
}
try {
$email->email_address = $request->email_address;
$email->email_name = $request->email_name;
$email->fetching_host = $request->fetching_host;
$email->fetching_port = $request->fetching_port;
$email->fetching_protocol = $request->fetching_protocol;
$email->sending_host = $request->sending_host;
$email->sending_port = $request->sending_port;
$email->sending_protocol = $this->getDriver($request->sending_protocol);
$email->sending_encryption = $request->sending_encryption;
if ($request->smtp_validate == 'on') {
$email->smtp_validate = $request->smtp_validate;
}
if ($request->input('password')) {
$email->password = Crypt::encrypt($request->input('password'));
}
if ($request->input('fetching_status') == 'on') {
$email->fetching_status = 1;
} else {
$email->fetching_status = 0;
}
if ($request->input('sending_status') == 'on') {
$email->sending_status = 1;
} else {
$email->sending_status = 0;
}
if ($request->input('auto_response') == 'on') {
$email->auto_response = 1;
} else {
$email->auto_response = 0;
}
//dd($email);
if ($imap_check !== null) {
$email->fetching_encryption = $imap_check[0];
} else {
$email->fetching_encryption = $request->input('fetching_encryption');
}
// fetching department value
$email->department = $this->departmentValue($request->input('department'));
// fetching priority value
$email->priority = $this->priorityValue($request->input('priority'));
// fetching helptopic value
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
// inserting the encrypted value of password
$email->password = Crypt::encrypt($request->input('password'));
$email->save(); // run save
if ($id === '') {
// Creating a default system email as the first email is inserted to the system
$email_settings = Email::where('id', '=', '1')->first();
$email_settings->sys_email = $email->id;
$email_settings->save();
} else {
$this->update($id, $request);
}
if (count($service_request) > 0) {
$this->saveMailService($email->id, $service_request, $this->getDriver($request->sending_protocol));
}
return 1;
} catch (Exception $e) {
return 0;
}
}
/**
* Show the form for editing the specified resource.
*
* @param type int $id
* @param type Department $department
* @param type Help_topic $help
* @param type Emails $email
* @param type Priority $priority
* @param type MailboxProtocol $mailbox_protocol
*
* @return type Response
*/
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
try {
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
// dd($sys_email);
// fetch the selected emails
$emails = $email->whereId($id)->first();
// get all the departments
$departments = $department->get();
//get count of emails
$count = $email->count();
// get all the helptopic
$helps = $help->get();
// get all the priority
$priority = $ticket_priority->get();
// get all the mailbox protocols
$mailbox_protocols = $mailbox_protocol->get();
$service = new \App\Model\MailJob\MailService();
$services = $service->lists('name', 'id')->toArray();
// return if the execution is succeeded
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email', 'services'))->with('count', $count);
} catch (Exception $e) {
// return if try fails
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Check for email input validation.
*
* @param EmailsRequest $request
*
* @return int
*/
public function validatingEmailSettingsUpdate($id, MailRequest $request)
{
return $this->validatingEmailSettings($request, $id);
}
/**
* Update the specified resource in storage.
*
* @param type $id
* @param type Emails $email
* @param type EmailsEditRequest $request
*
* @return type Response
*/
public function update($id, $request)
{
try {
if ($request->sys_email == 'on') {
$system = \DB::table('settings_email')
->where('id', '=', 1)
->update(['sys_email' => $id]);
} elseif ($request->input('count') <= 1 && $request->sys_email == null) {
$system = \DB::table('settings_email')
->where('id', '=', 1)
->update(['sys_email' => null]);
}
$return = 1;
} catch (Exception $e) {
$return = $e->getMessage();
}
return $return;
}
/**
* Remove the specified resource from storage.
*
* @param type int $id
* @param type Emails $email
*
* @return type Redirect
*/
public function destroy($id, Emails $email)
{
// fetching the details on the basis of the $id passed to the function
$default_system_email = Email::where('id', '=', '1')->first();
if ($default_system_email->sys_email) {
// checking if the default system email is the passed email
if ($id == $default_system_email->sys_email) {
return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email'));
}
}
try {
// fetching the database instance of the current email
$emails = $email->whereId($id)->first();
// checking if deleting the email is success or if it's carrying any dependencies
if ($emails->delete() == true) {
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
} else {
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
}
} catch (Exception $e) {
// returns if the try fails
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Create imap connection.
*
* @param type $request
*
* @return type int
*/
public function getImapStream($request, $validate)
{
$fetching_status = $request->input('fetching_status');
$username = $request->input('email_address');
$password = $request->input('password');
$protocol_id = $request->input('mailbox_protocol');
$fetching_protocol = '/'.$request->input('fetching_protocol');
$fetching_encryption = '/'.$request->input('fetching_encryption');
if ($fetching_encryption == '/none') {
$fetching_encryption2 = '/novalidate-cert';
$mailbox_protocol = $fetching_encryption2;
$host = $request->input('fetching_host');
$port = $request->input('fetching_port');
$mailbox = '{'.$host.':'.$port.$fetching_protocol.$mailbox_protocol.'}INBOX';
} else {
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
$host = $request->input('fetching_host');
$port = $request->input('fetching_port');
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
$mailbox_protocol = $fetching_encryption.$validate;
}
try {
$imap_stream = imap_open($mailbox, $username, $password);
} catch (\Exception $ex) {
\Log::error($ex->getMessage());
return $ex->getMessage();
}
//$imap_stream = imap_open($mailbox, $username, $password);
if ($imap_stream) {
$return = [0 => 1, 1 => $mailbox_protocol];
} else {
$return = [0 => 0];
}
return $return;
}
/**
* Check connection.
*
* @param type $imap_stream
*
* @return type int
*/
public function checkImapStream($imap_stream)
{
$check_imap_stream = imap_check($imap_stream);
if ($check_imap_stream) {
$imap_stream = 1;
} else {
$imap_stream = 0;
}
return $imap_stream;
}
/**
* Get smtp connection.
*
* @param type $request
*
* @return int
*/
public function getSmtp($request)
{
$sending_status = $request->input('sending_status');
// cheking for the sending protocol
if ($request->input('sending_protocol') == 'smtp') {
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = $request->input('sending_host'); // Specify main and backup SMTP servers
//$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $request->input('email_address'); // SMTP username
$mail->Password = $request->input('password'); // SMTP password
$mail->SMTPSecure = $request->input('sending_encryption'); // Enable TLS encryption, `ssl` also accepted
$mail->Port = $request->input('sending_port'); // TCP port to connect to
if (!$request->input('smtp_validate')) {
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
];
if ($mail->smtpConnect($mail->SMTPOptions) == true) {
$mail->smtpClose();
$return = 1;
} else {
$return = 0;
}
} else {
if ($mail->smtpConnect()) {
$mail->smtpClose();
$return = 1;
} else {
$return = 0;
}
}
} elseif ($request->input('sending_protocol') == 'mail') {
$return = 1;
}
return $return;
}
/**
* Checking if department value is null.
*
* @param type $dept
*
* @return type string or null
*/
public function departmentValue($dept)
{
if ($dept) {
$email_department = $dept;
} else {
$email_department = null;
}
return $email_department;
}
/**
* Checking if priority value is null.
*
* @param type $priority
*
* @return type string or null
*/
public function priorityValue($priority)
{
if ($priority) {
$email_priority = $priority;
} else {
$email_priority = null;
}
return $email_priority;
}
/**
* Checking if helptopic value is null.
*
* @param type $help_topic
*
* @return type string or null
*/
public function helpTopicValue($help_topic)
{
if ($help_topic) {
$email_help_topic = $help_topic;
} else {
$email_help_topic = null;
}
return $email_help_topic;
}
public function emailService($service, $value = [])
{
switch ($service) {
case 'mailgun':
$this->setServiceConfig($service, $value);
case 'mandrill':
$this->setServiceConfig($service, $value);
case 'ses':
$this->setServiceConfig($service, $value);
}
}
public function setServiceConfig($service, $value)
{
//dd($service);
if (count($value) > 0) {
foreach ($value as $k => $v) {
\Config::set("services.$service.$k", $v);
}
}
}
public function jsonResponse($out, $in)
{
if ($out !== 1) {
$result = ['fails' => Lang::get('lang.outgoing_email_connection_failed')];
}
if ($in[0] !== 1) {
$result = ['fails' => Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings')];
}
if ($out === 1 && $in[0] === 1) {
$result = ['success' => Lang::get('lang.success')];
}
return response()->json(compact('result'));
}
public function saveMailService($emailid, $request, $driver)
{
$mail_service = new \App\Model\MailJob\FaveoMail();
$mails = $mail_service->where('email_id', $emailid)->get();
if (count($request) > 0) {
foreach ($mails as $mail) {
$mail->delete();
}
foreach ($request as $key => $value) {
$mail_service->create([
'drive' => $driver,
'key' => $key,
'value' => $value,
'email_id' => $emailid,
]);
}
}
}
}

View File

@@ -9,13 +9,13 @@ use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic;
// Request
use Exception;
// Class
use Form;
use Illuminate\Http\Request;
// Class
use Input;
use Lang;
use Redirect;
use Exception;
use Form;
/**
* FormController
@@ -23,13 +23,12 @@ use Redirect;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class FormController extends Controller
{
class FormController extends Controller {
private $fields;
private $forms;
public function __construct(Fields $fields, Forms $forms)
{
public function __construct(Fields $fields, Forms $forms) {
$this->fields = $fields;
$this->forms = $forms;
$this->middleware('auth', [
@@ -44,7 +43,7 @@ class FormController extends Controller
'jqueryScript',
'jqueryCheckboxScript',
'jquerySelectScript',
],
]
]);
}
@@ -53,8 +52,7 @@ class FormController extends Controller
*
* @return type
*/
public function home()
{
public function home() {
return view('forms.home');
}
@@ -65,8 +63,7 @@ class FormController extends Controller
*
* @return Response
*/
public function index(Forms $forms)
{
public function index(Forms $forms) {
try {
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
} catch (Exception $e) {
@@ -79,8 +76,7 @@ class FormController extends Controller
*
* @return Response
*/
public function create()
{
public function create() {
try {
return view('themes.default1.admin.helpdesk.manage.form.form');
} catch (Exception $e) {
@@ -95,15 +91,13 @@ class FormController extends Controller
*
* @return Response
*/
public function show($id)
{
public function show($id) {
try {
$forms = new Forms();
$form = $forms->find($id);
//dd($form);
if ($form) {
$fields = $form->fields();
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields'));
}
throw new Exception("Sorry we can't find your request");
@@ -117,13 +111,12 @@ class FormController extends Controller
*
* @return Response
*/
public function store(Request $request)
{
public function store(Request $request) {
$this->validate($request, [
'formname' => 'required|unique:custom_forms,formname',
'label.*' => 'required',
'name.*' => 'required',
'type.*' => 'required',
'label.*' => 'required',
'name.*' => 'required',
'type.*' => 'required',
]);
try {
$forms = new Forms();
@@ -138,18 +131,19 @@ class FormController extends Controller
$name = str_slug(Input::get('name')[$i], '_');
$field = Fields::create([
'forms_id' => $forms->id,
'label' => Input::get('label')[$i],
'name' => $name,
'type' => Input::get('type')[$i],
'label' => Input::get('label')[$i],
'name' => $name,
'type' => Input::get('type')[$i],
'required' => $require[$i],
]);
$field_id = $field->id;
$this->createValues($field_id, Input::get('value')[$i]);
$this->createValues($field_id, Input::get('value')[$i],null,$name);
}
}
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
} catch (Exception $ex) {
dd($ex);
return redirect()->back()->with('fails', $ex->getMessage());
}
}
@@ -164,8 +158,7 @@ class FormController extends Controller
*
* @return type redirect
*/
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
{
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) {
$fields = $field->where('forms_id', $id)->get();
$help_topics = $help_topic->where('custom_form', '=', $id)->get();
foreach ($help_topics as $help_topic) {
@@ -181,8 +174,7 @@ class FormController extends Controller
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
}
public function edit($id)
{
public function edit($id) {
try {
$forms = new Forms();
$form = $forms->find($id);
@@ -195,12 +187,12 @@ class FormController extends Controller
}
throw new Exception("Sorry we can't find your request");
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function addChildForm($id)
{
public function addChildForm($id) {
try {
$forms = new Forms();
$form = $forms->find($id);
@@ -213,17 +205,17 @@ class FormController extends Controller
}
throw new Exception("Sorry we can't find your request");
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function update($id, Request $request)
{
public function update($id, Request $request) {
$this->validate($request, [
'formname' => 'required|unique:custom_forms,formname,'.$id,
'label.*' => 'required',
'name.*' => 'required',
'type.*' => 'required',
'formname' => 'required|unique:custom_forms,formname,' . $id,
'label.*' => 'required',
'name.*' => 'required',
'type.*' => 'required',
]);
try {
if (!$request->input('formname')) {
@@ -232,7 +224,7 @@ class FormController extends Controller
$form = new Forms();
$forms = $form->find($id);
if (!$forms) {
throw new Exception('Sorry we can not find your request');
throw new Exception("Sorry we can not find your request");
}
$forms->formname = Input::get('formname');
$forms->save();
@@ -249,24 +241,23 @@ class FormController extends Controller
$name = str_slug(Input::get('name')[$i], '_');
$field = $field->create([
'forms_id' => $forms->id,
'label' => Input::get('label')[$i],
'name' => $name,
'type' => Input::get('type')[$i],
'label' => Input::get('label')[$i],
'name' => $name,
'type' => Input::get('type')[$i],
'required' => Input::get('required')[$i],
]);
$field_id = $field->id;
$this->createValues($field_id, Input::get('value')[$i]);
$this->createValues($field_id, Input::get('value')[$i],null,$name);
}
return redirect()->back()->with('success', 'updated');
} catch (Exception $ex) {
dd($ex);
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function renderForm($formid)
{
$html = '';
public function renderForm($formid) {
$html = "";
$forms = new Forms();
$form = $forms->find($formid);
if ($form) {
@@ -275,58 +266,54 @@ class FormController extends Controller
$html .= self::getForm($field);
}
}
return self::requiredStyle().$html;
return self::requiredStyle() . $html;
}
public static function getType($type)
{
public static function getType($type) {
switch ($type) {
case 'select':
return 'select';
case 'text':
return 'text';
case 'email':
return 'email';
case 'textarea':
return 'textarea';
case 'select':
return 'select';
case 'radio':
return 'radio';
case 'checkbox':
return 'checkbox';
case 'hidden':
return 'hidden';
case 'password':
return 'password';
case "select":
return "select";
case "text":
return "text";
case "email":
return "email";
case "textarea":
return "textarea";
case "select":
return "select";
case "radio":
return "radio";
case "checkbox":
return "checkbox";
case "hidden":
return "hidden";
case "password":
return "password";
}
}
public static function getAttribute($type)
{
public static function getAttribute($type) {
switch ($type) {
case 'select':
case "select":
return "null,['class'=>'form-control']";
case 'text':
case "text":
return "['class'=>'form-control']";
case 'email':
case "email":
return "['class'=>'form-control']";
case 'textarea':
case "textarea":
return "['class'=>'form-control']";
case 'radio':
return '';
case 'checkbox':
return '';
case 'hidden':
return '';
case 'password':
case "radio":
return "";
case "checkbox":
return "";
case "hidden":
return "";
case "password":
return "['class'=>'form-control']";
}
}
public static function getForm($field)
{
public static function getForm($field) {
$required = false;
$required_class = self::requiredClass($field->required);
if ($field->required === '1') {
@@ -335,33 +322,32 @@ class FormController extends Controller
$type = $field->type;
$field_type = self::getType($type);
switch ($field_type) {
case 'select':
case "select":
return self::selectForm($field_type, $field, $required, $required_class);
case 'text':
return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case 'email':
return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case 'password':
return Form::label($field->label, $field->label, ['class' => $required_class]).
case "text":
return Form::label($field->label, $field->label, ['class' => $required_class]) .
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "email":
return Form::label($field->label, $field->label, ['class' => $required_class]) .
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "password":
return Form::label($field->label, $field->label, ['class' => $required_class]) .
Form::$field_type($field->name, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case 'textarea':
return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case 'radio':
case "textarea":
return Form::label($field->label, $field->label, ['class' => $required_class]) .
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "radio":
return self::radioForm($field_type, $field, $required, $required_class);
case 'checkbox':
case "checkbox":
return self::checkboxForm($field_type, $field, $required, $required_class);
case 'hidden':
return Form::$field_type($field->name, null, ['id' => $field->id]);
case "hidden":
return Form::$field_type($field->name, NULL, ['id' => $field->id]);
}
}
public function createValues($fieldid, $values, $childid = null, $key = '')
{
public function createValues($fieldid, $values, $childid = NULL, $key = "") {
if ($values) {
$values_array = explode(',', $values);
$field_values = new \App\Model\helpdesk\Form\FieldValue();
@@ -374,9 +360,9 @@ class FormController extends Controller
if (count($values_array) > 0) {
foreach ($values_array as $value) {
$field_values->create([
'field_id' => $fieldid,
'child_id' => $childid,
'field_key' => $key,
'field_id' => $fieldid,
'child_id' => $childid,
'field_key' => $key,
'field_value' => str_slug($value, '_'),
]);
}
@@ -384,8 +370,7 @@ class FormController extends Controller
}
}
public function addChild($fieldid, Request $request)
{
public function addChild($fieldid, Request $request) {
$ids = $request->except('_token');
try {
foreach ($ids as $valueid => $formid) {
@@ -399,91 +384,86 @@ class FormController extends Controller
//}
}
}
return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function renderChild(Request $request)
{
public function renderChild(Request $request) {
self::setSession();
$render = '';
$render = "";
$value = $request->input('valueid');
$fieldid = $request->input('fieldid');
$field_values = new \App\Model\helpdesk\Form\FieldValue();
$field_value = $field_values->where('field_id', $fieldid)->where('field_value', $value)->first();
$child = '';
$child = "";
if ($field_value) {
$child = $field_value->child_id;
}
if ($child !== '') {
if ($child !== "") {
$render = $this->renderForm($child);
}
return $render;
}
public static function jqueryScript($value, $fieldid, $fieldname, $type = '', $index = '')
{
if ($type == 'select') {
public static function jqueryScript($value, $fieldid, $fieldname, $type = "", $index = "") {
if ($type == "select") {
return self::jquerySelectScript($fieldid);
}
if ($type == 'checkbox') {
if ($type == "checkbox") {
return self::jqueryCheckboxScript($fieldid, $index);
}
return '<script>
$("#'.str_slug($value).'").on("change", function () {
var valueid = $("#'.str_slug($value).'").val();
var fieldid = $("#'.$fieldid.str_slug($value).'").val();
send'.$fieldid.str_slug($value).'(valueid,fieldid);
$("#' . str_slug($value) . '").on("change", function () {
var valueid = $("#' . str_slug($value) . '").val();
var fieldid = $("#' . $fieldid . str_slug($value) . '").val();
send' . $fieldid . str_slug($value) . '(valueid,fieldid);
});
function send'.$fieldid.str_slug($value).'(valueid,fieldid) {
function send' . $fieldid . str_slug($value) . '(valueid,fieldid) {
$.ajax({
url: "'.url('forms/render/child/').'",
url: "' . url('forms/render/child/') . '",
dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) {
$("#'.$fieldname.'").html(response);
$("#' . $fieldname . '").html(response);
},
error: function (response) {
$("#'.$fieldname.'").html(response);
$("#' . $fieldname . '").html(response);
}
});
}
</script>';
}
public static function jqueryCheckboxScript($fieldid, $index)
{
public static function jqueryCheckboxScript($fieldid, $index) {
$session = self::getSession();
$fields = new Fields();
$field = $fields->find($fieldid);
if ($field) {
return '<script>
$("#'.$session.$index.'").on("change", function () {
var valueid = $("#'.$session.$index.'").val();
var fieldid = $("#f'.$session.$index.'").val();
$("#' . $session . $index . '").on("change", function () {
var valueid = $("#' . $session . $index . '").val();
var fieldid = $("#f' . $session . $index . '").val();
if($(this).is(":checked")) {
send'.$session.$index.'(valueid,fieldid);
send' . $session . $index . '(valueid,fieldid);
}else{
$("#div'.$session.'"+valueid).empty();
$("#div' . $session . '"+valueid).empty();
}
});
function send'.$session.$index.'(valueid,fieldid) {
function send' . $session . $index . '(valueid,fieldid) {
$.ajax({
url: "'.url('forms/render/child/').'",
url: "' . url('forms/render/child/') . '",
dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) {
$("#div'.$session.'"+valueid).html(response);
$("#div' . $session . '"+valueid).html(response);
},
error: function (response) {
$("#div'.$session.'"+valueid).html(response);
$("#div' . $session . '"+valueid).html(response);
}
});
}
@@ -491,32 +471,31 @@ class FormController extends Controller
}
}
public static function jquerySelectScript($fieldid)
{
public static function jquerySelectScript($fieldid) {
$fields = new Fields();
$field = $fields->find($fieldid);
$session = self::getSession();
if ($field) {
return '<script>
$(document).ready(function () {
var valueid = $(".'.$session.$fieldid.'").val();
var fieldid = $("#hidden'.$session.$fieldid.'").val();
send'.$session.$fieldid.'(valueid,fieldid);
$(".'.$session.$fieldid.'").on("change", function () {
valueid = $(".'.$session.$fieldid.'").val();
var fieldid = $("#hidden'.$session.$fieldid.'").val();
send'.$session.$fieldid.'(valueid,fieldid);
var valueid = $(".' . $session . $fieldid . '").val();
var fieldid = $("#hidden' . $session . $fieldid . '").val();
send' . $session . $fieldid . '(valueid,fieldid);
$(".' . $session . $fieldid . '").on("change", function () {
valueid = $(".' . $session . $fieldid . '").val();
var fieldid = $("#hidden' . $session . $fieldid . '").val();
send' . $session . $fieldid . '(valueid,fieldid);
});
function send'.$session.$fieldid.'(valueid,fieldid) {
function send' . $session . $fieldid . '(valueid,fieldid) {
$.ajax({
url: "'.url('forms/render/child/').'",
url: "' . url('forms/render/child/') . '",
dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) {
$("#'.$session.$field->name.'").html(response);
$("#' . $session . $field->name . '").html(response);
},
error: function (response) {
$("#'.$session.$field->name.'").html(response);
$("#' . $session . $field->name . '").html(response);
}
});
}
@@ -526,60 +505,55 @@ class FormController extends Controller
}
}
public static function selectForm($field_type, $field, $required, $required_class)
{
public static function selectForm($field_type, $field, $required, $required_class) {
$session = self::getSession();
$script = self::jqueryScript($field_value = '', $field->id, $field->name, $field_type);
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => 'hidden'.$session.$field->id]).Form::label($field->label, $field->label, ['class' => $required_class]);
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => $field->values()->lists('field_value', 'field_value')->toArray()], null, ['class' => "form-control $session$field->id", 'id' => $session.$field->id, 'required' => $required]).'</br>';
$html = $script.$form_hidden.$select;
$response_div = '<div id='.$session.$field->name.'></div>';
return $html.$response_div;
$script = self::jqueryScript($field_value = "", $field->id, $field->name, $field_type);
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => "hidden" . $session . $field->id]) . Form::label($field->label, $field->label, ['class' => $required_class]);
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => self::removeUnderscoreFromDB($field->values()->lists('field_value', 'field_value')->toArray())], null, ['class' => "form-control $session$field->id", 'id' => $session . $field->id, 'required' => $required]) . "</br>";
$html = $script . $form_hidden . $select;
$response_div = "<div id=" . $session . $field->name . "></div>";
return $html . $response_div;
}
public static function radioForm($field_type, $field, $required, $required_class)
{
$radio = '';
$html = '';
public static function radioForm($field_type, $field, $required, $required_class) {
$radio = "";
$html = "";
$values = $field->values()->lists('field_value')->toArray();
if (count($values) > 0) {
foreach ($values as $field_value) {
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
$radio .= '<div>'.Form::hidden('fieldid[]', $field->id, ['id' => $field->id.str_slug($field_value)]);
$radio .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]).$script.'<span> '.removeUnderscore($field_value).'</span></div>';
}
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$radio.'<div id='.$field->name.'></br></div>';
}
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
$radio .= "<div>" . Form::hidden('fieldid[]', $field->id, ['id' => $field->id . str_slug($field_value)]);
$radio .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]) . $script . "<span> " . removeUnderscore($field_value) . "</span></div>";
}
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $radio . "<div id=" . $field->name . "></br></div>";
}
return $html;
}
public static function checkboxForm($field_type, $field, $required, $required_class)
{
public static function checkboxForm($field_type, $field, $required, $required_class) {
$session = self::getSession();
$checkbox = '';
$html = '';
$checkbox = "";
$html = "";
$values = $field->values()->lists('field_value')->toArray();
if (count($values) > 0) {
$i = 1;
foreach ($values as $field_value) {
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type, $i);
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f'.$session.$i]);
$checkbox .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => $session.$i, 'required' => $required]);
$checkbox .= '<span> '.removeUnderscore($field_value).'</span>';
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f' . $session . $i]);
$checkbox .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => $session . $i, 'required' => $required]);
$checkbox .= "<span> " . removeUnderscore($field_value) . "</span>";
//$checkbox .="</br>";
$checkbox .= '<div>'.$script.'<div id=div'.$session.$field_value.'></div></div>';
$checkbox .="<div>" . $script . "<div id=div" . $session . $field_value . "></div></div>";
$i++;
}
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$checkbox;
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $checkbox;
}
return $html;
}
public static function requiredStyle()
{
public static function requiredStyle() {
$style = "<style>
.required:after {
color: #e32 !important;
@@ -587,34 +561,39 @@ class FormController extends Controller
display:inline !important;
}
</style>";
return $style;
}
public static function requiredClass($required)
{
$class = '';
public static function requiredClass($required) {
$class = "";
if ($required === '1') {
$class = 'required';
$class = "required";
}
return $class;
}
public static function setSession()
{
public static function setSession() {
$form = self::getSession();
$form++;
\Session::set('fromid', $form);
}
public static function getSession()
{
public static function getSession() {
$form = 0;
if (\Session::has('fromid')) {
$form = \Session::get('fromid');
}
return $form;
}
public static function removeUnderscoreFromDB($array) {
$result = [];
if (is_array($array) && count($array) > 0) {
foreach ($array as $key => $value) {
$result[$key] = removeUnderscore($value);
}
}
return $result;
}
}

View File

@@ -124,6 +124,10 @@ class GroupController extends Controller
{
// Database instannce to the current id
$var = $group->whereId($id)->first();
$is_group_assigned = User::select('id')->where('assign_group', '=', $id)->count();
if ($is_group_assigned >= 1 && $request->input('group_status') == '0') {
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.Lang::get('lang.can-not-inactive-group').'</li>');
}
// Updating Name
$var->name = $request->input('name');
//Updating Status

View File

@@ -87,8 +87,7 @@ class HelptopicController extends Controller
$forms = $form->get();
$agents = $agent->where('role', '=', 'agent')->get();
$slas = $sla->get();
$priority = Ticket_Priority::where('status', '=', 1)->get();
$priority = Ticket_Priority::where('status','=',1)->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
@@ -148,7 +147,7 @@ class HelptopicController extends Controller
$topics = $topic->whereId($id)->first();
$forms = $form->get();
$slas = $sla->get();
$priority = Ticket_Priority::where('status', '=', 1)->get();
$priority = Ticket_Priority::where('status','=',1)->get();
$sys_help_topic = \DB::table('settings_ticket')
->select('help_topic')
->where('id', '=', 1)->first();

View File

@@ -8,6 +8,7 @@ use App;
use App\Http\Controllers\Controller;
//supports
use App\Http\Requests;
use Cache;
use Config;
//classes
use File;
@@ -16,8 +17,8 @@ use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Input;
use Lang;
use UnAuth;
use Validator;
use UnAuth;
/**
* SlaController.
@@ -52,6 +53,7 @@ class LanguageController extends Controller
} else {
return \Redirect::back();
}
}
/**
@@ -87,10 +89,11 @@ class LanguageController extends Controller
return \Datatable::collection(new Collection($values))
->addColumn('language', function ($model) {
if ($model == Config::get('app.fallback_locale')) {
return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')';
return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')';
} else {
return Config::get('languages.'.$model);
}
})
->addColumn('id', function ($model) {
return $model;
@@ -226,17 +229,16 @@ class LanguageController extends Controller
if ($success) {
//sending back with success message
Session::flash('success', Lang::get('lang.delete-success'));
return Redirect::back();
} else {
//sending back with error message
Session::flash('fails', Lang::get('lang.lang-doesnot-exist'));
return Redirect::back();
}
} else {
Session::flash('fails', Lang::get('lang.lang-fallback-lang'));
return redirect('languages');
}
} else {
@@ -245,4 +247,5 @@ class LanguageController extends Controller
return redirect('languages');
}
}
}

View File

@@ -5,33 +5,61 @@ namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Common\NotificationController;
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Common\FileuploadController;
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CreateTicketRequest;
use App\Http\Requests\helpdesk\TicketRequest;
use App\Http\Requests\helpdesk\PriorityRequest;
// models
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Ticket\Ticket_Form_Data;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Timezones;
use App\User;
use Auth;
use DB;
use Exception;
use ForceUTF8\Encoding;
use GeoIP;
// classes
use Hash;
use Illuminate\Http\Request;
use Illuminate\support\Collection;
use Input;
use Lang;
use Mail;
use PDF;
use UTC;
/**
* TicketController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class PriorityController extends Controller
{
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController)
{
class PriorityController extends Controller {
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController) {
$this->PhpMailController = $PhpMailController;
$this->NotificationController = $NotificationController;
$this->middleware('auth');
@@ -42,61 +70,57 @@ class PriorityController extends Controller
*
* @return type response
*/
public function priorityIndex()
{
$user_status = CommonSettings::where('id', '=', 6)->first();
public function priorityIndex() {
$user_status=CommonSettings::where('option_name','=', 'user_priority')->first();
// dd( $user_status);
return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status'));
}
/**
/**
* Show the Inbox ticket list page.
*
* @return type response
*/
public function userPriorityIndex(Request $request)
{
try {
$user_status = $request->user_settings_priority;
public function userPriorityIndex(Request $request) {
try {
$user_status= $request->user_settings_priority;
CommonSettings::where('option_name','=', 'user_priority')->update(['status' => $user_status]);
CommonSettings::where('id', '=', 6)->update(['status' => $user_status]);
return 'Your Status Updated';
} catch (Exception $e) {
return 'Your Status Updated';
} catch (Exception $e) {
return Redirect()->back()->with('fails', $e->getMessage());
}
}
/**
*
* @return type
*/
public function priorityIndex1()
{
public function priorityIndex1() {
try {
$ticket = new Ticket_Priority();
$tickets = $ticket->select('priority_id', 'priority', 'priority_desc', 'priority_color', 'status', 'is_default', 'ispublic')->get();
return \Datatable::Collection($tickets)
->showColumns('priority', 'priority_desc')
->addColumn('priority_color', function ($model) {
->addColumn('priority_color', function($model) {
return "<button class='btn' style = 'background-color:$model->priority_color'></button>";
})
->addColumn('status', function ($model) {
->addColumn('status', function($model) {
if ($model->status == 1) {
return "<a style='color:green'>active</a>";
} elseif ($model->status == 0) {
Ticket_Priority::where('priority_id', '=', '$priority_id')
->update(['priority_id' => '']);
return "<a style='color:red'>inactive</a>";
}
})
->addColumn('action', function ($model) {
->addColumn('action', function($model) {
if ($model->is_default > 0) {
return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs' disabled='disabled'>Edit</a>&nbsp;<a href=".url('ticket_priority/'.$model->priority_id.'/destroy')." class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs' disabled='disabled'>Edit</a>&nbsp;<a href=" . url('ticket/priority/' . $model->priority_id . '/destroy') . " class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
} else {
return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs'>Edit</a>&nbsp;<a class='btn btn-danger btn-xs' onclick='confirmDelete(".$model->priority_id.")'>Delete </a>";
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs'>Edit</a>&nbsp;<a class='btn btn-danger btn-xs' onclick='confirmDelete(" . $model->priority_id . ")'>Delete </a>";
}
})
->searchColumns('priority')
@@ -108,45 +132,42 @@ class PriorityController extends Controller
}
/**
*
* @return type
*/
public function priorityCreate()
{
public function priorityCreate() {
return view('themes.default1.admin.helpdesk.manage.ticket_priority.create');
}
public function priorityCreate1(PriorityRequest $request)
{
$tk_priority = new Ticket_Priority();
public function priorityCreate1(PriorityRequest $request) {
$tk_priority = new Ticket_Priority;
$tk_priority->priority = $request->priority;
$tk_priority->status = $request->status;
$tk_priority->priority_desc = $request->priority_desc;
$tk_priority->priority_color = $request->priority_color;
$tk_priority->ispublic = $request->ispublic;
$tk_priority->save();
return \Redirect::route('priority.index')->with('success', Lang::get('lang.priority_successfully_created'));
}
/**
*
* @param type $priority_id
*
* @return type
*/
public function priorityEdit($priority_id)
{
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
public function priorityEdit($priority_id) {
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
return view('themes.default1.admin.helpdesk.manage.ticket_priority.edit', compact('tk_priority'));
}
/**
*
* @param PriorityRequest $request
*
* @return type
*/
public function priorityEdit1(PriorityRequest $request)
{
public function priorityEdit1(PriorityRequest $request) {
$priority_id = $request->priority_id;
$tk_priority = Ticket_Priority::findOrFail($priority_id);
$tk_priority->priority = $request->priority;
@@ -156,22 +177,21 @@ class PriorityController extends Controller
$tk_priority->ispublic = $request->ispublic;
$tk_priority->save();
if ($request->input('default_priority') == 'on') {
Ticket_Priority::where('is_default', '=', 1)
Ticket_Priority::where('is_default', '>', 0)
->update(['is_default' => 0]);
Ticket_Priority::where('priority_id', '=', $priority_id)
->update(['is_default' => 1]);
}
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.priority_successfully_updated')));
}
/**
*
* @param type $priority_id
*
* @return type
*/
public function destroy($priority_id)
{
public function destroy($priority_id) {
$default_priority = Ticket_Priority::where('is_default', '>', '0')->first();
// dd($default_priority->is_default);
$topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]);
@@ -192,4 +212,5 @@ class PriorityController extends Controller
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.delete_successfully')));
}
}

View File

@@ -7,11 +7,10 @@ use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CompanyRequest;
use App\Http\Requests\helpdesk\EmailRequest;
use App\Http\Requests\helpdesk\Job\TaskRequest;
use App\Http\Requests\helpdesk\RatingUpdateRequest;
use App\Http\Requests\helpdesk\StatusRequest;
// models
use App\Http\Requests\helpdesk\SystemRequest;
// models
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template;
@@ -20,10 +19,9 @@ use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ratings\Rating;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\Followup;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\Responder;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket;
@@ -33,29 +31,30 @@ use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Time_format;
use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Workflow\WorkflowClose;
// classes
use App\Model\helpdesk\Settings\CommonSettings;
use DateTime;
// classes
use DB;
use Exception;
use File;
use Illuminate\Http\Request;
use Input;
use Lang;
use App\Http\Requests\helpdesk\Job\TaskRequest;
/**
* SettingsController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class SettingsController extends Controller
{
class SettingsController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
public function __construct() {
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
@@ -69,8 +68,7 @@ class SettingsController extends Controller
*
* @return Response
*/
public function getcompany(Company $company)
{
public function getcompany(Company $company) {
try {
/* fetch the values of company from company table */
$companys = $company->whereId('1')->first();
@@ -90,14 +88,13 @@ class SettingsController extends Controller
*
* @return Response
*/
public function postcompany($id, Company $company, CompanyRequest $request)
{
public function postcompany($id, Company $company, CompanyRequest $request) {
/* fetch the values of company request */
$companys = $company->whereId('1')->first();
if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'uploads/company/';
$fileName = rand(0000, 9999).'.'.$name;
$fileName = rand(0000, 9999) . '.' . $name;
Input::file('logo')->move($destinationPath, $fileName);
$companys->logo = $fileName;
}
@@ -111,7 +108,7 @@ class SettingsController extends Controller
return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -120,8 +117,7 @@ class SettingsController extends Controller
*
* @return type string
*/
public function deleteLogo()
{
public function deleteLogo() {
$path = $_GET['data1']; //get file path of logo image
if (!unlink($path)) {
return 'false';
@@ -148,8 +144,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings)
{
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings) {
try {
/* fetch the values of system from system table */
$systems = $system->whereId('1')->first();
@@ -183,8 +178,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function postsystem($id, System $system, SystemRequest $request)
{
public function postsystem($id, System $system, SystemRequest $request) {
try {
/* fetch the values of system request */
$systems = $system->whereId('1')->first();
@@ -208,11 +202,18 @@ class SettingsController extends Controller
->update(['status' => $request->send_otp]);
$email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory')
->update(['status' => $request->email_mandatory]);
if($request->has('itil')){
$itil = $request->input('itil');
$sett = CommonSettings::firstOrCreate(['option_name'=>'itil']);
$sett->status = $itil;
$sett->save();
}
/* redirect to Index page with Success Message */
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated') . '<br>' . $e->getMessage());
}
}
@@ -226,8 +227,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority)
{
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) {
try {
/* fetch the values of ticket from ticket table */
$tickets = $ticket->whereId('1')->first();
@@ -251,8 +251,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function postticket($id, Ticket $ticket, Request $request)
{
public function postticket($id, Ticket $ticket, Request $request) {
try {
/* fetch the values of ticket request */
$tickets = $ticket->whereId('1')->first();
@@ -273,7 +272,7 @@ class SettingsController extends Controller
return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -286,8 +285,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getemail(Email $email, Template $template, Emails $email1)
{
public function getemail(Email $email, Template $template, Emails $email1) {
try {
/* fetch the values of email from Email table */
$emails = $email->whereId('1')->first();
@@ -311,8 +309,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function postemail($id, Email $email, EmailRequest $request)
{
public function postemail($id, Email $email, EmailRequest $request) {
try {
/* fetch the values of email request */
$emails = $email->whereId('1')->first();
@@ -331,7 +328,7 @@ class SettingsController extends Controller
return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -344,8 +341,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow)
{
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow) {
// try {
/* fetch the values of email from Email table */
$emails = $email->whereId('1')->first();
@@ -356,45 +352,43 @@ class SettingsController extends Controller
$workflow = $workflow->whereId('1')->first();
$cron_path = base_path('artisan');
$command = ":- <pre>***** php $cron_path schedule:run > /dev/null 2>&1</pre>";
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run > /dev/null 2>&1</pre>";
$warn = '';
$command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>";
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>";
$warn = "";
$condition = new \App\Model\MailJob\Condition();
$job = $condition->checkActiveJob();
$commands = [
'' => 'Select',
'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute',
'' => 'Select',
'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute',
'everyThirtyMinutes' => 'Every Thirty Minute',
'hourly' => 'Every Hour',
'daily' => 'Every Day',
'dailyAt' => 'Daily at',
'weekly' => 'Every Week',
'monthly' => 'Monthly',
'yearly' => 'Yearly',
'hourly' => 'Every Hour',
'daily' => 'Every Day',
'dailyAt' => 'Daily at',
'weekly' => 'Every Week',
'monthly' => 'Monthly',
'yearly' => 'Yearly',
];
$followupcommands = [
'' => 'Select',
'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute',
'' => 'Select',
'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute',
'everyThirtyMinutes' => 'Every Thirty Minute',
'hourly' => 'Every Hour',
'daily' => 'Every Day',
'weekly' => 'Every Week',
'monthly' => 'Monthly',
'yearly' => 'Yearly',
'hourly' => 'Every Hour',
'daily' => 'Every Day',
'weekly' => 'Every Week',
'monthly' => 'Monthly',
'yearly' => 'Yearly',
];
if (ini_get('register_argc_argv') == '') {
if (ini_get('register_argc_argv') == "") {
//$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron";
}
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared'));
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands','followupcommands','condition','shared'));
// } catch {
// }
}
/**
* Update the specified schedular in storage for cron job.
*
@@ -403,16 +397,18 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow)
{
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow) {
try {
$followup = $followup->whereId('1')->first();
$status = $request->followup_notification_cron;
if ($status = 'null') {
$followup=$followup->whereId('1')->first();
$status=$request->followup_notification_cron;
if ($status='null') {
$followup->status = $request->followup_notification_cron;
}
if ($status = 1) {
if($status= 1) {
$followup->status = $request->followup_notification_cron;
$followup->condition = $request->followup_notification_commands;
$followup->save();
@@ -448,7 +444,7 @@ class SettingsController extends Controller
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>');
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -459,8 +455,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getresponder(Responder $responder)
{
public function getresponder(Responder $responder) {
try {
/* fetch the values of responder from responder table */
$responders = $responder->whereId('1')->first();
@@ -479,8 +474,7 @@ class SettingsController extends Controller
*
* @return type
*/
public function postresponder(Responder $responder, Request $request)
{
public function postresponder(Responder $responder, Request $request) {
try {
/* fetch the values of responder request */
$responders = $responder->whereId('1')->first();
@@ -497,7 +491,7 @@ class SettingsController extends Controller
return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -508,8 +502,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function getalert(Alert $alert)
{
public function getalert(Alert $alert) {
try {
/* fetch the values of alert from alert table */
$alerts = $alert->whereId('1')->first();
@@ -529,8 +522,7 @@ class SettingsController extends Controller
*
* @return type Response
*/
public function postalert($id, Alert $alert, Request $request)
{
public function postalert($id, Alert $alert, Request $request) {
try {
/* fetch the values of alert request */
$alerts = $alert->whereId('1')->first();
@@ -585,7 +577,7 @@ class SettingsController extends Controller
return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>');
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
}
}
@@ -594,8 +586,7 @@ class SettingsController extends Controller
*
* @return type json
*/
public function generateApiKey()
{
public function generateApiKey() {
$key = str_random(32);
return $key;
@@ -606,8 +597,7 @@ class SettingsController extends Controller
*
* @return type view
*/
public function settings()
{
public function settings() {
return view('themes.default1.admin.helpdesk.setting');
}
@@ -619,8 +609,7 @@ class SettingsController extends Controller
*
* @return Response
*/
public function getStatuses()
{
public function getStatuses() {
try {
/* fetch the values of company from company table */
$statuss = \DB::table('ticket_status')->get();
@@ -639,8 +628,7 @@ class SettingsController extends Controller
*
* @return Response
*/
public function getEditStatuses($id)
{
public function getEditStatuses($id) {
try {
/* fetch the values of company from company table */
$status = \DB::table('ticket_status')->where('id', '=', $id)->first();
@@ -659,8 +647,7 @@ class SettingsController extends Controller
*
* @return Response
*/
public function editStatuses($id, StatusRequest $request)
{
public function editStatuses($id, StatusRequest $request) {
try {
/* fetch the values of company from company table */
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
@@ -691,8 +678,7 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request)
{
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request) {
try {
/* fetch the values of company from company table */
$statuss->name = $request->input('name');
@@ -721,8 +707,7 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function deleteStatuses($id)
{
public function deleteStatuses($id) {
try {
if ($id > 5) {
/* fetch the values of company from company table */
@@ -742,8 +727,7 @@ class SettingsController extends Controller
*
* @return type view
*/
public function notificationSettings()
{
public function notificationSettings() {
return view('themes.default1.admin.helpdesk.settings.notification');
}
@@ -752,8 +736,7 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function deleteReadNoti()
{
public function deleteReadNoti() {
$markasread = UserNotification::where('is_read', '=', 1)->get();
foreach ($markasread as $mark) {
$mark->delete();
@@ -768,14 +751,13 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function deleteNotificationLog()
{
public function deleteNotificationLog() {
$days = Input::get('no_of_days');
if ($days == null) {
return redirect()->back()->with('fails', 'Please enter valid no of days');
}
$date = new DateTime();
$date->modify($days.' day');
$date->modify($days . ' day');
$formatted_date = $date->format('Y-m-d H:i:s');
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
foreach ($markasread as $mark) {
@@ -783,7 +765,7 @@ class SettingsController extends Controller
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
}
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.');
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since') . $days . ' days.');
}
/**
@@ -791,8 +773,7 @@ class SettingsController extends Controller
*
* @return type View
*/
public function RatingSettings()
{
public function RatingSettings() {
try {
$ratings = Rating::orderBy('display_order', 'asc')->get();
@@ -809,8 +790,7 @@ class SettingsController extends Controller
*
* @return type view
*/
public function editRatingSettings($id)
{
public function editRatingSettings($id) {
try {
$rating = Rating::whereId($id)->first();
@@ -825,8 +805,7 @@ class SettingsController extends Controller
*
* @return type Redirect
*/
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
{
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request) {
try {
$rating = $ratings->whereId($id)->first();
$rating->name = $request->input('name');
@@ -848,12 +827,11 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function createRating()
{
public function createRating() {
try {
return view('themes.default1.admin.helpdesk.settings.create-ratings');
} catch (Exception $ex) {
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>');
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created') . '<li>' . $ex->getMessage() . '</li>');
}
}
@@ -866,8 +844,7 @@ class SettingsController extends Controller
*
* @return type redirect
*/
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request)
{
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request) {
$rating->name = $request->input('name');
$rating->display_order = $request->input('display_order');
$rating->allow_modification = $request->input('allow_modification');
@@ -886,16 +863,13 @@ class SettingsController extends Controller
*
* @return type Redirect
*/
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
{
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs) {
$ratingrefs->where('rating_id', '=', $slug)->delete();
Rating::whereId($slug)->delete();
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
}
public function saveConditions()
{
public function saveConditions() {
if (\Input::get('fetching-commands') && \Input::get('notification-commands')) {
$fetching_commands = \Input::get('fetching-commands');
$fetching_dailyAt = \Input::get('fetching-dailyAt');
@@ -906,66 +880,62 @@ class SettingsController extends Controller
$fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt);
$notification_command = $this->getCommand($notification_commands, $notification_dailyAt);
$work_command = $this->getCommand($work_commands, $workflow_dailyAt);
$jobs = ['fetching' => $fetching_command, 'notification' => $notification_command, 'work' => $work_command];
$jobs = ['fetching'=>$fetching_command,'notification'=>$notification_command,'work'=>$work_command];
$this->storeCommand($jobs);
}
}
public function getCommand($command, $daily_at)
{
public function getCommand($command, $daily_at) {
if ($command == 'dailyAt') {
$command = "dailyAt,$daily_at";
}
return $command;
}
public function storeCommand($array = [])
{
public function storeCommand($array=[]){
$command = new \App\Model\MailJob\Condition();
$commands = $command->get();
if ($commands->count() > 0) {
foreach ($commands as $condition) {
if($commands->count()>0){
foreach($commands as $condition){
$condition->delete();
}
}
if (count($array) > 0) {
foreach ($array as $key => $save) {
if(count($array)>0){
foreach($array as $key=>$save){
$command->create([
'job' => $key,
'value' => $save,
'job'=>$key,
'value'=>$save,
]);
}
}
}
public function getTicketNumber(Request $request)
{
public function getTicketNumber(Request $request) {
$this->validate($request, [
'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'],
'type' => 'required',
'type' => 'required',
]);
$format = $request->input('format');
$type = $request->input('type');
$number = $this->switchNumber($format, $type);
return $number;
}
public function switchNumber($format, $type)
{
public function switchNumber($format, $type) {
switch ($type) {
case 'random':
case "random":
return $this->createRandomNumber($format);
case 'sequence':
case "sequence":
return $this->createSequencialNumber($format);
}
}
public function createRandomNumber($format)
{
$number = '';
public function createRandomNumber($format) {
$number = "";
$array = str_split($format);
for ($i = 0; $i < count($array); $i++) {
if ($array[$i] === '$') {
@@ -978,13 +948,11 @@ class SettingsController extends Controller
$number .= $array[$i];
}
}
return $number;
}
public function createSequencialNumber($format)
{
$number = '';
public function createSequencialNumber($format) {
$number = "";
$array_format = str_split($format);
$count = count($array_format);
for ($i = 0; $i < $count; $i++) {
@@ -997,17 +965,16 @@ class SettingsController extends Controller
$number .= '0';
}
if ($array_format[$i] !== '$' && $array_format[$i] !== '#') {
$number .= $array_format[$i];
}
}
return $number;
//return $this->nthTicketNumber($number);
}
public function checkCurrentFormat($current, $format)
{
public function checkCurrentFormat($current, $format) {
$check = true;
$array_current = str_split($current);
$array_format = str_split($format);
@@ -1021,12 +988,11 @@ class SettingsController extends Controller
return false;
}
}
return $check;
}
public function nthTicketNumber($current, $type, $format, $force = false)
{
public function nthTicketNumber($current, $type, $format, $force = false) {
$check = $this->checkCurrentFormat($current, $format);
if ($check === false && $force === false) {
$current = $this->createSequencialNumber($format);
@@ -1046,17 +1012,16 @@ class SettingsController extends Controller
if ($type === 'random') {
$number = $this->createRandomNumber($format);
}
return $number;
}
public function getRandomAlphebet()
{
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
public function getRandomAlphebet() {
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$shuffled = str_shuffle($alpha);
$shuffled_array = str_split($shuffled);
$char = $shuffled_array[0];
return $char;
}
}

View File

@@ -2,87 +2,76 @@
namespace App\Http\Controllers\Admin\helpdesk\SocialMedia;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Settings\SocialMedia;
use Exception;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Exception;
use App\Model\helpdesk\Settings\SocialMedia;
class SocialMediaController extends Controller
{
public function __construct()
{
class SocialMediaController extends Controller {
public function __construct() {
$this->middleware(['auth', 'roles'], ['except' => ['configService']]);
}
public function settings($provider)
{
public function settings($provider) {
try {
$social = new SocialMedia();
return view('themes.default1.admin.helpdesk.settings.social-media.settings', compact('social', 'provider'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function postSettings($provider, Request $request)
{
public function postSettings($provider, Request $request) {
$this->validate($request, [
'client_id' => 'required',
'client_id' => 'required',
'client_secret' => 'required',
'redirect' => 'required|url',
'redirect' => 'required|url',
]);
try {
$requests = $request->except('_token');
$this->insertProvider($provider, $requests);
return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) {
dd($ex);
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function deleteProvider($provider, $requests)
{
public function deleteProvider($provider, $requests) {
$social = new SocialMedia();
$socials = $social->where('provider', $provider)->get();
if ($socials->count() > 0) {
foreach ($socials as $media) {
if (array_key_exists($media->key, $requests)) {
if (array_key_exists($media->key,$requests)) {
$media->delete();
}
}
}
}
public function insertProvider($provider, $requests = [])
{
public function insertProvider($provider, $requests = []) {
$this->deleteProvider($provider, $requests);
$social = new SocialMedia();
foreach ($requests as $key => $value) {
$social->create([
'provider' => $provider,
'key' => $key,
'value' => $value,
'key' => $key,
'value' => $value,
]);
}
}
public function index()
{
public function index() {
try {
$social = new SocialMedia();
return view('themes.default1.admin.helpdesk.settings.social-media.index', compact('social'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function configService()
{
public function configService() {
$social = new SocialMedia();
$services = $this->services();
foreach ($services as $service) {
@@ -93,8 +82,7 @@ class SocialMediaController extends Controller
// dd(\Config::get('services'));
}
public function services()
{
public function services() {
return [
'facebook',
'google',
@@ -104,4 +92,5 @@ class SocialMediaController extends Controller
'bitbucket',
];
}
}

View File

@@ -9,9 +9,9 @@ use App\Http\Requests\helpdesk\TeamRequest;
use App\Http\Requests\helpdesk\TeamUpdate;
// models
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Groups;
use App\Model\helpdesk\Agent\Teams;
use App\User;
// classes
use DB;
@@ -102,8 +102,7 @@ class TeamController extends Controller
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>');
}
}
/**
/**
* Show the form for editing the specified resource.
*
* @param type $id
@@ -118,76 +117,79 @@ class TeamController extends Controller
try {
$user = $user->whereId($id)->first();
$teams = $team->whereId($id)->first();
// $team_lead_name=User::whereId($teams->team_lead)->first();
// $team_lead = $team_lead_name->first_name . " " . $team_lead_name->last_name;
// $total_members = $assign_team_agent->where('team_id',$id)->count();
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams', 'id'));
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams','id'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
public function getshow($id)
{
// dd($request);
public function getshow($id) {
// dd($request);
// $id = $request->input('show_id');
// dd($id);
$users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role')
->join('users', 'users.id', '=', 'team_assign_agent.agent_id')
->where('team_assign_agent.team_id', '=', $id);
$users = DB::table('team_assign_agent')->select('team_assign_agent.id','team_assign_agent.team_id','users.user_name','users.first_name' ,'users.last_name','users.active','users.assign_group','users.primary_dpt','users.role')
->join('users','users.id','=','team_assign_agent.agent_id')
->where('team_assign_agent.team_id', '=',$id);
// ->get();
// dd($users);
return \Datatable::query($users)
->showColumns('user_name')
->addColumn('first_name', function ($model) {
->addColumn('first_name', function($model) {
$full_name = ucfirst($model->first_name).' '.ucfirst($model->last_name);
return $full_name;
})
return $full_name;
})
->addColumn('active', function ($model) {
->addColumn('active', function($model) {
if ($model->active == '1') {
$role = "<a class='btn btn-success btn-xs'>".'Active'.'</a>';
$role = "<a class='btn btn-success btn-xs'>".'Active'."</a>";
} elseif ($model->active == 'agent') {
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'.'</a>';
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'."</a>";
}
return $role;
})
return $role;
})
->addColumn('assign_group', function ($model) {
$group = Groups::whereId($model->assign_group)->first();
return $group->name;
})
->addColumn('primary_dpt', function ($model) {
$dept = Department::whereId($model->primary_dpt)->first();
return $dept->name;
})
->addColumn('role', function ($model) {
->addColumn('assign_group', function($model) {
$group=Groups::whereId($model->assign_group)->first();
return ($group->name);
})
->addColumn('primary_dpt', function($model) {
$dept=Department::whereId($model->primary_dpt)->first();
return $dept->name;
})
->addColumn('role', function($model) {
if ($model->role == 'admin') {
$role = "<a class='btn btn-success btn-xs'>".$model->role.'</a>';
$role = "<a class='btn btn-success btn-xs'>".$model->role."</a>";
} elseif ($model->role == 'agent') {
$role = "<a class='btn btn-primary btn-xs'>".$model->role.'</a>';
$role = "<a class='btn btn-primary btn-xs'>".$model->role."</a>";
}
return $role;
})
return $role;
})
// ->showColumns('role')
->searchColumns('first_name', 'last_name')
->orderColumns('first_name', 'last_name')
->searchColumns('first_name','last_name')
->orderColumns('first_name','last_name')
->make();
}
}
/**
* Show the form for editing the specified resource.

View File

@@ -13,25 +13,26 @@ use App\Http\Requests\helpdesk\TemplateUdate;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template;
use App\Model\helpdesk\Utility\Languages;
use App\Model\helpdesk\Settings\CommonSettings;
// classes
use Exception;
use Illuminate\Http\Request;
use Input;
use Lang;
/**
* TemplateController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class TemplateController extends Controller
{
class TemplateController extends Controller {
/**
* Create a new controller instance.
*
* @return type void
*/
public function __construct(PhpMailController $PhpMailController)
{
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
$this->middleware('auth');
$this->middleware('roles');
@@ -44,8 +45,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function index(Template $template)
{
public function index(Template $template) {
try {
$templates = $template->get();
@@ -63,8 +63,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function create(Languages $language, Template $template)
{
public function create(Languages $language, Template $template) {
try {
$templates = $template->get();
$languages = $language->get();
@@ -83,8 +82,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function store(Template $template, TemplateRequest $request)
{
public function store(Template $template, TemplateRequest $request) {
try {
/* Check whether function success or not */
if ($template->fill($request->input())->save() == true) {
@@ -107,8 +105,7 @@ class TemplateController extends Controller
*
* @return Response
*/
public function show($id)
{
public function show($id) {
//
}
@@ -121,41 +118,37 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function listdirectories()
{
$path = \Config::get('view.paths')[0].'/emails/';
public function listdirectories() {
$path = \Config::get('view.paths')[0] . '/emails/';
$directories = scandir($path);
$directory = str_replace('/', '-', $path);
return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory'));
}
public function listtemplates($template, $path)
{
public function listtemplates($template, $path) {
$paths = str_replace('-', '/', $path);
$directory2 = $paths.$template;
$directory2 = $paths . $template;
$templates = scandir($directory2);
$directory = str_replace('/', '-', $directory2.'/');
$directory = str_replace('/', '-', $directory2 . '/');
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory'));
}
public function readtemplate($template, $path)
{
public function readtemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$handle = fopen($directory.$template, 'r');
$contents = fread($handle, filesize($directory.$template));
$handle = fopen($directory . $template, 'r');
$contents = fread($handle, filesize($directory . $template));
fclose($handle);
return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path'));
}
public function createtemplate()
{
public function createtemplate() {
$directory = '../resources/views/emails/';
$fname = Input::get('folder_name');
$filename = $directory.$fname;
$filename = $directory . $fname;
// images folder creation using php
// $mydir = dirname( __FILE__ )."/html/images";
@@ -167,7 +160,7 @@ class TemplateController extends Controller
if (!file_exists($filename)) {
mkdir($filename, 0777);
}
$files = array_filter(scandir($directory.'default'));
$files = array_filter(scandir($directory . 'default'));
foreach ($files as $file) {
if ($file === '.' or $file === '..') {
@@ -175,29 +168,27 @@ class TemplateController extends Controller
}
if (!is_dir($file)) {
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
$destination = $directory.$fname.'/';
$destination = $directory . $fname . '/';
copy($directory.'default/'.$file, $destination.$file);
copy($directory . 'default/' . $file, $destination . $file);
}
}
return \Redirect::back()->with('success', 'Successfully copied');
}
public function writetemplate($template, $path)
{
public function writetemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$b = Input::get('templatedata');
file_put_contents($directory.$template, print_r($b, true));
file_put_contents($directory . $template, print_r($b, true));
return \Redirect::back()->with('success', 'Successfully updated');
}
public function deletetemplate($template, $path)
{
public function deletetemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$dir = $directory.$template;
$dir = $directory . $template;
$status = \DB::table('settings_email')->first();
if ($template == 'default' or $template == $status->template) {
return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!');
@@ -206,7 +197,7 @@ class TemplateController extends Controller
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != '.' && $object != '..') {
unlink($dir.'/'.$object);
unlink($dir . '/' . $object);
}
}
rmdir($dir);
@@ -217,15 +208,13 @@ class TemplateController extends Controller
return \Redirect::back()->with('success', 'Successfully Deleted');
}
public function activateset($setname)
{
public function activateset($setname) {
\DB::table('settings_email')->update(['template' => $setname]);
return \Redirect::back()->with('success', 'You have Successfully Activated this Set');
}
public function edit($id, Template $template, Languages $language)
{
public function edit($id, Template $template, Languages $language) {
try {
$templates = $template->whereId($id)->first();
$languages = $language->get();
@@ -245,8 +234,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function update($id, Template $template, TemplateUdate $request)
{
public function update($id, Template $template, TemplateUdate $request) {
try {
//TODO validation
$templates = $template->whereId($id)->first();
@@ -272,8 +260,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function destroy($id, Template $template)
{
public function destroy($id, Template $template) {
try {
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
@@ -297,8 +284,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function formDiagno(Emails $email)
{
public function formDiagno(Emails $email) {
try {
$emails = $email->get();
@@ -315,8 +301,7 @@ class TemplateController extends Controller
*
* @return type
*/
public function postDiagno(DiagnosRequest $request)
{
public function postDiagno(DiagnosRequest $request) {
try {
$to = $request->input('to');
$subject = $request->input('subject');
@@ -328,13 +313,12 @@ class TemplateController extends Controller
}
$controller = new PhpMailController();
$controller->setMailConfig($from_address);
$controller->laravelMail($to, '', $subject, $msg, [], null);
$controller->laravelMail($to, '', $subject, $msg,[],null);
return redirect()->back()->with('success', 'Mail has send successfully');
} catch (Exception $e) {
dd($e);
return redirect()->back()->with('fails', $e->getMessage());
}
}
}

View File

@@ -2,116 +2,104 @@
namespace App\Http\Controllers\Admin\helpdesk;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Exception;
use Illuminate\Http\Request;
class UrlSettingController extends Controller
{
public function __construct()
{
class UrlSettingController extends Controller {
public function __construct() {
$this->middleware('auth');
}
public function settings(Request $request)
{
public function settings(Request $request) {
$url = $request->url();
$www = $this->checkWWW($url);
$https = $this->checkHTTP($url);
//dd($www, $https);
try {
return view('themes.default1.admin.helpdesk.settings.url.settings', compact('www', 'https'));
return view('themes.default1.admin.helpdesk.settings.url.settings',compact('www','https'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function postSettings(Request $request)
{
public function postSettings(Request $request) {
try {
$www = $request->input('www');
$ssl = $request->input('ssl');
$string_www = $this->www($www);
$sting_ssl = $this->ssl($ssl);
$string = $string_www.$sting_ssl;
$string = $string_www . $sting_ssl;
$this->writeHtaccess($string);
return redirect()->back()->with('success', 'updated');
} catch (Exception $ex) {
dd($ex);
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function www($www)
{
public function www($www) {
switch ($www) {
case 'yes':
case "yes":
return $this->changeWww();
case 'no':
case "no":
return $this->changeNonwww();
}
}
public function changeWww()
{
public function changeWww() {
$string = "RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
return $string;
}
public function changeNonwww()
{
// $string = "\nRewriteEngine On
//RewriteBase /
//RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
//RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
$string = '';
public function changeNonwww() {
$string = "RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
return $string;
}
public function ssl($ssl)
{
public function ssl($ssl) {
switch ($ssl) {
case 'yes':
case "yes":
return $this->changeHttps();
case 'no':
case "no":
return $this->changeHttp();
}
}
public function changeHttps()
{
public function changeHttps() {
$string = "RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
return $string;
}
public function changeHttp()
{
public function changeHttp() {
//$string = "RewriteCond %{HTTPS} off
//RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$string = '';
$string = "";
return $string;
}
public function writeHtaccess($string)
{
public function writeHtaccess($string) {
//dd(public_path('.htaccess'),base_path('.htaccess'));
$file = public_path('.htaccess');
if(!\File::exists($file)){
$file = base_path('/../.htaccess');
}
$this->deleteCustom();
$content = file_get_contents($file);
file_put_contents($file, $content."#custom\n".$string);
file_put_contents($file, $content . "#custom\n" . $string);
$new_content = file_get_contents($file);
}
public function deleteCustom()
{
public function deleteCustom() {
$file = public_path('.htaccess');
if(!\File::exists($file)){
$file = base_path('/../.htaccess');
}
$content = file_get_contents($file);
$custom_pos = strpos($content, '#custom');
if ($custom_pos) {
@@ -120,28 +108,23 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
file_put_contents($file, $content);
}
public function checkWwwInUrl($url)
{
public function checkWwwInUrl($url) {
$check = false;
if (strpos($url, 'www') !== false) {
$check = true;
}
return $check;
}
public function checkHttpsInUrl($url)
{
public function checkHttpsInUrl($url) {
$check = false;
if (strpos($url, 'https') !== false) {
$check = true;
}
return $check;
}
public function checkWWW($url)
{
public function checkWWW($url) {
$check = $this->checkWwwInUrl($url);
$array['www'] = true;
$array['nonwww'] = false;
@@ -149,12 +132,9 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$array['www'] = false;
$array['nonwww'] = true;
}
return $array;
}
public function checkHTTP($url)
{
public function checkHTTP($url) {
$check = $this->checkHttpsInUrl($url);
$array['https'] = true;
$array['http'] = false;
@@ -162,7 +142,7 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$array['https'] = false;
$array['http'] = true;
}
return $array;
}
}

View File

@@ -356,7 +356,7 @@ class WorkflowController extends Controller
*/
public function priority($id)
{
$priorities = Ticket_Priority::all();
$priorities = Ticket_Priority::where('status', '=', 1)->get();
$var = "<select name='action[".$id."][b]' class='form-control' required>";
foreach ($priorities as $priority) {
$var .= "<option value='".$priority->priority_id."'>".$priority->priority_desc.'</option>';