CHANGE_CLIENT_ONBOARDING_ADD_CLIENT_LOGO_IS_DOWNLOAD_BTN_POLICY_IS_ADDON : RV
This commit is contained in:
parent
5882b2c7e0
commit
16a730b3c5
@ -230,8 +230,10 @@ class ClientController extends AdminController
|
||||
{
|
||||
|
||||
$this->myLogger->logme('error','Client general info function called');
|
||||
$file_name = file_Upload($this->request->getFile('client_logo'));
|
||||
$data = $this->request->getPost();
|
||||
$data['created_by'] = get_session_userid();
|
||||
$data['client_logo'] = $file_name;
|
||||
$insert = $this->clientModel->insert($data);
|
||||
if($insert){
|
||||
$client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
|
||||
@ -246,9 +248,13 @@ class ClientController extends AdminController
|
||||
public function editClientGeneralInfo()
|
||||
{
|
||||
$this->myLogger->logme('error','edit client general info function called');
|
||||
$file_name = file_Upload($this->request->getFile('client_logo'));
|
||||
$id = $this->request->getPost('PrimaryKey');
|
||||
$data = $this->request->getPost();
|
||||
$data['updated_by'] = get_session_userid();
|
||||
if(!empty($file_name)){
|
||||
$data['client_logo'] = $file_name;
|
||||
}
|
||||
$update = $this->clientModel->update($id,$data);
|
||||
if($update){
|
||||
return $this->respond(['status' => true,'code' => 200,'data' => $data], 200);
|
||||
@ -511,6 +517,8 @@ class ClientController extends AdminController
|
||||
$data['claims_experience_for_last_3_years'] = $this->request->getPost('claims_experience_for_last_3_years');
|
||||
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
|
||||
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
|
||||
$data['is_addon'] = $this->request->getPost('is_addon');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -565,6 +573,7 @@ class ClientController extends AdminController
|
||||
$data['claims_experience_for_last_3_years'] = $this->request->getPost('claims_experience_for_last_3_years');
|
||||
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
|
||||
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
|
||||
$data['is_addon'] = $this->request->getPost('is_addon');
|
||||
|
||||
$data['updated_by'] = get_session_userid();
|
||||
$insert = $this->clientPolicyModel->update($id,$data);
|
||||
@ -583,7 +592,7 @@ class ClientController extends AdminController
|
||||
|
||||
public function createClientPolicyPremium()
|
||||
{
|
||||
try {
|
||||
try {
|
||||
$policy_type = $this->request->getPost('policy_type');
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$client_policy_id = $this->request->getPost('client_policy_id');
|
||||
@ -767,7 +776,7 @@ class ClientController extends AdminController
|
||||
}else{
|
||||
return $this->respond(['status' => false,'code' => 404, 'data' => $data,'message' => 'no data found'], 200);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
// Handle exceptions here
|
||||
echo 'Error: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ use App\Models\FileModel;
|
||||
use App\Models\BatchListModel;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\EmpEndorsementModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
|
||||
use App\Controllers\Jobs ;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
@ -32,6 +33,7 @@ class EmpDataServiceController extends BaseController
|
||||
protected $batchListModel;
|
||||
protected $batchFileModel;
|
||||
protected $empEndorsementModel;
|
||||
protected $clientDepositModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -46,6 +48,7 @@ class EmpDataServiceController extends BaseController
|
||||
$this->batchListModel = new BatchListModel();
|
||||
$this->batchFileModel = new BatchFileModel();
|
||||
$this->empEndorsementModel = new EmpEndorsementModel();
|
||||
$this->clientDepositModel = new ClientDepositModel();
|
||||
}
|
||||
|
||||
|
||||
@ -366,32 +369,31 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
public function cashDepositCalculationForInception($arrayData = [])
|
||||
{
|
||||
$arrayData = array(
|
||||
array(
|
||||
0 => 6,
|
||||
1 => 10,
|
||||
2 => 17,
|
||||
3 => 101,
|
||||
4 => 102
|
||||
),
|
||||
);
|
||||
if (!empty($arrayData)) {
|
||||
$query = $this->employeePolicyModel->query("
|
||||
SELECT SUM(rata_premimum + gst) AS total_sum
|
||||
FROM employee_polices
|
||||
WHERE id IN (" . implode(',', $arrayData) . ")
|
||||
");
|
||||
$row = $query->getRow();
|
||||
$
|
||||
$insert = $this->clientDepositModel->insert();
|
||||
$query = $this->clientDepositModel->orderBy('id', 'DESC')->limit(1)->get();
|
||||
$cashDepositLastEntry = $query->getRow();
|
||||
|
||||
// Flatten the array to get all IDs in a single array
|
||||
$idArray = call_user_func_array('array_merge', $arrayData);
|
||||
print_r($cashDepositLastEntry); die;
|
||||
|
||||
// Select from the employee_policy table where the id is in the $idArray
|
||||
$results = $this->employeePolicyModel
|
||||
->select('employee_polices.pro_rata_premium')
|
||||
->whereIn('id', $idArray)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
return $row ? $row->total_sum : 0;
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Output the results
|
||||
print_r($results); die;
|
||||
|
||||
}
|
||||
|
||||
public function cashDepositCalculationForSIEnhancement($arrayData)
|
||||
public function cashDepositCalculationForSIEnhancement($arrayData = [])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -399,11 +399,11 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
$action = ['action' => 'inception'];
|
||||
|
||||
$depositeData = [
|
||||
$employeeIds,
|
||||
$action
|
||||
];
|
||||
$empDataServiceController->cashDepositCalculationForInception();
|
||||
// $depositeData = [
|
||||
// $employeeIds,
|
||||
// ];
|
||||
// print_r($employeeIds); die;
|
||||
$empDataServiceController->cashDepositCalculationForInception($employeeIds);
|
||||
// echo '<pre>';
|
||||
// print_r($depositeData); die;
|
||||
|
||||
|
||||
@ -44,32 +44,53 @@ if (!function_exists('change_date_format')) {
|
||||
}
|
||||
|
||||
if (!function_exists('file_Upload')) {
|
||||
|
||||
function file_Upload($fileToUpload, $imageDetails = null)
|
||||
{
|
||||
$fileName = $fileToUpload->getClientName();
|
||||
if ($fileToUpload !== NULL && $fileName !== "") {
|
||||
// Retrieve the name of the file
|
||||
$fileName = $fileToUpload->getName();
|
||||
|
||||
// Check if the file is not null and has a name
|
||||
if ($fileToUpload !== null && $fileName !== "") {
|
||||
// Check if the file is valid and has not been moved already
|
||||
if ($fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
|
||||
// Check if the image exists in the upload folder
|
||||
$existingImagePath = ROOTPATH . 'public/uploads/' . $imageDetails; // Adjust filename field based on your database structure
|
||||
// Construct the path where the image should exist
|
||||
$existingImagePath = ROOTPATH . 'public/uploads/logo/' . $imageDetails;
|
||||
|
||||
// Check if imageDetails is not null and if the image exists in the upload folder
|
||||
if ($imageDetails !== null && file_exists($existingImagePath)) {
|
||||
// If the image exists, delete it
|
||||
unlink($existingImagePath);
|
||||
}
|
||||
|
||||
|
||||
// Move the new image to the upload folder
|
||||
$fileToUpload->move(ROOTPATH . 'public/uploads', $fileName);
|
||||
$fileToUpload->move(ROOTPATH . 'public/uploads/logo', $fileName);
|
||||
}
|
||||
} else {
|
||||
// Set fileName to empty string if file is null or doesn't have a name
|
||||
$fileName = "";
|
||||
}
|
||||
|
||||
// Return the file name
|
||||
return $fileName;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('compressImage')) {
|
||||
function compressImage($file, $destinationPath, $newWidth = 100, $newHeight = 100)
|
||||
{
|
||||
// Load the image manipulation library
|
||||
$image = \Config\Services::image();
|
||||
|
||||
// Resize and compress the image
|
||||
$image->withFile($file)
|
||||
->fit($newWidth, $newHeight, 'center')
|
||||
->save($destinationPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('fancy_date_time_format'))
|
||||
{
|
||||
function fancy_date_time_format($datetime,$return_type = 'fancy') {
|
||||
|
||||
@ -21,6 +21,8 @@ class ClientModel extends Model
|
||||
"city",
|
||||
"state",
|
||||
"pincode",
|
||||
"is_download_btn",
|
||||
"client_logo",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"is_active",
|
||||
|
||||
@ -33,6 +33,7 @@ class ClientPolicyModel extends Model
|
||||
"claims_incurred_amount",
|
||||
"policy_terms",
|
||||
"open_for_enrollment",
|
||||
"is_addon",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"Is_active",
|
||||
|
||||
@ -103,6 +103,21 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="gst">Logo</label>
|
||||
<input type="file" name="client_logo" id="client_logo" onchange="PreviewImage();"><br>
|
||||
<span class="text-danger"> Image dimensions 100 x 100 pixels and size of 200KB. </span>
|
||||
</div>
|
||||
<div class="form-group col-md-6 float-right" style="position: relative;top: 20px;">
|
||||
<img src="<?= isset($client['client_logo']) && !empty($client['client_logo']) ? base_url() . "public/uploads/logo/" . $client['client_logo'] : 'http://ssl.gstatic.com/accounts/ui/avatar_2x.png' ?>" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input value="1" type="checkbox" name="is_download_btn" <?= (isset($client['is_download_btn']) && $client['is_download_btn'] == 1) ? 'checked' : '' ?>>
|
||||
<label>Download Excel</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
@ -122,6 +137,12 @@
|
||||
var PrimaryKey = $('#general_PrimaryKey').val();
|
||||
var form_action = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#client_logo').change(function() {
|
||||
validateFile(this);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#general_form").submit(function(event) {
|
||||
@ -159,6 +180,8 @@ $(document).ready(function () {
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
console.log(res);
|
||||
|
||||
if(res){
|
||||
setTimeout(function() {
|
||||
|
||||
@ -246,5 +269,71 @@ function onlyNumbers(event){
|
||||
return false;
|
||||
}
|
||||
|
||||
function PreviewImage() {
|
||||
var oFReader = new FileReader();
|
||||
oFReader.readAsDataURL(document.getElementById("client_logo").files[0]);
|
||||
|
||||
oFReader.onload = function (oFREvent) {
|
||||
document.getElementById("uploadPreview").src = oFREvent.target.result;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// function validateFile(input) {
|
||||
// const file = input.files[0];
|
||||
// const allowedExtensions = ["jpg", "jpeg", "png"];
|
||||
// const fileExtension = file.name.split(".").pop().toLowerCase();
|
||||
|
||||
// if (!allowedExtensions.includes(fileExtension)) {
|
||||
// toastr.warning('Only JPG, JPEG, PNG files are allowed.', 'Invalid file type.');
|
||||
// document.getElementById("uploadPreview").src = "http://ssl.gstatic.com/accounts/ui/avatar_2x.png";
|
||||
// input.value = "";
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
function validateFile(input) {
|
||||
const file = input.files[0];
|
||||
const allowedExtensions = ["jpg", "jpeg", "png"];
|
||||
const fileExtension = file.name.split(".").pop().toLowerCase();
|
||||
|
||||
// Check if the file extension is allowed
|
||||
if (!allowedExtensions.includes(fileExtension)) {
|
||||
toastr.warning('Only JPG, JPEG, PNG files are allowed.', 'Invalid file type.');
|
||||
document.getElementById("uploadPreview").src = "";
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
// Check file size
|
||||
const fileSize = file.size / 1024; // in KB
|
||||
if (fileSize > 200) {
|
||||
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
// Check image dimensions
|
||||
const img = new Image();
|
||||
img.onload = function() {
|
||||
if (this.width !== 100 || this.height !== 100) {
|
||||
toastr.warning('Image dimensions should be 100x100 pixels.', 'Invalid image dimensions.');
|
||||
$("#uploadPreview").attr("src", "http://ssl.gstatic.com/accounts/ui/avatar_2x.png");
|
||||
input.value = "";
|
||||
return;
|
||||
}
|
||||
// If both size and dimensions are valid, you can proceed with your logic here
|
||||
// For example, you can display the image
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
document.getElementById("uploadPreview").src = e.target.result;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
img.src = URL.createObjectURL(file);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -85,13 +85,18 @@
|
||||
<label for="policy_status">Policy Status</label>
|
||||
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
|
||||
</div>
|
||||
<div >
|
||||
<input value="1" type="checkbox" name="is_addon" id="is_addon">
|
||||
<label >Add On</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<!-- <hr> -->
|
||||
|
||||
<div id="policy_fields"></div>
|
||||
|
||||
<div id="policy_fields"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
id="btnSubmit">Submit</button>
|
||||
@ -246,6 +251,8 @@
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
console.log(res);
|
||||
|
||||
if (res.status === false) {
|
||||
toastr.error('Policy Dose Not Create', 'Error');
|
||||
@ -365,6 +372,8 @@
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -392,6 +401,12 @@
|
||||
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
|
||||
$('#policy_status_field').show();
|
||||
|
||||
if (res.data.is_addon == 1) {
|
||||
$('#is_addon').prop('checked', true);
|
||||
} else {
|
||||
$('#is_addon').prop('checked', false);
|
||||
}
|
||||
|
||||
/** do not delete this comment condition
|
||||
|
||||
// if(res.data.policy_type_id == 1){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user