164 lines
9.9 KiB
PHP
164 lines
9.9 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() . "campaign_creation_insert"; ?>" method="post" enctype="multipart/form-data" id="myForm">
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="campaign_name" class="col-form-label">Campaign Name<span class="text-danger"> *</span></label>
|
|
<input type="text" class="form-control" id="campaign_name" name="campaign_name" value="<?= isset($campaign_details['campaign_name']) ? $campaign_details['campaign_name'] : '' ?>" placeholder="Campaign Name" required />
|
|
<div class="invalid-feedback"> Please provide. </div>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="group_id" class="col-form-label">Group<span class="text-danger"> *</span></label>
|
|
<!-- <select id="group_id" name="group_id[]" class="form-control select2-multiple" data-toggle="select2" multiple="multiple" data-placeholder="Choose ..." required> -->
|
|
<select id="group_id" name="group_id[]" class="form-control" multiple="multiple" required>
|
|
<option value="">Choose the Group</option>
|
|
<?php foreach ($group_details as $value) { ?>
|
|
<option value="<?php echo $value['group_id']; ?>"
|
|
<?php if (isset($campaign_details['group_id']) && in_array($value['group_id'], $campaign_details['group_id'])) echo "selected"; ?>>
|
|
<?php echo $value['group_name']; ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<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-8">
|
|
<label for="scheduled" class="col-form-label">Scheduled Date/Time<span class="text-danger"></span></label>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<input class="form-control" type="date" name="scheduled_date" id="example-date" value="<?= isset($campaign_details['scheduled_date']) ? $campaign_details['scheduled_date'] : '' ?>">
|
|
</div>
|
|
<div class="col-6">
|
|
<input class="form-control" type="time" name="scheduled_time" id="example-time" value="<?= isset($campaign_details['scheduled_time']) ? $campaign_details['scheduled_time'] : '' ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group col-md-12">
|
|
<label for="load_templateid" class="col-form-label">Template<span class="text-danger"> *</span></label>
|
|
<select id="load_templateid" name="template_id" class="form-control" required>
|
|
<option value="">Choose the Template</option>
|
|
<!-- <?php foreach ($template_details as $value) { ?>
|
|
<option value="<?php echo $value['template_id']; ?>" <?php if (isset($campaign_details['template_id']) && ($campaign_details['template_id'] === $value['template_id'])) echo "selected"; ?>>
|
|
<?php echo $value['template_name']; ?></option>
|
|
<?php } ?> -->
|
|
</select>
|
|
</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($campaign_details['message'])){ echo $campaign_details['message']; }else{ ?>
|
|
<h5>Hello {User}, </h5>
|
|
<p>Please, write text here!</p>
|
|
<?php } ?>
|
|
</textarea>
|
|
</div> -->
|
|
</div>
|
|
|
|
<input type="hidden" id="campaign_id" name="campaign_id" placeholder="hidden for template id" value="<?= isset($campaign_details['campaign_id']) ? $campaign_details['campaign_id'] : '' ?>" />
|
|
<?php if (!empty($campaign_details)) { ?>
|
|
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
|
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($campaign_details) && $campaign_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() . "campaign_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
|
|
var mode = "<?= isset($campaign_details['mode']) ? $campaign_details['mode'] : ""; ?>";
|
|
var template = "<?= isset($campaign_details['template_id']) ? $campaign_details['template_id'] : ""; ?>";
|
|
load_details(mode,template);
|
|
|
|
$('input[name="mode"]').on('change', function() {
|
|
var selectedValue = $(this).val();
|
|
console.log('selectedValue',selectedValue);
|
|
load_details(selectedValue,template);
|
|
});
|
|
|
|
if(mode != ""){
|
|
var emailRadio = document.getElementById("emailRadio");
|
|
var whatsappRadio = document.getElementById("whatsappRadio");
|
|
if(mode == 'Email'){
|
|
emailRadio.checked = true;
|
|
whatsappRadio.checked = false;
|
|
}
|
|
if(mode == 'Whatsapp'){
|
|
emailRadio.checked = false;
|
|
whatsappRadio.checked = true;
|
|
}
|
|
load_details(mode,template);
|
|
}
|
|
});
|
|
|
|
function load_details(mode,template) {
|
|
var mode = (mode != "") ? mode : 'Email';
|
|
var temp_arr = <?php echo json_encode($template_details); ?>;
|
|
var filtered_data = $.grep(temp_arr, function(item) {
|
|
return item['mode'] === mode;
|
|
});
|
|
$('#load_templateid').empty();
|
|
$('#load_templateid').append($('<option>', { value: "", text: "Choose the Template" }));
|
|
$.each(filtered_data, function(k, v) {
|
|
$('#load_templateid').append($('<option>', {
|
|
value: v.template_id,
|
|
text: v.template_name,
|
|
selected: (v.template_id == template) ? true : false
|
|
}));
|
|
});
|
|
}
|
|
</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>
|
|
<script>
|
|
// Get the current date and time
|
|
const now = new Date();
|
|
const currentDate = now.toISOString().split('T')[0]; // Get current date in YYYY-MM-DD format
|
|
|
|
const dateInput = document.getElementById('example-date');
|
|
|
|
dateInput.setAttribute('min', currentDate);
|
|
|
|
</script>
|