Skip to content

Commit e87e436

Browse files
authored
Merge pull request #1 from ECLK/master
update
2 parents 227ee6b + 31d8cff commit e87e436

28 files changed

+3239
-44
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ APP_KEY=base64:sBNbJThk+cKYWyRAisG8KYkFAkv527csvLTIMlRcP8I=
44
APP_DEBUG=true
55
APP_LOG_LEVEL=debug
66
APP_URL=http://localhost
7-
NOMINETION_API=https://jsonplaceholder.typicode.com/users
7+
NOMINETION_API=https://apim-gateway.ecdev.opensource.lk/nominations/0.9/
8+
NOMINETION_API_KEY=45c03f99-c08c-39cb-a46b-ce3d322f0479
89

910
DB_CONNECTION=mysql
1011
DB_HOST=127.0.0.1

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/vendor/
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Laravel 4 specific
7+
bootstrap/compiled.php
8+
app/storage/
9+
10+
# Laravel 5 & Lumen specific
11+
public/storage
12+
public/hot
13+
14+
# Laravel 5 & Lumen specific with changed public path
15+
public_html/storage
16+
public_html/hot
17+
18+
storage/*.key
19+
.env
20+
Homestead.yaml
21+
Homestead.json
22+
/.vagrant
23+
.phpunit.result.cache
24+
storage/framework/views/ae5a9a730500788d3a7068e5205c4fdaa854b85b.php
25+
storage/logs/laravel.log
26+
storage/logs/laravel.log

app/Http/Controllers/FormController.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,47 @@
33
namespace App\Http\Controllers;
44

55
use Illuminate\Http\Request;
6-
use GuzzleHttp\Client;
76

87
class FormController extends Controller
98
{
109
public function viewPE9()
1110
{
12-
$client = new Client();
13-
$response = $client->request('GET', env('NOMINETION_API'));
14-
$statusCode = $response->getStatusCode();
15-
// $body = $response->getBody();
11+
$client = resolve('nomination.client');
12+
$response = $client->request('GET', 'teams');
13+
$statusCode = $response->getStatusCode();
1614
$body = $response->getBody()->getContents();
1715
$obj = json_decode($body);
18-
//dd($body);
1916
return view('pe9')->with('Fdata',$obj);
2017

2118
}
2219

2320
public function viewPE30()
2421
{
25-
$client = new Client();
26-
$response = $client->request('GET', env('NOMINETION_API'));
22+
$client = resolve('nomination.client');
23+
$response = $client->request('GET','elections/electionStatus/APPROVE');
2724
$statusCode = $response->getStatusCode();
28-
// $body = $response->getBody();
2925
$body = $response->getBody()->getContents();
3026
$obj = json_decode($body);
31-
//dd($body);
3227
return view('pe30x1x2')->with('Fdata',$obj);
33-
3428
}
29+
30+
public function getDistrict(Request $request){
31+
$client = new Client();
32+
$response = $client->request('GET', env('NOMINETION_API').'?id='.$request->id);
33+
$statusCode = $response->getStatusCode();
34+
$body = $response->getBody()->getContents();
35+
$data = json_decode($body);
36+
return response()->json($data);
37+
}
38+
39+
public function getBallot(Request $request){
40+
$client = new Client();
41+
$response = $client->request('GET', env('NOMINETION_API'));
42+
$statusCode = $response->getStatusCode();
43+
$body = $response->getBody()->getContents();
44+
$data = json_decode($body);
45+
return response()->json($data);
46+
47+
48+
}
3549
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
6+
use GuzzleHttp\Client;
7+
8+
class NominationClientServiceProvider extends ServiceProvider
9+
{
10+
11+
public function register()
12+
{
13+
$this->app->bind('nomination.client', function () {
14+
$config = [
15+
'base_uri' => env('NOMINETION_API'),
16+
'headers' => [
17+
'Authorization' => 'Bearer ' . env('NOMINETION_API_KEY')
18+
]
19+
];
20+
return new Client($config);
21+
});
22+
}
23+
}

bootstrap/cache/services.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
24 => 'App\\Providers\\AuthServiceProvider',
2929
25 => 'App\\Providers\\EventServiceProvider',
3030
26 => 'App\\Providers\\RouteServiceProvider',
31+
27 => 'App\\Providers\\NominationClientServiceProvider',
3132
),
3233
'eager' =>
3334
array (
@@ -45,6 +46,7 @@
4546
11 => 'App\\Providers\\AuthServiceProvider',
4647
12 => 'App\\Providers\\EventServiceProvider',
4748
13 => 'App\\Providers\\RouteServiceProvider',
49+
14 => 'App\\Providers\\NominationClientServiceProvider',
4850
),
4951
'deferred' =>
5052
array (

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
// App\Providers\BroadcastServiceProvider::class,
177177
App\Providers\EventServiceProvider::class,
178178
App\Providers\RouteServiceProvider::class,
179-
179+
App\Providers\NominationClientServiceProvider::class,
180180
],
181181

182182
/*

readme.md

100755100644
File mode changed.

resources/views/layout.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<link href="https://fonts.googleapis.com/css?family=Raleway:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
1818
<link href="https://fonts.googleapis.com/css?family=Lora:400,400i,700,700i" rel="stylesheet">
1919

20+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
21+
2022
<!-- Custom styles for this template -->
2123
<link href="css/business-casual.min.css" rel="stylesheet">
2224

@@ -102,6 +104,9 @@
102104
</div>
103105
</footer>
104106

107+
@stack('scripts')
108+
109+
105110
<!-- Bootstrap core JavaScript -->
106111
<script src="vendor/jquery/jquery.min.js"></script>
107112
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

resources/views/pe30x1x2.blade.php

Lines changed: 91 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
@extends('layout')
22
@section('content')
3+
4+
@php
5+
$selec=0;
6+
@endphp
7+
38
<div class="container">
49
<div class="row justify-content-md-center">
510
<div class="col col-lg-3">
611
<form> <center>
7-
<select class="custom-select custom-select-lg mb-3" id="election" name="election"onChange >
12+
<select class="custom-select custom-select-lg mb-3" class="election" name="election"onChange >
13+
<option value="0" disabled="true" selected="true">Select Election</option>
814
@foreach($Fdata as $data)
915
<option value="{{ $data->id }}">{{ $data->name }}</option>
1016
@endforeach
1117
</select>
1218
</div>
1319
<div class="col col-lg-3">
14-
<select class="custom-select custom-select-lg mb-3" id="district" name="district" >
15-
<option value="pe">Select The District </option>
16-
<option value="pre">PRE</option>
17-
<option value="mc">MC</option>
18-
<option value="r">R</option>
20+
21+
<select class="custom-select custom-select-lg mb-3" class="district" name="district" >
22+
<option value="0" disabled="true" selected="true">Select District</option>
1923
</select>
24+
2025
</div>
2126
</div> </div>
2227
<center>
23-
<button type="button" class="btn btn-primary">Generate Report </button>
28+
<Button type="button" class="btn btn-primary" id="bellot">Generate Report </Button>
2429
</center>
2530
</form>
2631
</center>
@@ -49,25 +54,19 @@
4954

5055
</h5>
5156
<p> Ballot Paper No:...............................................................................................................................................................................</p>
52-
<table align="center" border="1" cellpadding="5" width="80%">
57+
<table align="center" border="1" cellpadding="5" width="80%" id="tblBellot">
58+
<thead>
5359
<tr>
5460
<th align="right"> Party Name</th>
5561
<th align="left"> Symbol</th>
5662
<th align="left"> No</th>
5763
</tr>
58-
59-
@foreach($Fdata as $data)
60-
<tr>
61-
<td>{{$data->id}}</td>
62-
<td>{{$data->name}}</td>
63-
<td>{{$data->username}}</td>
64-
65-
</tr>
66-
@endforeach
64+
</thead>
65+
<tbody>
66+
67+
</tbody>
6768

6869
</table >
69-
70-
7170
<table align="center" border="1" cellpadding="5" width="80%">
7271
<tr>
7372
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
@@ -94,6 +93,79 @@
9493
<center> <input class="btn btn-primary" type="button" onclick="printDiv('example')" value="Print Data" /> </center>
9594
</section>
9695

96+
@push('scripts')
97+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
98+
<script>
99+
100+
// $(document).ready(function(){
101+
102+
// -------------------------Get District----------------------------------
103+
$("select[name='election']").change(function () {
104+
105+
var elec_id=$(this).val();
106+
var op=" ";
107+
108+
$.ajax({
109+
type:'GET',
110+
url:'{!!URL::to('getDistrict')!!}',
111+
data:{'id':elec_id},
112+
success:function(data){
113+
114+
op+='<option value="0" disabled="true" >Select District</option>';
115+
for(var i=0;i<data.length;i++){
116+
op+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
117+
118+
}
119+
$("select[name='district']").html("");
120+
$("select[name='district']").append(op);
121+
122+
},
123+
error:function(){
124+
125+
}
126+
});
127+
});
128+
129+
// -------------------------Get Bellot----------------------------------
130+
$("#bellot").click(function () {
131+
var elec_id = $("select[name='election']").val();
132+
var dist_id = $("select[name='district']").val();
133+
var op=" ";
134+
135+
$.ajax({
136+
type:'GET',
137+
url:'{!!URL::to('getBallot')!!}',
138+
data:{'elecid':elec_id,'disid':dist_id},
139+
success:function(data){
140+
141+
for(var i=0;i<data.length;i++){
142+
143+
op+='<tr>';
144+
op+='<td>'+data[i].id+'</td><td>'+data[i].name+'</td><td>'+data[i].username+'</td>';
145+
op+='</tr>';
146+
147+
}
148+
$("#tblBellot tbody").empty();
149+
$("#tblBellot tbody").append(op);
150+
151+
},
152+
error:function(){
153+
154+
}
155+
});
156+
});
157+
158+
// ---------------------------------------------------------------------
159+
160+
161+
// });
162+
163+
</script>
164+
165+
166+
167+
@endpush
168+
97169

98170

99171
@endsection

resources/views/text.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@push('scripts')
2+
<script>
3+
//------------------------------------------------------------------------
4+
$("select[name='election']").change(function () {
5+
var election_id = $("select[name='election']").val();
6+
if (election_id !== '' && election_id !== null) {
7+
$("select[name='district']").prop('disabled',
8+
false).find('option[value]').remove();
9+
10+
$.ajaxSetup({
11+
headers: {
12+
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
13+
}
14+
});
15+
16+
$.ajax({
17+
method: 'POST',
18+
url: '/getDistrict',
19+
data: {id: election_id },
20+
21+
success: function(response){
22+
$.each(response, function (key, value) {
23+
$("select[name='district']")
24+
.append($("<option></option>")
25+
.attr("value", key)
26+
.text(value));
27+
});
28+
},
29+
error: function(response){
30+
31+
}
32+
});
33+
34+
$.ajax({
35+
type: 'POST',
36+
url: {{ url('/getDistrict') }},
37+
data: {id: election_id },
38+
})
39+
.done(function (data) {
40+
$.each(data, function (key, value) {
41+
$("select[name='district']")
42+
.append($("<option></option>")
43+
.attr("value", key)
44+
.text(value));
45+
});
46+
})
47+
.fail(function(jqXHR, textStatus){
48+
console.log(jqXHR);
49+
});
50+
51+
52+
} else {
53+
$("select[name='district']").prop('disabled',
54+
true).find("option[value]").remove();
55+
}
56+
});
57+
// ------------------------------------------------------------------------
58+
</script>
59+
60+
61+
62+
@ndpush

0 commit comments

Comments
 (0)