106 lines
6.2 KiB
PHP
106 lines
6.2 KiB
PHP
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="header-title"><?= $page_name; ?></h4>
|
|
<form class="parsley-examples" action="<?= base_url() . "template_creation_insert"; ?>" method="post" enctype="multipart/form-data" id="myForm">
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-12">
|
|
<label for="templatename" class="col-form-label">Template Name<span class="text-danger"> *</span></label>
|
|
<input type="text" class="form-control" id="templatename" name="templatename" value="<?= isset($template_details['template_name']) ? $template_details['template_name'] : '' ?>" placeholder="Template Name" required />
|
|
<div class="invalid-feedback"> Please provide. </div>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="mode" class="col-form-label col-md-3">Mode<span class="text-danger"></span></label>
|
|
<div class="col-md-9 mt-1">
|
|
<div class="custom-control custom-radio custom-control-inline">
|
|
<input type="radio" id="emailRadio" name="mode" class="custom-control-input" value="Email" checked>
|
|
<label class="custom-control-label" for="emailRadio">Email</label>
|
|
</div>
|
|
<div class="custom-control custom-radio custom-control-inline">
|
|
<input type="radio" id="whatsappRadio" name="mode" class="custom-control-input" value="Whatsapp">
|
|
<label class="custom-control-label" for="whatsappRadio">Whatsapp</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-6" id="emailSubject" style="display: block;">
|
|
<label for="templatename" class="col-form-label">subject</label>
|
|
<input type="text" class="form-control" id="subject" name="subject" value="<?= isset($template_details['subject']) ? $template_details['subject'] : '' ?>" placeholder="Subject" />
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
|
<textarea id="summernote-basic" name="templatemessage" class="form-control" rows="7">
|
|
<?php if(isset($template_details['message'])){ echo $template_details['message']; }else{ ?>
|
|
<h5>Hello {User}, </h5>
|
|
<p>Please, write text here!</p>
|
|
<?php } ?>
|
|
</textarea>
|
|
</div>
|
|
</div>
|
|
<input type="hidden" id="template_id" name="template_id" placeholder="hidden for template id" value="<?= isset($template_details['template_id']) ? $template_details['template_id'] : '' ?>" />
|
|
<?php if (!empty($template_details)) { ?>
|
|
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
|
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($template_details) && $template_details['isactive'] == 1 ? 'checked' : '' ?>>
|
|
<label for="isactive"> Is Active</label>
|
|
</div>
|
|
<br>
|
|
<?php } ?>
|
|
<div class="form-group text-right m-b-0">
|
|
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">
|
|
Submit
|
|
</button>
|
|
<button type="reset" class="btn btn-primary waves-effect mr-1">
|
|
Reset
|
|
</button>
|
|
<a href="<?= base_url() . "template_creation"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div> <!-- end card-body-->
|
|
</div> <!-- end card-->
|
|
</div> <!-- end col-->
|
|
</div><!-- end row -->
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Listen for changes in the radio buttons
|
|
$('input[name="mode"]').on('change', function() {
|
|
var selectedValue = $(this).val();
|
|
if (selectedValue === 'Email') {
|
|
$('#emailSubject').show();
|
|
} else {
|
|
$('#emailSubject').hide();
|
|
}
|
|
});
|
|
|
|
var mode = "<?= isset($template_details['mode']) ? $template_details['mode'] : ""; ?>";
|
|
if(mode != ""){
|
|
var emailRadio = document.getElementById("emailRadio");
|
|
var whatsappRadio = document.getElementById("whatsappRadio");
|
|
if(mode == 'Email'){
|
|
emailRadio.checked = true;
|
|
whatsappRadio.checked = false;
|
|
$('#emailSubject').show();
|
|
}else if(mode == 'Whatsapp'){
|
|
emailRadio.checked = false;
|
|
whatsappRadio.checked = true;
|
|
$('#emailSubject').hide();
|
|
}
|
|
}
|
|
|
|
});
|
|
</script>
|
|
<script>
|
|
document.getElementById('myForm').addEventListener('submit', function(event) {
|
|
var form = event.target;
|
|
if (form.checkValidity() === false) {
|
|
form.reportValidity(); // Display validation error messages
|
|
event.preventDefault(); // Prevent form submission if it's not valid
|
|
$('#submitBtn').prop('disabled', false);
|
|
} else {
|
|
$('#submitBtn').prop('disabled', true);
|
|
}
|
|
});
|
|
</script>
|