diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 392f362e..b53251e2 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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(); } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index b74999c9..09493bbf 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -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 = []) { } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index d04be584..67e5f6b5 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -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 '
';
// print_r($depositeData); die;
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 34ede33e..ce5de4c4 100644
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -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') {
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index 3ccf26a1..25a5249d 100644
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -21,6 +21,8 @@ class ClientModel extends Model
"city",
"state",
"pincode",
+ "is_download_btn",
+ "client_logo",
"created_by",
"updated_by",
"is_active",
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index b8dbc9d9..ff437dc1 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -33,6 +33,7 @@ class ClientPolicyModel extends Model
"claims_incurred_amount",
"policy_terms",
"open_for_enrollment",
+ "is_addon",
"created_by",
"updated_by",
"Is_active",
diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php
index e743434f..278938f6 100644
--- a/app/Views/client_basic_info.php
+++ b/app/Views/client_basic_info.php
@@ -103,6 +103,21 @@
+
+
+
+
+ Image dimensions 100 x 100 pixels and size of 200KB.
+
+
+
" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"/>
+
+
+
+
+ >
+
+
+
+
+
+
-
+
-
-
+
+
+
@@ -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){