Skip to content

Commit

Permalink
Merge pull request #1 from ECLK/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
arulcancan authored Mar 16, 2020
2 parents 227ee6b + 31d8cff commit e87e436
Show file tree
Hide file tree
Showing 28 changed files with 3,239 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ APP_KEY=base64:sBNbJThk+cKYWyRAisG8KYkFAkv527csvLTIMlRcP8I=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
NOMINETION_API=https://jsonplaceholder.typicode.com/users
NOMINETION_API=https://apim-gateway.ecdev.opensource.lk/nominations/0.9/
NOMINETION_API_KEY=45c03f99-c08c-39cb-a46b-ce3d322f0479

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
Expand Down
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/vendor/
node_modules/
npm-debug.log
yarn-error.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot

# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot

storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache
storage/framework/views/ae5a9a730500788d3a7068e5205c4fdaa854b85b.php
storage/logs/laravel.log
storage/logs/laravel.log
36 changes: 25 additions & 11 deletions app/Http/Controllers/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,47 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use GuzzleHttp\Client;

class FormController extends Controller
{
public function viewPE9()
{
$client = new Client();
$response = $client->request('GET', env('NOMINETION_API'));
$statusCode = $response->getStatusCode();
// $body = $response->getBody();
$client = resolve('nomination.client');
$response = $client->request('GET', 'teams');
$statusCode = $response->getStatusCode();
$body = $response->getBody()->getContents();
$obj = json_decode($body);
//dd($body);
return view('pe9')->with('Fdata',$obj);

}

public function viewPE30()
{
$client = new Client();
$response = $client->request('GET', env('NOMINETION_API'));
$client = resolve('nomination.client');
$response = $client->request('GET','elections/electionStatus/APPROVE');
$statusCode = $response->getStatusCode();
// $body = $response->getBody();
$body = $response->getBody()->getContents();
$obj = json_decode($body);
//dd($body);
return view('pe30x1x2')->with('Fdata',$obj);

}

public function getDistrict(Request $request){
$client = new Client();
$response = $client->request('GET', env('NOMINETION_API').'?id='.$request->id);
$statusCode = $response->getStatusCode();
$body = $response->getBody()->getContents();
$data = json_decode($body);
return response()->json($data);
}

public function getBallot(Request $request){
$client = new Client();
$response = $client->request('GET', env('NOMINETION_API'));
$statusCode = $response->getStatusCode();
$body = $response->getBody()->getContents();
$data = json_decode($body);
return response()->json($data);


}
}
23 changes: 23 additions & 0 deletions app/Providers/NominationClientServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use GuzzleHttp\Client;

class NominationClientServiceProvider extends ServiceProvider
{

public function register()
{
$this->app->bind('nomination.client', function () {
$config = [
'base_uri' => env('NOMINETION_API'),
'headers' => [
'Authorization' => 'Bearer ' . env('NOMINETION_API_KEY')
]
];
return new Client($config);
});
}
}
2 changes: 2 additions & 0 deletions bootstrap/cache/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
24 => 'App\\Providers\\AuthServiceProvider',
25 => 'App\\Providers\\EventServiceProvider',
26 => 'App\\Providers\\RouteServiceProvider',
27 => 'App\\Providers\\NominationClientServiceProvider',
),
'eager' =>
array (
Expand All @@ -45,6 +46,7 @@
11 => 'App\\Providers\\AuthServiceProvider',
12 => 'App\\Providers\\EventServiceProvider',
13 => 'App\\Providers\\RouteServiceProvider',
14 => 'App\\Providers\\NominationClientServiceProvider',
),
'deferred' =>
array (
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

App\Providers\NominationClientServiceProvider::class,
],

/*
Expand Down
Empty file modified readme.md
100755 → 100644
Empty file.
5 changes: 5 additions & 0 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<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">
<link href="https://fonts.googleapis.com/css?family=Lora:400,400i,700,700i" rel="stylesheet">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Custom styles for this template -->
<link href="css/business-casual.min.css" rel="stylesheet">

Expand Down Expand Up @@ -102,6 +104,9 @@
</div>
</footer>

@stack('scripts')


<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
Expand Down
110 changes: 91 additions & 19 deletions resources/views/pe30x1x2.blade.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
@extends('layout')
@section('content')

@php
$selec=0;
@endphp

<div class="container">
<div class="row justify-content-md-center">
<div class="col col-lg-3">
<form> <center>
<select class="custom-select custom-select-lg mb-3" id="election" name="election"onChange >
<select class="custom-select custom-select-lg mb-3" class="election" name="election"onChange >
<option value="0" disabled="true" selected="true">Select Election</option>
@foreach($Fdata as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
</div>
<div class="col col-lg-3">
<select class="custom-select custom-select-lg mb-3" id="district" name="district" >
<option value="pe">Select The District </option>
<option value="pre">PRE</option>
<option value="mc">MC</option>
<option value="r">R</option>

<select class="custom-select custom-select-lg mb-3" class="district" name="district" >
<option value="0" disabled="true" selected="true">Select District</option>
</select>

</div>
</div> </div>
<center>
<button type="button" class="btn btn-primary">Generate Report </button>
<Button type="button" class="btn btn-primary" id="bellot">Generate Report </Button>
</center>
</form>
</center>
Expand Down Expand Up @@ -49,25 +54,19 @@

</h5>
<p> Ballot Paper No:...............................................................................................................................................................................</p>
<table align="center" border="1" cellpadding="5" width="80%">
<table align="center" border="1" cellpadding="5" width="80%" id="tblBellot">
<thead>
<tr>
<th align="right"> Party Name</th>
<th align="left"> Symbol</th>
<th align="left"> No</th>
</tr>

@foreach($Fdata as $data)
<tr>
<td>{{$data->id}}</td>
<td>{{$data->name}}</td>
<td>{{$data->username}}</td>

</tr>
@endforeach
</thead>
<tbody>

</tbody>

</table >


<table align="center" border="1" cellpadding="5" width="80%">
<tr>
<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>
Expand All @@ -94,6 +93,79 @@
<center> <input class="btn btn-primary" type="button" onclick="printDiv('example')" value="Print Data" /> </center>
</section>

@push('scripts')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
// $(document).ready(function(){
// -------------------------Get District----------------------------------
$("select[name='election']").change(function () {
var elec_id=$(this).val();
var op=" ";
$.ajax({
type:'GET',
url:'{!!URL::to('getDistrict')!!}',
data:{'id':elec_id},
success:function(data){
op+='<option value="0" disabled="true" >Select District</option>';
for(var i=0;i<data.length;i++){
op+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
}
$("select[name='district']").html("");
$("select[name='district']").append(op);
},
error:function(){
}
});
});
// -------------------------Get Bellot----------------------------------
$("#bellot").click(function () {
var elec_id = $("select[name='election']").val();
var dist_id = $("select[name='district']").val();
var op=" ";
$.ajax({
type:'GET',
url:'{!!URL::to('getBallot')!!}',
data:{'elecid':elec_id,'disid':dist_id},
success:function(data){
for(var i=0;i<data.length;i++){
op+='<tr>';
op+='<td>'+data[i].id+'</td><td>'+data[i].name+'</td><td>'+data[i].username+'</td>';
op+='</tr>';
}
$("#tblBellot tbody").empty();
$("#tblBellot tbody").append(op);
},
error:function(){
}
});
});
// ---------------------------------------------------------------------
// });
</script>



@endpush



@endsection
62 changes: 62 additions & 0 deletions resources/views/text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@push('scripts')
<script>
//------------------------------------------------------------------------
$("select[name='election']").change(function () {
var election_id = $("select[name='election']").val();
if (election_id !== '' && election_id !== null) {
$("select[name='district']").prop('disabled',
false).find('option[value]').remove();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
method: 'POST',
url: '/getDistrict',
data: {id: election_id },
success: function(response){
$.each(response, function (key, value) {
$("select[name='district']")
.append($("<option></option>")
.attr("value", key)
.text(value));
});
},
error: function(response){
}
});
$.ajax({
type: 'POST',
url: {{ url('/getDistrict') }},
data: {id: election_id },
})
.done(function (data) {
$.each(data, function (key, value) {
$("select[name='district']")
.append($("<option></option>")
.attr("value", key)
.text(value));
});
})
.fail(function(jqXHR, textStatus){
console.log(jqXHR);
});
} else {
$("select[name='district']").prop('disabled',
true).find("option[value]").remove();
}
});
// ------------------------------------------------------------------------
</script>

@ndpush
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@
// ----------------------------------------------------
Route::get('/pe9', 'FormController@viewPE9');
Route::get('/pe30x1x2', 'FormController@viewPE30');
Route::get('/getDistrict', 'FormController@getDistrict');
Route::get('/getBallot', 'FormController@getBallot');

Original file line number Diff line number Diff line change
@@ -1 +1 @@
a:3:{s:6:"_token";s:40:"fE8w05ChkJnQ18hjzcwIBS8uJ04GUjqdZqDBVeEZ";s:9:"_previous";a:1:{s:3:"url";s:30:"http://localhost:8000/pe30x1x2";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}
a:3:{s:6:"_token";s:40:"ZIjByK6yKfQqSn74odE2bs6SFfLh1sv4mDDMPY98";s:9:"_previous";a:1:{s:3:"url";s:30:"http://localhost:8000/pe30x1x2";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}

This file was deleted.

This file was deleted.

Loading

0 comments on commit e87e436

Please sign in to comment.