@extends('admin.template')
@section('content')
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title-box" id="total">
                        <h2>Total Verified: {{$verified}}</h2>
                        <br>
                        <h2>Total Voted:  {{$total_voted}}</h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@push('dash-script')

    <script type="text/javascript" src="{{asset('admin/js/plugins/jquery/jquery.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/jquery/jquery-ui.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/bootstrap/bootstrap.min.js')}}"></script>

    <script type='text/javascript' src="{{asset('admin/js/plugins/icheck/icheck.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/mcustomscrollbar/jquery.mCustomScrollbar.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/scrolltotop/scrolltopcontrol.js')}}"></script>

    <script type="text/javascript" src="{{asset('admin/js/plugins/morris/raphael-min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/morris/morris.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/rickshaw/d3.v3.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/rickshaw/rickshaw.min.js')}}"></script>
    <script type='text/javascript' src="{{asset('admin/js/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js')}}"></script>
    <script type='text/javascript' src="{{asset('admin/js/plugins/jvectormap/jquery-jvectormap-world-mill-en.js')}}"></script>
    <script type='text/javascript' src="{{asset('admin/js/plugins/bootstrap/bootstrap-datepicker.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/owl/owl.carousel.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/moment.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/plugins/daterangepicker/daterangepicker.js')}}"></script>

    {{--<script type="text/javascript" src="{{asset('admin/js/settings.js')}}"></script>--}}
    <script type="text/javascript" src="{{asset('admin/js/plugins.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/actions.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/demo_dashboard.js')}}"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>


    <script>
        var ctx1 = document.getElementById("myChart1");
        var ctx2 = document.getElementById("myChart2");
        var ctx3 = document.getElementById("myChart3");
        var ctx4 = document.getElementById("myChart4");
        var ctx5 = document.getElementById("myChart5");
        var ctx6 = document.getElementById("myChart6");
        var ctx7 = document.getElementById("myChart7");
        var ctx8 = document.getElementById("myChart8");

        $.get('{{route('graph.results')}}',function (result) {
            console.log(result)
            var myDoughnutChart1 = new Chart(ctx1, {
                type: 'bar',
                data : {
                    datasets: [{
                        label: '# of Votes',
                        data: result.output,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)']
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },


                    title: {
                        display: true,
                        text: 'Receive and consider the audited Financial Statements and reports for 2019'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart2 = new Chart(ctx2, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output2,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Re-elect Olumide Olatunji as Managing Director'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                },
            });
            var myDoughnutChart3 = new Chart(ctx3, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output3,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Re-elect Abena Amoah'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart4 = new Chart(ctx4, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output4,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Re-elect Dela Selormey'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart5 = new Chart(ctx5, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output5,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Re-elect Dolapo Ogundimu'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart6 = new Chart(ctx6, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output6,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Re-elect Ernest Mintah'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart7 = new Chart(ctx7, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output7,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Authorize directors to fix the fees of auditors'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });
            var myDoughnutChart8 = new Chart(ctx8, {
                type: 'bar',
                data : {
                    datasets: [{
                        data: result.output8,
                        backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                    }],


                    labels: [
                        'For',
                        'Against',
                        'Abstain',
                    ],

                },
                options: {
                    legend: {
                        display: false,
                        labels: {
                            fontColor: 'white'
                        }
                    },

                    title: {
                        display: true,
                        text: 'Approve renumeration of directors'
                    },
                    scales: {
                        xAxes: [{
                            stacked: true
                        }],
                        yAxes: [{
                            stacked: true
                        }]
                    }
                }
            });

        });


        function ajaxRefresh()
        {
            $.get('results',function (result) {
                console.log(result);
                var myDoughnutChart1 = new Chart(ctx1, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            label: '# of Votes',
                            data: result.output,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Receive and consider the audited Financial Statements and reports for 2019'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart2 = new Chart(ctx2, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output2,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },

                        title: {
                            display: true,
                            text: 'Re-elect Olumide Olatunji as Managing Director'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart3 = new Chart(ctx3, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output3,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },

                        title: {
                            display: true,
                            text: 'Re-elect Abena Amoah'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart4 = new Chart(ctx4, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output4,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Re-elect Dela Selormey'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart5 = new Chart(ctx5, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output5,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Re-elect Dolapo Ogundimu'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart6 = new Chart(ctx6, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output6,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Re-elect Ernest Mintah'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart7 = new Chart(ctx7, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output7,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Authorize directors to fix the fees of auditors'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });
                var myDoughnutChart8 = new Chart(ctx8, {
                    type: 'bar',
                    data : {
                        datasets: [{
                            data: result.output8,
                            backgroundColor:['rgb(0,128,0,0.9)','rgb(255,0,0,0.9)','rgb(255,165,0)' ]
                        }],


                        labels: [
                            'For',
                            'Against',
                            'Abstain',
                        ],

                    },
                    options: {
                        legend: {
                            display: false,
                            labels: {
                                fontColor: 'white'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Approve renumeration of directors'
                        },
                        scales: {
                            xAxes: [{
                                stacked: true
                            }],
                            yAxes: [{
                                stacked: true
                            }]
                        }
                    }
                });

            });
        }

        setInterval( ajaxRefresh, 10000);
    </script>



    <script>

        function ajaxReload()
        {
            $.get('{{route('graph.top.results')}}',function (data) {

                $('#total').html('<h2>Total Verified: '+data.verified+'</h2> <br> <h2>Total Voted:  '+data.total+'</h2>')

                $('#box1').html('<h3>Receive and consider the audited Financial Statements and reports for 2019</h3><br>\n' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output1.for+'% &nbsp; &nbsp; '+data.output1.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output1.against+'% &nbsp; &nbsp; '+data.output1.against_total+' Votes</span> <hr>\n' +
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output1.abstain+'% &nbsp; &nbsp; '+data.output1.abstain_total+' Votes</span>');

                $('#box2').html('<h3>Re-elect Olumide Olatunji as Managing Director</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output2.for+'% &nbsp; &nbsp; '+data.output2.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output2.against+'% &nbsp; &nbsp; '+data.output2.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output2.abstain+'% &nbsp; &nbsp; '+data.output2.abstain_total+' Votes</span>');

                $('#box3').html('<h3>Re-elect Abena Amoah</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output3.for+'% &nbsp; &nbsp; '+data.output3.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output3.against+'% &nbsp; &nbsp; '+data.output3.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output3.abstain+'% &nbsp; &nbsp; '+data.output3.abstain_total+' Votes</span>');

                $('#box4').html('<h3>Re-elect Dela Selormey</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output4.for+'% &nbsp; &nbsp; '+data.output4.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output4.against+'% &nbsp; &nbsp; '+data.output4.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output4.abstain+'% &nbsp; &nbsp; '+data.output4.abstain_total+' Votes</span>');

                $('#box5').html('<h3>Re-elect Dolapo Ogundimu</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output5.for+'% &nbsp; &nbsp; '+data.output5.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output5.against+'% &nbsp; &nbsp; '+data.output5.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output5.abstain+'% &nbsp; &nbsp; '+data.output5.abstain_total+' Votes</span>');

                $('#box6').html('<h3>Re-elect Ernest Mintah</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output6.for+'% &nbsp; &nbsp; '+data.output6.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output6.against+'% &nbsp; &nbsp; '+data.output6.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output6.abstain+'% &nbsp; &nbsp; '+data.output6.abstain_total+' Votes</span>');

                $('#box7').html('<h3>Authorize directors to fix the fees of auditors</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output7.for+'% &nbsp; &nbsp; '+data.output7.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output7.against+'% &nbsp; &nbsp; '+data.output7.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output7.abstain+'% &nbsp; &nbsp; '+data.output7.abstain_total+' Votes</span>');

                $('#box8').html('<h3>Approve renumeration of directors</h3>\n<br>' +
                    '<span style="color: green; font-size: 20px">For : ' +data.output8.for+'% &nbsp; &nbsp; '+data.output8.for_total+' Votes</span><br/><hr>\n' +
                    '<span style="color: red; font-size: 20px">Against : ' +data.output8.against+'% &nbsp; &nbsp; '+data.output8.against_total+' Votes</span><hr>\n'+
                    '<span style="color: orange; font-size: 20px">Abstain : ' +data.output8.abstain+'% &nbsp; &nbsp; '+data.output8.abstain_total+' Votes</span>');


            });
        }


        setInterval( ajaxReload, 10000);
    </script>



@endpush

