2090 lines
90 KiB
PHP
Executable File
2090 lines
90 KiB
PHP
Executable File
<style>
|
||
#notification_table{
|
||
overflow-x : unset;
|
||
}
|
||
.preview_button{
|
||
display:none;
|
||
}
|
||
|
||
.scrollb {
|
||
overflow-y: auto !important;
|
||
}
|
||
#editor-container {
|
||
width: 100%;
|
||
min-height: 600px;
|
||
}
|
||
|
||
.modal-dialog {
|
||
max-width: 90% !important;
|
||
width: 90% !important;
|
||
}
|
||
|
||
/* Also ensure the modal body has proper height */
|
||
|
||
.modal-body {
|
||
min-height: 600px;
|
||
padding: 20px;
|
||
}
|
||
|
||
/* If you're using Bootstrap's modal, you might also want to ensure proper positioning */
|
||
.modal-dialog {
|
||
margin: 1.75rem auto;
|
||
}
|
||
|
||
</style>
|
||
<div class="tab-pane fade" id="notification-tab">
|
||
<input type="hidden" id="client_id_for_client_branch" value="<?= isset($notification['id']) ? $notification['id'] : '' ?>" />
|
||
<div class="row float-right" style="padding-bottom: 10px;position: relative;right: 13px;">
|
||
</div>
|
||
|
||
<div class="table-responsive" id="notification_table">
|
||
|
||
<!-- <form id="notification_enable_form"> -->
|
||
|
||
<div>
|
||
<p><?php
|
||
|
||
// print_r($notification);
|
||
$member_welcome_mail = 0;
|
||
$member_reminder_mail = 0;
|
||
// $member_ecard_mail = 0;
|
||
$member_review_and_summary_mail = 0;
|
||
// $account_maneger_summary_mail = 0;
|
||
// $client_hr_summary_mail = 0;
|
||
if (isset($notification)) {
|
||
foreach ($notification as $value) {
|
||
|
||
if ($value['template_name'] == 'member_welcome_mail') {
|
||
$member_welcome_mail = $value['enabled'];
|
||
}
|
||
|
||
if ($value['template_name'] == 'member_reminder_mail') {
|
||
$member_reminder_mail = $value['enabled'];
|
||
}
|
||
|
||
// if ($value['template_name'] == 'member_ecard_mail') {
|
||
// $member_ecard_mail = $value['enabled'];
|
||
// }
|
||
|
||
if ($value['template_name'] == 'member_review_and_summary_mail') {
|
||
$member_review_and_summary_mail = $value['enabled'];
|
||
}
|
||
|
||
// if ($value['template_name'] == 'account_maneger_summary_mail') {
|
||
// $account_maneger_summary_mail = $value['enabled'];
|
||
// }
|
||
|
||
// if ($value['template_name'] == 'client_hr_summary_mail') {
|
||
// $client_hr_summary_mail = $value['enabled'];
|
||
// }
|
||
}
|
||
}
|
||
?></p>
|
||
</div>
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Team mail ID<span class="text-danger"></span></label>
|
||
<textarea name="" id="nhance_team_mail_ids" class="form-control" placeholder="Example: jhon@gmail.com, dave@gmail.com"><?php echo isset($client['common_mails']) ? $client['common_mails'] : ''; ?></textarea>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">HR mail ID<span class="text-danger"></span></label>
|
||
<textarea name="" id="hr_mail_id" class="form-control" placeholder="Example: jhon@gmail.com, dave@gmail.com"><?php echo isset($client['hr_mails']) ? $client['hr_mails'] : ''; ?></textarea>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="mail_domain">Mail Domain<span class="text-danger"></span></label>
|
||
<input type="text" name="" id="mail_domain" class="form-control" placeholder="Only one Domain Name. Example: nhance.com" value="<?php echo isset($client['mail_domain']) ? $client['mail_domain'] : ''; ?>">
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="reply_to">Reply To Mail<span class="text-danger"></span></label>
|
||
<input type="text" name="" id="reply_to" class="form-control" placeholder="Only one Reply-to mail. Example: jhon@gmail.com" value="<?php echo isset($client['reply_to']) ? $client['reply_to'] : ''; ?>">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Member welcome mail</label>
|
||
<label class="switch">
|
||
<input id="member_welcome_mail_btn" type="checkbox" name="member_welcome_mail_btn" <?= ($member_welcome_mail == 1) ? 'checked' : '' ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="member_welcome_mail" onclick="getMailTemplateData(this)" data-target="#member_welcome_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Member reminder mail</label>
|
||
<label class="switch">
|
||
<input id="member_reminder_mail_btn" type="checkbox" name="member_reminder_mail_btn" <?= $member_reminder_mail == 1 ? 'checked' : '' ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="member_reminder_mail" onclick="getMailTemplateData(this)" data-target="#member_reminder_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- <div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Member ECard mail</label>
|
||
<label class="switch">
|
||
<input id="member_ecard_mail_btn" type="checkbox" name="member_ecard_mail_btn" <?php //echo "$member_ecard_mail == 1 ? 'checked' : ''" ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="member_ecard_mail" onclick="getMailTemplateData(this)" data-target="#member_ecard_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
</div> -->
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Member Review and summary mail</label>
|
||
<label class="switch">
|
||
<input id="member_review_and_summary_mail_btn" type="checkbox" name="member_review_and_summary_mail_btn" <?= $member_review_and_summary_mail == 1 ? 'checked' : '' ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="member_review_and_summary_mail" onclick="getMailTemplateData(this)" data-target="#member_review_and_summary_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- <div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Account Manager summary mail</label>
|
||
<label class="switch">
|
||
<input id="account_maneger_summary_mail_btn" type="checkbox" name="account_maneger_summary_mail_btn" <?php // $account_maneger_summary_mail ? 'checked' : '' ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="account_maneger_summary_mail" onclick="getMailTemplateData(this)" data-target="#account_maneger_summary_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
</div> -->
|
||
|
||
<!-- <div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_name">Client HR summary mail</label>
|
||
<label class="switch">
|
||
<input id="client_hr_summary_mail_btn" type="checkbox" name="client_hr_summary_mail_btn" <?php // $client_hr_summary_mail == 1 ? 'checked' : '' ?>>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<a href="" data-toggle="modal" id="client_hr_summary_mail" onclick="getMailTemplateData(this)" data-target="#client_hr_summary_mail_modal">Edit</a>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<textarea style="display:none;" name="" id="" class="form-control "></textarea>
|
||
</div>
|
||
</div> -->
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<a style="float:right;" id="notification_enable_form_submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- </form> -->
|
||
</div>
|
||
|
||
</div>
|
||
<!-- end -->
|
||
|
||
|
||
|
||
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="member_welcome_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width scrollb">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Template Name : Member welcome mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="member_welcome_mail_form" enctype="multipart/form-data">
|
||
|
||
<input type="hidden" class="form-control" id="template_name" name="template_name" value="Member Welcome Mail" readonly>
|
||
<input type="hidden" id="member_welcome_mail_template_name" value="member_welcome_mail">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-1">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="member_welcome_mailmodal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary' || $value == 'enrollment_open_date' || $value == 'enrollment_close_date') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<div id="member_welcome_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||
|
||
<table id="attachment_table" class="table table-sm mb-0" style="margin-top: 30px;">
|
||
<thead>
|
||
<tr>
|
||
<th>Attachments</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="attachment_tbody">
|
||
</tbody>
|
||
</table>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="member_reminder_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" aria-modal="true">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Member reminder mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="member_reminder_mail_form" enctype="multipart/form-data">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Template Name</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="template_name" name="template_name" class="form-control" value="Member Reminder Mail" readonly placeholder="Template Name">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- <div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select name="" id="" class="form-control" style="z-index: 1;float: right;position: absolute;margin-top: 18px;right: 53px;width: 100px;height: 30px;">
|
||
<option value="">1</option>
|
||
<option value="">2</option>
|
||
<option value="">3</option>
|
||
<option value="">4</option>
|
||
<option value="">6</option>
|
||
</select>
|
||
</div>
|
||
</div> -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="member_reminder_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<div id="member_reminder_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div id="editor" name="content"></div>
|
||
|
||
|
||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||
|
||
<table id="attachment_table" class="table table-sm mb-0" style="margin-top: 30px;">
|
||
<thead>
|
||
<tr>
|
||
<th>Attachments</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="attachment_tbody_reminder_mail_attachments">
|
||
</tbody>
|
||
</table>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
|
||
id="">Preview</button>
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<!-- Modal content for the Large example -->
|
||
<?php /*
|
||
<div class="modal fade" id="member_ecard_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Member ecard mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="member_ecard_mail_form" enctype="multipart/form-data">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Template Name</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="template_name" name="template_name" class="form-control" value="Member Ecard Mail" readonly placeholder="Template Name">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="member_ecard_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<div id="member_ecard_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div id="editor" name="content"></div>
|
||
|
||
|
||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||
<table id="attachment_table_ecard" class="table table-sm mb-0" style="margin-top: 30px;">
|
||
<thead>
|
||
<tr>
|
||
<th>Attachments</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="attachment_tbody_ecard">
|
||
</tbody>
|
||
</table>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
|
||
id="">Preview</button>
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div>
|
||
*/ ?>
|
||
|
||
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="member_review_and_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Member Review and summary mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="member_review_and_summary_mail_form" enctype="multipart/form-data">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Template Name</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="template_name" name="template_name" value="Member Review and Summary Mail" readonly class="form-control" placeholder="Template Name">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- <div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select name="" id="" class="form-control" style="z-index: 1;float: right;position: absolute;margin-top: 18px;right: 53px;width: 100px;height: 30px;">
|
||
<option value="">1</option>
|
||
<option value="">2</option>
|
||
<option value="">3</option>
|
||
<option value="">4</option>
|
||
<option value="">6</option>
|
||
</select>
|
||
</div>
|
||
</div> -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="member_review_and_summary_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<div id="member_review_and_summary_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div id="editor"></div>
|
||
|
||
|
||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
|
||
id="">Preview</button>
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
<?php /*
|
||
|
||
<div class="modal fade" id="account_maneger_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Member Review and summary mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="text-center" id="no_data"></div>
|
||
<form role="form" class="parsley-examples" method="post" id="account_maneger_summary_mail_form" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Template Name</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="template_name" name="template_name" value="Account Maneger Summary Mail" readonly class="form-control" placeholder="Template Name">
|
||
</div>
|
||
</div>
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="account_maneger_summary_mail_modal_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<!-- <div class="form-row" id="rac_rate_dropdown"> -->
|
||
<div class="form-group col-md-12">
|
||
<div id="account_maneger_summary_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
<!-- </div> -->
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
|
||
id="">Preview</button>
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="client_hr_summary_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Member Review and summary mail <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="client_hr_summary_mail_form" enctype="multipart/form-data">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Template Name</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="template_name" name="template_name" value="Client HR Summary Mail" readonly class="form-control" placeholder="Template Name">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-2">
|
||
<label for="emp_code">Subject</label>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||
</div>
|
||
<div class="form-group col-md-2 testmail" style="display: none;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- <div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select name="" id="" class="form-control" style="z-index: 1;float: right;position: absolute;margin-top: 18px;right: 53px;width: 100px;height: 30px;">
|
||
<option value="">1</option>
|
||
<option value="">2</option>
|
||
<option value="">3</option>
|
||
<option value="">4</option>
|
||
<option value="">6</option>
|
||
|
||
</select>
|
||
</div>
|
||
</div> -->
|
||
</div> -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<select id="client_hr_summary_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;" onchange="copyToClipboard(this)">
|
||
<option value="">PlaceHolders</option>
|
||
<?php foreach ($placeHolders as $value): ?>
|
||
<?php if ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
|
||
<?php $valueChange = str_replace('_', ' ', $value);
|
||
$valueChange = ucwords($valueChange); ?>
|
||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||
<?php } ?>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
<span id="copy-feedback" style="display: none; position: absolute; top: 50px; right: 10px; color: green; font-size: 12px;">Copied to clipboard!</span>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<!-- Unlayer editor -->
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-12">
|
||
<div id="client_hr_summary_mail_editor_container" style="height: 600px"></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div id="editor"></div>
|
||
|
||
|
||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
|
||
id="">Preview</button>
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
<!-- /.modal -->
|
||
*/ ?>
|
||
|
||
|
||
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-hidden="false" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Testing Mail Data<span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
<!-- <script>
|
||
$(document).ready(function() {
|
||
const fileInput = document.getElementById("Question_title_fileInput");
|
||
|
||
fileInput.addEventListener("change", () => {
|
||
const file = fileInput.files[0];
|
||
if (file) {
|
||
const reader = new FileReader();
|
||
reader.onload = function(e) {
|
||
const imageUrl = e.target.result;
|
||
editor.selection.insertImage(imageUrl);
|
||
};
|
||
reader.readAsDataURL(file);
|
||
}
|
||
fileInput.value = '';
|
||
});
|
||
|
||
|
||
})
|
||
|
||
function testMailSend(input) {
|
||
|
||
let test_mail = prompt("Please enter test mail:");
|
||
console.log('mail address:', test_mail);
|
||
|
||
if (test_mail !== null || test_mail !== "") {
|
||
|
||
if (isValidEmail(test_mail)) {
|
||
|
||
var template_id = $(input).data('id');
|
||
console.log('templte id', template_id);
|
||
|
||
if (template_id) {
|
||
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
|
||
console.log('testing mail url:', url);
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('Test mail send function response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status == true) {
|
||
|
||
let respond = res.respond;
|
||
console.log('Parsed respond', respond)
|
||
|
||
if (respond.status == 'success') {
|
||
toastr.success(respond.message, 'Success')
|
||
} else {
|
||
toastr.warning(respond.message, 'Warning')
|
||
}
|
||
|
||
} else {
|
||
toastr.warning('Failed to sent mail', 'Success')
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
let alert_msg = 'Template ID not exist'
|
||
toastr.warning(alert_msg, 'Warning');
|
||
}
|
||
|
||
} else {
|
||
toastr.warning('Please enter the valid mail', 'Warning');
|
||
}
|
||
|
||
} else {
|
||
|
||
toastr.warning('Please enter the valid mail', 'Warning');
|
||
}
|
||
|
||
}
|
||
|
||
function isValidEmail(email) {
|
||
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||
return emailPattern.test(email);
|
||
}
|
||
|
||
function addHTMLInput(data = null) {
|
||
|
||
console.log('addHTMLInput function called');
|
||
console.log(template_name);
|
||
var container = '';
|
||
if (template_name == 'member_welcome_mail') {
|
||
container = document.getElementById('attachment_tbody');
|
||
} else {
|
||
container = document.getElementById('attachment_tbody_ecard');
|
||
}
|
||
|
||
if (data) {
|
||
|
||
$(container).empty();
|
||
|
||
data.forEach(item => {
|
||
const newRow = document.createElement('tr');
|
||
newRow.className = 'dynamic-form-row';
|
||
|
||
newRow.innerHTML = `
|
||
<td> ${item.file_name} </td>
|
||
<td> <a class="fa fa-trash" data-id="${item.id}" onclick="removeAttachment('${item.id}')"></a></td>
|
||
`;
|
||
|
||
container.appendChild(newRow);
|
||
});
|
||
|
||
// Creating another row for the form with file input
|
||
const newFormRow = document.createElement('tr');
|
||
newFormRow.className = 'dynamic-form-row';
|
||
|
||
newFormRow.innerHTML = `
|
||
<td>
|
||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||
<div class="form-row">
|
||
<div class="form-group col-3">
|
||
<input type="file" class="file-input__input" name="file" required>
|
||
</div>
|
||
<div class="form-group col-2">
|
||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</td>
|
||
`;
|
||
|
||
container.appendChild(newFormRow);
|
||
|
||
} else {
|
||
// If no data is passed, create a new empty row
|
||
const newRow = document.createElement('tr');
|
||
newRow.className = 'dynamic-form-row';
|
||
|
||
newRow.innerHTML = `
|
||
<td>
|
||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||
<div class="form-row">
|
||
<div class="form-group col-3">
|
||
<input type="file" class="file-input__input" name="file" required>
|
||
</div>
|
||
<div class="form-group col-2">
|
||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</td>
|
||
`;
|
||
container.appendChild(newRow);
|
||
}
|
||
}
|
||
|
||
function removeHTMLInput(element) {
|
||
if (template_name == 'member_welcome_mail') {
|
||
const container = document.getElementById('attachment_tbody');
|
||
} else {
|
||
const container = document.getElementById('attachment_tbody_ecard');
|
||
}
|
||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||
|
||
if (rows.length > 1) {
|
||
const row = element.closest('.dynamic-form-row');
|
||
row.remove();
|
||
}
|
||
}
|
||
|
||
function submitAttachmentForm(event, form) {
|
||
|
||
event.preventDefault(); // Prevent the default form submission
|
||
|
||
// var template_name = template_name;
|
||
var client_id = $('#general_PrimaryKey').val();
|
||
// console.log(client_id);
|
||
|
||
const formData = new FormData(form);
|
||
formData.append('template_name', template_name);
|
||
formData.append('client_id', client_id);
|
||
console.log(formData.template_name);
|
||
const fileInput = form.querySelector('input[type="file"]');
|
||
|
||
// Check if a file is selected
|
||
if (!fileInput.files.length) {
|
||
toastr.warning("Please select a file to upload.");
|
||
return;
|
||
}
|
||
|
||
// Optional: Display a loading indicator
|
||
const submitButton = form.querySelector('button[type="submit"]');
|
||
submitButton.disabled = true;
|
||
submitButton.innerText = 'Uploading...';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
// AJAX request to upload the file
|
||
$.ajax({
|
||
url: '<?= base_url('client/notification/add_attachment') ?>', // Replace with your actual upload URL
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(response) {
|
||
|
||
console.log(response)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (response.status == true) {
|
||
toastr.success(response.message, 'Success');
|
||
addHTMLInput(response.data);
|
||
} else {
|
||
toastr.error(response.message, 'Error');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Handle error
|
||
console.error('Upload error occurred:');
|
||
console.error('Status: ', status); // Status of the request
|
||
console.error('Error: ', error); // Specific error message
|
||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||
|
||
// Optionally log server response, if available
|
||
if (xhr.responseText) {
|
||
console.error('Response Text: ', xhr.responseText);
|
||
}
|
||
|
||
toastr.warning('Error uploading file', 'Warning');
|
||
console.error('Upload error:', error);
|
||
},
|
||
complete: function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Re-enable the submit button and reset its text
|
||
submitButton.disabled = false;
|
||
submitButton.innerText = 'Submit';
|
||
}
|
||
});
|
||
}
|
||
|
||
function removeAttachment(id) {
|
||
|
||
// var template_name = template_name
|
||
var client_id = $('#general_PrimaryKey').val();
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('client/notification/removeAttachment/'); ?>' + id + '/' + client_id + '/' + template_name,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('removeAttachment response', res)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status == true) {
|
||
toastr.success(res.message, 'Success')
|
||
addHTMLInput(res.data);
|
||
} else {
|
||
toastr.warning(res.message, 'Warning')
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
}
|
||
</script> -->
|
||
|
||
<script>
|
||
// Global editor variable
|
||
let editor = null;
|
||
let template_name = '';
|
||
$(document).ready(function() {
|
||
const fileInput = document.getElementById("Question_title_fileInput");
|
||
|
||
fileInput.addEventListener("change", () => {
|
||
const file = fileInput.files[0];
|
||
if (file) {
|
||
const reader = new FileReader();
|
||
reader.onload = function(e) {
|
||
const imageUrl = e.target.result;
|
||
editor.selection.insertImage(imageUrl);
|
||
};
|
||
reader.readAsDataURL(file);
|
||
}
|
||
fileInput.value = '';
|
||
});
|
||
|
||
|
||
})
|
||
|
||
function testMailSend(input) {
|
||
|
||
let test_mail = prompt("Please enter test mail:");
|
||
console.log('mail address:', test_mail);
|
||
|
||
if (test_mail !== null || test_mail !== "") {
|
||
|
||
if (isValidEmail(test_mail)) {
|
||
|
||
var template_id = $(input).data('id');
|
||
console.log('templte id', template_id);
|
||
|
||
if (template_id) {
|
||
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
|
||
console.log('testing mail url:', url);
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('Test mail send function response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status == true) {
|
||
|
||
let respond = res.respond;
|
||
console.log('Parsed respond', respond)
|
||
|
||
if (respond.status == 'success') {
|
||
toastr.success(respond.message, 'Success')
|
||
} else {
|
||
toastr.warning(respond.message, 'Warning')
|
||
}
|
||
|
||
} else {
|
||
toastr.warning('Failed to sent mail', 'Warning')
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
let alert_msg = 'Template ID not exist'
|
||
toastr.warning(alert_msg, 'Warning');
|
||
}
|
||
|
||
} else {
|
||
toastr.warning('Please enter the valid mail', 'Warning');
|
||
}
|
||
|
||
} else {
|
||
|
||
toastr.warning('Please enter the valid mail', 'Warning');
|
||
}
|
||
|
||
}
|
||
|
||
function isValidEmail(email) {
|
||
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||
return emailPattern.test(email);
|
||
}
|
||
|
||
function addHTMLInput(data = null) {
|
||
|
||
console.log('addHTMLInput function called');
|
||
console.log(template_name);
|
||
var container = '';
|
||
if( template_name == 'member_welcome_mail' ) {
|
||
container = document.getElementById('attachment_tbody');
|
||
}
|
||
else if( template_name == "member_reminder_mail" ){
|
||
container = document.getElementById('attachment_tbody_reminder_mail_attachments');
|
||
}
|
||
//else {
|
||
// container = document.getElementById('attachment_tbody_ecard');
|
||
// }
|
||
|
||
if (data && template_name == "member_welcome_mail") {
|
||
|
||
$('#attachment_tbody').empty();
|
||
|
||
data.forEach(item => {
|
||
const newRow = document.createElement('tr');
|
||
newRow.className = 'dynamic-form-row';
|
||
|
||
newRow.innerHTML = `
|
||
<td> ${item.file_name} </td>
|
||
<td> <a class="fa fa-trash" data-id="${item.id}" onclick="removeAttachment('${item.id}')"></a></td>
|
||
`;
|
||
|
||
container.appendChild(newRow);
|
||
});
|
||
|
||
// Creating another row for the form with file input
|
||
const newFormRow = document.createElement('tr');
|
||
newFormRow.className = 'dynamic-form-row';
|
||
|
||
newFormRow.innerHTML = `
|
||
<td>
|
||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||
<div class="form-row">
|
||
<div class="form-group col-5">
|
||
<input type="file" class="file-input__input" name="file">
|
||
</div>
|
||
<div class="form-group col-2">
|
||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</td>
|
||
`;
|
||
|
||
container.appendChild(newFormRow);
|
||
|
||
}
|
||
|
||
else if (data && template_name == "member_reminder_mail") {
|
||
|
||
$('#attachment_tbody_reminder_mail_attachments').empty();
|
||
|
||
data.forEach(item => {
|
||
const newRow = document.createElement('tr');
|
||
newRow.className = 'dynamic-form-row';
|
||
|
||
newRow.innerHTML = `
|
||
<td> ${item.file_name} </td>
|
||
<td> <a class="fa fa-trash" data-id="${item.id}" onclick="removeAttachment('${item.id}')"></a></td>
|
||
`;
|
||
|
||
container.appendChild(newRow);
|
||
});
|
||
|
||
// Creating another row for the form with file input
|
||
const newFormRow = document.createElement('tr');
|
||
newFormRow.className = 'dynamic-form-row';
|
||
|
||
newFormRow.innerHTML = `
|
||
<td>
|
||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||
<div class="form-row">
|
||
<div class="form-group col-5">
|
||
<input type="file" class="file-input__input" name="file">
|
||
</div>
|
||
<div class="form-group col-2">
|
||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</td>
|
||
`;
|
||
|
||
container.appendChild(newFormRow);
|
||
|
||
} else {
|
||
|
||
|
||
// If no data is passed, create a new empty row
|
||
const newRow = document.createElement('tr');
|
||
newRow.className = 'dynamic-form-row';
|
||
|
||
newRow.innerHTML = `
|
||
<td>
|
||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||
<div class="form-row">
|
||
<div class="form-group col-5">
|
||
<input type="file" class="file-input__input" name="file">
|
||
</div>
|
||
<div class="form-group col-2">
|
||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</td>
|
||
`;
|
||
container.appendChild(newRow);
|
||
}
|
||
}
|
||
|
||
function removeHTMLInput(element) {
|
||
if (template_name == 'member_welcome_mail') {
|
||
const container = document.getElementById('attachment_tbody');
|
||
} //else {
|
||
// const container = document.getElementById('attachment_tbody_ecard');
|
||
// }
|
||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||
|
||
if (rows.length > 1) {
|
||
const row = element.closest('.dynamic-form-row');
|
||
row.remove();
|
||
}
|
||
}
|
||
|
||
function submitAttachmentForm(event, form) {
|
||
|
||
event.preventDefault(); // Prevent the default form submission
|
||
|
||
// var template_name = template_name;
|
||
var client_id = $('#general_PrimaryKey').val();
|
||
// console.log(client_id);
|
||
|
||
const formData = new FormData(form);
|
||
formData.append('template_name', template_name);
|
||
formData.append('client_id', client_id);
|
||
console.log(formData.template_name);
|
||
const fileInput = form.querySelector('input[type="file"]');
|
||
|
||
// Check if a file is selected
|
||
if (!fileInput.files.length) {
|
||
toastr.warning("Please select a file to upload.", "Validation Error");
|
||
return;
|
||
}
|
||
|
||
// Optional: Display a loading indicator
|
||
const submitButton = form.querySelector('button[type="submit"]');
|
||
submitButton.disabled = true;
|
||
submitButton.innerText = 'Uploading...';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
// AJAX request to upload the file
|
||
$.ajax({
|
||
url: '<?= base_url('client/notification/add_attachment') ?>', // Replace with your actual upload URL
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(response) {
|
||
|
||
console.log(response)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (response.status == true) {
|
||
toastr.success(response.message, 'Success');
|
||
addHTMLInput(response.data);
|
||
} else {
|
||
toastr.error(response.message, 'Error');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Handle error
|
||
console.error('Upload error occurred:');
|
||
console.error('Status: ', status); // Status of the request
|
||
console.error('Error: ', error); // Specific error message
|
||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||
|
||
// Optionally log server response, if available
|
||
if (xhr.responseText) {
|
||
console.error('Response Text: ', xhr.responseText);
|
||
}
|
||
|
||
toastr.warning('Error uploading file', 'Warning');
|
||
console.error('Upload error:', error);
|
||
},
|
||
complete: function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
// Re-enable the submit button and reset its text
|
||
submitButton.disabled = false;
|
||
submitButton.innerText = 'Submit';
|
||
}
|
||
});
|
||
}
|
||
|
||
function removeAttachment(id) {
|
||
|
||
// var template_name = template_name
|
||
var client_id = $('#general_PrimaryKey').val();
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('client/notification/removeAttachment/'); ?>' + id + '/' + client_id + '/' + template_name,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('removeAttachment response', res)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status == true) {
|
||
toastr.success(res.message, 'Success')
|
||
addHTMLInput(res.data);
|
||
} else {
|
||
toastr.warning(res.message, 'Warning')
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
}
|
||
// Function to check if unlayer is loaded and available
|
||
function isUnlayerLoaded() {
|
||
return typeof unlayer !== 'undefined' && unlayer !== null;
|
||
}
|
||
|
||
// Enhanced waiting function with better error handling
|
||
function waitForUnlayer(callback, maxAttempts = 20) {
|
||
let attempts = 0;
|
||
|
||
const checkUnlayer = setInterval(function() {
|
||
attempts++;
|
||
console.log("Checking for Unlayer, attempt:", attempts);
|
||
|
||
if (isUnlayerLoaded()) {
|
||
clearInterval(checkUnlayer);
|
||
console.log("Unlayer loaded successfully");
|
||
callback(true);
|
||
} else if (attempts >= maxAttempts) {
|
||
clearInterval(checkUnlayer);
|
||
console.error("Unlayer failed to load after", attempts, "attempts");
|
||
callback(false);
|
||
}
|
||
}, 1000); // Increased interval to 1 second
|
||
}
|
||
|
||
// Improved editor initialization function
|
||
function initializeEditor(callback) {
|
||
|
||
console.log("Starting editor initialization...");
|
||
|
||
const editorContainer = document.getElementById(`${template_name}_editor_container`);
|
||
if (!editorContainer) {
|
||
console.error("Editor container not found");
|
||
if (callback) callback(null);
|
||
return;
|
||
}
|
||
|
||
// Ensure the script is loaded
|
||
if (!document.querySelector('script[src*="unlayer"]')) {
|
||
console.error("Unlayer script is not included in the page");
|
||
if (callback) callback(null);
|
||
return;
|
||
}
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
waitForUnlayer(function(unlayerLoaded) {
|
||
if (!unlayerLoaded) {
|
||
console.error("Unlayer not available");
|
||
if (callback) callback(null);
|
||
return;
|
||
}
|
||
|
||
try {
|
||
// Destroy existing instance if it exists
|
||
if (editor) {
|
||
console.log("Destroying existing editor...");
|
||
editor.destroy();
|
||
editor = null;
|
||
}
|
||
|
||
// Clear the container
|
||
editorContainer.innerHTML = '';
|
||
|
||
// Create new editor instance with error handling
|
||
console.log("Creating new editor instance...");
|
||
editor = unlayer.createEditor({
|
||
id: `${template_name}_editor_container`,
|
||
projectId: 263979,
|
||
displayMode: "email",
|
||
features: {
|
||
textEditor: {
|
||
tables: true
|
||
},
|
||
preview: {
|
||
enabled: true,
|
||
deviceOptions: ['desktop', 'mobile']
|
||
},
|
||
preview: { enabled: true },
|
||
imageEditor: {
|
||
enabled: true
|
||
},
|
||
appearance: {
|
||
theme: 'light',
|
||
panels: {
|
||
tools: {
|
||
dock: "right"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
branding: false,
|
||
tools: {
|
||
// Configure any specific tools you need
|
||
text: {
|
||
enabled: true
|
||
},
|
||
image: {
|
||
enabled: true
|
||
}
|
||
}
|
||
});
|
||
|
||
// Verify editor initialization
|
||
if (!editor || typeof editor.loadDesign !== 'function') {
|
||
throw new Error("Editor initialization failed - editor instance is invalid");
|
||
}
|
||
|
||
console.log("Editor initialization completed successfully");
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').fadeOut();
|
||
if (callback) callback(editor);
|
||
|
||
} catch (error) {
|
||
console.error("Error in editor initialization:", error);
|
||
if (callback) callback(null);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').fadeOut();
|
||
}
|
||
});
|
||
}
|
||
|
||
// Modified template data function with better error handling
|
||
function getMailTemplateData(element) {
|
||
template_name = element.id;
|
||
const validTemplates = [
|
||
"member_reminder_mail", "member_welcome_mail","member_review_and_summary_mail"
|
||
];
|
||
|
||
if (!validTemplates.includes(template_name)) {
|
||
console.error("Invalid template name:", template_name);
|
||
return;
|
||
}
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
const primaryKey = $('#general_PrimaryKey').val();
|
||
const baseUrl = '<?= base_url("client/notification/getMailTemplateData/") ?>';
|
||
const form_action = `${baseUrl}${template_name}/${primaryKey}`;
|
||
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
console.log('get Mail Template Data', res);
|
||
|
||
if (res) {
|
||
// Set subject
|
||
$(`#${template_name}_form #subject`).val(res.subject || '');
|
||
|
||
// Initialize editor with retry mechanism
|
||
let retryCount = 0;
|
||
const initWithRetry = function() {
|
||
initializeEditor(function(editorInstance) {
|
||
if (!editorInstance && retryCount < 3) {
|
||
console.log(`Retrying editor initialization (${retryCount + 1}/3)...`);
|
||
retryCount++;
|
||
setTimeout(initWithRetry, 1000);
|
||
return;
|
||
}
|
||
|
||
if (!editorInstance) {
|
||
console.error("Editor initialization failed after retries");
|
||
toastr.error('Editor initialization failed. Please refresh the page.');
|
||
return;
|
||
}
|
||
|
||
if (res.mail_content_json) {
|
||
try {
|
||
const design = JSON.parse(res.mail_content_json);
|
||
editorInstance.loadDesign(design);
|
||
console.log("Design loaded successfully");
|
||
hideBranding();
|
||
} catch (error) {
|
||
console.error("Error parsing mail content JSON:", error);
|
||
toastr.error('Error loading email template');
|
||
}
|
||
} else {
|
||
hideBranding()
|
||
}
|
||
});
|
||
};
|
||
|
||
initWithRetry();
|
||
|
||
if (res.data && (template_name == 'member_welcome_mail' )) {
|
||
console.log("file attachment for member_welcome_mail");
|
||
console.log(template_name);
|
||
addHTMLInput(res.data);
|
||
}
|
||
if (res.data && ( template_name == "member_reminder_mail" )) {
|
||
console.log("file attachment for member_reminder_mail");
|
||
console.log(template_name);
|
||
addHTMLInput(res.data);
|
||
} //else {
|
||
// addHTMLInput();
|
||
// }
|
||
|
||
// Update UI elements
|
||
$('.testmail').toggle(!!res.id);
|
||
$('#attachment_table').toggle(!!res.id);
|
||
$('#attachment_table_ecard').toggle(!!res.id);
|
||
$('.setid').attr('data-id', res.id || '');
|
||
} else {
|
||
console.log("Inside else");
|
||
let retryCount = 0;
|
||
const initWithRetry = function() {
|
||
initializeEditor(function(editorInstance) {
|
||
if (!editorInstance && retryCount < 3) {
|
||
console.log(`Retrying editor initialization (${retryCount + 1}/3)...`);
|
||
retryCount++;
|
||
setTimeout(initWithRetry, 1000);
|
||
return;
|
||
}
|
||
|
||
if (!editorInstance) {
|
||
console.error("Editor initialization failed after retries");
|
||
toastr.error('Editor initialization failed. Please refresh the page.');
|
||
return;
|
||
}
|
||
hideBranding();
|
||
|
||
});
|
||
};
|
||
|
||
initWithRetry();
|
||
}
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("Ajax error:", {
|
||
status,
|
||
error,
|
||
response: xhr.responseText
|
||
});
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.error('Failed to load template data');
|
||
}
|
||
});
|
||
}
|
||
|
||
// $('#account_maneger_summary_mail_form').submit(function(event) {
|
||
// event.preventDefault();
|
||
|
||
// // Check if editor instance exists
|
||
// if (!editor) {
|
||
// console.error("Editor not initialized");
|
||
// toastr.error("Editor not ready. Please try again.");
|
||
// return;
|
||
// }
|
||
|
||
// // Use the editor instance instead of unlayer directly
|
||
// editor.exportHtml(function(data) {
|
||
// var formData = $('#account_maneger_summary_mail_form').serializeArray();
|
||
|
||
// // Append Unlayer editor data
|
||
// formData.push({
|
||
// name: 'mailContent',
|
||
// value: data.html
|
||
// });
|
||
// formData.push({
|
||
// name: 'client_id',
|
||
// value: $('#general_PrimaryKey').val()
|
||
// });
|
||
// formData.push({
|
||
// name: 'mailJson',
|
||
// value: JSON.stringify(data.design)
|
||
// });
|
||
|
||
// console.log(formData);
|
||
|
||
// // Show loading indicators
|
||
// $('.loader').fadeIn();
|
||
// $('.loader-mask').fadeIn();
|
||
|
||
// var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
// $.ajax({
|
||
// url: form_action,
|
||
// type: "POST",
|
||
// data: formData,
|
||
// dataType: 'json',
|
||
// success: function(res) {
|
||
// $('#account_maneger_summary_mail_modal').find('.close').click();
|
||
// toastr.success('Template saved successfully');
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// },
|
||
// error: function(xhr, status, error) {
|
||
// console.error(xhr.responseText);
|
||
// console.error(status, error);
|
||
// setTimeout(function() {
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// toastr.warning('Something Went Wrong!', 'Warning');
|
||
// }, 1000);
|
||
// }
|
||
// });
|
||
// });
|
||
// });
|
||
|
||
$('#member_welcome_mail_form').submit(function(event) {
|
||
event.preventDefault();
|
||
|
||
// Check if editor instance exists
|
||
if (!editor) {
|
||
console.error("Editor not initialized");
|
||
toastr.error("Editor not ready. Please try again.");
|
||
return;
|
||
}
|
||
|
||
// Use the editor instance instead of unlayer directly
|
||
editor.exportHtml(function(data) {
|
||
var formData = $('#member_welcome_mail_form').serializeArray();
|
||
|
||
// Append Unlayer editor data
|
||
formData.push({
|
||
name: 'mailContent',
|
||
value: data.html
|
||
});
|
||
formData.push({
|
||
name: 'client_id',
|
||
value: $('#general_PrimaryKey').val()
|
||
});
|
||
formData.push({
|
||
name: 'mailJson',
|
||
value: JSON.stringify(data.design)
|
||
});
|
||
|
||
console.log(formData);
|
||
|
||
// Show loading indicators
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "POST",
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
$('#member_welcome_mail_modal').find('.close').click();
|
||
toastr.success('Template saved successfully');
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Went Wrong!', 'Warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
$('#member_reminder_mail_form').submit(function(event) {
|
||
event.preventDefault();
|
||
|
||
// Check if editor instance exists
|
||
if (!editor) {
|
||
console.error("Editor not initialized");
|
||
toastr.error("Editor not ready. Please try again.");
|
||
return;
|
||
}
|
||
|
||
// Use the editor instance instead of unlayer directly
|
||
editor.exportHtml(function(data) {
|
||
var formData = $('#member_reminder_mail_form').serializeArray();
|
||
|
||
// Append Unlayer editor data
|
||
formData.push({
|
||
name: 'mailContent',
|
||
value: data.html
|
||
});
|
||
formData.push({
|
||
name: 'client_id',
|
||
value: $('#general_PrimaryKey').val()
|
||
});
|
||
formData.push({
|
||
name: 'mailJson',
|
||
value: JSON.stringify(data.design)
|
||
});
|
||
|
||
console.log(formData);
|
||
|
||
// Show loading indicators
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "POST",
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
$('#member_reminder_mail_modal').find('.close').click();
|
||
toastr.success('Template saved successfully');
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Went Wrong!', 'Warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
// $('#member_ecard_mail_form').submit(function(event) {
|
||
// event.preventDefault();
|
||
|
||
// // Check if editor instance exists
|
||
// if (!editor) {
|
||
// console.error("Editor not initialized");
|
||
// toastr.error("Editor not ready. Please try again.");
|
||
// return;
|
||
// }
|
||
|
||
// // Use the editor instance instead of unlayer directly
|
||
// editor.exportHtml(function(data) {
|
||
// var formData = $('#member_ecard_mail_form').serializeArray();
|
||
|
||
// // Append Unlayer editor data
|
||
// formData.push({
|
||
// name: 'mailContent',
|
||
// value: data.html
|
||
// });
|
||
// formData.push({
|
||
// name: 'client_id',
|
||
// value: $('#general_PrimaryKey').val()
|
||
// });
|
||
// formData.push({
|
||
// name: 'mailJson',
|
||
// value: JSON.stringify(data.design)
|
||
// });
|
||
|
||
// console.log(formData);
|
||
|
||
// // Show loading indicators
|
||
// $('.loader').fadeIn();
|
||
// $('.loader-mask').fadeIn();
|
||
|
||
// var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
// $.ajax({
|
||
// url: form_action,
|
||
// type: "POST",
|
||
// data: formData,
|
||
// dataType: 'json',
|
||
// success: function(res) {
|
||
// $('#member_ecard_mail_modal').find('.close').click();
|
||
// toastr.success('Template saved successfully');
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// },
|
||
// error: function(xhr, status, error) {
|
||
// console.error(xhr.responseText);
|
||
// console.error(status, error);
|
||
// setTimeout(function() {
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// toastr.warning('Something Went Wrong!', 'Warning');
|
||
// }, 1000);
|
||
// }
|
||
// });
|
||
// });
|
||
// });
|
||
|
||
|
||
$('#member_review_and_summary_mail_form').submit(function(event) {
|
||
event.preventDefault();
|
||
|
||
// Check if editor instance exists
|
||
if (!editor) {
|
||
console.error("Editor not initialized");
|
||
toastr.error("Editor not ready. Please try again.");
|
||
return;
|
||
}
|
||
|
||
// Use the editor instance instead of unlayer directly
|
||
editor.exportHtml(function(data) {
|
||
var formData = $('#member_review_and_summary_mail_form').serializeArray();
|
||
|
||
// Append Unlayer editor data
|
||
formData.push({
|
||
name: 'mailContent',
|
||
value: data.html
|
||
});
|
||
formData.push({
|
||
name: 'client_id',
|
||
value: $('#general_PrimaryKey').val()
|
||
});
|
||
formData.push({
|
||
name: 'mailJson',
|
||
value: JSON.stringify(data.design)
|
||
});
|
||
|
||
console.log(formData);
|
||
|
||
// Show loading indicators
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "POST",
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
$('#member_review_and_summary_mail_modal').find('.close').click();
|
||
toastr.success('Template saved successfully');
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Went Wrong!', 'Warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
// $('#client_hr_summary_mail_form').submit(function(event) {
|
||
// event.preventDefault();
|
||
|
||
// // Check if editor instance exists
|
||
// if (!editor) {
|
||
// console.error("Editor not initialized");
|
||
// toastr.error("Editor not ready. Please try again.");
|
||
// return;
|
||
// }
|
||
|
||
// // Use the editor instance instead of unlayer directly
|
||
// editor.exportHtml(function(data) {
|
||
// var formData = $('#client_hr_summary_mail_form').serializeArray();
|
||
|
||
// // Append Unlayer editor data
|
||
// formData.push({
|
||
// name: 'mailContent',
|
||
// value: data.html
|
||
// });
|
||
// formData.push({
|
||
// name: 'client_id',
|
||
// value: $('#general_PrimaryKey').val()
|
||
// });
|
||
// formData.push({
|
||
// name: 'mailJson',
|
||
// value: JSON.stringify(data.design)
|
||
// });
|
||
|
||
// console.log(formData);
|
||
|
||
// // Show loading indicators
|
||
// $('.loader').fadeIn();
|
||
// $('.loader-mask').fadeIn();
|
||
|
||
// var form_action = '<?= base_url("client/notification/create") ?>';
|
||
|
||
// $.ajax({
|
||
// url: form_action,
|
||
// type: "POST",
|
||
// data: formData,
|
||
// dataType: 'json',
|
||
// success: function(res) {
|
||
// $('#client_hr_summary_mail_modal').find('.close').click();
|
||
// toastr.success('Template saved successfully');
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// },
|
||
// error: function(xhr, status, error) {
|
||
// console.error(xhr.responseText);
|
||
// console.error(status, error);
|
||
// setTimeout(function() {
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
// toastr.warning('Something Went Wrong!', 'Warning');
|
||
// }, 1000);
|
||
// }
|
||
// });
|
||
// });
|
||
// });
|
||
|
||
function hideBranding() {
|
||
$('iframe').on('load', function() {
|
||
console.log('Iframe loaded.');
|
||
const iframe = $(this);
|
||
|
||
// Overlay the branding area
|
||
const overlay = $('<div>', {
|
||
css: {
|
||
position: 'absolute',
|
||
bottom: '0', // Adjust based on branding position
|
||
left: '0',
|
||
width: iframe.width(),
|
||
height: '30px', // Adjust height to cover branding
|
||
backgroundColor: 'white',
|
||
zIndex: '9999',
|
||
pointerEvents: 'none',
|
||
},
|
||
});
|
||
const iframeParent = iframe.parent();
|
||
if (iframeParent.css('position') === 'static') {
|
||
iframeParent.css('position', 'relative');
|
||
}
|
||
|
||
iframeParent.append(overlay);
|
||
console.log('Overlay added to hide branding.');
|
||
});
|
||
}
|
||
|
||
function copyToClipboard(selectElement) {
|
||
const value = selectElement.value; // Get the selected value
|
||
if (value) {
|
||
// Use the Clipboard API to copy the value
|
||
navigator.clipboard.writeText(value)
|
||
.then(() => {
|
||
const feedback = document.getElementById('copy-feedback');
|
||
feedback.style.display = 'inline'; // Show the feedback message
|
||
setTimeout(() => {
|
||
feedback.style.display = 'none'; // Hide the feedback message after 2 seconds
|
||
}, 2000);
|
||
})
|
||
.catch(err => {
|
||
console.error('Failed to copy text: ', err);
|
||
});
|
||
}
|
||
}
|
||
$(document).on('click', '#notification_enable_form_submit', function() {
|
||
var formData = [];
|
||
// console.log($('#hr_mail_id').val());
|
||
|
||
formData.push({name:'client_id', value: $('#general_PrimaryKey').val()})
|
||
formData.push({ name: 'nhance_team_mail_ids', value: $('#nhance_team_mail_ids').val() });
|
||
formData.push({ name: 'hr_mail_id', value: $('#hr_mail_id').val() });
|
||
formData.push({ name: 'mail_domain', value: $('#mail_domain').val() });
|
||
formData.push({ name: 'reply_to', value: $('#reply_to').val() });
|
||
formData.push({ name: 'member_welcome_mail_btn', value: $('#member_welcome_mail_btn').prop('checked') });
|
||
formData.push({ name: 'member_reminder_mail_btn', value: $('#member_reminder_mail_btn').prop('checked') });
|
||
// formData.push({ name: 'member_ecard_mail_btn', value: $('#member_ecard_mail_btn').prop('checked') });
|
||
formData.push({ name: 'member_review_and_summary_mail_btn', value: $('#member_review_and_summary_mail_btn').prop('checked') });
|
||
// formData.push({ name: 'account_maneger_summary_mail_btn', value: $('#account_maneger_summary_mail_btn').prop('checked') });
|
||
// formData.push({ name: 'client_hr_summary_mail_btn', value: $('#client_hr_summary_mail_btn').prop('checked') });
|
||
console.log("form data",formData);
|
||
var form_action = '<?= base_url("client/notification/update_enable") ?>';
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "POST",
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function(res)
|
||
{
|
||
console.log(res);
|
||
if (res)
|
||
{
|
||
toastr.success('Update Successfully');
|
||
}
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
},
|
||
error: function (xhr, status, error)
|
||
{
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function()
|
||
{
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Wrong!', 'Warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
})
|
||
</script>
|