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

This commit is contained in:
VENKATESHWARAN 2025-12-18 18:05:00 +05:30
commit 2bd43c094f
16 changed files with 882 additions and 97 deletions

View File

@ -654,7 +654,8 @@ $routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], funct
$routes->post("ticketSave", "ThzController::ticketSave");
});
//API FAQ
$routes->match(['get','post','delete'], 'FAQ', 'AppContentManagementController::FAQ');
//claims
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
@ -791,6 +792,9 @@ $routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails");
$routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType');
$routes->get("ticketHistoryList", "ThzController::ticketHistoryList");
// General FAQ
$routes->match(['get','post','delete'], 'FAQ', 'AppContentManagementController::FAQ');
//for testing
$routes->group('test', function($routes) {

View File

@ -11,6 +11,7 @@ use CodeIgniter\API\ResponseTrait;
use App\Models\AddImgModel;
use App\Models\FEContentModel;
use App\Models\ClientModel;
use App\Models\FAQModel;
class AppContentManagementController extends AdminController
{
@ -19,6 +20,7 @@ class AppContentManagementController extends AdminController
protected $addImgModel;
protected $feContentModel;
protected $clientModel;
protected $faqModel;
public function __construct()
@ -27,6 +29,7 @@ class AppContentManagementController extends AdminController
$this->addImgModel = new AddImgModel();
$this->feContentModel = new FEContentModel();
$this->clientModel = new ClientModel();
$this->faqModel = new FAQModel();
}
//listing
public function add_image_index()
@ -156,4 +159,139 @@ class AppContentManagementController extends AdminController
echo view('layout/footer');
}
//
// public function FAQ()
// {
// $data['tab_name'] = "FAQ's";
// $data['page_name'] = "FAQ's";
// return $this->loadLayout('faq_list', $data);
// $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
// $data = $this->request->getGet();
// $faq_list = $this->faqModel->select('*')->where('is_active', 1)->orderBy('id', 'desc')->findAll();
// if ($returnType === 'api') {
// if (empty($faq_list)) {
// $this->myLogger->logme('error', 'empty tickets in ticket list: ' . json_encode($faq));
// return $this->response->setJSON([ 'status' => 'error','message' => 'No Details found'])->setStatusCode(404);
// }
// } else {
// $data['tab_name'] = "FAQ's";
// $data['page_name'] = "FAQ's";
// return $this->loadLayout('faq_list', $data);
// }
// return $this->response->setJSON([
// 'status' => 'success',
// 'data' => [],
// ])->setStatusCode(200);
// }
public function FAQ()
{
$method = strtolower($this->request->getMethod());
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
$ref = ['timestamp' => date('Y-m-d H:i:s')];
try {
// --- 1. POST: CREATE OR UPDATE ---
if ($method === 'post') {
$id = $this->request->getPost('faq_id');
$data = array_filter($this->request->getPost(), fn($v) => $v !== '' && $v !== null);
if (empty($id)) {
$status = $this->faqModel->insert($data);
$msg = "Created";
} else {
$status = $this->faqModel->update($id, $data);
$msg = "Updated";
}
// if ($returnType === 'web') {
// return redirect()->back()->with($status ? 'success' : 'error', "FAQ $msg " . ($status ? 'successfully' : 'failed'));
// }
// return $this->response->setJSON([
// ])->setStatusCode($result ? 200 : 400);
return $this->response->setJSON([
'status' => $status ? 'success' : 'error',
'message' => "FAQ $msg " . ($status ? 'successfully' : 'failed'),
'code' => $status ? 200 : 400,
'data' => $data,
'ref' => $ref
])->setStatusCode($status ? 200 : 400);
}
// --- 2. GET: FETCH LIST OR SINGLE ---
elseif ($method === 'get') {
$id = $this->request->getGet('faq_id');
if (!empty($id)) {
// $row = $this->faqModel->where('is_active', 1)->find($id);
$row = $this->faqModel->find($id);
$data['faq_list'] = $row ? [$row] : [];
} else {
// $data['faq_list'] = $this->faqModel->where('is_active', 1)->orderBy('id', 'desc')->findAll();
$data['faq_list'] = $this->faqModel->orderBy('id', 'desc')->findAll();
}
if ($returnType === 'web') {
$data['tab_name'] = "FAQ's";
$data['page_name'] = "FAQ's";
// print_r($data);die;
return $this->loadLayout('faq_list', $data);
}
// API Response Logic
if (empty($data['faq_list'])) {
return $this->response->setJSON([
'status' => $returnType === 'web' ? false : 'error',
'message' => 'No data found',
'code' => 404,
'data' => [],
'ref' => $ref
])->setStatusCode(200); // Using 200 with error status is common for mobile apps to prevent crashes
}
return $this->response->setJSON([
'status' => $returnType === 'web' ? true : 'success',
'message' => 'Data retrieved',
'code' => 200,
'data' => $data,
'ref' => $ref
])->setStatusCode(200);
}
// --- 3. DELETE: SOFT DELETE ---
elseif ($method === 'delete') {
$id = $this->request->getGet('faq_id');
$status = (!empty($id)) ? $this->faqModel->update($id, ['is_active' => 0]) : false;
return $this->response->setJSON([
'status' => $status ? ($returnType === 'web' ? true : 'success') : ($returnType === 'web' ? false : 'error'),
'message' => $status ? 'Data removed successfully' : 'Failed to remove or ID missing',
'code' => $status ? 200 : 400,
'data' => [],
'ref' => $ref
])->setStatusCode( 200 );
}
} catch (\Throwable $e) {
$msg = $e->getMessage();
return $this->response->setJSON([
'status' => $returnType === 'web' ? false : 'error',
'code' => 500,
'message' => $msg,
'ref' => ['file' => $e->getFile(), 'line' => $e->getLine()]
])->setStatusCode(500);
}
}
}

View File

@ -51,12 +51,14 @@ class PayoutController extends BaseController
$data = $this->request->getPost();
// print_r($data); die;
$agent_id = $data['agent_id'] ?? null;
// $agent_id = $data['agent_id'] ?? null; because dropdown hided
$pos_id = $data['pos_id'] ?? null;
$status_id = $data['status_id'] ?? null;
$start_date = $data['start_date'] ?? null;
$end_date = $data['end_date'] ?? null;
$payout_data = $this->invoiceModel->invoiceList($agent_id, $status_id, $start_date, $end_date);
// $payout_data = $this->invoiceModel->invoiceList($agent_id, $status_id, $start_date, $end_date); // because dropdown hided
$payout_data = $this->invoiceModel->invoiceList($pos_id, $status_id, $start_date, $end_date);
$payout_data['payout_list_data'] = $payout_data;
$payout_data = view('payout_list', $payout_data);
@ -86,7 +88,8 @@ class PayoutController extends BaseController
// for list
$data['payout_status'] = $this->payout_status;
$data['agent_list'] = $this->invoiceModel->agentList();
// $data['agent_list'] = $this->invoiceModel->agentList(); // because dropdown hided
$data['pos_list'] = $this->invoiceModel->posList();
$data['page_name'] = "Invoices";
$payout_data['payout_list_data'] = $this->invoiceModel->invoiceList();
$data['payout_list'] = view('payout_list', $payout_data);
@ -204,8 +207,9 @@ class PayoutController extends BaseController
$title = $type === 'add' ? 'Add Payouts'
: ($type === 'edit' ? 'Edit Payouts'
: ($type === 'view' ? 'View Payouts'
: ($type === 'adjustment' ? 'Payouts Adjustment'
: 'Payouts'));
: 'Payouts')));
$data['tab_name'] = $title;
$data['page_name'] = $title;
@ -215,10 +219,12 @@ class PayoutController extends BaseController
if($type == 'add')
{
$data['agents'] = $this->invoiceModel->agentList(['is_active' => 1]); // common both add and edit
$data['pos_list'] = $this->invoiceModel->posList(['is_active' => 1]); // common both add and edit
}
else
{
$data['agents'] = $this->invoiceModel->agentList(); // common both add and edit
$data['pos_list'] = $this->invoiceModel->posList(); // common both add and edit
}
// $data['checked_policy_numbers'] = [];
// $data['invoice'] = [];
@ -236,16 +242,21 @@ class PayoutController extends BaseController
return $this->loadLayout('invoice_policy_mapping_add', $data);
}
if (($type === 'edit' || $type === 'adjustment') && !empty($id)) {
if (($type === 'edit' || $type === 'view' || $type === 'adjustment') && !empty($id)) {
$invoice = $this->invoiceModel->where('id', $id)->first();
// print_r($invoice);die;
$data['freeze_edit'] = $this->auditHistory->where('table_name', 'partner_invoice')->where('pk', $id)->countAllResults();
if($type === 'view'){ $data['freeze_edit'] = 1; }
$agentId = $invoice['agent_id'] ?? null;
// $agentId = $invoice['agent_id'] ?? null;
$posId = $invoice['pos_id'] ?? null;
$data['payouts'] = $this->invoiceModel->payoutList(2 ,$agentId,$id);
$data['extra_payouts'] = $agentId ? $this->invoiceModel->payoutList(3, $agentId) : [];
// $data['payouts'] = $this->invoiceModel->payoutList(2 ,$agentId,$id);
// $data['extra_payouts'] = $agentId ? $this->invoiceModel->payoutList(3, $agentId) : [];
$data['payouts'] = $this->invoiceModel->payoutList(2 ,$posId,$id);
// print_r($data['payouts']);die;
$data['extra_payouts'] = $posId ? $this->invoiceModel->payoutList(3, $posId) : [];
$invoice_items = $this->invoiceItemModel->where('invoice_id', $id)->findAll();
@ -518,6 +529,7 @@ class PayoutController extends BaseController
// Get invoice data from database
$invoiceData = $this->getInvoiceData($invoiceId);
// print_r($invoiceData);die;
if (empty($invoiceData)) {
return $this->respond([
@ -591,6 +603,27 @@ class PayoutController extends BaseController
}
// private function getInvoiceData($invoiceId)
// {
// $invoice_data = $this->invoiceModel
// ->select('
// partner_invoice.*,
// pa.name as agent_name,
// pa.email as agent_email,
// pa.mobile as agent_mobile,
// pa.address as agent_address,
// pa.agent_code,
// pa.certificate_file_name,
// pa.commission_retain
// ')
// ->join('partner_agent pa', 'partner_invoice.agent_id = pa.id')
// ->where('partner_invoice.is_active', 1)
// ->where('partner_invoice.id', $invoiceId)
// ->first();
// return $invoice_data;
// }
private function getInvoiceData($invoiceId)
{
$invoice_data = $this->invoiceModel
@ -604,9 +637,20 @@ class PayoutController extends BaseController
pa.address as agent_address,
pa.agent_code,
pa.certificate_file_name,
pa.commission_retain
pa.commission_retain,
pos.name as pos_name,
pos.email as pos_email,
pos.mobile as pos_mobile,
pos.address as pos_address,
pos.city as pos_city,
pos.pincode as pos_pincode,
pos.state as pos_state,
pos.pos_code,
pos.certificate_file_name as pos_certificate_file_name,
pos.bank_name,pos.account_holder_name,pos.account_number,pos.ifsc_code,
')
->join('partner_agent pa', 'partner_invoice.agent_id = pa.id')
->join('partner_agent pa', 'partner_invoice.agent_id = pa.id','left')
->join('partner_pos pos', 'partner_invoice.pos_id = pos.id')
->where('partner_invoice.is_active', 1)
->where('partner_invoice.id', $invoiceId)
->first();

View File

@ -585,11 +585,11 @@ class UserController extends AdminController
try{
// Listing
if ($method === 'get') {
$types = $this->partnerStaffModel->findAll();
if (empty($types)) {
return $this->response->setJSON(['status' => 'error','message' => 'No Staff found'])->setStatusCode(404);
$manager = $this->partnerStaffModel->where('role_id',1)->findAll();
if (empty($manager)) {
return $this->response->setJSON(['status' => 'error','message' => 'No Manager found'])->setStatusCode(404);
}
return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200);
return $this->response->setJSON(['status' => 'success','data' => $manager])->setStatusCode(200);
}
// add/update

56
app/Models/FAQModel.php Normal file
View File

@ -0,0 +1,56 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class FAQModel extends Model
{
protected $table = 'faq';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'category',
'question',
'answer',
'created_on',
'created_by',
'updated_on',
'updated_by',
'is_active',
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}
}

View File

@ -75,8 +75,8 @@ class InvoiceModel extends Model
return $data;
}
public function invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null)
// public function invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null) because dropdown hided
public function invoiceList($pos_id = null, $status_id = null, $start_date = null, $end_date = null)
{
$data = $this->select("
partner_invoice.*,
@ -105,14 +105,21 @@ class InvoiceModel extends Model
WHEN payout_status = 2 THEN 'Completed'
END AS status_text,
partner_agent.name as agent_name
partner_agent.name as agent_name,
partner_pos.name as pos_name
")
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id','left')
->join('partner_pos', 'partner_invoice.pos_id = partner_pos.id')
->where('partner_invoice.is_active', 1)
->where('partner_invoice.broker_id', 1);
if(!empty($agent_id)){
$data->where('partner_invoice.agent_id', $agent_id);
// if(!empty($agent_id)){
// $data->where('partner_invoice.agent_id', $agent_id);
// } // because dropdown hided
if(!empty($pos_id)){
$data->where('partner_invoice.pos_id', $pos_id);
}
if(!empty($status_id)){
@ -128,7 +135,8 @@ class InvoiceModel extends Model
->where('partner_invoice.invoice_date <=', $endDate);
}
if(!empty($agent_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
// if(!empty($agent_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
if(!empty($pos_id) && !empty($status_id) && !empty($start_date) && !empty($end_date)){
$fromDate = date('Y-m-d', strtotime('-60 days'));
$toDate = date('Y-m-d 23:59:59');
@ -153,6 +161,21 @@ class InvoiceModel extends Model
return $this->db->table('partner_agent')->get()->getResultArray();
}
public function posList(array $params = [])
{
$builder = $this->db->table('partner_pos')
->select('partner_pos.*, partner_staff.name AS manager_name')
->join('partner_staff', 'partner_staff.id = partner_pos.manager_id', 'left')
->orderBy('partner_pos.id', 'DESC');
if (isset($params['is_active'])) {
$builder->where('partner_pos.is_active', $params['is_active']);
}
return $builder->get()->getResultArray();
}
public function utrSummary($invoice_id)
{
$data = $this->select("
@ -194,7 +217,7 @@ class InvoiceModel extends Model
}
public function payoutList($flag, $agentId = null, $invoiceId = null)
public function payoutList($flag, $posId = null, $invoiceId = null)
{
$builder = $this->db->table('policy_transaction pt')
->select('
@ -210,13 +233,15 @@ class InvoiceModel extends Model
pii.commission_amount as paid_amount,
pi.payout_status,
pp.id as partner_policy_id,
pp.policy_transaction_id
pp.policy_transaction_id,
pt.pos_id as posId
')
->join('partner_invoice_items pii','pii.policy_no = pt.policy_no','left')
->join('partner_invoice pi','pi.id = pii.invoice_id','left')
->join('partner_policy pp','pt.policy_no = pp.policy_number AND pt.agent_id = pp.agent_id AND pt.id = pp.policy_transaction_id')
->where('pt.is_active',1)
->where('pt.agent_id IS NOT NULL');
->where('pt.pos_id IS NOT NULL');
// ->where('pt.agent_id IS NOT NULL');
if ($flag == 1) { // Add mode
// EXCLUDE all policies that exist in partner_invoice_items
@ -230,16 +255,22 @@ class InvoiceModel extends Model
if ($invoiceId) {
$builder->where('pi.id', $invoiceId); // only policies of this invoice
}
if ($agentId) {
$builder->where('pt.agent_id', $agentId);
// if ($agentId) {
// $builder->where('pt.agent_id', $agentId);
// }
if ($posId) {
$builder->where('pt.pos_id', $posId);
}
}
if ($flag == 3) { // Extra policies
// Policies not assigned to any invoice
$builder->where('pii.id IS NULL', null, false);
if ($agentId) {
$builder->where('pt.agent_id', $agentId);
// if ($agentId) {
// $builder->where('pt.agent_id', $agentId);
// }
if ($posId) {
$builder->where('pt.pos_id', $posId);
}
}

View File

@ -16,7 +16,7 @@ class PartnerStaffModel extends Model
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','retention_rate'];
protected $allowedFields = ['name','email','mobile','emp_id','role_id','email_otp','is_active','created_by','updated_by','manager_id','retention_rate','nhance_branch_id'];
// automatic timestamps
protected $useTimestamps = true;

View File

@ -489,9 +489,9 @@ table.dataTable tbody td {
<div class="form-row">
<div class="form-group col-md-6">
<label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label>
<label for="nhance_branch_id">Nhance Branch<span class="text-danger">*</span></label>
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
<option value="">Select NHance Branch</option>
<option value="">Select Nhance Branch</option>
<?php foreach($NHanceBranchData as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['branch_name'] ?></option>
<?php } ?>
@ -594,7 +594,7 @@ table.dataTable tbody td {
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add Nhance Partner </h4>
<h4 class="modal-title">Add Nhance Partner Manager </h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
@ -609,7 +609,7 @@ table.dataTable tbody td {
<div class="form-row">
<div class="form-group col-md-6">
<label for="partner_name">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="partner_name" placeholder="Ente Name" name="name" required>
<input type="text" class="form-control" id="partner_name" placeholder="Enter Name" name="name" required>
</div>
<div class="form-group col-md-6">
<label for="mobile_no">Mobile Number<span class="text-danger">*</span></label>
@ -630,10 +630,20 @@ table.dataTable tbody td {
</div>
<div class="form-row">
<div class="form-group col-md-12">
<div class="form-group col-md-6">
<label for="partner_nhance_branch_id">Nhance Branch<span class="text-danger">*</span></label>
<select class="form-control" id="partner_nhance_branch_id" name="nhance_branch_id" required>
<option value="">Select Nhance Branch</option>
<?php foreach($NHanceBranchData as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['branch_name'] ?></option>
<?php } ?>
</select>
</div>
<!-- <div class="form-group col-md-6">
<label for="locn">Address</label>
<textarea class="form-control" id="locn" name="address" placeholder="Enter address" rows="3" maxlength="1500"></textarea>
</div>
</div> -->
</div>
@ -880,12 +890,18 @@ table.dataTable tbody td {
$(document).ready(function () {
$('#nhance_branch_id').select2();
$('#partner_nhance_branch_id').select2();
$('#rm_id').select2();
$('#nhance_branch_id')
.val(null) // ✅ MUST be null
.trigger('change.select2'); // ✅ correct trigger
$('#partner_nhance_branch_id')
.val(null) // ✅ MUST be null
.trigger('change.select2'); // ✅ correct trigger
var incentiveMonthPicker = flatpickr("#incentive_month", {
dateFormat: "Y-m-d", // real value stored (hidden)
@ -1152,10 +1168,21 @@ table.dataTable tbody td {
$('#partner_name').val(user.name);
$('#email_addr').val(user.email);
$('#mobile_no').val(user.mobile);
$('#locn').val(user.address);
// $('#locn').val(user.address);
$('#retention_rate').val(user.retention_rate);
if (user.nhance_branch_id !== null &&
user.nhance_branch_id !== "" &&
user.nhance_branch_id !== 0) {
$('#partner_nhance_branch_id')
.val(user.nhance_branch_id)
.trigger('change.select2');
} else {
$('#partner_nhance_branch_id')
.val(null) // ✅ MUST be null
.trigger('change.select2'); // ✅ correct trigger
}
// $('#btnPartnerSubmit').html('Update');
$('.modal-title').html('Update Nhance Partner');
$('.modal-title').html('Update Nhance Partner Manager');
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
myModal.show(); // open modal
});
@ -1163,10 +1190,12 @@ table.dataTable tbody td {
$('body').on('click', '.btnPartnerDelete', function () {
var partner_role = $(this).attr('data-role');
var alertText = "You need to remove this user";
if (partner_role == 2) {
if (partner_role == 3) {
alertText = "You need to remove this Staff";
} else if (partner_role == 2) {
alertText = "You need to remove this Handler";
} else if (partner_role == 1) {
alertText = "You need to remove this Manager and related agent and staff are also delete";
alertText = "You need to remove this Manager and related Handler and Staff are also delete";
}
Swal.fire({
@ -1246,23 +1275,25 @@ table.dataTable tbody td {
var name = document.getElementById('partner_name').value.trim();
var mobile = document.getElementById('mobile_no').value.trim();
var email = document.getElementById('email_addr').value.trim();
var address = document.getElementById('locn').value.trim();
// var address = document.getElementById('locn').value.trim();
var rate = document.getElementById('retention_rate').value.trim();
var nb = document.getElementById('partner_nhance_branch_id').value.trim();
// Validation checks
if (name === "" || mobile === "" || email === "") {
console.log(name);
console.log(mobile);
console.log(email);
if (name === "" || mobile === "" || email === "" || rate === "" || nb === "") {
// console.log(name);
// console.log(mobile);
// console.log(email);
toastr.warning('Please fill all required fields.', 'Warning');
form.classList.add('was-validated');
return;
}
if (address.length > 1500) {
toastr.error('Address cannot exceed 1500 characters', 'Warning');
form.classList.add('was-validated');
return;
}
// if (address.length > 1500) {
// toastr.error('Address cannot exceed 1500 characters', 'Warning');
// form.classList.add('was-validated');
// return;
// }
var mobilePattern = /^[6-9]\d{9}$/; // must start with 69 and be 10 digits
if (!mobilePattern.test(mobile)) {
@ -1857,8 +1888,10 @@ table.dataTable tbody td {
$('#email_addr').val('');
$('#partner_id').val('');
$('#mobile_no').val('');
$('#locn').val('');
$('.modal-title').html('Add Nhance Partner');
// $('#locn').val('');
$('#retention_rate').val('');
$('#partner_nhance_branch_id').val('0');
$('.modal-title').html('Add Nhance Partner Manager');
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
myModal.show(); // open modal

355
app/Views/faq_list.php Normal file
View File

@ -0,0 +1,355 @@
<style>
.dataTables_filter {
position: absolute;
}
.dataTables_length label {height: 21px !important;}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Category</th>
<th class="font-weight-medium">Question</th>
<th class="font-weight-medium">Answer</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($faq_list)) { $slno = 1; ?>
<?php foreach($faq_list as $index => $row) { ?>
<tr>
<td class="text-center"><?= $slno++; ?></td>
<td><?php $category = $row['category'] ? $row['category'] : 'N/A';
echo (strlen($category) > 50)
? htmlspecialchars(substr($category, 0, 50)) . "..."
: htmlspecialchars($category);
?></td>
<td><?php $question = $row['question'] ? $row['question'] : 'N/A';
echo (strlen($question) > 50)
? htmlspecialchars(substr($question, 0, 50)) . "..."
: htmlspecialchars($question);
?></td>
<td><?php $answer = $row['answer'] ? $row['answer'] : 'N/A';
echo (strlen($answer) > 50)
? htmlspecialchars(substr($answer, 0, 50)) . "..."
: htmlspecialchars($answer);
?></td>
<td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td>
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<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" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<!-- <tr>
<td colspan="6" class="text-center">No data available</td>
</tr> -->
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add FAQ Details</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<form class="parsley-examples" id="FAQForm" enctype="multipart/form-data">
<input type="hidden" name="faq_id" id="faq_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="category">Category<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="category" name="category" placeholder="Enter Category" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="question">Question<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="question" name="question" placeholder="Enter Question" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="answer">Answer<span class="text-danger">*</span></label>
<!-- <textarea id="answer" name="answer" class="form-control" required></textarea> -->
<textarea id="answer" name="answer" class="form-control answer" rows="7">
<!-- <h5>Hello {USER_NAME}, </h5>
<p>We create simple, flat & responsive custom mail template.</p>
<p>Please, write text here!</p> -->
</textarea>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn app-btn-secondary" id="btnSubmit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- <script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/ckeditor.js"></script> -->
<script>
// let faqEditor;
let editor;
// ClassicEditor
// .create(document.querySelector('#answer'))
// .then(editor => {
// faqEditor = editor; // Save the instance here
// })
// .catch(error => { console.error(error); });
var table;
$(document).ready(function () {
//JoDit editor
const editorConfig = {
buttons: [
"undo", "redo", "|",
"paragraph",
"bold", "italic", "strikethrough", "|",
"superscript", "subscript", "|",
"ul", "ol", "|",
"outdent", "indent", "|",
"blockquote", "table", "|",
"align", "fontsize", "|",
"source"
],
controls: {
paragraph: {
list: {
p: "Normal",
h1: "Heading 1",
h2: "Heading 2",
h3: "Heading 3",
h4: "Heading 4"
}
}
},
fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"], // Font sizes in pixels
showPlaceholder: false,
toolbarButtonSize: "small",
toolbarAdaptive: false,
saveHeightInStorage: true,
minHeight: 400,
height: 400, // Optional fixed height
defaultMode: "1", // Start in WYSIWYG mode
enableDragAndDropFileToEditor: true, // Allow file uploads via drag and drop
placeholder: "Start typing here...", // Optional placeholder text
};
// 2. Initialize
editor = Jodit.make("#answer", editorConfig);
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
resetValues();openModal();
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'FAQ-List',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){ resetValues(); })
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
function handleSaveEditAndDelete(type = 'submit', el = null) {
let form = document.getElementById('FAQForm');
let url = '<?= base_url('FAQ') ?>';
let method = "POST";
let faq_id = el ? $(el).data('id') : null;
let formData;
if (type === 'submit') {
if (editor) {
$('#answer').val(editor.value);
}
// CREATE FORMDATA FROM FORM
formData = new FormData(form);
formData.set('return_type', 'web');
} else if (type == 'edit') {
method = "GET";
if (faq_id) url += '?faq_id=' + faq_id ;
$('#modalLabel').text('Edit FAQ Details');
$('#FAQForm')[0].reset();
} else if (type == 'remove') {
method = "DELETE";
if (faq_id) url += '?faq_id=' + faq_id ;
}
$('.loader, .loader-mask').fadeIn();
$.ajax({
url: url,
type: method,
data: (type === 'submit') ? formData : null,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
console.log('Response:', response);
if (response.status === 'success' || response.status === true) {
if (type == 'edit') {
let record = response.data.faq_list[0]; // single record
appendEditData(record);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
// if(el) $(el).closest('tr').remove();
window.location.reload();
// window.location.href = "<?= base_url('FAQ?return_type=web') ?>";
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
$('#FAQForm')[0].reset();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader, .loader-mask').fadeOut();
},
error: function () {
$('.loader, .loader-mask').fadeOut();
}
});
}
function resetValues(){
$('#modalLabel').text('Add FAQ Details');
$('#FAQForm')[0].reset();
if (typeof editor !== 'undefined') {
editor.value = '';
}
}
function appendEditData(data) {
$('#FAQForm')[0].reset();
$('#faq_id').val(data.id);
$('#category').val(data.category);
$('#question').val(data.question);
if (editor) {
editor.value = data.answer || '';
}
openModal();
}
$('#FAQForm').on('submit', function(e) {
e.preventDefault();
const form = this;
// HTML5 built-in validation
if (!form.checkValidity()) {
form.reportValidity(); // shows required/pattern tooltips
return;
}
if (typeof editor !== 'undefined') {
// Strip HTML tags and trim whitespace to see if there is actual text
const plainText = editor.value.replace(/<[^>]*>/g, '').trim();
// Check if it's truly empty or just contains empty tags like <p><br></p>
if (editor.value === '' || plainText === '') {
toastr.warning("Answer is required", 'Warning');
return; // Stop the function here
}
}
// If valid, submit via AJAX
handleSaveEditAndDelete('submit');
});
</script>

View File

@ -98,7 +98,7 @@ table.dataTable tbody td { padding: 4px 4px !important; }
<label>Invoice Date <span class="text-danger"></span></label>
<input class="form-control" type="date" id="invoiceDate" required value="<?= isset($invoice['invoice_date']) ? $invoice['invoice_date'] : '' ?>" >
</div>
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="agents"> Agents <span class="text-danger"></span></label>
<select class="form-control" id="agentSelect" name="agents_id" onchange="loadPolicies()" required>
@ -114,6 +114,23 @@ table.dataTable tbody td { padding: 4px 4px !important; }
}
?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="pos"> POS <span class="text-danger"></span></label>
<select class="form-control" id="posSelect" name="pos_id" onchange="loadPolicies()" required>
<option value="">Select pos</option>
<?php
if(isset($pos_list) && count($pos_list)) {
foreach($pos_list as $pos): ?>
<option value="<?= $pos['id'] ?>"
<?= isset($invoice['pos_id']) && $invoice['pos_id'] == $pos['id'] ? 'selected' : '' ?>>
<?= $pos['name'] ?> - <?= $pos['pos_code'] ?>
</option>
<?php endforeach;
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label>Policy Till Date<span class="text-danger"></span></label>
@ -481,17 +498,20 @@ table.dataTable tbody td { padding: 4px 4px !important; }
}
// ---- Filter policies by agent/date ----
// ---- Filter policies by agent/POS/date ----
function filterPolicies() {
const fromDate = getEl('fromDate')?.value || '';
const toDate = getEl('toDate')?.value || '';
const agentId = getEl('agentSelect')?.value || '';
// const agentId = getEl('agentSelect')?.value || '';
const posId = getEl('posSelect')?.value || '';
const policyTillDate = getEl('policyTillDate')?.value || '';
if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
// if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
if (!posId || posId === '0') return toastr.warning('Please select an POS', 'Required');
filteredPolicies = window.allPolicies.filter(p => {
if (String(p.agentId) !== String(agentId)) return false;
// if (String(p.agentId) !== String(agentId)) return false;
// if (String(p.posId) !== String(posId)) return false;
if (policyTillDate && p.date_db > policyTillDate) return false;
if (fromDate && p.date_db < fromDate) return false;
if (toDate && p.date_db > toDate) return false;
@ -503,7 +523,9 @@ table.dataTable tbody td { padding: 4px 4px !important; }
// ---- Load policies for selected agent ----
function loadPolicies() {
const agentId = getEl('agentSelect')?.value || '';
// const agentId = getEl('agentSelect')?.value || '';
const posId = getEl('posSelect')?.value || '';
console.log('-->',posId);
const policyTillDate = getEl('policyTillDate')?.value || '';
const list = getEl('policyListBody');
if (!list) return;
@ -518,16 +540,30 @@ table.dataTable tbody td { padding: 4px 4px !important; }
list.innerHTML = '';
if (!agentId || agentId === '0') {
list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select an agent</td></tr>`;
// if (!agentId || agentId === '0') {
// list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select an agent</td></tr>`;
// updateSummary();
// reloadDataTable();
// return;
// }
// Filter policies for the selected agent
// filteredPolicies = window.allPolicies.filter(p => {
// if (String(p.agentId) !== String(agentId)) return false;
// if (policyTillDate && p.date_db > policyTillDate) return false;
// return true;
// });
if (!posId || posId === '0') {
list.innerHTML = `<tr><td colspan="${colspan}" class="text-center text-danger">Please select a POS</td></tr>`;
updateSummary();
reloadDataTable();
return;
}
// Filter policies for the selected agent
// Filter policies for the selected POS
filteredPolicies = window.allPolicies.filter(p => {
if (String(p.agentId) !== String(agentId)) return false;
if (String(p.posId) !== String(posId)) return false;
if (policyTillDate && p.date_db > policyTillDate) return false;
return true;
});
@ -652,8 +688,11 @@ table.dataTable tbody td { padding: 4px 4px !important; }
// ---- Show More Policies ----
function showMorePolicies() {
const agentId = getEl('agentSelect')?.value || '';
if (!agentId) return toastr.warning('Please select an agent', 'Required');
// const agentId = getEl('agentSelect')?.value || '';
// if (!agentId) return toastr.warning('Please select an agent', 'Required');
const posId = getEl('posSelect')?.value || '';
if (!posId) return toastr.warning('Please select an POS', 'Required');
if (!window.extraPolicies || window.extraPolicies.length === 0) {
return toastr.info('No more policies available.', 'Information');
@ -664,11 +703,13 @@ table.dataTable tbody td { padding: 4px 4px !important; }
// Filter extraPolicies: same agent + not already in filteredPolicies
const newPolicies = window.extraPolicies.filter(p => {
return String(p.agentId) === String(agentId) && !existingPolicyIds.has(p.id);
// return String(p.agentId) === String(agentId) && !existingPolicyIds.has(p.id);
return String(p.posId) === String(posId) && !existingPolicyIds.has(p.id);
});
if (newPolicies.length === 0) {
toastr.info('No more policies available for this agent.', 'Information');
// toastr.info('No more policies available for this agent.', 'Information');
toastr.info('No more policies available for this POS.', 'Information');
return;
}
@ -690,13 +731,15 @@ table.dataTable tbody td { padding: 4px 4px !important; }
// ---- Save invoice ----
function saveInvoice() {
const agentId = getEl('agentSelect')?.value || '';
// const agentId = getEl('agentSelect')?.value || '';
const posId = getEl('posSelect')?.value || '';
const invoiceNo = getEl('invoiceNo')?.value || '';
const invoiceDate = getEl('invoiceDate')?.value || '';
const policyTillDate = getEl('policyTillDate')?.value || '';
const invoiceID = getEl('invoiceID')?.value || '';
if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
// if (!agentId || agentId === '0') return toastr.warning('Please select an agent', 'Required');
if (!posId || posId === '0') return toastr.warning('Please select an pos', 'Required');
if (!invoiceDate) return toastr.warning('Please select invoice date', 'Required');
if (selectedPolicies.size === 0) return toastr.warning('Please select at least one policy', 'Required');
@ -728,10 +771,11 @@ table.dataTable tbody td { padding: 4px 4px !important; }
const invoiceData = {
invoice_id: invoiceID,
invoice_no: invoiceNo,
agent_id: agentId,
// agent_id: agentId,
invoice_date: invoiceDate,
invoice_amount: totalAmount,
policies: policies
policies: policies,
pos_id: posId
};
// console.log(invoiceData);return true;
@ -774,7 +818,8 @@ table.dataTable tbody td { padding: 4px 4px !important; }
const invoiceDateEl = getEl('invoiceDate');
const policyTillDateEl = getEl('policyTillDate');
const agentSelectEl = getEl('agentSelect');
// const agentSelectEl = getEl('agentSelect');
const posSelectEl = getEl('posSelect');
// Set max date (today)
if (invoiceDateEl) invoiceDateEl.max = today;
@ -783,20 +828,25 @@ table.dataTable tbody td { padding: 4px 4px !important; }
if (invoiceType == 'add') {
// -------- ADD MODE --------
if (agentSelectEl) agentSelectEl.value = '';
// if (agentSelectEl) agentSelectEl.value = '';
if (posSelectEl) posSelectEl.value = '';
if (invoiceDateEl) invoiceDateEl.required = true;
if (policyTillDateEl) policyTillDateEl.required = true;
if (agentSelectEl) agentSelectEl.required = true;
// if (agentSelectEl) agentSelectEl.required = true;
if (posSelectEl) posSelectEl.required = true;
// Enable Select2
$('#agentSelect').prop('disabled', false).select2();
// $('#agentSelect').prop('disabled', false).select2();
$('#posSelect').prop('disabled', false).select2();
}
else {
// -------- EDIT,ADJUSTMENT MODE --------
if (agentSelectEl) agentSelectEl.readOnly = true;
// if (agentSelectEl) agentSelectEl.readOnly = true;
if (posSelectEl) posSelectEl.readOnly = true;
// Disable Select2 (readonly)
$('#agentSelect').prop('disabled', true);
// $('#agentSelect').prop('disabled', true);
$('#posSelect').prop('disabled', true);
// Remove red star (*) from label
const agentLabel = document.querySelector('label[for="agents"] .text-danger');
@ -810,9 +860,16 @@ table.dataTable tbody td { padding: 4px 4px !important; }
if (getEl('policyTillDate')) getEl('policyTillDate').valueAsDate = new Date();
}
const agentEl = getEl('agentSelect');
if (agentEl) {
agentEl.addEventListener('change', () => {
// const agentEl = getEl('agentSelect');
// if (agentEl) {
// agentEl.addEventListener('change', () => {
// selectedPolicies.clear();
// loadPolicies();
// });
// }
const posEl = getEl('posSelect');
if (posEl) {
posEl.addEventListener('change', () => {
selectedPolicies.clear();
loadPolicies();
});
@ -826,10 +883,12 @@ table.dataTable tbody td { padding: 4px 4px !important; }
if (policyTillDateEl) policyTillDateEl.addEventListener('change', loadPolicies);
if (agentEl && agentEl.value && agentEl.value !== '0') loadPolicies();
// if (agentEl && agentEl.value && agentEl.value !== '0') loadPolicies();
if (posEl && posEl.value && posEl.value !== '0') loadPolicies();
else {
const body = getEl('policyListBody');
if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select an agent</td></tr>`;
// if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select an agent</td></tr>`;
if (body) body.innerHTML = `<tr><td colspan="${colspan}" class="text-center">Please select a POS</td></tr>`;
reloadDataTable();
}
});
@ -843,6 +902,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Determine if we should freeze edits
const shouldFreeze =
(freeze > 0 && type === 'view') ||
(freeze > 0 && type === 'edit') ||
(payout_status === 2 && (type === 'adjustment' || type === 'edit'));

View File

@ -95,6 +95,7 @@
<div class="invoice-container">
<table>
<!--
<?php if(isset($agent_name)) : ?>
<tr>
<td colspan="3" class="header"><?= $agent_name ?></td>
@ -106,7 +107,42 @@
<td colspan="3" class="header"><?= $agent_address ?></td>
</tr>
<?php endif; ?>
-->
<?php if(isset($pos_name)) : ?>
<tr>
<td colspan="3" class="header"><?= $pos_name ?></td>
</tr>
<?php endif; ?>
<?php if(isset($pos_address) && !empty($pos_address)) :
$pos_a = trim($pos_address ?? '');
$pos_c = trim($pos_city ?? '');
$pos_s = trim($pos_state ?? '');
$pos_p = trim($pos_pincode ?? '');
if ($pos_p === '0' || $pos_p === 0) {$pos_p = '';}
$address = '';
if ($pos_a && $pos_c && $pos_s && $pos_p) { $address = "$pos_a, <br>$pos_c, $pos_s - $pos_p.";
} elseif ($pos_a && $pos_c && $pos_s) { $address = "$pos_a, <br>$pos_c, $pos_s.";
} elseif ($pos_a && $pos_c && $pos_p) { $address = "$pos_a, <br>$pos_c - $pos_p.";
} elseif ($pos_a && $pos_s && $pos_p) { $address = "$pos_a, <br>$pos_s - $pos_p.";
} elseif ($pos_a && $pos_c) { $address = "$pos_a, <br>$pos_c.";
} elseif ($pos_a && $pos_s) { $address = "$pos_a, <br>$pos_s.";
} elseif ($pos_a && $pos_p) { $address = "$pos_a - $pos_p.";
} elseif ($pos_c && $pos_s && $pos_p) { $address = "$pos_c, $pos_s - $pos_p.";
} elseif ($pos_c && $pos_s) { $address = "$pos_c, $pos_s.";
} elseif ($pos_c && $pos_p) { $address = "$pos_c - $pos_p.";
} elseif ($pos_s && $pos_p) { $address = "$pos_s - $pos_p.";
} elseif ($pos_a) { $address = "$pos_a<br>";
} elseif ($pos_c) { $address = "$pos_c.";
} elseif ($pos_s) { $address = "$pos_s.";
} elseif ($pos_p) { $address = "$pos_p.";
} else { $address = '-';}
?>
<tr>
<td colspan="3" class="header"><?= $address ?></td>
</tr>
<?php endif; ?>
<tr>
<td class="section-header">Bill To:</td>
<td class="section-header">Invoice No</td>
@ -144,11 +180,18 @@
<strong>Amount Payable in words : <?= isset($invoice_no) && !empty($invoice_amount) ? numberToWords((int)$invoice_amount) . ' Only' : "-" ?> </strong>
</div>
<div class="bank-details">
<!-- <div class="bank-details">
<strong>BANK ACCOUNT DETAILS</strong><br>
ACCOUNT NUMBER : <?= isset($agent_account_no) && !empty($agent_account_no) ? $agent_account_no : "-" ?><br>
IFSC CODE : <?= isset($agent_ifsc_code) && !empty($agent_ifsc_code) ? $agent_ifsc_code : "-" ?><br>
Bank NAME : <?= isset($agent_bank_name) && !empty($agent_bank_name) ? $agent_bank_name : "-" ?>
</div> -->
<div class="bank-details">
<strong>BANK ACCOUNT DETAILS</strong><br>
ACCOUNT HOLDER NAME : <?= isset($account_holder_name) && !empty($account_holder_name) ? $account_holder_name : "-" ?><br>
ACCOUNT NUMBER : <?= isset($account_number) && !empty($account_number) ? $account_number : "-" ?><br>
IFSC CODE : <?= isset($ifsc_code) && !empty($ifsc_code) ? $ifsc_code : "-" ?><br>
Bank NAME : <?= isset($bank_name) && !empty($bank_name) ? $bank_name : "-" ?>
</div>
<div class="signature">

View File

@ -2098,6 +2098,9 @@
<li>
<a href="<?= base_url('/frontend_content') ?>">Front-end Content</a>
</li>
<li>
<a href="<?= base_url('/FAQ?return_type=web') ?>"> FAQ's </a>
</li>
</ul>
</div>
</li>

View File

@ -107,7 +107,7 @@
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
resetValues();openModal();
}
},
{

View File

@ -209,7 +209,8 @@
<th class="font-weight-medium">UTR Total Amount</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Agent</th>
<!-- <th class="font-weight-medium">Agent</th> -->
<th class="font-weight-medium">POS</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
@ -224,15 +225,17 @@
<td> <?= format_indian_number($row['total_utr_amount']) ?> </td>
<td> <?= format_indian_number($row['balance_amount']) ?> </td>
<td> <?= $row['status_text'] ?> </td>
<td> <?= $row['agent_name'] ?? " - " ?> </td>
<!-- <td> <?= $row['agent_name'] ?? " - " ?> </td> -->
<td> <?= $row['pos_name'] ?? " - " ?> </td>
<td>
<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" onclick="fetchUtrDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')"><i class="mdi mdi-bank-transfer mr-2 text-muted font-18 vertical-middle"></i>UTR</a>
<a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<!-- <a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a> -->
<a href="<?= base_url('payout/invoices?type=view&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View</a>
<a href="<?= base_url('payout/invoices?type=adjustment&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-tune mr-2 text-muted font-18 vertical-middle"></i>Adjustment</a>
<a onclick="fetchPreviewInvoiceDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')" class="dropdown-item"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
<a onclick="fetchPreviewInvoiceDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')" class="dropdown-item"><i class="mdi mdi-file mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
</div>
</div>
</td>

View File

@ -14,7 +14,7 @@
<div class="card-body">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="client_branch">Agents<span class="text-danger"></span></label>
<select class="form-control" id="agent_id" name="agent_id">
<option value="">Select Agent</option>
@ -24,6 +24,17 @@
<?php endforeach; ?>
<?php endif; ?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="pos_id">POS<span class="text-danger"></span></label>
<select class="form-control" id="pos_id" name="pos_id">
<option value="">Select POS (Manager)</option>
<?php if (isset($pos_list) && !empty($pos_list)) : ?>
<?php foreach ($pos_list as $pos) : ?>
<option value="<?= $pos['id']; ?>"><?= htmlspecialchars($pos['name'] . ' (' . $pos['manager_name'] . ')'); ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<div class="form-group col-md-3">
@ -72,7 +83,8 @@
let utrHasBeenChanged = false;
$(document).ready(function(){
$('#agent_id').select2();
// $('#agent_id').select2(); because dropdown hided
$('#pos_id').select2();
$('#startDate').val('');
$('#endDate').val('');
$('#reportrange').val('');
@ -121,7 +133,8 @@
$('#clear-filters').on('click', function() {
// Reset all select dropdowns to the first option
$('#agent_id').val('').change();
// $('#agent_id').val('').change(); because dropdown hided
$('#pos_id').val('').change();
$('#status_id').val('').change();
// Clear the date range inputs
@ -135,14 +148,15 @@
function fetchPayoutList(internalCall = false)
{
let agent_id = $('#agent_id').val();
// let agent_id = $('#agent_id').val(); because dropdown hided
let pos_id = $('#pos_id').val();
let status_id = $('#status_id').val();
let start_date = $('#startDate').val();
let end_date = $('#endDate').val();
console.log({agent_id, status_id, start_date, end_date, internalCall, utrHasBeenChanged});
console.log({pos_id, status_id, start_date, end_date, internalCall, utrHasBeenChanged});
if(!internalCall){
if (!agent_id && !status_id && !start_date && !end_date) {
if (!pos_id && !status_id && !start_date && !end_date) {
toastr.warning("Please select any one filter!", "WARNING");
return false;
}
@ -152,7 +166,8 @@
// Data to send in the AJAX request
let requestData = {
agent_id: agent_id,
// agent_id: agent_id, because dropdown hided
pos_id: pos_id,
status_id: status_id,
start_date: start_date,
end_date: end_date,

View File

@ -226,7 +226,7 @@
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
resetValues();openModal();
}
},
{