Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-09-05 11:26:47 +05:30
commit 8683d8ff70
22 changed files with 1633 additions and 276 deletions

View File

@ -73,6 +73,9 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) {
$routes->get("deactive/(:hash)", "UserController::deactive/$1");
$routes->get("rolesandteams", "UserController::getRolesAndTeams");
$routes->get("getUserActivityHistory", "UserController::getUserActivityHistory");
$routes->match(['get','post','put'], 'partner', 'UserController::partner');
$routes->match(['get','post','put'], 'partnerIncentive', 'UserController::partnerIncentive');
$routes->get("download-incentive-file/(:any)", "UserController::downloadIncentivesFile/$1");
});
$routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {

View File

@ -18,6 +18,8 @@ use App\Models\UserTeamsModel;
use App\Helpers\BookStackUserHelper;
use App\Models\AuthHistoryModel;
use App\Models\UserActivityHistoryModel;
use App\Models\PartnerStaffModel;
use App\Models\PartnerManagerIncentiveFileModel;
class UserController extends AdminController
@ -32,6 +34,8 @@ class UserController extends AdminController
protected $bookStack;
protected $authHistoryModel;
protected $userActivityHistoryModel;
protected $partnerStaffModel;
protected $partnerManagerIncentiveFileModel;
public function __construct()
{
@ -45,6 +49,8 @@ class UserController extends AdminController
$this->bookStack = new BookStackUserHelper();
$this->authHistoryModel = new AuthHistoryModel();
$this->userActivityHistoryModel = new UserActivityHistoryModel();
$this->partnerStaffModel = new PartnerStaffModel();
$this->partnerManagerIncentiveFileModel = new PartnerManagerIncentiveFileModel();
}
public function list()
@ -563,4 +569,211 @@ class UserController extends AdminController
}
}
public function partner()
{
$method = $this->request->getMethod(); // get, post
try{
// Listing
if ($method === 'get') {
$types = $this->partnerStaffModel->findAll();
if (empty($types)) {
return $this->response->setJSON(['status' => 'error','message' => 'No Staff found'])->setStatusCode(404);
}
return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200);
}
// add/update
if ($method === 'post') {
$data = $this->request->getPost();
if (!empty($data['id'])) {
$text = "update";
$result = $this->partnerStaffModel->update($data['id'], $data);
$updateID = $data['id'];
} else {
$text = "create";
$data['role_id'] = 1;
$data['created_by'] = get_session_userid();
$insertID = $this->partnerStaffModel->insert($data);
$result = true;
}
$id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null);
return $this->response->setJSON([
'status' => $id ? 'success' : 'error',
'message' => $id ? "Staff {$text}d successfully" : "Unable to {$text} staff. Please try again.",
'id' => $id
])->setStatusCode($id ? 200 : 400);
}
// delete
if ($method === 'put') {
$data = $this->request->getRawInput();
$id = $data['id'] ?? null;
if (!$id) {
return $this->response->setJSON(['status' => 'error', 'message' => 'ID is required'])->setStatusCode(400);
}
$staff = $this->partnerStaffModel->find($id);
if (!$staff) {
return $this->response->setJSON(['status' => 'error','message' => 'Staff not found'])->setStatusCode(404);
}
if ($staff['is_active'] == 1) {
$result = $this->partnerStaffModel->update($id, ['is_active' => 0]);
$message = "Staff deleted successfully";
} else {
return $this->response->setJSON(['status' => 'error','message' => 'Staff already deleted'])->setStatusCode(400);
}
return $this->response->setJSON([
'status' => $result ? 'success' : 'error',
'message' => $result ? $message : "Unable to delete staff. Please try again.",
'id' => $id
])->setStatusCode($result ? 200 : 400);
}
return $this->response->setJSON([ 'status' => 'error', 'message' => 'Invalid request method' ])->setStatusCode(405);
}
catch (\Throwable $e) {
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|| $e instanceof \mysqli_sql_exception
|| $e instanceof \PDOException;
$context = ['title' => get_class($e),'type' => get_class($e),'code' => $code,'message' => $e->getMessage(),'file' => $e->getFile(),'line' => $e->getLine()];
$this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0);
return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(),
'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine()
])->setStatusCode($code);
}
}
public function partnerIncentive()
{
$method = $this->request->getMethod(); // get, post
try{
// Listing
if ($method === 'get') {
$manager_id = $this->request->getGet('manager_id');
$files = $this->partnerManagerIncentiveFileModel->where('manager_id', $manager_id)->findAll();
if (empty($files)) {
return $this->response->setJSON(['status' => 'error','message' => 'No Records found'])->setStatusCode(404);
}
return $this->response->setJSON(['status' => 'success','data' => $files])->setStatusCode(200);
}
// add/update
if ($method === 'post') {
$file = $this->request->getFile('incentive_file_name');
$month = $this->request->getPost('incentive_month');
$managerId = $this->request->getPost('manager_id');
$fileId = $this->request->getPost('id');
if ($file && $file->isValid() && !$file->hasMoved()) {
$fileName = $file->getName();
$path = WRITEPATH.'uploads/incentives';
$file->move($path, $fileName);
$data = [
'manager_id' => $managerId,
'incentive_month' => date('Y-m-d', strtotime($month)),
'incentive_file_name' => $fileName,
'created_by' => get_session_userid()
];
if ($fileId) {
$text = "update";
$this->partnerManagerIncentiveFileModel->update($fileId, $data);
$updateID = $data['id'];
} else {
$text = "create";
$insertID = $this->partnerManagerIncentiveFileModel->insert($data);
$result = true;
}
$id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null);
return $this->response->setJSON([
'status' => $id ? 'success' : 'error',
'message' => $id ? "File {$text}d successfully" : "Unable to {$text} file. Please try again.",
'id' => $id
])->setStatusCode($id ? 200 : 400);
}
return $this->response->setJSON([
'status' => 'error',
'message' => "Unable to Upload file. Please try again.",
'id' => ''
])->setStatusCode(400);
}
// delete
if ($method === 'put') {
$data = $this->request->getRawInput();
$id = $data['id'] ?? null;
if (!$id) {
return $this->response->setJSON(['status' => 'error', 'message' => 'ID is required'])->setStatusCode(400);
}
$files = $this->partnerManagerIncentiveFileModel->find($id);
if (!$files) {
return $this->response->setJSON(['status' => 'error','message' => 'No Records found'])->setStatusCode(404);
}
if ($files['is_active'] == 1) {
$result = $this->partnerManagerIncentiveFileModel->update($id, ['is_active' => 0]);
$message = "Files deleted successfully";
} else {
return $this->response->setJSON(['status' => 'error','message' => 'files already deleted'])->setStatusCode(400);
}
return $this->response->setJSON([
'status' => $result ? 'success' : 'error',
'message' => $result ? $message : "Unable to delete staff. Please try again.",
'id' => $id
])->setStatusCode($result ? 200 : 400);
}
return $this->response->setJSON([ 'status' => 'error', 'message' => 'Invalid request method' ])->setStatusCode(405);
}
catch (\Throwable $e) {
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|| $e instanceof \mysqli_sql_exception
|| $e instanceof \PDOException;
$context = ['title' => get_class($e),'type' => get_class($e),'code' => $code,'message' => $e->getMessage(),'file' => $e->getFile(),'line' => $e->getLine()];
$this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0);
return $this->response->setJSON([ 'status' => 'error', 'message' => $isDbError ? 'Data Access Error' : $e->getMessage(),
'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine()
])->setStatusCode($code);
}
}
public function downloadIncentivesFile($file_name)
{
$file_name = basename($file_name);
$filePath = WRITEPATH . 'uploads/incentives/' . $file_name;
try {
if (file_exists($filePath)) {
return $this->response->download($filePath, null);
} else {
$data['message'] = 'File Not Found';
echo view('errors/404', $data);
}
} catch (\Exception $e) {
// Handle any exceptions
$errorMessage = $e->getMessage();
$this->myLogger->logme('error', $errorMessage);
// You can return an error response here
echo $errorMessage;
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class PartnerManagerIncentiveFileModel extends Model
{
protected $table = 'partner_manager_incentive_file';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array'; // or 'object'
protected $useSoftDeletes = false;
protected $allowedFields = [
'manager_id',
'incentive_month',
'incentive_file_name',
'is_active',
'created_by',
'created_on',
'updated_by',
'updated_on'
];
// Timestamps
protected $useTimestamps = true;
protected $createdField = 'created_on';
protected $updatedField = 'updated_on';
protected $dateFormat = 'datetime'; // can be 'date' or 'int'
// Validation Rules (optional, can add more)
// protected $validationRules = [
// 'manager_id' => 'required|integer',
// 'incentive_month' => 'required|valid_date',
// 'incentive_file_name'=> 'required|string|max_length[150]',
// ];
// protected $validationMessages = [
// 'manager_id' => [
// 'required' => 'Manager ID is required',
// 'integer' => 'Manager ID must be a number',
// ],
// 'incentive_month' => [
// 'required' => 'Incentive Month is required',
// 'valid_date' => 'Incentive Month must be a valid date (Y-m-d)',
// ],
// 'incentive_file_name' => [
// 'required' => 'File name is required',
// 'max_length' => 'File name cannot exceed 150 characters',
// ],
// ];
// protected $skipValidation = false;
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class PartnerStaffModel extends Model
{
protected $table = 'partner_staff'; // table name
protected $primaryKey = 'id'; // primary key
protected $useAutoIncrement = true;
// return results as array
protected $returnType = 'array';
protected $useSoftDeletes = false;
// allowed fields for insert/update
protected $allowedFields = ['name','email','mobile','emp_id','role_id','email_otp','is_active','created_by','updated_by','manager_id'];
// automatic timestamps
protected $useTimestamps = true;
protected $createdField = 'created_on';
protected $updatedField = 'updated_on';
protected $dateFormat = 'datetime';
// validation rules
// protected $validationRules = [
// 'name' => 'required|min_length[2]|max_length[150]',
// 'email' => 'permit_empty|valid_email|max_length[150]',
// 'mobile' => 'permit_empty|regex_match[/^[0-9]{10,20}$/]',
// ];
// protected $validationMessages = [
// 'name' => [
// 'required' => 'Name is required',
// 'min_length' => 'Name must have at least 2 characters',
// 'max_length' => 'Name cannot exceed 150 characters'
// ],
// 'email' => [
// 'valid_email' => 'Please provide a valid email address',
// 'max_length' => 'Email cannot exceed 150 characters'
// ],
// 'mobile' => [
// 'regex_match' => 'Mobile number must be 1020 digits only'
// ]
// ];
// protected $skipValidation = false;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-lg" <?= !isset($CD_Master_Data) ? 'style="max-width: 35% !important; margin:5px auto!important;"' : '' ?>>
@ -78,8 +79,8 @@
</div>
<div id="cdButtonWrapper" class="form-group text-right m-b-0">
<button class="btn app-btn-outline-secondary app-btn-border-radius mr-2 " type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="resetCdMasterFormModal()">Cancel</button>
<button class="btn app-btn-secondary app-btn-border-radius waves-effect waves-light" id="cd_master_btn_Submit">Submit</button>
<button class="btn app-btn-outline-secondary mr-2 " type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="resetCdMasterFormModal()">Cancel</button>
<button class="btn btn-primary waves-effect waves-light" id="cd_master_btn_Submit">Submit</button>
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
</div>
</form>

View File

@ -61,37 +61,6 @@ input:checked + .slider:before {
}
</style>
<style>
.form-input-icon {
position: relative;
width: 100%; /* match Bootstrap's width */
}
.form-input-icon input[type="file"].form-control {
padding-right: 40px; /* space for the icon */
cursor: pointer;
}
.form-input-icon input[type="file"].form-control::file-selector-button {
display: none;
}
.form-input-icon .form-additional-icon {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
font-size: 18px;
color: #555;
pointer-events: none;
}
input[type="radio"] {
accent-color: #40B2B6; /* sets the checked color */
}
</style>
<div class="tab-pane fade active show" id="general-q-tab">
@ -190,10 +159,10 @@ input:checked + .slider:before {
<div class="form-group row">
<label for="insurer_logo" class="col-md-4 col-form-label">Insurer Logo</label>
<div class="col-md-5">
<div class="form-input-icon">
<div class="input-icon">
<input type="file" class="form-control" id="insurer_logo" name="insurer_logo"
accept="image/jpeg, image/jpg, image/png" onchange="PreviewImage();">
<i class="mdi mdi-upload form-additional-icon"></i>
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
<div class="col-md-3">

View File

@ -33,7 +33,7 @@
<div class="tab-pane fade" id="branch-tab" style="padding-left: 25px;">
<div class="row float-right" style="padding-bottom: 10px;position: relative;">
<a href="#" id="btnBranchAdd" class="btn app-btn-primary app-btn-border-radius mr-2"><span class="mdi mdi-plus" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</a>
<a href="#" id="btnBranchAdd" class="btn app-btn-primary mr-2"><span class="mdi mdi-plus" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</a>
</div>
<div class="table-responsive" id="branch_table" >
@ -244,9 +244,9 @@
<!-- Submit / Cancel -->
<div class="form-row">
<!-- <div class="form-group col-md-12 mt-2"> -->
<div class="mt-2">
<button type="submit" class="btn app-btn-secondary app-btn-border-radius mr-2" id="btnSubmit">Submit</button>
<button type="button" class="btn app-btn-outline-secondary app-btn-border-radius btnBack" id="btnBack" data-dismiss="modal" aria-hidden="true">Cancel</button>
<div style="margin-top: 85px;">
<button type="submit" class="btn btn-primary mr-2" id="btnSubmit">Submit</button>
<button type="button" class="btn app-btn-outline-secondary btnBack" id="btnBack" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
<!-- </div> -->
</div>
@ -254,13 +254,11 @@
<!-- Right Section: Contact Details -->
<div class="col-md-4" style="background:#f8f9fa; max-height: calc(80vh - 50px); overflow-y:auto; border-radius:8px; padding:10px;">
<!-- First Contact -->
<div class="bg-white p-2 mb-2 rounded">
<div id="contact_1_wrapper" class="bg-white p-2 mb-2 rounded contact-block">
<div class="d-flex justify-content-between align-items-center mb-2">
<h6 class="modal-subtitle mb-0">Contact 1</h6>
<div class="d-flex align-items-center">
<i class="mdi mdi-plus text-primary ac me-3" style="cursor:pointer; font-size:24px !important;" onclick="appendContactHtml()" id="add"></i>
<i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="contact_1_remove"></i>
</div>
</div>
@ -268,26 +266,30 @@
<!-- Contact Form Fields -->
<input type="hidden" name="primarykey[]" id="contact_id_1" value=""/>
<div class="form-group mb-2">
<label for="name_1">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="name_1" required>
<label for="name">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="name" required>
</div>
<div class="form-group mb-2">
<label for="designation_1">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="designation_1" required>
<label for="designation">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="designation" required>
</div>
<div class="form-group mb-2">
<label for="email_1">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="email_1" required>
<label for="email">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="email" required>
</div>
<div class="form-group mb-2">
<label for="mobile_1">Mobile <span class="text-danger">*</span></label>
<input type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" id="mobile_1" required>
<label for="mobile">Mobile <span class="text-danger">*</span></label>
<input type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" id="mobile" required>
</div>
</div>
<!-- Container for dynamically added contacts -->
<div id="container"></div>
<div>
<button type="button" class="btn btn-primary btn-sm ac me-3" style="width: 100%;" onclick="appendContactHtml()" id="add"><i class="mdi mdi-plus"></i> Add Contact</button>
</div>
</div>
</div>
@ -456,7 +458,7 @@
// $('#add_branch').hide();
// $('#branch_table').show();
$('.btnBack').hide();
// $('.btnBack').hide();
// $('#btnBranchAdd').show();
},
@ -505,6 +507,7 @@
// $('#branch_table').show();
$('.btnBack').show();
// $('#btnBranchAdd').hide();
console.log("res.levelcontact[0].id"+res.levelcontact[0].id);
$('#branch_name').val(res.insurerbranch.branch_name);
$('#branch_code').val(res.insurerbranch.branch_code);
$('#state option[value="' + res.insurerbranch.state + '"]').prop('selected', true);
@ -545,102 +548,187 @@
// function appendContactHtml(contact = false, reset = false) {
// console.log('appendContactHtml function called ')
// contactCount++;
// var container = document.getElementById('container');
// var uniqueId = Date.now().toString();
// var html = `
// <div id="${uniqueId}" class="bg-white p-2 mb-2 rounded">
// <div class="d-flex justify-content-between align-items-center mb-2">
// <h6 class="modal-subtitle mb-0">Contact ${contactCount}</h6>
// <div class="d-flex align-items-center">
// <i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="${uniqueId}_remove"></i>
// </div>
// </div>
// <br>
// <div class="form-row">
// <input type="hidden" name="primarykey[]" id="contact_id_1" value="${contact !== undefined && contact !== false ? contact.id : ''}"/>
// <div class="form-group col-md-12">
// <label for="${uniqueId}_first_name">Name<span class="text-danger">*</span></label>
// <input value="${contact !== undefined && contact !== false ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="${uniqueId}_name" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
// <input data-parsley-type="email" value="${contact !== undefined && contact !== false ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
// <input data-parsley-type="number" data-parsley-length="[10,10]" pattern="[0-9]{10}" value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
// <input value="${contact !== undefined && contact !== false ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="${uniqueId}_designation" required>
// </div>
// </div>
// </div>
// `;
// if(reset == false){
// container.insertAdjacentHTML('beforeend', html);
// storeButtonId(uniqueId + '_add');
// if (contactCount >= 3) {
// hideStoredAddButtons();
// }
// }
// }
// function removeContact(button) {
// var uniqueId = button.id.split("_")[0];
// var contactSection = document.getElementById(uniqueId);
// if (contactSection) {
// contactSection.parentNode.removeChild(contactSection);
// contactCount --;
// if (contactCount < 3) {
// var addButton = document.querySelector('.ac');
// if (addButton) {
// addButton.style.display = 'block';
// }
// }
// }
// }
// function storeButtonId(id) {
// var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
// buttonIds.push(id);
// localStorage.setItem('buttonIds', JSON.stringify(buttonIds));
// }
// function hideStoredAddButtons() {
// var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
// storedIds.forEach(function(id) {
// var addButton = document.getElementById(id);
// var first_addButton = document.querySelector('.ac')
// if (addButton) {
// addButton.style.display = 'none';
// first_addButton.style.display = 'none';
// }
// });
// }
function renumberContacts() {
var contacts = document.querySelectorAll('.contact-block');
contacts.forEach(function(contact, index) {
let title = contact.querySelector('.modal-subtitle');
if (title) {
title.textContent = "Contact " + (index + 1); // auto numbering
}
});
contactCount = contacts.length; // keep global in sync
}
function appendContactHtml(contact = false, reset = false) {
console.log('appendContactHtml function called ');
console.log('appendContactHtml function called ')
contactCount++;
var container = document.getElementById('container');
var uniqueId = Date.now().toString();
var container = document.getElementById('container');
var uniqueId = Date.now().toString();
var html = `
<div id="${uniqueId}" class="bg-white p-2 m-1 rounded">
<div class="bg-white p-2 mb-2 rounded">
<div class="d-flex justify-content-between align-items-center mb-2">
<h6 class="modal-subtitle mb-0">Contact ${contactCount}</h6>
<div class="d-flex align-items-center">
<i class="mdi mdi-plus text-primary ac me-3" style="cursor:pointer; font-size:24px !important;" onclick="appendContactHtml()" id="${uniqueId}_add"></i>
<i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="${uniqueId}_remove"></i>
</div>
</div>
<br>
<div class="form-row">
<input type="hidden" name="primarykey[]" id="contact_id_1" value="${contact !== undefined && contact !== false ? contact.id : ''}"/>
<div class="form-group col-md-12">
<label for="${uniqueId}_first_name">Name<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="${uniqueId}_name" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
<input data-parsley-type="email" value="${contact !== undefined && contact !== false ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
<input data-parsley-type="number" data-parsley-length="[10,10]" pattern="[0-9]{10}" value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="${uniqueId}_designation" required>
</div>
</div>
</div>
var html = `
<div id="${uniqueId}" class="bg-white p-2 mb-2 rounded contact-block">
<div class="d-flex justify-content-between align-items-center mb-2">
<h6 class="modal-subtitle mb-0"></h6>
<div class="d-flex align-items-center">
<i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="${uniqueId}_remove"></i>
</div>
</div>
`;
if(reset == false){
container.insertAdjacentHTML('beforeend', html);
storeButtonId(uniqueId + '_add');
if (contactCount >= 3) {
hideStoredAddButtons();
}
}
<div class="form-row">
<input type="hidden" name="primarykey[]" value="${contact ? contact.id : ''}"/>
<div class="form-group col-md-12">
<label>Name<span class="text-danger">*</span></label>
<input value="${contact ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Email<span class="text-danger">*</span></label>
<input value="${contact ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Mobile<span class="text-danger">*</span></label>
<input value="${contact ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Designation<span class="text-danger">*</span></label>
<input value="${contact ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" required>
</div>
</div>
</div>
`;
if(!reset){
container.insertAdjacentHTML('beforeend', html);
renumberContacts(); // ✅ fix numbering
toggleAddButton();
}
}
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
var contactSection = document.getElementById(uniqueId);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
contactCount --;
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'block';
}
}
}
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
var contactSection = document.getElementById(uniqueId);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
renumberContacts(); // ✅ renumber after removal
toggleAddButton();
}
}
function storeButtonId(id) {
function toggleAddButton() {
var totalContacts = document.querySelectorAll('.contact-block, #contact_1_wrapper').length;
var addButton = document.querySelector('.ac');
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
buttonIds.push(id);
localStorage.setItem('buttonIds', JSON.stringify(buttonIds));
if (totalContacts >= 3) {
addButton.style.display = 'none';
} else {
addButton.style.display = 'block';
}
}
function hideStoredAddButtons() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
storedIds.forEach(function(id) {
var addButton = document.getElementById(id);
var first_addButton = document.querySelector('.ac')
if (addButton) {
addButton.style.display = 'none';
first_addButton.style.display = 'none';
}
});
}
function showNextAddButton() {
var storedIds = JSON.parse(localStorage.getItem('buttonIds')) || [];
var addButtonShown = false;

View File

@ -62,13 +62,13 @@
<div class="form-group col-md-6" style="position: relative;top: 28px;">
<label for="email"><span class="text-danger"></span></label>
<a href="#" class="btn app-btn-secondary app-btn-border-radius mr-2" onclick="checkInsurerTemplete(this)">Copy</a>
<a href="#" class="btn app-btn-secondary mr-2" onclick="checkInsurerTemplete(this)">Copy</a>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<div class="float-right">
<label for="email"><span class="text-danger"></span></label>
<a href="#" class="btn app-btn-primary app-btn-border-radius" onclick="addNewJsonExportTemplate(this)"><i class="mdi mdi-plus"></i> Add </a>
<a href="#" class="btn app-btn-primary " onclick="addNewJsonExportTemplate(this)"><i class="mdi mdi-plus"></i> Add </a>
</div>
</div>
@ -194,7 +194,7 @@
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary app-btn-border-radius waves-effect waves-light mr-1">Submit</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
</div>
</form>
</div>
@ -511,8 +511,8 @@
</div>
<div class="form-group col-md-2" style="position: relative;left: 28px;">
<a class="btn app-btn-secondary app-btn-border-radius waves-effect waves-light mr-1" onclick="addHTMLInput(this)"><i class="mdi mdi-plus text-white" style="cursor:pointer; font-size:15px !important;"></i></a>
<a class="btn btn-danger app-btn-border-radius waves-effect waves-light" onclick="removeHTMLInput(this)"><i class="mdi mdi-trash-can text-white" style="cursor:pointer; font-size:15px !important;"></i></a>
<a class="btn app-btn-secondary waves-effect waves-light mr-1" onclick="addHTMLInput(this)"><i class="mdi mdi-plus text-white" style="cursor:pointer; font-size:15px !important;"></i></a>
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)"><i class="mdi mdi-trash-can text-white" style="cursor:pointer; font-size:15px !important;"></i></a>
</div>
</div>
`;

View File

@ -12,7 +12,7 @@
</a>
</div>
</div> -->
<div class="row" style="padding-bottom: 10px;padding-left: 20px;">
<div class="row" style="padding-bottom: 10px;padding-left: 5px;">
<h4 class="d-flex align-items-center" style="gap: 8px;">
<span onclick="history.back()" style="cursor: pointer;">
<i class="mdi mdi-chevron-left" style="font-size: 43px;"></i>

View File

@ -1,4 +1,4 @@
<div class="tab-pane fade" id="branch-tab" style="padding-left: 22px;">
<div class="tab-pane fade" id="branch-tab">
<div class="row float-right" style="padding-bottom: 10px;position: relative;right: 13px;">
<button type="button" id="btnBranchAdd" class="btn btn-primary waves-effect waves-light btn-sm"><span class="mdi mdi-plus-box-outline" aria-hidden="true" style="padding: 5px 10px;"></span>Add KYC Docs</button>
@ -89,10 +89,10 @@
<!-- Form Actions -->
<div class="form-group text-right mb-0">
<button type="button" class="btn app-btn-outline-secondary app-btn-border-radius waves-effect btnBack" id="btnBack" data-dismiss="modal">
<button type="button" class="btn app-btn-outline-secondary waves-effect btnBack" id="btnBack" data-dismiss="modal">
Cancel
</button>
<button type="submit" class="btn app-btn-secondary app-btn-border-radius waves-effect waves-light mr-1" id="btnSubmit">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">
Submit
</button>
</div>

View File

@ -1,7 +1,7 @@
<div class="tab-pane fade active show" id="general-q-tab">
<div class="row">
<div class="col-12">
<div class="card-body">
<div class="card-body subcard">
<div class="custom-form">
<form role="form" class="parsley-examples" method="post" id="kyc_general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
@ -21,7 +21,7 @@
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary app-btn-border-radius waves-effect waves-light mr-1"
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack"
id="btnBack">Cancel</button>

View File

@ -34,7 +34,7 @@ body {
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<div class="row" style="padding-bottom: 10px;padding-left: 20px;">
<div class="row" style="padding-bottom: 10px;">
<h4 class="d-flex align-items-center" style="gap: 8px;">
<span onclick="history.back()" style="cursor: pointer;">
<i class="mdi mdi-chevron-left" style="font-size: 43px;"></i>

View File

@ -520,8 +520,6 @@ a.app-text-success:hover, a.app-text-success:focus {
box-shadow: 0 0 0 0.15rem rgba(226, 103, 40, 0.5); }
.app-btn-border-radius{ border-radius: 10px !important; }
.app-badge-primary {
color: #ffffff;
background-color: #00999E; }
@ -1093,9 +1091,9 @@ a.app-badge-secondary:focus, a.app-badge-secondary.focus {
}
.custom-form .form-control {
background-color: #F5FFFF !important;
border: 1px solid #ccc; /* optional */
border: none !important;
/* color: #000; keep text readable */
box-shadow: none !important;
box-shadow: 0px 1px 1px 0px #00000040;
}
.custom-form .form-control:focus {
background-color: #F5FFFF !important;
@ -1103,7 +1101,7 @@ a.app-badge-secondary:focus, a.app-badge-secondary.focus {
}
.custom-form .select2-container--default .select2-selection--multiple {
background-color: #F5FFFF !important;
border: 1px solid #ccc;
border: none !important;
}
.custom-form .select2-container .select2-selection--single {
background-color: #F5FFFF !important;
@ -1121,7 +1119,64 @@ a.app-badge-secondary:focus, a.app-badge-secondary.focus {
margin-top:0 !important;
padding-top: 0 !important;
}
.subcard{
padding-top: 0px;
padding-left: 5px;
}
.btn-custom {
font-weight: 500;
font-style: normal;
font-size: 12px;
line-height: 1;
letter-spacing: 0;
text-align: center;
}
</style>
<style>
/* Common wrapper (works for text/file inputs) */
.input-icon {
position: relative;
display: block;
width: 100%;
}
/* All form controls inside */
.input-icon .form-control {
width: 100%;
box-sizing: border-box;
padding-right: 40px; /* always keep space for icon */
cursor: pointer;
}
/* Hide default file button */
.input-icon .form-control[type="file"]::file-selector-button {
display: none;
}
.input-icon input[type="file"].form-control {
padding-right: 40px; /* space for the icon */
cursor: pointer;
}
/* Common icon class */
.input-icon .additional-icon {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
font-size: 18px;
color: #555;
pointer-events: none;
}
input[type="radio"] {
accent-color: #40B2B6; /* sets the checked color */
}
</style>
</head>

View File

@ -1,7 +1,7 @@
<div class="tab-pane fade active show" id="general-q-tab">
<div class="row">
<div class="col-12">
<div class="card-body">
<div class="card-body subcard">
<div class="custom-form">
<form role="form" class="parsley-examples" method="post" id="policytype_general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
@ -76,7 +76,7 @@
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary app-btn-border-radius waves-effect waves-light mr-1"
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack"
id="btnBack">Cancel</button>

View File

@ -42,7 +42,7 @@ body {
<a href="<?= base_url("master/policy/list"); ?>"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i> </a>
</div>
</div> -->
<div class="row" style="padding-bottom: 10px;padding-left: 20px;">
<div class="row" style="padding-bottom: 10px;">
<h4 class="d-flex align-items-center" style="gap: 8px;">
<span onclick="history.back()" style="cursor: pointer;">
<i class="mdi mdi-chevron-left" style="font-size: 43px;"></i>

View File

@ -32,21 +32,6 @@ table.dataTable td.wrap {
word-break: break-word;
}
.btn-custom {
font-weight: 500;
font-style: normal;
font-size: 12px;
line-height: 1;
letter-spacing: 0;
text-align: center;
}
</style>
@ -281,8 +266,8 @@ table.dataTable td.wrap {
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn app-btn-primary app-btn-border-radius mr-2 " onclick="resetTicket()">Reset</button>
<button type="submit" class="btn app-btn-secondary app-btn-border-radius" onclick="submitTicket(event)">Save</button>
<button type="button" class="btn app-btn-primary mr-2 " onclick="resetTicket()">Reset</button>
<button type="submit" class="btn app-btn-secondary " onclick="submitTicket(event)">Save</button>
</div>
</form>
</div>
@ -314,7 +299,7 @@ table.dataTable td.wrap {
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn-custom app-btn-secondary app-btn-border-radius " onclick="updateAssignTo()">Save</button>
<button type="button" class="btn-custom app-btn-secondary " onclick="updateAssignTo()">Save</button>
</div>
</div>
</div>
@ -610,7 +595,7 @@ $(document).ready(function() {
buttons: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Create New Ticket </span>',
className: 'btn app-btn-primary app-btn-border-radius mr-2',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openTicket();
}
@ -618,7 +603,7 @@ $(document).ready(function() {
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary app-btn-border-radius',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',

View File

@ -386,7 +386,7 @@ hr{
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn app-btn-secondary app-btn-border-radius" onclick="submitTicket()">Save</button>
<button type="button" class="btn app-btn-secondary " onclick="submitTicket()">Save</button>
</div>
</form>
</div>

View File

@ -28,7 +28,7 @@
font-size: 14px;
}
.delete-btn {
/* .delete-btn {
background-color: #e5f7f6;
color: #00999E;
border: none;
@ -36,7 +36,7 @@
padding: 6px 20px;
cursor: pointer;
font-size: 14px;
}
} */
.helper-text {
font-size: 12px;
@ -58,7 +58,7 @@
<div class="tab-pane fade active show" id="general-q-tab">
<div class="row">
<div class="col-12">
<div class="card-body" style="padding-top: 0px;">
<div class="card-body subcard">
<div class="custom-form">
<form role="form" class="parsley-examples" method="post" id="tpa_general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
@ -144,7 +144,7 @@
<div class="col">
<div class="d-flex">
<button type="button" class="upload-btn" onclick="document.getElementById('tpa_logo').click();">Upload</button>
<button type="button" class="delete-btn" onclick="removeImage0();">Delete</button>
<!-- <button type="button" class="delete-btn" onclick="removeImage0();">Delete</button> -->
</div>
<div class="helper-text" id="fileNameText0">
<?= isset($tpa['tpa_logo']) && !empty($tpa['tpa_logo']) ? $tpa['tpa_logo'] : '( Upload Your TPA Logo )' ?>
@ -177,7 +177,7 @@
<div class="col">
<div class="d-flex">
<button type="button" class="upload-btn" onclick="document.getElementById('fc').click();">Upload</button>
<button type="button" class="delete-btn" onclick="removeImage1();">Delete</button>
<!-- <button type="button" class="delete-btn" onclick="removeImage1();">Delete</button> -->
</div>
<div class="helper-text" id="fileNameText1">
<?= isset($tpa['front_card']) && !empty($tpa['front_card']) ? $tpa['front_card'] : '( Upload Your Front card Image )' ?>
@ -210,7 +210,7 @@
<div class="col">
<div class="d-flex">
<button type="button" class="upload-btn" onclick="document.getElementById('bc').click();">Upload</button>
<button type="button" class="delete-btn" onclick="removeImage4();">Delete</button>
<!-- <button type="button" class="delete-btn" onclick="removeImage4();">Delete</button> -->
</div>
<div class="helper-text" id="fileNameText4">
<?= isset($tpa['back_card']) && !empty($tpa['back_card']) ? $tpa['back_card'] : '( Upload Your Back card Image )' ?>
@ -230,7 +230,7 @@
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn app-btn-secondary app-btn-border-radius waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<button type="submit" class="btn app-btn-secondary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button>
</div>
</form>

View File

@ -29,10 +29,10 @@
max-height: 80vh;
}
</style>
<div class="tab-pane fade" id="branch-tab" style="padding-left: 22px;">
<div class="tab-pane fade" id="branch-tab">
<div class="row float-right" style="padding-bottom: 10px;position: relative;">
<a href="#" id="btnBranchAdd" class="btn app-btn-primary app-btn-border-radius mr-2"><span class="mdi mdi-plus" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</a>
<a href="#" id="btnBranchAdd" class="btn app-btn-primary mr-2"><span class="mdi mdi-plus" aria-hidden="true" style="padding: 5px 10px;"></span>Add Branch</a>
</div>
<div class="table-responsive" id="branch_table" >
@ -241,8 +241,8 @@
<div class="form-row">
<!-- <div class="form-group col-md-12 mt-2"> -->
<div class="mt-2">
<button type="submit" class="btn app-btn-secondary app-btn-border-radius mr-2" id="btnSubmit">Submit</button>
<button type="button" class="btn app-btn-outline-secondary app-btn-border-radius btnBack" id="btnBack" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn app-btn-secondary mr-2" id="btnSubmit">Submit</button>
<button type="button" class="btn app-btn-outline-secondary btnBack" id="btnBack" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
<!-- </div> -->
</div>
@ -250,13 +250,11 @@
<!-- Right Section: Contact Details -->
<div class="col-md-4" style="background:#f8f9fa; max-height: calc(80vh - 50px); overflow-y:auto; border-radius:8px; padding:10px;">
<!-- First Contact -->
<div class="bg-white p-2 mb-2 rounded">
<div id="contact_1_wrapper" class="bg-white p-2 mb-2 rounded contact-block">
<div class="d-flex justify-content-between align-items-center mb-2">
<h6 class="modal-subtitle mb-0">Contact 1</h6>
<div class="d-flex align-items-center">
<i class="mdi mdi-plus text-primary ac me-3" style="cursor:pointer; font-size:24px !important;" onclick="appendContactHtml()" id="add"></i>
<i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="contact_1_remove"></i>
</div>
</div>
@ -264,26 +262,30 @@
<!-- Contact Form Fields -->
<input type="hidden" name="primarykey[]" id="contact_id_1" value=""/>
<div class="form-group mb-2">
<label for="name_1">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="name_1" required>
<label for="name">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="name" required>
</div>
<div class="form-group mb-2">
<label for="designation_1">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="designation_1" required>
<label for="designation">Designation <span class="text-danger">*</span></label>
<input type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="designation" required>
</div>
<div class="form-group mb-2">
<label for="email_1">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="email_1" required>
<label for="email">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="email" required>
</div>
<div class="form-group mb-2">
<label for="mobile_1">Mobile <span class="text-danger">*</span></label>
<input type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" id="mobile_1" required>
<label for="mobile">Mobile <span class="text-danger">*</span></label>
<input type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" id="mobile" required>
</div>
</div>
<!-- Container for dynamically added contacts -->
<div id="container"></div>
<div>
<button type="button" class="btn btn-primary btn-sm ac me-3" style="width: 100%;" onclick="appendContactHtml()" id="add"><i class="mdi mdi-plus"></i> Add Contact</button>
</div>
</div>
</div>
@ -451,7 +453,7 @@ $(document).ready(function () {
myModal.hide();
// $('#add_branch').hide();
// $('#branch_table').show();
$('.btnBack').hide();
// $('.btnBack').hide();
// $('#btnBranchAdd').show();
},
error: function (xhr, status, error) {
@ -587,75 +589,163 @@ $(document).ready(function () {
function appendContactHtml(contact = false, reset = false) {
// function appendContactHtml(contact = false, reset = false) {
console.log('appendContactHtml function called ')
contactCount++;
// console.log('appendContactHtml function called ')
// contactCount++;
// var container = document.getElementById('container');
// var uniqueId = Date.now().toString();
// var html = `
// <div id="${uniqueId}">
// <hr>
// <h6 class="header-title">Contact ${contactCount}</h6>
// <br>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_first_name">Name<span class="text-danger">*</span></label>
// <input value="${contact !== undefined && contact !== false ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="${uniqueId}_name" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
// <input value="${contact !== undefined && contact !== false ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="${uniqueId}_designation" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
// <input data-parsley-type="email" value="${contact !== undefined && contact !== false ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" required>
// </div>
// </div>
// <div class="form-row">
// <div class="form-group col-md-12">
// <label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
// <input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" required>
// </div>
// </div>
// <div class="form-group" style="display: flex;">
// <button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)" id="${uniqueId}_remove">Remove</button>
// </div>
// </div>
// `;
// if(reset == false){
// console.log(reset)
// container.insertAdjacentHTML('beforeend', html);
// storeButtonId(uniqueId + '_add');
// if (contactCount >= 3) {
// hideStoredAddButtons();
// }
// }
// }
function renumberContacts() {
var contacts = document.querySelectorAll('.contact-block');
contacts.forEach(function(contact, index) {
let title = contact.querySelector('.modal-subtitle');
if (title) {
title.textContent = "Contact " + (index + 1); // auto numbering
}
});
contactCount = contacts.length; // keep global in sync
}
function appendContactHtml(contact = false, reset = false) {
console.log('appendContactHtml function called ');
var container = document.getElementById('container');
var uniqueId = Date.now().toString();
var html = `
<div id="${uniqueId}">
<hr>
<h6 class="header-title">Contact ${contactCount}</h6>
<br>
<div class="form-row">
<div class="form-group col-md-6">
<label for="${uniqueId}_first_name">Name<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="${uniqueId}_name" required>
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" id="${uniqueId}_designation" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
<input data-parsley-type="email" value="${contact !== undefined && contact !== false ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" required>
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" required>
</div>
</div>
<div class="form-group" style="display: flex;">
<button style="margin-right: 10px;" type="button" class="btn btn-primary btn-sm ac" onclick="appendContactHtml()" id="${uniqueId}_add">Add Contact</button>
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)" id="${uniqueId}_remove">Remove</button>
<div id="${uniqueId}" class="bg-white p-2 mb-2 rounded contact-block">
<div class="d-flex justify-content-between align-items-center mb-2">
<h6 class="modal-subtitle mb-0"></h6>
<div class="d-flex align-items-center">
<i class="mdi mdi-trash-can text-danger" style="cursor:pointer; font-size:24px !important;" onclick="removeContact(this)" id="${uniqueId}_remove"></i>
</div>
</div>
<div class="form-row">
<input type="hidden" name="primarykey[]" value="${contact ? contact.id : ''}"/>
<div class="form-group col-md-12">
<label>Name<span class="text-danger">*</span></label>
<input value="${contact ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Email<span class="text-danger">*</span></label>
<input value="${contact ? contact.email : ''}" type="email" class="form-control" placeholder="Enter Contact Email" name="email[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Mobile<span class="text-danger">*</span></label>
<input value="${contact ? contact.mobile : ''}" type="tel" class="form-control" placeholder="Enter Contact Mobile" pattern="[0-9]{10}" name="mobile[]" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label>Designation<span class="text-danger">*</span></label>
<input value="${contact ? contact.designation : ''}" type="text" class="form-control" placeholder="Enter Designation Name" name="designation[]" required>
</div>
</div>
</div>
`;
if(reset == false){
console.log(reset)
if(!reset){
container.insertAdjacentHTML('beforeend', html);
storeButtonId(uniqueId + '_add');
if (contactCount >= 3) {
hideStoredAddButtons();
}
renumberContacts(); // ✅ fix numbering
toggleAddButton();
}
}
function removeContact(button) {
var uniqueId = button.id.split("_")[0];
var contactSection = document.getElementById(uniqueId);
if (contactSection) {
contactSection.parentNode.removeChild(contactSection);
contactCount --;
if (contactCount < 3) {
var addButton = document.querySelector('.ac');
if (addButton) {
addButton.style.display = 'block';
}
}
renumberContacts(); // ✅ renumber after removal
toggleAddButton();
}
}
function toggleAddButton() {
var totalContacts = document.querySelectorAll('.contact-block, #contact_1_wrapper').length;
var addButton = document.querySelector('.ac');
if (totalContacts >= 3) {
addButton.style.display = 'none';
} else {
addButton.style.display = 'block';
}
}
// function removeContact(button) {
// var uniqueId = button.id.split("_")[0];
// var contactSection = document.getElementById(uniqueId);
// if (contactSection) {
// contactSection.parentNode.removeChild(contactSection);
// contactCount --;
// if (contactCount < 3) {
// var addButton = document.querySelector('.ac');
// if (addButton) {
// addButton.style.display = 'block';
// }
// }
// }
// }
function storeButtonId(id) {
var buttonIds = JSON.parse(localStorage.getItem('buttonIds')) || [];

View File

@ -34,7 +34,7 @@ body {
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;padding-left: 20px;">
<div class="row" style="padding-bottom: 10px;">
<h4 class="d-flex align-items-center" style="gap: 8px;">
<span onclick="history.back()" style="cursor: pointer;">
<i class="mdi mdi-chevron-left" style="font-size: 43px;"></i>

View File

@ -218,8 +218,8 @@ table.dataTable tbody td {
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button class="btn app-btn-outline-secondary app-btn-border-radius mr-2 close" type="button" id="close_btn" data-dismiss="modal" aria-label="Close" aria-hidden="true">Cancel</button>
<button type="submit" id="btnSubmit" class="btn app-btn-secondary app-btn-border-radius waves-effect waves-light" id="cd_master_btn_Submit">Submit</button>
<button class="btn app-btn-outline-secondary mr-2 colse" type="button" id="close_btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" id="btnSubmit" class="btn app-btn-secondary waves-effect waves-light" id="cd_master_btn_Submit">Submit</button>
</div>
</form>
</div>