Merge pull request #234 from gillidandaweb/gillidandaweb-emailto-workflow

Add "email to" workflow
This commit is contained in:
Manish Verma
2016-10-10 18:39:04 +05:30
committed by GitHub
10 changed files with 78 additions and 48 deletions

View File

@@ -120,6 +120,7 @@ class MailController extends Controller
$mail = $mailbox->getMail($mailId);
try {
$mail = $mailbox->getMail($mailId);
} catch (\PhpImap\Exception $e) {
echo 'Connection error';
}
@@ -171,6 +172,8 @@ class MailController extends Controller
} else {
$subject = 'No Subject';
}
$to = $mail->to;
$fromname = $mail->fromName;
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
@@ -182,7 +185,7 @@ class MailController extends Controller
$form_data = null;
$team_assign = null;
$ticket_status = null;
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail->getAttachments());
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail->getAttachments());
if ($result[1] == true) {
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();

View File

@@ -40,33 +40,35 @@ class TicketWorkflowController extends Controller
*
* @return type response
*/
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail)
public function workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $mail)
{
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'subject' => $subject, 'message' => $body];
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'email_to' => $to, 'subject' => $subject, 'message' => $body];
$ticket_settings_details = ['help_topic' => $helptopic, 'sla' => $sla, 'priority' => $priority, 'source' => $source, 'dept' => $dept, 'assign' => $assign, 'team' => $team_assign, 'status' => $ticket_status, 'reject' => false];
// get all the workflow common to the entire system which includes any type of ticket creation where the execution order of the workflow should be starting with ascending order
$workflows = WorkflowName::where('target', '=', 'A-0')->where('status', '=', '1')->orderBy('order', 'asc')->get();
foreach ($workflows as $workflow) {
// checking if any workflow defined in the system
if ($workflow) {
// get all the rules of workflow which has a foreign key of those workflow which are applied to creating any ticket from any source
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get();
foreach ($worklfow_rules as $worklfow_rule) {
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get();
foreach ($workflow_rules as $workflow_rule) {
// checking for the workflow rules to which workflow rule type it is
if ($worklfow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
if ($workflow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'subject') {
} elseif ($workflow_rule->matching_scenario == 'subject') {
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
}
}
@@ -78,24 +80,24 @@ class TicketWorkflowController extends Controller
$workflows_webs = WorkflowName::where('target', '=', 'A-1')->where('status', '=', '1')->orderBy('order', 'asc')->get();
foreach ($workflows_webs as $workflows_web) {
if ($workflows_web) {
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get();
foreach ($worklfow_rules as $worklfow_rule) {
if ($worklfow_rule) {
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get();
foreach ($workflow_rules as $workflow_rule) {
if ($workflow_rule) {
// checking for the workflow rules to which workflow rule type it is
if ($worklfow_rule->matching_scenario == 'email') {
if ($this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
if ($workflow_rule->matching_scenario == 'email') {
if ($this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
if ($this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_name') {
if ($this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'subject') {
if ($this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'subject') {
if ($this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'message') {
if ($this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'message') {
if ($this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
}
}
@@ -109,24 +111,32 @@ class TicketWorkflowController extends Controller
$workflows_emails = WorkflowName::where('target', '=', 'A-2')->where('status', '=', '1')->orderBy('order', 'asc')->get();
foreach ($workflows_emails as $workflows_email) {
if ($workflows_email) {
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get();
foreach ($worklfow_rules as $worklfow_rule) {
if ($worklfow_rule) {
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get();
foreach ($workflow_rules as $workflow_rule) {
if ($workflow_rule) {
// checking for the workflow rules to which workflow rule type it is
if ($worklfow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
if ($workflow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'subject') {
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_to') {
foreach ($contact_details['email_to'] as $email_toaddress => $email_toname) {
if ($rule_condition = $this->checkRuleCondition($email_toaddress, $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
break;
}
}
} elseif ($workflow_rule->matching_scenario == 'subject') {
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
}
}
@@ -140,24 +150,28 @@ class TicketWorkflowController extends Controller
$workflows_apis = WorkflowName::where('target', '=', 'A-4')->where('status', '=', '1')->orderBy('order', 'asc')->get();
foreach ($workflows_apis as $workflows_api) {
if ($workflows_api) {
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get();
foreach ($worklfow_rules as $worklfow_rule) {
if ($worklfow_rule) {
$workflow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get();
foreach ($workflow_rules as $workflow_rule) {
if ($workflow_rule) {
// checking for the workflow rules to which workflow rule type it is
if ($worklfow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
if ($workflow_rule->matching_scenario == 'email') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_to') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'subject') {
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'email_name') {
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
}
} elseif ($worklfow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
} elseif ($workflow_rule->matching_scenario == 'subject') {
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
}
} elseif ($workflow_rule->matching_scenario == 'message') {
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $workflow_rule->matching_relation, $workflow_rule->matching_value) == true) {
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
}
}
@@ -204,6 +218,7 @@ class TicketWorkflowController extends Controller
// } elseif($condition == 'not_match') {
//
// }
return $return;
}

View File

@@ -68,6 +68,7 @@ class ClientTicketController extends Controller
$fromaddress = $user_cred->email;
$fromname = $user_cred->user_name;
$to = '';
$phone = '';
$phonecode = '';
$mobile_number = '';
@@ -86,7 +87,7 @@ class ClientTicketController extends Controller
$inline_attachment = null;
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $inline_attachment);
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $to, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response, $inline_attachment);
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
}

View File

@@ -149,6 +149,7 @@ class FormController extends Controller
$name = $request->input('Name');
$phone = $request->input('Phone');
$email = $request->input('Email');
$to = '';
$subject = $request->input('Subject');
$details = $request->input('Details');
$phonecode = $request->input('Code');
@@ -200,7 +201,7 @@ class FormController extends Controller
} else {
$inline_attachment = null;
}
$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, $inline_attachment);
$result = $this->TicketWorkflowController->workflow($email, $name, $to, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response, $inline_attachment);
if ($result[1] == 1) {
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
@@ -244,6 +245,7 @@ class FormController extends Controller
$fromaddress = $user_cred->email;
$fromname = $user_cred->user_name;
$to = '';
$phone = '';
$phonecode = '';
$mobile_number = '';
@@ -260,7 +262,7 @@ class FormController extends Controller
$ticket_status = null;
$auto_response = 0;
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
$this->TicketWorkflowController->workflow($fromaddress, $to, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
} else {

View File

@@ -95,6 +95,7 @@ return [
'create_email' => 'Create Email',
'email_address' => 'Email Address',
'email_name' => 'Email Name',
'email_to' => 'Email to',
'help_topic' => 'Help Topic',
'auto_response' => 'Auto Response',
'host_name' => 'Host Name',

Binary file not shown.

View File

@@ -96,6 +96,7 @@ return [
'create_email' => 'Crea Email',
'email_address' => 'Indirizzo Email',
'email_name' => 'Nome Email',
'email_to' => 'Email to',
'help_topic' => 'Argomento della Guida',
'auto_response' => 'Auto Risposta',
'host_name' => 'Nome Host',

View File

@@ -93,6 +93,7 @@ return [
'create_email' => 'Создать Email',
'email_address' => 'Email Address',
'email_name' => 'Email Name',
'email_to' => 'Email to',
'help_topic' => 'Help Topic',
'auto_response' => 'Автоматический Ответ',
'host_name' => 'Host Name',

View File

@@ -136,6 +136,7 @@ class="active"
<option value="">-- {!! Lang::get('lang.select_one') !!} --</option>
<option value="email">{!! Lang::get('lang.email') !!}</option>
<option value="email_name">{!! Lang::get('lang.email_name') !!}</option>
<option value="email_to">{!! Lang::get('lang.email_to') !!}</option>
<option value="subject">{!! Lang::get('lang.subject') !!}</option>
<option value="message">{!! Lang::get('lang.message') !!}/{!! Lang::get('lang.body') !!}</option>
</select>

View File

@@ -179,6 +179,11 @@ class="active"
echo "selected='selected'";
}
?> >{!! Lang::get('lang.email_name') !!}</option>
<option value="email_to" <?php
if ($workflow_rule->matching_scenario == 'email_to') {
echo "selected='selected'";
}
?> >{!! Lang::get('lang.email_to') !!}</option>
<option value="subject" <?php
if ($workflow_rule->matching_scenario == 'subject') {
echo "selected='selected'";