File size: 26,530 Bytes
89a1081 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | @push("style-include")
<link rel="stylesheet" href="{{ asset('assets/theme/global/css/select2.min.css')}}">
@endpush
@extends('admin.layouts.app')
@section('panel')
<main class="main-body">
<div class="container-fluid px-0 main-content">
<div class="page-header">
<div class="page-header-left">
<h2>{{ translate("Send "). $title }}</h2>
<div class="breadcrumb-wrapper">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{ route("admin.dashboard") }}">{{ translate("Dashboard") }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page"> {{ translate("Send "). $title }} </li>
</ol>
</nav>
</div>
</div>
</div>
<div class="card">
<div class="form-header">
<div class="row gy-4 align-items-center">
<div class="col-xxl-2 col-xl-3">
<h4 class="card-title">{{ translate("Choose audience") }}</h4>
</div>
<div class="col-xxl-10 col-xl-9">
<div class="form-tab">
<ul class="nav" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" data-bs-toggle="tab" href="#singleAudience" role="tab" aria-selected="true">
<i class="bi bi-person-fill"></i>{{ translate("Single audience") }} </a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" data-bs-toggle="tab" href="#groupAudience" role="tab" aria-selected="false" tabindex="-1">
<i class="bi bi-people-fill"></i> {{ translate("Group audience") }} </a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" data-bs-toggle="tab" href="#importFile" role="tab" aria-selected="false" tabindex="-1">
<i class="bi bi-file-earmark-plus-fill"></i> {{ translate("Import file") }} </a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="card-body pt-0">
<form action="{{route('admin.communication.store', ['type' => 'email'])}}" method="POST" enctype="multipart/form-data" id="sms_send">
@csrf
<div class="tab-content">
<div class="tab-pane fade show active" id="singleAudience" role="tabpanel">
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Recipient Email") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="form-inner">
<label for="email_contact" class="form-label">{{ translate("Email Address") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate('Provide a valid email address') }}">
<i class="ri-question-line"></i>
</span>
</label>
<input type="email" class="form-control" name="contacts" id="email_contact" placeholder="{{ translate("Enter recipient email address") }}" aria-label="email_contact" autocomplete=""/>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="groupAudience" role="tabpanel">
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate('From Group')}}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="row gy-3 align-items-end">
<div class="col-12">
<div class="form-inner">
<label for="contacts" class="form-label">{{ translate("Choose Group") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate("Only the contact groups with sms contact are available") }}">
<i class="ri-question-line"></i>
</span>
</label>
<select class="form-select select2-search" id="contacts" data-placeholder="{{ translate("Choose groups") }}" aria-label="contacts" name="contacts[]" multiple>
<option value=""></option>
@foreach($groups as $group)
<option value="{{$group->id}}">{{$group->name}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-12 group-logic d-none">
<div class="form-inner">
<label class="form-label"> {{ translate("Add Logic") }} </label>
<div class="form-inner-switch">
<label class="pointer" for="group_logic" >{{translate('Add Logic to Groups to select specific contacts based on attrbitues')}}</label for="group_logic" >
<div class="switch-wrapper mb-1 checkbox-data">
<input type="checkbox" value="true" name="group_logic" id="group_logic" class="switch-input">
<label for="group_logic" class="toggle">
<span></span>
</label>
</div>
</div>
</div>
</div>
<div class="form-item group-logic-items mt-3"></div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="importFile" role="tabpanel">
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Import file") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="form-inner">
<label for="file" class="form-label"> {{ translate("Import File") }}
</label>
<input type="file" name="contacts" id="file" class="form-control" aria-label="file" />
<p class="form-element-note">{{ translate("Download a demo csv file from this link: ") }} <a href="{{route('demo.file.download', ['extension' => 'csv' , 'type' => $type])}}">{{ translate("demo.csv") }}</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Choose Gateway") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="row gy-3 align-items-end">
<div class="col-12">
<div class="form-inner">
<label for="gateways" class="form-label">{{ translate("Choose From an available gateway") }}</label>
<select class="form-select select2-search" id="gateway_id" data-placeholder="{{ translate("Select a gateway") }}" data-show="5" aria-label="gateway_id" name="gateway_id">
<option value=""></option>
<option value="0">{{ translate("Random Rotation") }}</option>
<option value="-1">{{ translate("Automatic") }}</option>
@foreach($gateways as $type => $gateway)
<optgroup label="{{ ucfirst($type) }}">
@foreach($gateway as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</optgroup>
@endforeach
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Schedule At") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="form-inner">
<label for="ChooseGateway" class="form-label">{{ translate("Choose Date & Time") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate("You can select date and time for schedule operation. Or leave it empty to send normally") }}">
<i class="ri-question-line"></i>
</span>
</label>
<div class="input-group">
<input type="datetime-local" class="form-control singleDateTimePicker singleDate" placeholder="{{ translate("Select schedule time") }}" name="schedule_at"/>
<span class="input-group-text calendar-icon" id="filterByDate">
<i class="ri-calendar-2-line"></i>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Sender Information") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="form-inner mb-3">
<label for="email_from_name" class="form-label">{{ translate("Email From Name") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate('Provide a from name which will displayed as the nameof the source') }}">
<i class="ri-question-line"></i>
</span>
</label>
<input type="text" class="form-control" name="email_from_name" id="email_from_name" placeholder="{{ translate("Enter email from name") }}" aria-label="email_from_name" autocomplete=""/>
</div>
<div class="form-inner mb-3">
<label for="reply_to_address" class="form-label">{{ translate("Reply To Address") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate('Reply to email address helps recipient to communcate with you') }}">
<i class="ri-question-line"></i>
</span>
</label>
<input type="email" class="form-control" name="reply_to_address" id="reply_to_address" placeholder="{{ translate("Enter reply to email address") }}" aria-label="reply_to_address" autocomplete=""/>
</div>
</div>
</div>
</div>
<div class="form-element">
<div class="row gy-3">
<div class="col-xxl-2 col-xl-3">
<h5 class="form-element-title">{{ translate("Message body") }}</h5>
</div>
<div class="col-xxl-7 col-lg-9">
<div class="form-inner mb-3">
<label for="subject" class="form-label">{{ translate("Subject") }}<span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ translate('Provide a subject for the mail so it doesn\'t go into the spam') }}">
<i class="ri-question-line"></i>
</span>
</label>
<input type="text" class="form-control" name="message[subject]" id="email_contact" placeholder="{{ translate("Enter email subject") }}" aria-label="subject" autocomplete=""/>
</div>
<div class="form-inner position-relative speech-to-text" id="messageBox">
<div class="d-flex align-items-center justify-content-between w-100 flex-wrap gap-2 mb-2">
<label for="message" class="form-label mb-0">{{ translate("Write message") }}</label>
<button class="i-btn btn--sm p-0 bg-transparent text-primary available-template" id="selectEmailTemplate" type="button">
<i class="ri-layout-fill fs-5"></i>{{ translate("Use Template") }}</button>
</div>
<textarea class="form-control" name="message[message_body]" id="message" rows="5" placeholder="{{translate('Enter Email Content')}} @php echo "\nIf Contact is being selected from a group then to mention First Name Use {{". 'first_name' ."}} \nTo initiate text spinner type {Hello|Hi|Hola} to you, {Mr.|Mrs.|Ms.} {Lucia|Jimmy|Arnold}"@endphp"></textarea>
<div class="voice-icon">
<button type="button" class="icon-btn btn-sm primary-soft circle hover" id="text-to-speech-icon">
<i class="ri-mic-fill"></i>
<span class="tooltiptext"> {{ translate("Voice") }} </span>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xxl-9">
<div class="form-action justify-content-end">
<button type="submit" class="i-btn btn--primary btn--md"> {{ translate("Send") }} </button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</main>
@endsection
@section('modal')
<div class="modal fade" id="availableTemplate" tabindex="-1" aria-labelledby="availableTemplate" aria-hidden="true">
<div class="modal-dialog modal-md modal-dialog-centered ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> {{ translate("SMS Templates") }} </h5>
<button type="button" class="icon-btn btn-ghost btn-sm danger-soft circle modal-closer" data-bs-dismiss="modal">
<i class="ri-close-large-line"></i>
</button>
</div>
<div class="modal-body modal-md-custom-height">
<div class="row g-4">
<div class="col-12">
<div class="form-inner">
<label for="chooseTemplate" class="form-label">{{ translate("Available Templates") }}</label>
<select class="form-select select2-search" id="chooseTemplate" data-placeholder="{{ translate("Choose an SMS template") }}" aria-label="chooseTemplate">
<option value=""></option>
@foreach($templates as $template)
<option value="{{ json_encode($template->template_data) }}">{{ $template->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="template-data"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="i-btn btn--danger outline btn--md" data-bs-dismiss="modal"> {{ translate("Close") }} </button>
<button type="submit" id="saveTemplateButton" class="i-btn btn--primary btn--md"> {{ translate("Save") }} </button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="globalModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div id="modal-size" class="modal-dialog modal-fullscreen">
<div class="modal-content">
<div class="modal-header">
<h3 id="modal-title"></h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id="modal-body">
</div>
</div>
</div>
</div>
@endsection
@push("script-include")
<script src="{{asset('assets/theme/global/js/select2.min.js')}}"></script>
<script src="{{asset('assets/theme/global/js/template.js') }}"></script>
<script src="{{asset('assets/theme/global/js/BeePlugin.js') }}"></script>
@endpush
@push('script-push')
<script>
"use strict";
select2_search($('.select2-search').data('placeholder'));
ck_editor("#message");
$(document).ready(function() {
const modal = $('#globalModal');
$(document).on('click','#use-template',function(e){
var html = $(this).attr('data-html')
const domElement = document.querySelector( '.ck-editor__editable' );
const emailEditorInstance = domElement.ckeditorInstance;
emailEditorInstance.setData( html );
modal.modal('hide');
})
$(document).on('click','#selectEmailTemplate',function(e){
$("#selectEmailTemplate").html('{{translate("Template Loading...")}}');
appendTemplate()
e.preventDefault()
})
//load pre-build template method start
function appendTemplate(){
$.ajax({
method:"GET",
url:"{{ route('admin.template.email.fetch') }}",
dataType:'json'
}).then(response=>{
$("#selectEmailTemplate").html('{{translate("Use Email Template")}}');
appendModalData(response.view)
})
}
// append modal data method start
function appendModalData(view){
$('#modal-title').html(`{{translate('Pre Build Template')}}`)
var html = `
<div class="modal-body">
${view}
</div>
`
$('#modal-body').html(html)
modal.modal('show');
}
function handleMergedAttributes(attributes) {
var initialAttributeOptions = $(".group-logic-items").html();
$('#group_id').on('select2:unselect', function (e) {
$('.group-logic').addClass('d-none');
resetAttributeOptions();
function resetAttributeOptions() {
$(".group-logic-items").html(initialAttributeOptions);
}
});
$(".group-logic").removeClass("d-none");
$('#group_logic').change(function() {
var selectedAttributeValue;
if ($(this).is(':checked')) {
$(".group-logic-items").html(`
<div class="row">
<div class="col-md-6">
<label for="attribute_name" class="form-label">Attributes<sup class="text-danger">*</sup></label>
<select class="form-select repeat-scale" required name="attribute_name" id="attribute_name">
<option selected disabled>-- Select an Attribute --</option>
<option value="sms_contact">SMS Contact Number</option>
<option value="whatsapp_contact">WhatsApp Contact Number</option>
<option value="email_contact">Email Address</option>
<option value="first_name">First Name</option>
<option value="last_name">Last Name</option>
${getAttributesOptionsHTML(attributes)}
</select>
</div>
<div class="col-md-6" id="logic-input-container"></div>
</div>
`);
$('#attribute_name').change(function() {
selectedAttributeValue = $(this).val();
$('#logic-input-container').html(`
${getLogicInputHTML(selectedAttributeValue)}
`);
});
} else {
$(".group-logic-items").html('');
}
});
function getAttributesOptionsHTML(attributes) {
return Object.keys(attributes)
.map(attribute => `<option value="${attribute}::${attributes[attribute]}">${formatAttributeName(attribute)}</option>`)
.join('');
}
function formatAttributeName(attribute) {
return attribute.replace(/_/g, ' ').replace(/\b\w/g, firstLetter => firstLetter.toUpperCase());
}
function getLogicInputHTML(attribute) {
var value = attributes[attribute.split("::")[0]];
if (value && value != undefined) {
if (value == {{\App\Models\GeneralSetting::DATE}}) {
return `<div class="row"><div title="Only the contacts with this date in the '${attribute.split("::")[0]}' attribute will be selected for this Campaign" class="col-md-6"><label for="attribute_name" class="form-label">{{ translate("Select a Date") }}<sup class="text-danger">*</sup></label>
<input type="datetime-local" class="date-picker form-control" name="logic" id="logic"></div>
<div title="Only the contacts within this range in the '${attribute.split("::")[0]}' attribute will be selected for this Campaign" class="col-md-6"><label for="attribute_name" class="form-label">{{ translate("Select The Range") }}<sup class="text-danger">*</sup></label>
<input type="datetime-local" class="date-picker form-control" name="logic_range" id="logic_range"></div></div>`;
} else if (value == {{\App\Models\GeneralSetting::BOOLEAN}}) {
return `<label for="attribute_name" class="form-label">{{ translate("Conditions") }}<sup class="text-danger">*</sup></label>
<select class="form-select repeat-scale" required name="logic" id="logic">
<option selected disabled>${('-- Select a Logic --')}</option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>`;
} else if (value == {{\App\Models\GeneralSetting::NUMBER}}) {
return `<div class="row"><div title="Only the contacts with this number in the '${attribute.split("::")[0]}' attribute will be selected for this Campaign" class="col-md-6"><label for="attribute_name" class="form-label">{{ translate("Contains") }}<sup class="text-danger">*</sup></label>
<input type="number" class="form-control" name="logic" id="logic" placeholder="Enter a number"></div
<div class="row"><div title="Only the contacts within this range in the '${attribute.split("::")[0]}' attribute will be selected for this Campaign" class="col-md-6"><label for="attribute_name" class="form-label">{{ translate("Range") }}<sup class="text-danger">*</sup></label>
<input type="number" class="form-control" name="logic_range" id="logic_range" placeholder="Enter a number"></div`;
} else if (value == {{\App\Models\GeneralSetting::TEXT}}) {
return `<label for="attribute_name" class="form-label">{{ translate("Contains") }}<sup class="text-danger">*</sup></label>
<input type="text" class="form-control" name="logic" id="logic" placeholder="Enter text">`;
}
} else {
return `<label for="attribute_name" class="form-label">{{ translate("Contains") }}<sup class="text-danger">*</sup></label>
<input type="text" class="form-control" name="logic" id="logic" placeholder="Enter text">`;
}
}
}
function handleEmptyContacts(message) {
$('.group-logic').addClass("d-none");
$('.group-logic-items').addClass("d-none");
$('input[name=logic]').removeAttr('name');
$('input[name=group_logic]').removeAttr('name');
$('select[name=attribute_name]').removeAttr('name');
$('select[name=attribute_name]').prop('disabled', true);
notify('info', message);
}
$('#contacts').change(function() {
var selectedValues = $(this).val();
var channelValue = '{{ $type }}';
var csrfToken = $('meta[name="csrf-token"]').attr('content');
if (selectedValues) {
$.ajax({
url: '{{ route("admin.contact.group.fetch", ["type" => "meta_data"]) }}',
type: 'POST',
data: {
group_ids: selectedValues,
channel: "email",
},
headers: {
'X-CSRF-TOKEN': csrfToken,
},
success: function(response) {
if (response.status == true) {
handleMergedAttributes(response.merged_attributes);
} else {
handleEmptyContacts(response.message);
}
},
error: function(error) {
console.error(error);
}
});
}
});
$('#sms_send').on('submit', function(event) {
var activeTabId = $('.tab-content .tab-pane.active').attr('id');
// Clear data from inactive tabs
if (activeTabId !== 'singleAudience') {
$('#singleAudience input').val('');
}
if (activeTabId !== 'groupAudience') {
$('#groupAudience input').val('');
}
if (activeTabId !== 'importFile') {
$('#importFile input').val('');
}
});
});
</script>
@endpush
|