Updates
This commit is contained in:
@@ -11,14 +11,15 @@ use App\Model\helpdesk\Agent\Department;
|
||||
// models
|
||||
use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\User;
|
||||
use Exception;
|
||||
@@ -35,16 +36,15 @@ use Redirect;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class FormController extends Controller
|
||||
{
|
||||
class FormController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* Constructor to check.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||
$this->middleware('board');
|
||||
// creating a TicketController instance
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
@@ -57,31 +57,29 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getForm(Help_topic $topic, CountryCode $code)
|
||||
{
|
||||
public function getForm(Help_topic $topic, CountryCode $code) {
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('licence');
|
||||
}
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (!\Auth::check() && ($settings->status == 1 || $settings->status == '1')) {
|
||||
return redirect('auth/login')->with(['login_require' => 'Please login to your account for submitting a ticket', 'referer' => 'form']);
|
||||
return redirect('auth/login')->with(['login_require'=> 'Please login to your account for submitting a ticket', 'referer' => 'form']);
|
||||
}
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if (System::first()->status == 1) {
|
||||
$topics = $topic->get();
|
||||
$codes = $code->get();
|
||||
if ($phonecode->phonecode) {
|
||||
$phonecode = $phonecode->phonecode;
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if (System::first()->status == 1) {
|
||||
$topics = $topic->get();
|
||||
$codes = $code->get();
|
||||
if ($phonecode->phonecode) {
|
||||
$phonecode = $phonecode->phonecode;
|
||||
} else {
|
||||
$phonecode = "";
|
||||
}
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
$phonecode = '';
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,43 +90,43 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function postForm($id, Help_topic $topic)
|
||||
{
|
||||
public function postForm($id, Help_topic $topic) {
|
||||
if ($id != 0) {
|
||||
$helptopic = $topic->where('id', '=', $id)->first();
|
||||
$custom_form = $helptopic->custom_form;
|
||||
$values = Fields::where('forms_id', '=', $custom_form)->get();
|
||||
if (!$values) {
|
||||
|
||||
}
|
||||
if ($values) {
|
||||
foreach ($values as $form_data) {
|
||||
if ($form_data->type == 'select') {
|
||||
if ($form_data->type == "select") {
|
||||
$form_fields = explode(',', $form_data->value);
|
||||
$var = '';
|
||||
$var = "";
|
||||
foreach ($form_fields as $form_field) {
|
||||
$var .= '<option value="'.$form_field.'">'.$form_field.'</option>';
|
||||
$var .= '<option value="' . $form_field . '">' . $form_field . '</option>';
|
||||
}
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><select class="form-control" name="'.$form_data->name.'">'.$var.'</select>';
|
||||
} elseif ($form_data->type == 'radio') {
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><select class="form-control" name="' . $form_data->name . '">' . $var . '</select>';
|
||||
} elseif ($form_data->type == "radio") {
|
||||
$type2 = $form_data->value;
|
||||
$vals = explode(',', $type2);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($vals as $val) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$form_data->value.' ';
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '"> ' . $form_data->value . ' ';
|
||||
}
|
||||
echo '<br/>';
|
||||
} elseif ($form_data->type == 'textarea') {
|
||||
echo "<br/>";
|
||||
} elseif ($form_data->type == "textarea") {
|
||||
$type3 = $form_data->value;
|
||||
echo '<br/><label>'.$form_data->label.'</label></br><textarea id="unique-textarea" name="'.$form_data->name.'" class="form-control" style="height:15%;"></textarea>';
|
||||
} elseif ($form_data->type == 'checkbox') {
|
||||
echo '<br/><label>' . $form_data->label . '</label></br><textarea id="unique-textarea" name="' . $form_data->name . '" class="form-control" style="height:15%;"></textarea>';
|
||||
} elseif ($form_data->type == "checkbox") {
|
||||
$type4 = $form_data->value;
|
||||
$checks = explode(',', $type4);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($checks as $check) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'">  '.$check;
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '">  ' . $check;
|
||||
}
|
||||
} else {
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><input type="'.$form_data->type.'" class="form-control" name="'.$form_data->name.'" />';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><input type="' . $form_data->type . '" class="form-control" name="' . $form_data->name . '" />';
|
||||
}
|
||||
}
|
||||
echo '<br/><br/>';
|
||||
@@ -144,16 +142,15 @@ class FormController extends Controller
|
||||
* @param type Request $request
|
||||
* @param type User $user
|
||||
*/
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code)
|
||||
{
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code', 'priority');
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code) {
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token','mobile','Code', 'priority');
|
||||
$name = $request->input('Name');
|
||||
$phone = $request->input('Phone');
|
||||
if ($request->input('Email')) {
|
||||
if ($request->input('Email')) {
|
||||
if($request->input('Email')) {
|
||||
$email = $request->input('Email');
|
||||
} else {
|
||||
$email = null;
|
||||
$email = null;
|
||||
}
|
||||
} else {
|
||||
$email = null;
|
||||
@@ -168,18 +165,18 @@ class FormController extends Controller
|
||||
}
|
||||
$status = $ticket_settings->first()->status;
|
||||
$helptopic = $request->input('helptopic');
|
||||
$helpTopicObj = Help_topic::where('id', '=', $helptopic);
|
||||
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
||||
$helpTopicObj = Help_topic::where('id','=', $helptopic);
|
||||
if($helpTopicObj->exists() && ($helpTopicObj->value('status')==1)){
|
||||
$department = $helpTopicObj->value('department');
|
||||
} else {
|
||||
$defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic;
|
||||
$department = Help_topic::where('id', '=', $defaultHelpTopicID)->value('department');
|
||||
}else{
|
||||
$defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic;
|
||||
$department = Help_topic::where('id','=', $defaultHelpTopicID)->value('department');
|
||||
}
|
||||
$sla = $ticket_settings->first()->sla;
|
||||
|
||||
|
||||
// $priority = $ticket_settings->first()->priority;
|
||||
$default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
|
||||
$user_priority = CommonSettings::select('status')->where('option_name', '=', 'user_priority')->first();
|
||||
$default_priority = Ticket_Priority::where('is_default','=',1)->first();
|
||||
$user_priority = CommonSettings::where('option_name','=','user_priority')->first();
|
||||
if (!($request->input('priority'))) {
|
||||
$priority = $default_priority->priority_id;
|
||||
} else {
|
||||
@@ -196,8 +193,8 @@ class FormController extends Controller
|
||||
$geoipcode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if ($phonecode == null) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
@@ -206,8 +203,8 @@ class FormController extends Controller
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
||||
if (!count($code)) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
@@ -233,7 +230,7 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
// dd($result);
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is').' '.$result[0].'. '.Lang::get('lang.Please-save-this-for-future-reference'));
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is') . ' ' . $result[0] . '. ' . Lang::get('lang.Please-save-this-for-future-reference'));
|
||||
} else {
|
||||
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
||||
}
|
||||
@@ -247,14 +244,14 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function post_ticket_reply($id, Request $request)
|
||||
{
|
||||
public function post_ticket_reply($id, Request $request) {
|
||||
|
||||
try {
|
||||
if ($comment != null) {
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first();
|
||||
|
||||
$subject = $thread->title.'[#'.$tickets->ticket_number.']';
|
||||
$subject = $thread->title . '[#' . $tickets->ticket_number . ']';
|
||||
$body = $request->input('comment');
|
||||
|
||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||
@@ -288,14 +285,13 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getCustomForm(Request $request)
|
||||
{
|
||||
$html = '';
|
||||
public function getCustomForm(Request $request) {
|
||||
$html = "";
|
||||
$helptopic_id = $request->input('helptopic');
|
||||
$helptopics = new Help_topic();
|
||||
$helptopic = $helptopics->find($helptopic_id);
|
||||
if (!$helptopic) {
|
||||
throw new Exception('We can not find your request');
|
||||
throw new Exception("We can not find your request");
|
||||
}
|
||||
$custom_form = $helptopic->custom_form;
|
||||
if ($custom_form) {
|
||||
@@ -304,7 +300,7 @@ class FormController extends Controller
|
||||
$form_controller = new \App\Http\Controllers\Admin\helpdesk\FormController($fields, $forms);
|
||||
$html = $form_controller->renderForm($custom_form);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user