Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
9d113bbea3
@ -739,7 +739,6 @@ $routes->get('testTracelog','TestBusinessController::a');
|
||||
$routes->get("claimView", "EmployeeRestController::claimView");
|
||||
|
||||
// General Tickets
|
||||
|
||||
$routes->post("ticketSave", "ThzController::ticketSave");
|
||||
$routes->get("ticketList", "ThzController::ticketList");
|
||||
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
|
||||
@ -769,3 +768,11 @@ $routes->group('test', function($routes) {
|
||||
});
|
||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||
|
||||
//PARTNER PAYOUT
|
||||
$routes->group('payout', function($routes) {
|
||||
$routes->match (['get','post'],'list',"PayoutController::payoutList");
|
||||
$routes->post('fetchUtrDetails',"PayoutController::fetchUtrDetails");
|
||||
$routes->post('saveUtrDetails',"PayoutController::saveUtrDetails");
|
||||
$routes->post('removeUtrDetails',"PayoutController::removeUtrDetails");
|
||||
});
|
||||
|
||||
|
||||
@ -5673,6 +5673,10 @@ class ClientController extends AdminController
|
||||
// $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx");
|
||||
// dd($response);
|
||||
|
||||
// $TicketController = new TicketController();
|
||||
// $response = $TicketController->getMoreInfo($requestFrom = 'rest', $ticket_id = 70);
|
||||
// dd($response);
|
||||
|
||||
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
191
app/Controllers/PayoutController.php
Normal file
191
app/Controllers/PayoutController.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Models\InvoiceItemModel;
|
||||
use App\Models\InvoiceModel;
|
||||
use App\Models\InvoiceUtrModel;
|
||||
use App\Models\PolicyTransactionModel;
|
||||
|
||||
class PayoutController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
protected $myLogger;
|
||||
protected $invoiceItemModel;
|
||||
protected $invoiceModel;
|
||||
protected $invoiceUtrModel;
|
||||
protected $policyTransactionModel;
|
||||
protected $payout_status;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_session_context('PayoutController');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
$this->payout_status = [
|
||||
1 => "Draft",
|
||||
2 => "Pending",
|
||||
3 => "Complete",
|
||||
];
|
||||
|
||||
$this->invoiceItemModel = new InvoiceItemModel();
|
||||
$this->invoiceModel = new InvoiceModel();
|
||||
$this->invoiceUtrModel = new InvoiceUtrModel();
|
||||
$this->policyTransactionModel = new PolicyTransactionModel();
|
||||
}
|
||||
|
||||
public function payoutList()
|
||||
{
|
||||
// for filtering list
|
||||
if($this->request->is('post')){
|
||||
try{
|
||||
$data = $this->request->getPost();
|
||||
// print_r($data); die;
|
||||
|
||||
$agent_id = $data['agent_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['payout_list_data'] = $payout_data;
|
||||
$payout_data = view('payout_list', $payout_data);
|
||||
|
||||
if(!empty($payout_data)){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "No data found"], 200);
|
||||
}
|
||||
}catch (\Throwable $th) {
|
||||
|
||||
$this->myLogger->logme("error", "PayoutController - payoutList: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
|
||||
$errorData = [
|
||||
'message' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'code' => $th->getCode(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||
];
|
||||
$payout_data = view('payout_list');
|
||||
return $this->respond(['status' => false, 'code' => 500, 'data' => $payout_data, "message" => "No data found", 'error_data' => $errorData], 500);
|
||||
}
|
||||
}
|
||||
|
||||
// for list
|
||||
$data['payout_status'] = $this->payout_status;
|
||||
$data['agent_list'] = $this->invoiceModel->agentList();
|
||||
$payout_data['payout_list_data'] = $this->invoiceModel->invoiceList();
|
||||
$data['payout_list'] = view('payout_list', $payout_data);
|
||||
|
||||
// dd($data);
|
||||
return $this->loadLayout('payout_list_handler', $data);
|
||||
}
|
||||
|
||||
public function fetchUtrDetails()
|
||||
{
|
||||
$invoice_id = $this->request->getPost('invoice_id') ?? null;
|
||||
$payout_data = $this->constructUtrDetails($invoice_id);
|
||||
|
||||
if(!empty($payout_data)){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "No data found"], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function constructUtrDetails($invoice_id)
|
||||
{
|
||||
$utr_data = $this->invoiceUtrModel->where('is_active', 1)->where('invoice_id', $invoice_id)->findAll();
|
||||
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
|
||||
|
||||
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']) {
|
||||
$data['invoice_completed'] = true;
|
||||
}
|
||||
|
||||
$data['utr_list_data'] = $utr_data;
|
||||
$data['summary'] = $summary_data;
|
||||
$data = view('payout_utr_details', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function saveUtrDetails()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$invoice_id = $this->request->getPost('invoice_id') ?? null;
|
||||
$utr_id = $this->request->getPost('utr_pk') ?? null;
|
||||
|
||||
if(isset($data['utr_date'])){
|
||||
$data['utr_date'] = change_date_format($data['utr_date']);
|
||||
}
|
||||
|
||||
|
||||
if(!empty($utr_id)){
|
||||
|
||||
$update = $this->invoiceUtrModel->where('id', $utr_id)->set($data)->update();
|
||||
$payout_edit_data = $this->constructUtrDetails($invoice_id);
|
||||
|
||||
if($update){
|
||||
|
||||
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
|
||||
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']){
|
||||
$sql = "UPDATE partner_invoice SET payout_status = 2 WHERE id = ?";
|
||||
db_connect()->query($sql, [$invoice_id]);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_edit_data, "message" => "UTR successfully updated"], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_edit_data, "message" => "Failed to update UTR"], 200);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
unset($data['utr_pk']);
|
||||
$insert_id = $this->invoiceUtrModel->insert($data);
|
||||
$payout_data = $this->constructUtrDetails($invoice_id);
|
||||
|
||||
if($insert_id){
|
||||
|
||||
$summary_data = $this->invoiceModel->utrSummary($invoice_id);
|
||||
if($summary_data['invoice_amount'] == $summary_data['total_utr_amount']){
|
||||
$sql = "UPDATE partner_invoice SET payout_status = 2 WHERE id = ?";
|
||||
db_connect()->query($sql, [$invoice_id]);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data, "message" => "UTR added successfully"], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "Failed to add UTR"], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeUtrDetails()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
if(isset($data['utr_id'])){
|
||||
|
||||
$sql = "UPDATE partner_invoice_utr SET is_active = 0 WHERE id = ?";
|
||||
$update = db_connect()->query($sql, [$data['utr_id']]);
|
||||
|
||||
$payout_data = $this->constructUtrDetails($data['invoice_id'] ?? "");
|
||||
|
||||
if($update){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $payout_data, "message" => "UTR removed successfully"], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'data' => $payout_data, "message" => "Failed to remove UTR"], 200);
|
||||
}
|
||||
}else {
|
||||
return $this->respond(['status' => false, 'code' => 500, 'data' => "", "message" => "Failed to remove UTR"], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
41
app/Models/InvoiceItemModel.php
Normal file
41
app/Models/InvoiceItemModel.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class InvoiceItemModel extends Model
|
||||
{
|
||||
protected $table = 'partner_invoice_items';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'invoice_id',
|
||||
'policy_id',
|
||||
'policy_no',
|
||||
'commission_amount',
|
||||
'is_active',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
protected $validationRules = [
|
||||
'invoice_id' => 'required|integer',
|
||||
'policy_id' => 'required|integer',
|
||||
'policy_no' => 'required|max_length[100]',
|
||||
'commission_amount' => 'decimal'
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
}
|
||||
190
app/Models/InvoiceModel.php
Normal file
190
app/Models/InvoiceModel.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class InvoiceModel extends Model
|
||||
{
|
||||
protected $table = 'partner_invoice';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'invoice_no',
|
||||
'invoice_amount',
|
||||
'agent_id',
|
||||
'invoice_date',
|
||||
'is_active',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'payout_status',
|
||||
];
|
||||
|
||||
// Timestamps
|
||||
protected $useTimestamps = false;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation (optional)
|
||||
protected $validationRules = [
|
||||
'invoice_no' => 'required|max_length[100]',
|
||||
'invoice_amount' => 'decimal',
|
||||
'agent_id' => 'required|integer',
|
||||
'invoice_date' => 'required|valid_date',
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
public function invoiceList($agent_id = null, $status_id = null, $start_date = null, $end_date = null)
|
||||
{
|
||||
$data = $this->select("
|
||||
partner_invoice.*,
|
||||
|
||||
-- Total UTR Amount
|
||||
(SELECT SUM(piu.amount)
|
||||
FROM partner_invoice_utr piu
|
||||
WHERE piu.invoice_id = partner_invoice.id
|
||||
AND piu.is_active = 1
|
||||
) AS total_utr_amount,
|
||||
|
||||
-- Balance Amount
|
||||
(partner_invoice.invoice_amount -
|
||||
IFNULL(
|
||||
(SELECT SUM(piu2.amount)
|
||||
FROM partner_invoice_utr piu2
|
||||
WHERE piu2.invoice_id = partner_invoice.id
|
||||
AND piu2.is_active = 1
|
||||
),
|
||||
0)
|
||||
) AS balance_amount,
|
||||
|
||||
-- Payout status
|
||||
CASE
|
||||
WHEN payout_status = 1 THEN 'Pending'
|
||||
WHEN payout_status = 2 THEN 'Complete'
|
||||
END AS status_text,
|
||||
|
||||
partner_agent.name as agent_name
|
||||
")
|
||||
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
|
||||
->where('partner_invoice.is_active', 1);
|
||||
|
||||
if(!empty($agent_id)){
|
||||
$data->where('partner_invoice.agent_id', $agent_id);
|
||||
}
|
||||
|
||||
if(!empty($status_id)){
|
||||
$data->where('partner_invoice.payout_status', $status_id);
|
||||
}
|
||||
|
||||
if (!empty($start_date) && !empty($end_date)) {
|
||||
|
||||
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
|
||||
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
|
||||
|
||||
$data->where('partner_invoice.invoice_date >=', $startDate)
|
||||
->where('partner_invoice.invoice_date <=', $endDate);
|
||||
}
|
||||
|
||||
if(!empty($agent_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');
|
||||
|
||||
$data->where('partner_invoice.created_at >=', $fromDate)
|
||||
->where('partner_invoice.created_at <=', $toDate);
|
||||
|
||||
}
|
||||
|
||||
$return_data = $data->orderBy('partner_invoice.id','desc')->findAll();
|
||||
|
||||
// print_r($this->db->getLastQuery()); die;
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
public function agentList()
|
||||
{
|
||||
return $this->db->table('partner_agent')->where('is_active', 1)->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function utrSummary($invoice_id)
|
||||
{
|
||||
$data = $this->select("
|
||||
|
||||
partner_invoice.*,
|
||||
|
||||
-- Total UTR Amount
|
||||
(SELECT SUM(piu.amount)
|
||||
FROM partner_invoice_utr piu
|
||||
WHERE piu.invoice_id = partner_invoice.id
|
||||
AND piu.is_active = 1
|
||||
) AS total_utr_amount,
|
||||
|
||||
-- Balance Amount
|
||||
(partner_invoice.invoice_amount -
|
||||
IFNULL(
|
||||
(SELECT SUM(piu2.amount)
|
||||
FROM partner_invoice_utr piu2
|
||||
WHERE piu2.invoice_id = partner_invoice.id
|
||||
AND piu2.is_active = 1
|
||||
),
|
||||
0)
|
||||
) AS balance_amount,
|
||||
|
||||
-- Payout status
|
||||
CASE
|
||||
WHEN payout_status = 1 THEN 'Pending'
|
||||
WHEN payout_status = 2 THEN 'Complete'
|
||||
END AS status_text,
|
||||
|
||||
partner_agent.name as agent_name
|
||||
")
|
||||
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
|
||||
->where('partner_invoice.is_active', 1)
|
||||
->where('partner_invoice.id', $invoice_id)
|
||||
->first();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
73
app/Models/InvoiceUtrModel.php
Normal file
73
app/Models/InvoiceUtrModel.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class InvoiceUtrModel extends Model
|
||||
{
|
||||
protected $table = 'partner_invoice_utr';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'invoice_id',
|
||||
'utr_no',
|
||||
'amount',
|
||||
'utr_date',
|
||||
'is_active',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by'
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
protected $validationRules = [
|
||||
'invoice_id' => 'required|integer',
|
||||
'utr_no' => 'required|max_length[100]',
|
||||
'amount' => 'decimal'
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ class TicketClaimStatusModel extends Model
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = ["id", "ticket_type", "claim_status", "created_by", "updated_by", "is_active"];
|
||||
protected $allowedFields = ["id", "ticket_type", "claim_status", "display_name", "created_by", "updated_by", "is_active"];
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
|
||||
357
app/Views/payout_list.php
Normal file
357
app/Views/payout_list.php
Normal file
@ -0,0 +1,357 @@
|
||||
<style>
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.right-align-input {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.badge-container {
|
||||
background: #F0F0F0;
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.summary-box {
|
||||
background: #e3f2fd;
|
||||
padding: 15px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 20px;
|
||||
border-left: 4px solid #2196F3;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
.summary-box {
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.summary-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summary-row:last-child {
|
||||
margin-bottom: 0;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid #2196F3;
|
||||
}
|
||||
|
||||
.summary-row {
|
||||
padding: 0px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summary-row span:last-child {
|
||||
font-weight: bold;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
.utr-section {
|
||||
margin-top: 15px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.utr-heading {
|
||||
margin-bottom: 10px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.utr-form-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.utr-label {
|
||||
font-size: 13px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.utr-small-text {
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.utr-submit-wrapper {
|
||||
margin-bottom: 10px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.utr-list {
|
||||
margin-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.utr-table {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.utr-table thead tr {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.utr-table tbody {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.utr-dropdown-item {
|
||||
font-size: 13px;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
|
||||
.utr-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#payout_modal .modal-body {
|
||||
max-height: 550px; /* adjust as needed */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.utr-table td,
|
||||
.utr-table th {
|
||||
padding: 3px 8px !important;
|
||||
vertical-align: middle;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.utr-table tbody tr {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.utr-table thead th {
|
||||
padding: 5px 8px !important;
|
||||
}
|
||||
|
||||
.utr-table .btn-sm {
|
||||
padding: 1px 6px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.utr-table .mdi {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.utr-table .dropdown-menu {
|
||||
min-width: 110px;
|
||||
}
|
||||
|
||||
.utr-dropdown-item {
|
||||
padding: 7px 10px !important;
|
||||
}
|
||||
|
||||
table[data-custom-table-css="table"] tbody tr td {
|
||||
padding: 1px 10px !important;
|
||||
line-height: 12px;
|
||||
min-height: 40px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 style="position: relative;">Payout List <span id="payout_title"></span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">Inovice No</th>
|
||||
<th class="font-weight-medium">Invoice Date</th>
|
||||
<th class="font-weight-medium">Invoice Amount</th>
|
||||
<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">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($payout_list_data) && !empty($payout_list_data)) { ?>
|
||||
<?php foreach($payout_list_data as $index => $row){ ?>
|
||||
<tr>
|
||||
<td> <?= $index + 1 ?> </td>
|
||||
<td> <?= $row['invoice_no'] ?> </td>
|
||||
<td> <?= change_date_format($row['invoice_no'], null, 'd-M-Y') ?? "" ?> </td>
|
||||
<td> <?= format_indian_number($row['invoice_amount']) ?> </td>
|
||||
<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>
|
||||
<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/save?type="edit"') ?>" 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/save?type="adjustment"') ?>" class="dropdown-item"><i class="mdi mdi-tune mr-2 text-muted font-18 vertical-middle"></i>Adjustment</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="payout_modal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-lg" style="max-width: 800px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: gainsboro;">
|
||||
<h5 class="modal-title" id="myCenterModalLabel">UTR <span id="heading"></span></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modal_body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
|
||||
<script>
|
||||
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 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
|
||||
buttons: [
|
||||
{
|
||||
extend: 'collection',
|
||||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||||
className: 'btn app-btn-secondary ',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
title: 'List',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
title: 'List',
|
||||
sheetName: 'Policy-Tranction-payout-List',
|
||||
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
||||
className: 'app-btn-primary ',
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
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
|
||||
});
|
||||
} else {
|
||||
console.error("Table atet found.");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function fetchUtrDetails(invoice_id, invoice_no)
|
||||
{
|
||||
if (!invoice_id) {
|
||||
toastr.warning("Invoice Id not found!", "WARNING");
|
||||
return false;
|
||||
}
|
||||
|
||||
let heading_text = ' - ( Invoice No : ' + invoice_no + ' )';
|
||||
|
||||
$('#modal_body').empty();
|
||||
$('#heading').text(heading_text);
|
||||
$('#modal_body').append('<div class="text-center p-5"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('payout_modal'));
|
||||
myModal.show();
|
||||
|
||||
let url = '<?= base_url('payout/fetchUtrDetails') ?>';
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
invoice_id: invoice_id,
|
||||
};
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
$('#modal_body').empty();
|
||||
$('#heading').text(heading_text);
|
||||
$('#modal_body').append(response.data);
|
||||
|
||||
if (response.status == false) {
|
||||
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while fetching the data.', 'ERROR');
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
184
app/Views/payout_list_handler.php
Normal file
184
app/Views/payout_list_handler.php
Normal file
@ -0,0 +1,184 @@
|
||||
<div class="container-fluid-min">
|
||||
<div class="col-12" id="bds_filter">
|
||||
<div class="card-body">
|
||||
<div id="accordion" class="mb-3">
|
||||
<div class="card mb-1">
|
||||
<h4 class="m-1">
|
||||
<span>Filter</span>
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
|
||||
aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</h4>
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<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>
|
||||
<?php if (isset($agent_list) && !empty($agent_list)) : ?>
|
||||
<?php foreach ($agent_list as $agent) : ?>
|
||||
<option value="<?= $agent['id']; ?>"><?= $agent['name']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch_id">Status<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="status_id" name="status_id">
|
||||
<option value="">Select status</option>
|
||||
<?php if (isset($payout_status) && !empty($payout_status)) : ?>
|
||||
<?php foreach ($payout_status as $id => $status) : ?>
|
||||
<option value="<?= $id; ?>"><?= $status; ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="display: true;" id="date_div">
|
||||
<label>Date<span class="text-danger"></span></label>
|
||||
<div class="input-icon">
|
||||
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
|
||||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||||
</div>
|
||||
<input type="hidden" id="startDate">
|
||||
<input type="hidden" id="endDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
|
||||
<a class="btn btn-secondary" id="clear-filters">Clear</a>
|
||||
<a class="btn btn-primary" id="get-emp-list" onclick="fetchPayoutList(this);">Submit</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div id="payout_list">
|
||||
<?php if(isset($payout_list) && !empty($payout_list)) { echo $payout_list; }else{ } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#agent_id').select2();
|
||||
$('#startDate').val('');
|
||||
$('#endDate').val('');
|
||||
$('#reportrange').val('');
|
||||
})
|
||||
|
||||
$(function() {
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
// Get start and end dates from URL parameters, or use default values
|
||||
const startDateParam = params.get('start_date') || moment().subtract(60, 'days').format('DD-MM-YYYY');
|
||||
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
||||
|
||||
// Parse the dates to moment objects
|
||||
var start = moment(startDateParam, 'DD-MM-YYYY');
|
||||
var end = moment(endDateParam, 'DD-MM-YYYY');
|
||||
|
||||
function cb(start, end) {
|
||||
$('#reportrange').val(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
$('#endDate').val(end.format('DD-MM-YYYY'));
|
||||
}
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
locale: {
|
||||
format: 'DD-MM-YYYY'
|
||||
},
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
autoUpdateInput: false
|
||||
}, cb);
|
||||
|
||||
// Only update inputs when user selects a date range
|
||||
$('#reportrange').on('apply.daterangepicker', function(ev, picker) {
|
||||
cb(picker.startDate, picker.endDate);
|
||||
});
|
||||
|
||||
$('#clear-filters').on('click', function() {
|
||||
// Reset all select dropdowns to the first option
|
||||
$('#agent_id').val('').change();
|
||||
$('#status_id').val('').change();
|
||||
|
||||
// Clear the date range inputs
|
||||
$('#reportrange').val('');
|
||||
$('#startDate').val('');
|
||||
$('#endDate').val('');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function fetchPayoutList()
|
||||
{
|
||||
let agent_id = $('#agent_id').val();
|
||||
let status_id = $('#status_id').val();
|
||||
let start_date = $('#startDate').val();
|
||||
let end_date = $('#endDate').val();
|
||||
|
||||
if (!agent_id && !status_id && !start_date && !end_date) {
|
||||
toastr.warning("Please select any one filter!", "WARNING");
|
||||
return false;
|
||||
}
|
||||
|
||||
let url = '<?= base_url('payout/list') ?>';
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
agent_id: agent_id,
|
||||
status_id: status_id,
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
};
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
$('#payout_list').empty();
|
||||
$('#payout_list').append(response.data);
|
||||
|
||||
if (response.status == false) {
|
||||
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('#payout_list').empty();
|
||||
$('#payout_list').append(response.data);
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while fetching the data.', 'ERROR');
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
280
app/Views/payout_utr_details.php
Normal file
280
app/Views/payout_utr_details.php
Normal file
@ -0,0 +1,280 @@
|
||||
<div>
|
||||
|
||||
<div class="summary-box">
|
||||
<div class="summary-row">
|
||||
<span>Invoice Amount:</span>
|
||||
<span id="utrInvoiceAmount" data-id="<?php echo isset($summary['invoice_amount']) && !empty($summary['invoice_amount']) ? $summary['invoice_amount'] : ""?>">
|
||||
₹<?php echo isset($summary['invoice_amount']) && !empty($summary['invoice_amount']) ? format_indian_number($summary['invoice_amount']) : "0.00"?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span>Total Paid:</span>
|
||||
<span id="utrTotalPaid" data-id="<?php echo isset($summary['total_utr_amount']) && !empty($summary['total_utr_amount']) ? $summary['total_utr_amount'] : ""?>">
|
||||
₹<?php echo isset($summary['total_utr_amount']) && !empty($summary['total_utr_amount']) ? format_indian_number($summary['total_utr_amount']) : "0.00"?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span>Remaining Balance:</span>
|
||||
<span id="utrRemaining" data-id="<?php echo isset($summary['balance_amount']) && !empty($summary['balance_amount']) ? $summary['balance_amount'] : ""?>">
|
||||
₹<?php echo isset($summary['balance_amount']) && !empty($summary['balance_amount']) ? format_indian_number($summary['balance_amount']) : "0.00"?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="utrContent">
|
||||
<div class="utr-section">
|
||||
<!-- <h5 class="utr-heading">Add New UTR</h5> -->
|
||||
<form id="utrForm" role="form" class="parsley-examples">
|
||||
<input type="hidden" name="utr_pk" id="utr_pk">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo isset($summary['id']) && !empty($summary['id']) ? $summary['id'] : ""?>">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group utr-form-group">
|
||||
<label class="utr-label">UTR Number <span class="text-danger">*</span></label>
|
||||
<input type="text" name="utr_no" id="utrNumber" class="form-control form-control-sm" placeholder="Enter UTR number" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group utr-form-group">
|
||||
<label class="utr-label">Amount (₹) <span class="text-danger">*</span></label>
|
||||
<input type="number" name="amount" id="utrAmount" oninput="checkSum(this)" class="form-control form-control-sm" step="0.01" placeholder="Enter amount" required>
|
||||
<!-- <small class="utr-small-text">
|
||||
Max: <span id="maxUtrAmount">₹0.00</span>
|
||||
</small> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group utr-form-group">
|
||||
<label class="utr-label">Date <span class="text-danger">*</span></label>
|
||||
<input type="text" name="utr_date" id="utrDate" class="form-control form-control-sm" placeholder="DD/MM/YYYY" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3" style="<?= !isset($invoice_completed) ? 'display: block;' : 'display: none;' ?>">
|
||||
<div class="form-group utr-submit-wrapper">
|
||||
<a onclick="resetvalues()" class="btn btn-secondary btn-sm">Clear</a>
|
||||
<button id="utr_submit_btn" onclick="saveUtrDetails(event)" class="btn btn-primary btn-sm">Add UTR</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="utr-list" id="utrList">
|
||||
<h5 class="utr-heading">Existing UTRs</h5>
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" id="ticket-table" class="table table-sm w-100 nowrap utr-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">UTR No</th>
|
||||
<th class="font-weight-medium">Amount</th>
|
||||
<th class="font-weight-medium">Date</th>
|
||||
<!-- <th class="font-weight-medium">User</th> -->
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($utr_list_data) && !empty($utr_list_data)) { ?>
|
||||
<?php foreach($utr_list_data as $index => $row){
|
||||
$row['utr_date'] = change_date_format($row['utr_date'], null, 'd/m/Y') ?? " - "
|
||||
?>
|
||||
<tr>
|
||||
<td> <?= $index + 1 ?> </td>
|
||||
<td> <?= $row['utr_no'] ?> </td>
|
||||
<td> <?= format_indian_number($row['amount']) ?> </td>
|
||||
<td> <?= $row['utr_date'] ?> </td>
|
||||
<!-- <td> <?php // format_indian_number($row['created_user']) ?> </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 style="<?= !isset($invoice_completed) ? 'display: block;' : 'display: none;' ?>" class="dropdown-item utr-dropdown-item" onclick='updateUtr(<?= htmlspecialchars(json_encode($row ?? []), ENT_QUOTES, "UTF-8") ?>)'><i class="mdi mdi-pencil mr-2 text-muted utr-icon vertical-middle"></i>Edit</a>
|
||||
<a class="dropdown-item utr-dropdown-item" onclick="removeUtrApi(<?php echo isset($summary['id']) && !empty($summary['id']) ? $summary['id'] : ''?>, <?= $row['id'] ?>)"><i class="mdi mdi-delete mr-2 text-muted utr-icon vertical-middle"></i>Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var dob = flatpickr("#utrDate", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
maxDate: "today"
|
||||
});
|
||||
|
||||
function saveUtrDetails(e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
console.log('saveUtrDetails function called');
|
||||
|
||||
var isValid = $('#utrForm').parsley().validate();
|
||||
if (!isValid) {
|
||||
$('#utrForm').find('input, select, textarea').each(function() {
|
||||
if ($(this).parsley().isValid() === false && !$(this).val()) {
|
||||
console.log(' :) Empty field ID:', this.id);
|
||||
}
|
||||
});
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = new FormData($('#utrForm')[0]);
|
||||
|
||||
// Show loading state
|
||||
$('#utr_submit_btn').prop('disabled', true).text('Saving...');
|
||||
|
||||
let url = '<?= base_url('payout/saveUtrDetails') ?>';
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
$('#modal_body').empty();
|
||||
$('#modal_body').append(response.data);
|
||||
}else{
|
||||
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
|
||||
}
|
||||
|
||||
// Re-enable button
|
||||
$('#utr_submit_btn').prop('disabled', false).text('Add UTR');
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while fetching the data.', 'ERROR');
|
||||
},
|
||||
complete: function() {
|
||||
$('#utr_submit_btn').prop('disabled', false).text('Add UTR');
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
resetvalues();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateUtr(data){
|
||||
console.log("data", data)
|
||||
if(data){
|
||||
$('#utr_pk').val(data.id);
|
||||
$('#utrNumber').val(data.utr_no);
|
||||
$('#utrAmount').val(data.amount);
|
||||
$('#utrDate').val(data.utr_date);
|
||||
$('#utr_submit_btn').text('Update UTR');
|
||||
$('#utrNumber').trigger('focus');
|
||||
}
|
||||
}
|
||||
|
||||
function resetvalues(){
|
||||
$('#utr_pk').val("");
|
||||
$('#utrNumber').val("");
|
||||
$('#utrAmount').val("");
|
||||
$('#utrDate').val("");
|
||||
$('#utr_submit_btn').text('Add UTR');
|
||||
}
|
||||
|
||||
function removeUtrApi(invoice_id, utr_id) {
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "Do you want to remove this UTR?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Yes, Proceed!",
|
||||
cancelButtonText: "Cancel"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
removeUtr(invoice_id, utr_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function removeUtr(invoice_id, utr_id){
|
||||
|
||||
let url = '<?= base_url('payout/removeUtrDetails') ?>';
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
invoice_id: invoice_id,
|
||||
utr_id: utr_id,
|
||||
};
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
$('#modal_body').empty();
|
||||
$('#modal_body').append(response.data);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
}else{
|
||||
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while fetching the data.', 'ERROR');
|
||||
});
|
||||
}
|
||||
|
||||
function checkSum(input) {
|
||||
|
||||
let invoice_amt = parseFloat($('#utrInvoiceAmount').data('id')) || 0;
|
||||
let utr_amt = parseFloat($('#utrTotalPaid').data('id')) || 0;
|
||||
let balance_amt = parseFloat($('#utrRemaining').data('id')) || 0;
|
||||
|
||||
let input_amt = parseFloat($(input).val()) || 0;
|
||||
|
||||
console.log({ invoice_amt, utr_amt, balance_amt, input_amt });
|
||||
|
||||
let total_amt = utr_amt + input_amt;
|
||||
|
||||
if (total_amt > invoice_amt) {
|
||||
toastr.warning('UTR amount exceeds the invoice amount');
|
||||
$(input).val('');
|
||||
$('#utr_submit_btn').prop('disabled', true);
|
||||
}else{
|
||||
$('#utr_submit_btn').prop('disabled', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user