Commit 30d354c5 authored by Michael Ngei's avatar Michael Ngei

Merge branch 'iprsv2_mike' into 'master'

Iprsv2 mike

See merge request !25
parents 559c6ca4 0e4b99ea
......@@ -21,3 +21,4 @@ supervisord.pid
supervisord.log
worker.log
composer.lock
/config
......@@ -104,13 +104,10 @@ class PaymentsAPI extends Controller
$consumer_name = str_replace( ' ', '_', strtoupper($contract->client->name_sh));
//$res=Redis::set('name', 'mikee');
//$checkKey = Redis::get('search_quota:countsse:user23');
try{
if (Redis::exists("search_quota:max:".$consumer_name)) {
$tokens = $validated['tokens'];
$maxToken = Redis::get("search_quota:max:".$consumer_name);
// added tokens
$newMax = $tokens + $maxToken;
//set tokens
......@@ -126,11 +123,16 @@ class PaymentsAPI extends Controller
'contract_id' => $validated['contract_id'],
'USER_ID' => $validated['user_id'],
]);
//update tokens
Tokens::where('contract_id', $validated['contract_id'])->update([
'total_tokens' => $newMax,
]);
// Return success JSON response
return response()->json([
'success' => true,
'message' => 'Payment created successfully',
$this->jsonData,
], 201);
}
}else{
......@@ -148,7 +150,6 @@ class PaymentsAPI extends Controller
return response()->json([
'success' => true,
'message' => 'Payment created successfully',
$this->jsonData,
], 201);
}
}catch (\Predis\Connection\ConnectionException $redisException) {
......@@ -234,7 +235,6 @@ class PaymentsAPI extends Controller
]
]);
if ($response->successful()) {
//save it locally
$tokens = Tokens::create([
'TOTAL_TOKENS' => $tokens,
'contract_id' => $cid,
......
......@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Models\Client;
use App\Models\Contract;
use App\Models\Tokens;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
......@@ -29,12 +31,27 @@ class TokensController extends Controller
}
} while ($cursor !== '0');
dd($searchQuotas);
$counts = [];
foreach ($searchQuotas as $key => $value) {
if (str_contains($key, 'search_quota:count:')) {
$clientName = str_replace('search_quota:count:', '', $key);
$counts[$clientName] = $value;
}
}
// Update the Tokens table
foreach ($counts as $clientName => $usedTokens) {
$clients_found = Client::where('name_sh', $clientName)->first();
if($clients_found){
$contract = Contract::where('client_rid', $clients_found->rid)->first();
if ($contract) {
$updated = Tokens::where('CONTRACT_ID', $contract->rid)->update(['USED_TOKENS' => $usedTokens]);
}
}
}
$tokens = Tokens::with('contract.client')->get();
return view('tokens.tokens', [
'tokens' => $tokens,
'searchQuotas' => $searchQuotas
]);
}
/* public function index()
......
......@@ -15,12 +15,13 @@ class BirthModal extends Component
{
protected $listeners = ['openBirthModal'];
public $human;
public $birth_human;
public $hasRole = false;
public $role;
public $isOpen = false;
public $docums;
public $serialNum='';
public $birth_docums;
public $birth_serialNum='';
public $birth_familyrelation;
public function mount()
{
/** @var Auth $user current logged-in user */
......@@ -46,15 +47,14 @@ class BirthModal extends Component
public function openBirthModal($data): void
{
$entryNum= $data['entry_num'];
$birth_human = $this->getHumanBirth($entryNum);
if($birth_human){
$this->human = $birth_human[0];
$this->docums = $birth_human[1];
$this->familyrelation = $birth_human[2];
$this->serialNum = $data['entry_num'];
}
$birth= $this->getHumanBirth($entryNum);
if($birth){
$this->birth_human = $birth[0];
$this->birth_docums = $birth[1];
$this->birth_familyrelation = $birth[2];
$this->isOpen = true;
$this->birth_serialNum = $data['entry_num'];
}
}
/*public function placeholder()
......@@ -63,7 +63,7 @@ class BirthModal extends Component
}*/
public function closeModal()
{
$this->isOpen = false;
// $this->isOpen = false;
}
private function getHumanBirth($entry_num)
......
......@@ -72,7 +72,9 @@ class Searchform extends Component
break;
case 'Birth' :
if(!empty($this->searchBirthEntryNum)){
$this->search_count = 0;
$this->getBirthHuman();
}else{
session()->flash('error', 'Birth entry number not provided');
}
......@@ -235,23 +237,33 @@ class Searchform extends Component
}else{
session()->flash('error', 'Search parameter is missing..');
}*/
$rid = Docum::where('ser_num', '=', $this->searchBirthEntryNum)->value('rid_h');
if(!empty($this->searchBirthEntryNum)) {
$this->search_count=1;
$this->records_found=[];
$this->records_not_found=[];
$this->doctype ='Birth';
if($rid){
$human = Human::where('rid','=', $rid)->whereColumn('rid', 'pid')
$rid = Docum::where('ser_num', '=', $this->searchBirthEntryNum)->value('rid_h');
if ($rid) {
$human = Human::where('rid', '=', $rid)->whereColumn('rid', 'pid')
->get(['rid', 'pid', 'name', 'surn', 'last_name', 'sex', 'date_birth', 'date_death', 'o_pid']);
// dd($human);
if($human->isEmpty()){
if ($human->isEmpty()) {
throw new ModelNotFoundException('No record found');
}else{
$this->search_count=1;
$this->doctype ='Birth';
$this->records_found[]=$this->searchBirthEntryNum;
$this->serial_number[]=$this->searchBirthEntryNum;
$this->humans[] = $human;
} else {
$this->records_found[] = $this->searchBirthEntryNum;
$this->serial_number[] = $this->searchBirthEntryNum;
$this->humans = $human;
$this->showTableResults();
/* $this->dispatch('viewResults', $this->humans,$this->serial_number,
$this->doctype,$this->records_not_found,
$this->search_count,$this->records_found);*/
}
}
}else{
session()->flash('error', 'Search parameter is missing..');
}
}
/**
......@@ -260,6 +272,7 @@ class Searchform extends Component
*/
public function showTableResults(): void
{
$this->dispatch('viewResults', $this->humans,$this->serial_number,
$this->doctype,$this->records_not_found,
$this->search_count,$this->records_found);
......
......@@ -12,6 +12,7 @@ class Tableresult extends Component
protected $human=[];
public $records_not_found=[];
public $search_count=0;
public $records_found= [];
......@@ -51,7 +52,7 @@ class Tableresult extends Component
$this->dispatch('openPassportModal', ['id'=>$id,'pass_no'=>$pass_no,'doctype'=>$doctype]);
}
public function birthresultsModal($entry_num): void
public function birthresultsModal($entry_num)
{
$decodedId = urldecode($entry_num);
$this->dispatch('openBirthModal', ['entry_num' => $decodedId ]);
......@@ -59,6 +60,7 @@ class Tableresult extends Component
public function render()
{
\Log::info('Rendering Tableresult');
return view('livewire.search.tableresult');
}
/* public function placeholder()
......
......@@ -6,9 +6,9 @@
$modalStatus= 'show';
$modalStyle="display: block;";
}
$fname = $human['name'] ?? '';
$oname = $human['last_name'] ?? '';
$surname = $human['surn'] ?? '';
$fname = $birth_human['name'] ?? '';
$oname = $birth_human['last_name'] ?? '';
$surname = $birth_human['surn'] ?? '';
@endphp
......
......@@ -9,17 +9,17 @@
<div class="row" style="width: 100%;">
@if($role->hasPermissionTo("Basic View Birth Details"))
<div class="col-12 text-center">
@if(isset($human))
@if(isset($birth_human))
<small class="">Birth Entry Number</small>
<h4 class="upi">
{{ $docums[0]['SER_NUM'] }}
{{ $birth_docums[0]['SER_NUM'] }}
</h4>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</div>
<div class="col-12 text-center">
@if(isset($human))
@if(isset($birth_human))
<small class="">Country of Birth</small>
<p class="card-text">{{ $human->birth_country }}</p>
<span class="fi fi-ke" style="font-size: 2rem;"></span>
......@@ -40,24 +40,24 @@
<div class="row">
<div class="col-6">
<small>First name</small>
@if(isset($human->name))
<p class="field-value">{{ $human->name }}</p>
@if(isset($birth_human->name))
<p class="field-value">{{ $birth_human->name }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</div>
<div class="col-6">
<small>Surname</small>
@if(isset($human->surn))
<p class="field-value">{{ $human->surn }}</p>
<small>Sur name</small>
@if(isset($birth_human->surn))
<p class="field-value">{{ $birth_human->surn }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</div>
<div class="col-6">
<small>Other name</small>
@if(isset($human->last_name))
<p class="field-value">{{ $human->last_name }}</p>
@if(isset($birth_human->last_name))
<p class="field-value">{{ $birth_human->last_name }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
......@@ -66,16 +66,16 @@
</div>
<div class="col-6">
<small>Date of Birth</small>
@if(isset($human->date_birth))
<p class="field-value">{{ Carbon::parse($human->date_birth)->format("d-m-Y") }}</p>
@if(isset($birth_human->date_birth))
<p class="field-value">{{ Carbon::parse($birth_human->date_birth)->format("d-m-Y") }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</div>
<div class="col-6">
<small>Gender</small>
@if(isset($human->sex))
<p class="field-value">{{ $human->sex }}</p>
@if(isset($birth_human->sex))
<p class="field-value">{{ $birth_human->sex }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
......@@ -89,10 +89,10 @@
<div class="row">
<div class="col-8">
<small>Mother</small>
@if(isset($docums[0]['M_NAME']))
@if(isset($birth_docums[0]['M_NAME']))
<p class="field-value">
<i class="fas fa-female" style="color: #008500;"></i>
{{ $docums[0]['M_NAME'] }} {{ $docums[0]['M_OTHNAME'] }} {{ $docums[0]['M_SURN'] }}
{{ $birth_docums[0]['M_NAME'] }} {{ $birth_docums[0]['M_OTHNAME'] }} {{ $birth_docums[0]['M_SURN'] }}
</p>
@else
<div class="skeleton skeleton-text short"></div>
......@@ -101,9 +101,9 @@
@if($role->hasPermissionTo("Basic View Birth Mother ID number"))
<div class="col-4">
<small>ID no.</small>
@if(isset($docums[0]['MOTHER_DOC_NUMBER']))
@if(isset($birth_docums[0]['MOTHER_DOC_NUMBER']))
<p class="field-value">
{{ $docums[0]['MOTHER_DOC_NUMBER'] }}
{{ $birth_docums[0]['MOTHER_DOC_NUMBER'] }}
</p>
@else
<div class="skeleton skeleton-text short"></div>
......@@ -112,10 +112,10 @@
@endif
<div class="col-8">
<small>Father</small>
@if(isset($docums[0]['F_NAME']))
@if(isset($birth_docums[0]['F_NAME']))
<p class="field-value">
<i class="fas fa-male" style="color: #008500;"></i>
{{ $docums[0]['F_NAME'] }} {{ $docums[0]['F_OTHNAME'] }} {{ $docums[0]['F_SURN'] }}
{{ $birth_docums[0]['F_NAME'] }} {{ $birth_docums[0]['F_OTHNAME'] }} {{ $birth_docums[0]['F_SURN'] }}
</p>
@else
<div class="skeleton skeleton-text short"></div>
......@@ -123,7 +123,7 @@
</div>
@if($role->hasPermissionTo("Basic View Birth Father ID number"))
<div class="col-4">
@if(isset($docums[0]['F_NAME']))
@if(isset($birth_docums[0]['F_NAME']))
<small>ID no.</small>
-
@endif
......@@ -138,8 +138,8 @@
<div class="row">
<div class="col-6">
<small>District</small>
@if(isset($human->addressBirth->adresComp))
<p class="field-value">{{ $human->addressBirth->adresComp->name }}</p>
@if(isset($birth_human->addressBirth->adresComp))
<p class="field-value">{{ $birth_human->addressBirth->adresComp->name }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
......@@ -171,36 +171,38 @@
<x-adminlte-datatable id="clients-table searchResultsCard" :heads="$headings">
<tr>
<td>
@if(isset($docums[0]['O_PID']))
<p class="field-value">{{ $docums[0]['O_PID'] }}</p>
@if(isset($birth_docums[0]['O_PID']))
<p class="field-value">{{ $birth_docums[0]['O_PID'] }}</p>
@else
-
@endif
</td>
<td>
@if(isset($docums[0]['SER_NUM']))
<p class="field-value">{{ $docums[0]['SER_NUM'] }}</p>
@if(isset($birth_docums[0]['SER_NUM']))
<p class="field-value">{{ $birth_docums[0]['SER_NUM'] }}</p>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</td>
<td>
@if(isset($docums[0]['O_DATE']))
{{ Carbon::parse($human->data_scan)->format("d-m-Y") }}
@if(isset($birth_docums[0]['O_DATE']))
{{ Carbon::parse($birth_human->data_scan)->format("d-m-Y") }}
@else
<div class="skeleton skeleton-text short"></div>
@endif
</td>
<td>
@if(isset($docums[0]['SER_NUM']))
@if(isset($birth_docums[0]['SER_NUM']))
<span class="badge badge-success">
<i class="fa fa-check-circle"></i>Current</span>
<i class="fa fa-check-circle"></i>
Current
</span>
@else
<div class="skeleton skeleton-text short"></div>
@endif
</td>
</tr>
@if(isset($docums))<p>Replaced: <strong>{{ count($docums)-1 }}</strong> times</p>@endif
@if(isset($birth_docums))<p>Replaced: <strong>{{ count($birth_docums)-1 }}</strong> times</p>@endif
</x-adminlte-datatable>
</div>
</div>
......
......@@ -12,28 +12,28 @@
<div class="col-3">
<small>PIN</small>
<p class="field-value user-field-data">
{{ $human->pid ?? '-' }}
{{ $birth_human->pid ?? '-' }}
</p>
</div>
<div class="col-3">
<small>First name</small>
<p class="field-value user-field-data">
{{ $human->name ?? '-' }}
{{ $birth_human->name ?? '-' }}
</p>
</div>
<div class="col-3">
<small>Other names</small>
<p class="field-value user-field-data">
{{ $human->last_name ?? '-' }}
{{ $birth_human->last_name ?? '-' }}
</p>
</div>
<div class="col-3">
<small>Sur name</small>
<p class="field-value user-field-data">
{{ $human->surn ?? '-' }}
{{ $birth_human->surn ?? '-' }}
</p>
</div>
......@@ -43,20 +43,20 @@
<div class="col-3">
<small>ID Number</small>
<p class="field-value user-field-data">
{{ $human->o_pid ?? '-' }}
{{ $birth_human->o_pid ?? '-' }}
</p>
</div>
<div class="col-3">
<small>Gender</small>
<p class="field-value user-field-data">
{{ $human->sex ?? '-' }}
{{ $birth_human->sex ?? '-' }}
</p>
</div>
<div class="col-3">
<small>Date of Birth</small>
<p class="field-value user-field-data">
@if(isset($human->date_birth))
{{ Carbon::parse($human->date_birth)->format("d-m-Y") }}
@if(isset($birth_human->date_birth))
{{ Carbon::parse($birth_human->date_birth)->format("d-m-Y") }}
@else
-
@endif
......
@php use Carbon\Carbon;
@php
use Carbon\Carbon;
$currentDate = Carbon::now()->format('d-m-Y');
@endphp
@foreach($passport as $human_passport)
......@@ -14,8 +16,6 @@
@endif
</x-adminlte-card>
<div class="row" style="width: 100%;">
@if($role->hasPermissionTo("Basic View ID Details"))
<div class="col-12 text-center">
@if(isset($human_passport->identity_card_no))
......@@ -168,14 +168,31 @@
<td>
@if(isset($human_passport->expiry_date))
<p class="field-value">{{ Carbon::parse($human_passport->expiry_date)->format("d-m-Y") }}</p>
@php
$doc_date = Carbon::parse($human_passport->expiry_date)->format("d-m-Y") ?? '';
@endphp
@else
-
@endif
</td>
<td>
@if(isset($human_passport->expiry_date))
<span class="badge badge-secondary">
<i class="fa fa-check-circle"></i>Current</span>
@if ($doc_date < $currentDate)
<h4>
<span class="badge badge-danger">
EXPIRED
</span>
</h4>
@else
<h4>
<span class="badge badge-success">
<i class="fa fa-check-circle"></i>
Current
</span>
</h4>
@endif
@else
<div class="skeleton skeleton-text short"></div>
@endif
......@@ -188,13 +205,7 @@
</div>
<style>
.idDocimg{
background-image:url("../images/national_ID.png");
background-size: 30rem;
width: 80vw;
height: 25vh;
background-repeat: no-repeat
}
.skeleton-img{
padding: 8rem;
}
......
......@@ -6,12 +6,13 @@
$modalStatus= 'show';
$modalStyle="display: block;";
}
$fname = $passport['first_names'] ?? '';
$sname = $passport['last_name'] ?? '';
$fname = $passport[0]['first_names'] ?? '';
$sname = $passport[0]['last_name'] ?? '';
@endphp
<x-adminlte-modal id="searchModalPassport" class="{{ $modalStatus }}" style="{{ $modalStyle }}" size="lg" title="Passport Details: {{ $fname }} {{ $sname }}" v-centered static-backdrop scrollable>
<x-adminlte-modal id="searchModalPassport" class="{{ $modalStatus }}" style="{{ $modalStyle }}" size="lg"
title="Passport for: {{ $fname }} {{ $sname }}" v-centered static-backdrop scrollable>
<div class="modal-body">
<ul class="nav nav-tabs" id="custom-tabs-four-tab" role="tablist">
......
......@@ -40,7 +40,7 @@
<div class="row">
<x-adminlte-card theme="lightblue" theme-mode="outline">
<div>
<h5>Searched for: {{ $doctype }} record.</h5>
<h5>Searched for: <strong>{{ $doctype }} </strong></h5>
<small>Requested: </small>
<strong>{{ $search_count }} Record(s)</strong>
</div>
......@@ -88,7 +88,23 @@
default:
$docNumTitle='Doc Number';
}
if($doctype === 'ID')
{
$headings = [
'Maisha Num.',
'Serial Num.',
'First Name',
'Other Name',
'Sur Name',
'Nationality',
'Gender',
'Date of Birth',
'Date of Issue',
'Date of Expiry',
'Action'
];
$count=0;
}
if($doctype === 'Passport')
{
$headings = [
......@@ -104,17 +120,17 @@
'Action'
];
$count=0;
} else{
}
if($doctype === 'Birth') {
$headings = [
'ID number',
$docNumTitle,
'Entry Number',
'First name',
'Other names',
'Sur name',
'Nationality',
'COB',
'Gender',
'Date of birth',
'Action'
'Details'
];
$count=0;
}
......@@ -123,31 +139,27 @@
<x-adminlte-datatable id="clients-table searchResultsCard" :heads="$headings" striped hoverable bordered>
@foreach($humans as $human)
@if($doctype === 'Birth')
<tr>
<td>
<h4 class="text-black">{{ $doc_human['o_pid'] ?? '-' }}</h4>
</td>
<td>
<h4 class="text-info">{{ $serial_number[$count] ?? '-' }}</h4>
</td>
<td>
{{ $doc_human['name'] ?? '-' }}
{{ $human['name'] ?? '-' }}
</td>
<td>
{{ $doc_human['last_name'] ?? '-' }}
{{ $human['last_name'] ?? '-' }}
</td>
<td>
{{ $doc_human['surn'] ?? '-' }}
{{ $human['surn'] ?? '-' }}
</td>
<td>
KENYAN <span class="fi fi-ke" style="font-size: 1rem;"></span>
KEN
</td>
<td>
{{ $doc_human['sex'] ?? '-' }}
{{ $human['sex'] ?? '-' }}
</td>
<td></td>
<td> {{ Carbon::parse($human['date_birth'])->format("d-m-Y") ?? '-' }}</td>
<td>
<x-adminlte-button
label="Details"
......@@ -226,7 +238,7 @@
{{ $doc_human['surn'] ?? '-' }}
</td>
<td>
KENYAN <span class="fi fi-ke" style="font-size: 1rem;"></span>
KEN <span class="fi fi-ke" style="font-size: 1rem;"></span>
</td>
<td>
{{ $doc_human['sex'] ?? '-' }}
......@@ -234,6 +246,12 @@
<td>
{{ Carbon::parse($doc_human['date_birth'])->format("d-m-Y") ?? '-' }}
</td>
<td>
-
</td>
<td>
-
</td>
<td>
<x-adminlte-button
label="Details"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment