291 lines
12 KiB
PHP
291 lines
12 KiB
PHP
<!-- ============================================================== -->
|
|
<!-- Start Page Content here -->
|
|
<!-- ============================================================== -->
|
|
|
|
<div class="content-page">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-2">
|
|
</div>
|
|
<div class="col-8">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<h4 class="page-title"><?php echo $page_name; ?></h4>
|
|
<div class="page-title-right">
|
|
<a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light" style="color: #fff;background-color: #6c757d;border-color: #6c757d;"> Back </a>
|
|
|
|
<ol class="breadcrumb m-0">
|
|
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Minton</a></li>
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Pages</a></li>
|
|
<li class="breadcrumb-item active">Starter</li> -->
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-lg-2"></div>
|
|
<div class="col-lg-8">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form >
|
|
<div class="form-row">
|
|
<div class="form-group col-md-12">
|
|
<label for="inputEmail4" class="col-form-label">Business Name</label>
|
|
<input type="text" class="form-control" id="business_name" placeholder="Name" value="<?= isset($business['business_name']) ? $business['business_name'] : '' ?>" required>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="subject-input">Template Header</label>
|
|
<!-- basic summernote-->
|
|
<div id="summernote-header"></div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="subject-input">Template Footer</label>
|
|
<!-- basic summernote-->
|
|
<div id="summernote-footer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-envelope mr-1"></i> Mail Settings</h5>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="subject-input">Sender Email</label>
|
|
<input type="mail" id="email" class="form-control" value="<?= isset($business['email']) ? $business['email'] : '' ?>">
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
<label for="subject-input">User Name</label>
|
|
<input type="text" id="user_name" class="form-control" value="<?= isset($business['smtp_user']) ? $business['smtp_user'] : '' ?>">
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="subject-input">Password</label>
|
|
<input type="text" id="password" class="form-control" value="<?= isset($business['smtp_pass']) ? $business['smtp_pass'] : '' ?>">
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="subject-input">Host</label>
|
|
<input type="text" id="host" class="form-control" value="<?= isset($business['smtp_host']) ? $business['smtp_host'] : '' ?>">
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="subject-input">Port</label>
|
|
<input type="text" id="port" class="form-control" value="<?= isset($business['smtp_port']) ? $business['smtp_port'] : '' ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-envelope-open-text mr-1"></i>Test Mail</h5>
|
|
<div class="form-row" id="test_mail_config_div">
|
|
<div class="form-group col-md-6">
|
|
<label for="">Enter Your Mail-Id</label>
|
|
<input type="mail" class="form-control" id="r_email">
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for=""></label>
|
|
|
|
<button class="btn btn-primary" id="test-email-btn" type="button" style="margin-top: 29px;">Test Email</button>
|
|
<img src="<?= base_url()."public"; ?>/assets/images/submit-spin.svg" width="29px" height="29px" class="ml-2" id="submit-spin" style="display:none; margin-top: 2.1rem !important;"></img>
|
|
</div>
|
|
|
|
</div>
|
|
</form>
|
|
|
|
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
|
|
<input type="hidden" id="header_html" value='<?= isset($business['business_id']) ? $business['header_html'] : '' ?>'>
|
|
<input type="hidden" id="footer_html" value='<?= isset($business['business_id']) ? $business['footer_html'] : '' ?>'>
|
|
<?php if(isset($business['business_id']) > 0){ ?>
|
|
<button type="submit" id="savedata" class="btn btn-primary" style="float: right;">Submit</button>
|
|
<?php }else{ ?>
|
|
<button type="submit" id="savedata" class="btn btn-primary" style="float: right;" disabled>Submit</button>
|
|
<?php } ?>
|
|
|
|
</div>
|
|
</div> <!-- end card -->
|
|
</div>
|
|
<div class="col-lg-2"></div>
|
|
<!-- end col -->
|
|
|
|
</div>
|
|
|
|
|
|
</div> <!-- container -->
|
|
|
|
</div> <!-- content -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
$('#summernote-header').summernote({
|
|
height: 150, // set the height of the editor
|
|
toolbar: [
|
|
|
|
['style', ['style']],
|
|
['font', ['bold', 'italic', 'underline', 'clear' ]],
|
|
['fontname', ['fontname']],
|
|
['fontsize', ['fontsize']],
|
|
['color', ['color']],
|
|
['para', ['ul', 'ol', 'paragraph' , 'height']],
|
|
['table', ['table']],
|
|
['insert', [ 'picture']],
|
|
['view', ['fullscreen', 'codeview', 'help']],
|
|
['mybutton', ['customButton','Years']] // Custom button group
|
|
],
|
|
});
|
|
|
|
$('#summernote-footer').summernote({
|
|
height: 150, // set the height of the editor
|
|
toolbar: [
|
|
|
|
['style', ['style']],
|
|
['font', ['bold', 'italic', 'underline', 'clear' ]],
|
|
['fontname', ['fontname']],
|
|
['fontsize', ['fontsize']],
|
|
['color', ['color']],
|
|
['para', ['ul', 'ol', 'paragraph' , 'height']],
|
|
['table', ['table']],
|
|
['insert', [ 'picture']],
|
|
['view', ['fullscreen', 'codeview', 'help']],
|
|
['mybutton', ['customButton','Years']] // Custom button group
|
|
],
|
|
});
|
|
|
|
|
|
setTimeout(() =>
|
|
{
|
|
$('#summernote-header').summernote('code', $('#header_html').val());
|
|
$('#summernote-footer').summernote('code', $('#footer_html').val());
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
});
|
|
|
|
$("#test-email-btn").on("click", function()
|
|
{
|
|
$('#submit-spin').show();
|
|
$(this).hide();
|
|
|
|
formData ={
|
|
sender_email : $('#email').val(),
|
|
r_email : $('#r_email').val(),
|
|
SMTPHost : $('#host').val(),
|
|
SMTPUser : $('#user_name').val(),
|
|
SMTPPass : $('#password').val(),
|
|
SMTPPort : $('#port').val(),
|
|
mailType : 'html',
|
|
protocol : 'smtp',
|
|
};
|
|
// console.log(formData);
|
|
$.ajax({
|
|
url: '<?= base_url()."check_mail_config"; ?>',
|
|
type: 'POST',
|
|
data: formData,
|
|
json: true,
|
|
success: function(response) {
|
|
console.log(response);
|
|
|
|
if(JSON.parse(response).status == 'success'){
|
|
$('#savedata').prop('disabled', false);
|
|
toastr.success('Mail Sent successfully ', 'Success');
|
|
// window.location.href = '<?= base_url()."business_list"; ?>';
|
|
|
|
}else{
|
|
$('#savedata').prop('disabled', true);
|
|
toastr.warning('Mail sending failed. Please check your mail configuration.', 'Warning');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Handle errors here
|
|
console.error(xhr.responseText);
|
|
}
|
|
});
|
|
setTimeout(() => {
|
|
$('#submit-spin').hide();
|
|
$(this).show();
|
|
|
|
}, 2000);
|
|
|
|
})
|
|
|
|
$("#savedata").on("click", function()
|
|
{
|
|
var isValid = true;
|
|
var firstEmptyField = null;
|
|
|
|
// Find all elements with 'required' attribute
|
|
$('form [required]').each(function() {
|
|
var field = $(this);
|
|
|
|
// Check if the field is empty
|
|
if (field.val().trim() === '') {
|
|
isValid = false;
|
|
if (!firstEmptyField) {
|
|
firstEmptyField = field;
|
|
}
|
|
|
|
// Highlight the empty field
|
|
field.addClass('error');
|
|
} else {
|
|
// Remove error class if the field is not empty
|
|
field.removeClass('error');
|
|
}
|
|
});
|
|
|
|
if (!isValid) {
|
|
// Focus on the first empty field and show an error message
|
|
toastr.warning('Please fill in all required fields.', 'Warning');
|
|
firstEmptyField.focus();
|
|
return; // Prevent the AJAX call
|
|
}
|
|
|
|
var headerContent = $('#summernote-header').summernote('code');
|
|
var footerContent = $('#summernote-footer').summernote('code');
|
|
formData ={
|
|
business_id : $('#business_id').val(),
|
|
business_name : $('#business_name').val(),
|
|
header_html : headerContent,
|
|
footer_html : footerContent,
|
|
email : $('#email').val(),
|
|
smtp_host : $('#host').val(),
|
|
smtp_user : $('#user_name').val(),
|
|
smtp_pass : $('#password').val(),
|
|
smtp_port : $('#port').val(),
|
|
};
|
|
|
|
$.ajax({
|
|
url: '<?= base_url()."add_business"; ?>',
|
|
type: 'POST',
|
|
data: formData,
|
|
json: true,
|
|
success: function(response) {
|
|
if(response.success){
|
|
toastr.success('Data saved successfully ', 'Success');
|
|
window.location.href = '<?= base_url()."business_list"; ?>';
|
|
}else{
|
|
toastr.warning('Something went wrong', 'Warning');
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Handle errors here
|
|
console.error(xhr.responseText);
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- ============================================================== -->
|
|
<!-- End Page content -->
|
|
<!-- ============================================================== -->
|