Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
d1c396734f
@ -42,6 +42,7 @@ $routes->post("add_advertise_image", "AppContentManagementController::add_advert
|
||||
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
|
||||
$routes->get("getAdvertiseImage/(:any)", "AppContentManagementController::getAdvertiseImage/$1");
|
||||
$routes->get("frontend_content", "AppContentManagementController::frontend_content");
|
||||
$routes->get('showAdvertiseImage/(:any)', 'AdvertiseController::showAdvertiseImage/$1');
|
||||
|
||||
|
||||
// $routes->get('/', 'LoginController::index');
|
||||
|
||||
@ -40,36 +40,58 @@ class AppContentManagementController extends AdminController
|
||||
// $this->loadLayout('client_onboarding', $data);
|
||||
}
|
||||
|
||||
public function add_advertise_image(){
|
||||
public function add_advertise_image() {
|
||||
try {
|
||||
$file = $this->request->getFile('advertise_image');
|
||||
//1) original file name for vaildations
|
||||
$fileName = $file->getClientName(); //original file name for vaildations
|
||||
$existing = $this->addImgModel->where('name', $fileName)->where('is_active', 1)->first();
|
||||
if($existing){ return $this->respond(['status' => false, 'message' => 'This file has already been uploaded in active state.'], 400); }
|
||||
|
||||
// print_r($this->request->getPost());die;
|
||||
$uploadFilePath = ROOTPATH . 'public/uploads/advertiseImage/';
|
||||
$file_name = file_Upload($this->request->getFile('advertise_image'), $uploadFilePath);
|
||||
$data['id'] = $this->request->getPost('add_image_id');
|
||||
// $data['created_by'] = get_session_userid();
|
||||
$data['name'] = $file_name;
|
||||
//skip 1) and use this
|
||||
// $fileName = $file->getRandomName(); // Same Name Multiple time upload means different name
|
||||
|
||||
if($data['id'] == 0){
|
||||
$insert = $this->addImgModel->insert($data);
|
||||
if($insert){
|
||||
return $this->respond(['status' => true,'code' => 200,'data' => "success"], 200);
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->respond(['status' => false, 'message' => 'No file uploaded or invalid file.'], 400);
|
||||
}
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200);
|
||||
$uploadPath = WRITEPATH . 'uploads/advertiseImage/';
|
||||
if (!is_dir($uploadPath)) mkdir($uploadPath, 0755, true);
|
||||
|
||||
}
|
||||
}else{
|
||||
$id = $data['id'];
|
||||
$update = $this->addImgModel->update($id,$data);
|
||||
if($update){
|
||||
return $this->respond(['status' => true,'code' => 200,'data' => "success"], 200);
|
||||
|
||||
$file->move($uploadPath, $fileName);
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200);
|
||||
}
|
||||
$id = $this->request->getPost('add_image_id');
|
||||
$data = ['name' => $fileName];
|
||||
|
||||
if ($id == 0) {
|
||||
$this->addImgModel->insert($data);
|
||||
} else {
|
||||
$this->addImgModel->update($id, $data);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'message' => 'Image saved successfully.']);
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function showAdvertiseImage($fileName)
|
||||
{
|
||||
|
||||
$filePath = WRITEPATH . 'uploads/advertiseImage/' . $fileName;
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
return $this->response->setStatusCode(404, 'File not found');
|
||||
}
|
||||
|
||||
$mimeType = mime_content_type($filePath);
|
||||
header('Content-Type: ' . $mimeType);
|
||||
readfile($filePath);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
public function getAdvertiseImage($image_id){
|
||||
|
||||
$image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();
|
||||
|
||||
@ -53,7 +53,7 @@ table.dataTable thead th {
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item advertise_image_edit" href="#" data-toggle="modal" data-id="<?php echo $row['id']; ?>" data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a class="dropdown-item advertise_image_edit" href="#" data-toggle="modal" data-id="<?php echo $row['id']; ?>" data-name="<?php echo $row['name']; ?>" data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -82,17 +82,15 @@ table.dataTable thead th {
|
||||
<h4 id="advertise_add_edit">Add Advertise Image </h4>
|
||||
</div>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<form id="model_form_data" class="px-4">
|
||||
|
||||
<input type="text" name="add_image_id" id="add_image_id" value="0" hidden>
|
||||
<form id="model_form_data" class="px-4" enctype="multipart/form-data">
|
||||
<input type="hidden" name="add_image_id" id="add_image_id" value="0">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="branchname">Upload Image</label>
|
||||
<div class="input-icon">
|
||||
<input type="file" class="form-control" name="advertise_image" id="advertise_image"
|
||||
accept="image/*" onchange="PreviewImage();" required="">
|
||||
<input type="file" class="form-control" name="advertise_image" id="advertise_image" accept="image/*" onchange="PreviewImage();" required>
|
||||
<i class="mdi mdi-upload additional-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
@ -101,8 +99,9 @@ table.dataTable thead th {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-center">
|
||||
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitBranch(this)">Submit</button>
|
||||
<button type="button" class="btn btn-primary" onclick="submitBranch()">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -113,68 +112,69 @@ table.dataTable thead th {
|
||||
|
||||
<script>
|
||||
|
||||
var table;
|
||||
$(document).ready(function()
|
||||
{
|
||||
table = $('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [
|
||||
{
|
||||
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
||||
className: 'btn app-btn-primary',
|
||||
action: function (e, dt, node, config) {
|
||||
// your previous click logic here
|
||||
$('#add_image_id').val(0);
|
||||
$('#advertise_add_edit').html('Add Advertise Image');
|
||||
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||
$('#bike_make_login-modal').modal('show');
|
||||
}
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true ,
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function submitBranch(params) {
|
||||
function submitBranch() {
|
||||
const fileInput = $('#advertise_image')[0].files[0]; // get actual file object
|
||||
const imageId = $('#add_image_id').val();
|
||||
|
||||
// if ($('#add_image_id').val()) {
|
||||
// var url = '<?= base_url("edit_advertise_image/"); ?>'+$('#add_image_id').val();
|
||||
// }else{
|
||||
var url = '<?= base_url("add_advertise_image"); ?>';
|
||||
// }
|
||||
|
||||
var formData = new FormData($('#model_form_data')[0]);
|
||||
if (!fileInput) {
|
||||
toastr.warning('Please upload an image before submitting', 'Warning');
|
||||
$('#advertise_image').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
var url = '<?= base_url("add_advertise_image") ?>';
|
||||
var formData = new FormData();
|
||||
formData.append('advertise_image', fileInput);
|
||||
formData.append('add_image_id', imageId);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: url,
|
||||
url: url,
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$('#bike_model_login-modal').modal('hide');
|
||||
$('#bike_make_name').val('');
|
||||
|
||||
window.location.reload();
|
||||
if (response.status) {
|
||||
$('#bike_make_login-modal').modal('hide');
|
||||
$('#advertise_image').val('');
|
||||
$('#uploadPreview').attr('src', '<?= base_url('public/assets/images/avatar_2x.png') ?>');
|
||||
toastr.success('Image uploaded successfully!');
|
||||
window.location.reload();
|
||||
} else {
|
||||
toastr.error(response.message || 'Something went wrong.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
console.error('Status:', status);
|
||||
console.error('Error:', error);
|
||||
|
||||
let msg = 'Something went wrong. Please try again later.';
|
||||
|
||||
switch (xhr.status) {
|
||||
case 400:
|
||||
msg = xhr.responseJSON?.message || 'Bad Request — Invalid input.';
|
||||
break;
|
||||
case 401:
|
||||
msg = 'Unauthorized — Please log in again.';
|
||||
break;
|
||||
case 403:
|
||||
msg = 'Forbidden — You do not have permission.';
|
||||
break;
|
||||
case 404:
|
||||
msg = 'Not Found — Requested URL or resource not found.';
|
||||
break;
|
||||
case 500:
|
||||
console.log('Internal Server Error — Please contact support.');
|
||||
msg = xhr.responseJSON?.message || xhr.responseText || msg;
|
||||
break;
|
||||
default:
|
||||
msg = xhr.responseJSON?.message || xhr.responseText || msg;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -218,6 +218,46 @@ $(document).ready(function()
|
||||
}
|
||||
|
||||
|
||||
var table;
|
||||
|
||||
$(document).ready(function() {
|
||||
table = $('#tickets-table').DataTable({
|
||||
dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
buttons: [
|
||||
{
|
||||
text: '<i class="mdi mdi-plus"></i> <span class="btn-custom">Add</span>',
|
||||
className: 'btn app-btn-primary',
|
||||
action: function (e, dt, node, config) {
|
||||
// ✅ Call your modal logic
|
||||
callmodal();
|
||||
}
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true
|
||||
});
|
||||
});
|
||||
|
||||
// ✅ Define your modal function separately
|
||||
function callmodal() {
|
||||
$('#add_image_id').val(0);
|
||||
$('#advertise_add_edit').html('Add Advertise Image');
|
||||
$('#uploadPreview').attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||
$('#bike_model_login-modal').modal('show'); // ✅ this shows the modal
|
||||
var myModal = new bootstrap.Modal(document.getElementById('bike_make_login-modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
// $('#btnAdd').click(function () {
|
||||
// $('#add_image_id').val(0);
|
||||
// $('#advertise_add_edit').html('Add Advertise Image');
|
||||
@ -225,28 +265,52 @@ $(document).ready(function()
|
||||
|
||||
// })
|
||||
|
||||
$('.advertise_image_edit').click(function (params) {
|
||||
// console.log($(this).data('id'));
|
||||
$('#add_image_id').val($(this).data('id'));
|
||||
var url = '<?= base_url("getAdvertiseImage/"); ?>'+$(this).data('id') ;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
$('#advertise_add_edit').html('Edit Advertise Image');
|
||||
$('#uploadPreview').attr('src', '<?= base_url() . "public/uploads/advertiseImage/"?>' + response)
|
||||
.on('error', function() {
|
||||
$(this).attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||
});
|
||||
// $('.advertise_image_edit').click(function (params) {
|
||||
// // console.log($(this).data('id'));
|
||||
// $('#add_image_id').val($(this).data('id'));
|
||||
// var url = '<?= base_url("getAdvertiseImage/"); ?>'+$(this).data('id') ;
|
||||
// $.ajax({
|
||||
// type: 'GET',
|
||||
// url: url,
|
||||
// success: function (response) {
|
||||
// console.log(response);
|
||||
// $('#advertise_add_edit').html('Edit Advertise Image');
|
||||
// $('#uploadPreview').attr('src', '<?= base_url() . "public/uploads/advertiseImage/"?>' + response)
|
||||
// .on('error', function() {
|
||||
// $(this).attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||
// });
|
||||
|
||||
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
// },
|
||||
// error: function (xhr, status, error) {
|
||||
// console.error(xhr.responseText);
|
||||
// }
|
||||
|
||||
// })
|
||||
// })
|
||||
$(document).on('click', '.advertise_image_edit', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
const id = $(this).data('id');
|
||||
const name = $(this).data('name');
|
||||
console.log('Clicked ID:', id);
|
||||
console.log('<?= base_url(); ?>');
|
||||
|
||||
$('#add_image_id').val(id);
|
||||
$('#advertise_image').val(name);
|
||||
$('#advertise_add_edit').html('Edit Advertise Image');
|
||||
const imgUrl = '<?= base_url("showAdvertiseImage/"); ?>' + name;
|
||||
|
||||
$('#uploadPreview').attr('src', imgUrl)
|
||||
.on('error', function() {
|
||||
$(this).attr('src', '<?= base_url()."public/assets/images/avatar_2x.png" ?>');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
@ -51,23 +51,24 @@
|
||||
position: relative;
|
||||
width: 50px;
|
||||
height: 25px;
|
||||
background-color: #fff;
|
||||
background-color: #cccccc;
|
||||
border-radius: 25px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.2);
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.slider::before ,
|
||||
/* Round knob (always white) */
|
||||
.slider::before,
|
||||
.slider_blue::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
height: 19px;
|
||||
width: 19px;
|
||||
left: 3px;
|
||||
top: 3px;
|
||||
background-color: #ccc;
|
||||
border-radius: 50%;
|
||||
transition: 0.3s;
|
||||
content: "";
|
||||
position: absolute;
|
||||
height: 19px;
|
||||
width: 19px;
|
||||
left: 3px;
|
||||
top: 3px;
|
||||
background-color: #fff; /* always white */
|
||||
border-radius: 50%;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
|
||||
@ -215,6 +215,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -749,8 +750,8 @@
|
||||
<input style="width: 128%;" value="${data ? data : ''}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative;left: 88px;">
|
||||
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
|
||||
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
|
||||
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
|
||||
@ -1052,6 +1052,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
setTimeout(function() {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
@ -1761,15 +1762,14 @@
|
||||
value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]"
|
||||
class="form-control multiple_sum_insured mr-2" onkeypress="return onlyNumbers(event)"
|
||||
onkeyup="formatNumber(this); numtowordinkeyup(this)">
|
||||
<button type="button" class="btn btn-primary si-add-more mr-2" onclick="appendGMCSIAddMore()"
|
||||
style="background-color: #e26728; border:1px solid #e26728;">
|
||||
<i class="mdi mdi-plus"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger si-remove-multi mr-2" onclick="removeGMCAdditionalSI(this)"
|
||||
style="background-color: #BD0707;border:1px solid #BD0707">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary si-add-more mr-2" onclick="appendGMCSIAddMore()"
|
||||
style="background-color: #e26728; border:1px solid #e26728;"
|
||||
>
|
||||
<i class="mdi mdi-plus"></i>
|
||||
</button>
|
||||
|
||||
<div id='numberToWordSumInsured' class="text-danger-2 mr-2"></div>
|
||||
</div>
|
||||
|
||||
@ -499,6 +499,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
setTimeout(function() {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
@ -927,14 +928,14 @@
|
||||
style="max-width:200px;"
|
||||
value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]"
|
||||
class="form-control multiple_sum_insured mr-2" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
|
||||
<button type="button" class="btn btn-danger si-remove-multi mr-2" onclick="removeGMCAdditionalSI(this)"
|
||||
style="background-color: #BD0707;border:1px solid #BD0707">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary si-add-more mr-2" onclick="appendGPASIAddMore()"
|
||||
style="background-color: #e26728; border:1px solid #e26728;" >
|
||||
<i class="mdi mdi-plus"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger si-remove-multi mr-2" onclick="removeGMCAdditionalSI(this)"
|
||||
style="background-color: #BD0707;border:1px solid #BD0707">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</button>
|
||||
<div id='numberToWordSumInsured' class="text-danger-2 "></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -103,8 +103,8 @@ table.dataTable tbody td {
|
||||
<th style="display: none;">Premium <br> (without GST)</th>
|
||||
<!-- <th style="display: none;">GST @ 18%</th> -->
|
||||
<th>Total Premium</th>
|
||||
<th>BP %</th>
|
||||
<th>TP/Ter %</th>
|
||||
<th>BP%</th>
|
||||
<th>TP/Ter%</th>
|
||||
<th style="display: none;">Rewards</th>
|
||||
<th>Agreed Amount</th>
|
||||
<th>Invoiced Amount</th>
|
||||
@ -147,8 +147,8 @@ table.dataTable tbody td {
|
||||
<td class="right-align-input" style="display: none;"><?php echo $row['premium_wo_gst']; ?></td>
|
||||
<!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> -->
|
||||
<td class="right-align-input"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?> %</td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'] ?: '0.00';?> %</td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td>
|
||||
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'] ?: '0.00';?>%</td>
|
||||
<td class="right-align-input" style="display: none;"><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
Loading…
Reference in New Issue
Block a user