updates
This commit is contained in:
@@ -35,16 +35,15 @@ use Redirect;
|
|||||||
*
|
*
|
||||||
* @author Ladybird <info@ladybirdweb.com>
|
* @author Ladybird <info@ladybirdweb.com>
|
||||||
*/
|
*/
|
||||||
class FormController extends Controller
|
class FormController extends Controller {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
* Constructor to check.
|
* Constructor to check.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||||
{
|
|
||||||
$this->middleware('board');
|
$this->middleware('board');
|
||||||
// creating a TicketController instance
|
// creating a TicketController instance
|
||||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||||
@@ -57,15 +56,14 @@ class FormController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function getForm(Help_topic $topic, CountryCode $code)
|
public function getForm(Help_topic $topic, CountryCode $code) {
|
||||||
{
|
|
||||||
if (\Config::get('database.install') == '%0%') {
|
if (\Config::get('database.install') == '%0%') {
|
||||||
return \Redirect::route('licence');
|
return \Redirect::route('licence');
|
||||||
}
|
}
|
||||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
$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')) {
|
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();
|
$location = GeoIP::getLocation();
|
||||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||||
@@ -92,13 +90,13 @@ class FormController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type string
|
* @return type string
|
||||||
*/
|
*/
|
||||||
public function postForm($id, Help_topic $topic)
|
public function postForm($id, Help_topic $topic) {
|
||||||
{
|
|
||||||
if ($id != 0) {
|
if ($id != 0) {
|
||||||
$helptopic = $topic->where('id', '=', $id)->first();
|
$helptopic = $topic->where('id', '=', $id)->first();
|
||||||
$custom_form = $helptopic->custom_form;
|
$custom_form = $helptopic->custom_form;
|
||||||
$values = Fields::where('forms_id', '=', $custom_form)->get();
|
$values = Fields::where('forms_id', '=', $custom_form)->get();
|
||||||
if (!$values) {
|
if (!$values) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($values) {
|
if ($values) {
|
||||||
foreach ($values as $form_data) {
|
foreach ($values as $form_data) {
|
||||||
@@ -106,29 +104,29 @@ class FormController extends Controller
|
|||||||
$form_fields = explode(',', $form_data->value);
|
$form_fields = explode(',', $form_data->value);
|
||||||
$var = '';
|
$var = '';
|
||||||
foreach ($form_fields as $form_field) {
|
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>';
|
echo '<br/><label>' . ucfirst($form_data->label) . '</label><select class="form-control" name="' . $form_data->name . '">' . $var . '</select>';
|
||||||
} elseif ($form_data->type == 'radio') {
|
} elseif ($form_data->type == 'radio') {
|
||||||
$type2 = $form_data->value;
|
$type2 = $form_data->value;
|
||||||
$vals = explode(',', $type2);
|
$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) {
|
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/>';
|
echo '<br/>';
|
||||||
} elseif ($form_data->type == 'textarea') {
|
} elseif ($form_data->type == 'textarea') {
|
||||||
$type3 = $form_data->value;
|
$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>';
|
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') {
|
} elseif ($form_data->type == 'checkbox') {
|
||||||
$type4 = $form_data->value;
|
$type4 = $form_data->value;
|
||||||
$checks = explode(',', $type4);
|
$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) {
|
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 {
|
} 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/>';
|
echo '<br/><br/>';
|
||||||
@@ -144,104 +142,108 @@ class FormController extends Controller
|
|||||||
* @param type Request $request
|
* @param type Request $request
|
||||||
* @param type User $user
|
* @param type User $user
|
||||||
*/
|
*/
|
||||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code)
|
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code) {
|
||||||
{
|
try {
|
||||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code', 'priority');
|
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code', 'priority', 'attachment');
|
||||||
$name = $request->input('Name');
|
$name = $request->input('Name');
|
||||||
$phone = $request->input('Phone');
|
$phone = $request->input('Phone');
|
||||||
if ($request->input('Email')) {
|
|
||||||
if ($request->input('Email')) {
|
if ($request->input('Email')) {
|
||||||
$email = $request->input('Email');
|
if ($request->input('Email')) {
|
||||||
|
$email = $request->input('Email');
|
||||||
|
} else {
|
||||||
|
$email = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$email = null;
|
$email = null;
|
||||||
}
|
}
|
||||||
} else {
|
$subject = $request->input('Subject');
|
||||||
$email = null;
|
$details = $request->input('Details');
|
||||||
}
|
$phonecode = $request->input('Code');
|
||||||
$subject = $request->input('Subject');
|
if ($request->input('mobile')) {
|
||||||
$details = $request->input('Details');
|
$mobile_number = $request->input('mobile');
|
||||||
$phonecode = $request->input('Code');
|
|
||||||
if ($request->input('mobile')) {
|
|
||||||
$mobile_number = $request->input('mobile');
|
|
||||||
} else {
|
|
||||||
$mobile_number = null;
|
|
||||||
}
|
|
||||||
$status = $ticket_settings->first()->status;
|
|
||||||
$helptopic = $request->input('helptopic');
|
|
||||||
$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');
|
|
||||||
}
|
|
||||||
$sla = $ticket_settings->first()->sla;
|
|
||||||
|
|
||||||
// $priority = $ticket_settings->first()->priority;
|
|
||||||
$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;
|
|
||||||
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
|
||||||
$priority = $helpTopicObj->value('priority');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$priority = $request->input('priority');
|
|
||||||
}
|
|
||||||
$source = $ticket_source->where('name', '=', 'web')->first()->id;
|
|
||||||
$attachments = $request->file('attachment');
|
|
||||||
$collaborator = null;
|
|
||||||
$assignto = null;
|
|
||||||
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
|
||||||
$assignto = $helpTopicObj->value('auto_assign');
|
|
||||||
}
|
|
||||||
$auto_response = 0;
|
|
||||||
$team_assign = null;
|
|
||||||
if ($phone != null || $mobile_number != null) {
|
|
||||||
$location = GeoIP::getLocation();
|
|
||||||
$geoipcode = $code->where('iso', '=', $location->iso_code)->first();
|
|
||||||
if ($phonecode == null) {
|
|
||||||
$data = [
|
|
||||||
'fails' => Lang::get('lang.country-code-required-error'),
|
|
||||||
'phonecode' => $geoipcode->phonecode,
|
|
||||||
'country_code_error' => 1,
|
|
||||||
];
|
|
||||||
|
|
||||||
return Redirect::back()->with($data)->withInput($request->except('password'));
|
|
||||||
} else {
|
} else {
|
||||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
$mobile_number = null;
|
||||||
if (!count($code)) {
|
}
|
||||||
|
$status = $ticket_settings->first()->status;
|
||||||
|
$helptopic = $request->input('helptopic');
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
$sla = $ticket_settings->first()->sla;
|
||||||
|
|
||||||
|
// $priority = $ticket_settings->first()->priority;
|
||||||
|
$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;
|
||||||
|
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
||||||
|
$priority = $helpTopicObj->value('priority');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$priority = $request->input('priority');
|
||||||
|
}
|
||||||
|
$source = $ticket_source->where('name', '=', 'web')->first()->id;
|
||||||
|
$attachments = $request->file('attachment');
|
||||||
|
$collaborator = null;
|
||||||
|
$assignto = null;
|
||||||
|
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
||||||
|
$assignto = $helpTopicObj->value('auto_assign');
|
||||||
|
}
|
||||||
|
$auto_response = 0;
|
||||||
|
$team_assign = null;
|
||||||
|
if ($phone != null || $mobile_number != null) {
|
||||||
|
$location = GeoIP::getLocation();
|
||||||
|
$geoipcode = $code->where('iso', '=', $location->iso_code)->first();
|
||||||
|
if ($phonecode == null) {
|
||||||
$data = [
|
$data = [
|
||||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
'fails' => Lang::get('lang.country-code-required-error'),
|
||||||
'phonecode' => $geoipcode->phonecode,
|
'phonecode' => $geoipcode->phonecode,
|
||||||
'country_code_error' => 1,
|
'country_code_error' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
return Redirect::back()->with($data)->withInput($request->except('password'));
|
return Redirect::back()->with($data)->withInput($request->except('password'));
|
||||||
}
|
} else {
|
||||||
}
|
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
||||||
}
|
if (!count($code)) {
|
||||||
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
$data = [
|
||||||
// dd($result);
|
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||||
if ($result[1] == 1) {
|
'phonecode' => $geoipcode->phonecode,
|
||||||
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
|
'country_code_error' => 1,
|
||||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticketId->id)->first();
|
];
|
||||||
if ($attachments != null) {
|
|
||||||
foreach ($attachments as $attachment) {
|
return Redirect::back()->with($data)->withInput($request->except('password'));
|
||||||
if ($attachment != null) {
|
|
||||||
$name = $attachment->getClientOriginalName();
|
|
||||||
$type = $attachment->getClientOriginalExtension();
|
|
||||||
$size = $attachment->getSize();
|
|
||||||
$data = file_get_contents($attachment->getRealPath());
|
|
||||||
$attachPath = $attachment->getRealPath();
|
|
||||||
$ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
\Event::fire(new \App\Events\ClientTicketFormPost($form_extras, $email, $source));
|
||||||
|
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
||||||
// dd($result);
|
// 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'));
|
if ($result[1] == 1) {
|
||||||
} else {
|
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||||
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
$thread = Ticket_Thread::where('ticket_id', '=', $ticketId->id)->first();
|
||||||
|
if ($attachments != null) {
|
||||||
|
foreach ($attachments as $attachment) {
|
||||||
|
if ($attachment != null) {
|
||||||
|
$name = $attachment->getClientOriginalName();
|
||||||
|
$type = $attachment->getClientOriginalExtension();
|
||||||
|
$size = $attachment->getSize();
|
||||||
|
$data = file_get_contents($attachment->getRealPath());
|
||||||
|
$attachPath = $attachment->getRealPath();
|
||||||
|
$ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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'));
|
||||||
|
} else {
|
||||||
|
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
||||||
|
}
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
return redirect()->back()->with('fails', $ex->getMessage());
|
||||||
}
|
}
|
||||||
// dd($result);
|
// dd($result);
|
||||||
}
|
}
|
||||||
@@ -253,14 +255,13 @@ class FormController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type view
|
* @return type view
|
||||||
*/
|
*/
|
||||||
public function post_ticket_reply($id, Request $request)
|
public function post_ticket_reply($id, Request $request) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if ($comment != null) {
|
if ($comment != null) {
|
||||||
$tickets = Tickets::where('id', '=', $id)->first();
|
$tickets = Tickets::where('id', '=', $id)->first();
|
||||||
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->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');
|
$body = $request->input('comment');
|
||||||
|
|
||||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||||
@@ -294,8 +295,7 @@ class FormController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCustomForm(Request $request)
|
public function getCustomForm(Request $request) {
|
||||||
{
|
|
||||||
$html = '';
|
$html = '';
|
||||||
$helptopic_id = $request->input('helptopic');
|
$helptopic_id = $request->input('helptopic');
|
||||||
$helptopics = new Help_topic();
|
$helptopics = new Help_topic();
|
||||||
@@ -313,4 +313,5 @@ class FormController extends Controller
|
|||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -406,7 +406,7 @@ class SettingsController extends Controller
|
|||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
chmod($app, 0644);
|
chmod($app, 0644);
|
||||||
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 194;
|
$line_i_am_looking_for = 185;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
@@ -578,7 +578,7 @@ class SettingsController extends Controller
|
|||||||
if (!$plug) {
|
if (!$plug) {
|
||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 194;
|
$line_i_am_looking_for = 185;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
@@ -592,7 +592,7 @@ class SettingsController extends Controller
|
|||||||
|
|
||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 194;
|
$line_i_am_looking_for = 185;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
|
Reference in New Issue
Block a user