HTML Canvas ссылка на переменную передачи страницы - PullRequest
0 голосов
/ 25 сентября 2019

Мне нужно создать ссылку в HTML-канве, которая ссылается на другую страницу, она должна передать объект PHP на эту страницу, и тогда эта страница сможет отобразить этот объект (данные из базы данных)

код для отображения холста

<h2>Pending Packets per Location<h2>
<canvas class="my-4 w-100" id="pending" width="600" height="115"></canvas>

<h2>Completed Packets per Location</h2>
<canvas class="my-4 w-100" id="completed" width="600" height="115"></canvas>

<h2>Pending Expedited Re-admission packets per location</h2>
<canvas class="my-4 w-100" id="pendingreadmission" width="600" height="115"></canvas>

<h2>Completed Expedited Re-admission packets per location</h2>
<canvas class="my-4 w-100" id="completedreadmission" width="600" height="115"></canvas>

код для создания холста

<?php
        $facilities = DB::table('facilities')->get();
        foreach ($facilities as $facility){
            $pending[] = DB::table('documents')->whereNull('completed_at')->where('historical', 0)->where('readmission_packet', 0)->where('facility_id', $facility->id)->get();
            $completed[] = DB::table('documents')->whereNotNull('completed_at')->where('historical', 0)->where('facility_id', $facility->id)->get();
            $patientsReadmitting = DB::table('users')->where('readmitting', 1)->get();
            if($patientsReadmitting == null){
              foreach($patientsReadmitting as $readmitting){
                $pendingReadmission[] = DB::table('documents')->whereNull('completed_at')->where('user_id', $readmitting->id)->where('readmission_packet', 1)->where('facility_id', $facility->id)->get();              }
            } else {
                // user id 1 is an admin and will never have any documents
                $pendingReadmission[] = DB::table('documents')->whereNull('completed_at')->where('user_id', 1)->where('readmission_packet', 1)->where('facility_id', $facility->id)->get();
            }
            $completedReadmission[] = DB::table('documents')->whereNotNull('completed_at')->where('readmission_packet', 1)->where('facility_id', $facility->id)->get();

        }/**/      
    ?>
    <script src="{{mix('js/admin.js')}}"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/feather-icons/4.9.0/feather.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>      
    <script>
            /* globals Chart:false, feather:false */
        (function () {
          'use strict'

          feather.replace()

          // Graphs
          var ctx = document.getElementById('pending')
          // eslint-disable-next-line no-unused-vars
          var pending = new Chart(ctx, {
            type: 'bar',
            data: {
              labels: [
                <?php foreach ($facilities as $facility){
                    $facilityOut = '\'' . $facility->name . '\'' . ',';
                    echo $facilityOut;
                }?>
              ],
              datasets: [{
                data: [
                  <?php foreach ($pending as $data){
                      $pendingOut = $data->count() . ',';
                      echo $pendingOut;
                  }?>
                ],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
              }]
            },
            options: {
              scales: {
                yAxes: [{
                  ticks: {
                    beginAtZero: true
                  }
                }]
              },
              legend: {
                display: false
              }
            }
          })
        }())
    </script>
    <script>
        (function () {
          'use strict'

          feather.replace()

          // Graphs
          var ctx = document.getElementById('completed')
          // eslint-disable-next-line no-unused-vars
          var completed = new Chart(ctx, {
            type: 'bar',
            data: {
              labels: [
                <?php foreach ($facilities as $facility){
                    $facilityOut = '\'' . $facility->name . '\'' . ',';
                    echo $facilityOut;
                }?>
              ],
              datasets: [{
                data: [
                  <?php foreach ($completed as $data){
                      $completedOut = $data->count() . ',';
                      echo $completedOut;
                  }?>
                ],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
              }]
            },
            options: {
              scales: {
                yAxes: [{
                  ticks: {
                    beginAtZero: true
                  }
                }]
              },
              legend: {
                display: false
              }
            }
          })
        }())
    </script>
    <script>
        (function () {
          'use strict'

          feather.replace()

          // Graphs
          var ctx = document.getElementById('pendingreadmission')
          // eslint-disable-next-line no-unused-vars
          var pendingreadmission = new Chart(ctx, {
            type: 'bar',
            data: {
              labels: [
                <?php foreach ($facilities as $facility){
                    $facilityOut = '\'' . $facility->name . '\'' . ',';
                    echo $facilityOut;
                }?>
              ],
              datasets: [{
                data: [
                  <?php foreach ($pendingReadmission as $data){
                      $pendingReadmissionOut = $data->count() . ',';
                      echo $pendingReadmissionOut;
                  }?>
                ],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
              }]
            },
            options: {
              scales: {
                yAxes: [{
                  ticks: {
                    beginAtZero: true
                  }
                }]
              },
              legend: {
                display: false
              }
            }
          })
        }())
    </script>
    <script>
        (function () {
          'use strict'

          feather.replace()

          // Graphs
          var ctx = document.getElementById('completedreadmission')
          // eslint-disable-next-line no-unused-vars
          var completedreadmission = new Chart(ctx, {
            type: 'bar',
            data: {
              labels: [
                <?php foreach ($facilities as $facility){
                    $facilityOut = '\'' . $facility->name . '\'' . ',';
                    echo $facilityOut;
                }?>
              ],
              datasets: [{
                data: [
                  <?php foreach ($completedReadmission as $data){
                      $completedReadmissionOut = $data->count() . ',';
                      echo $completedReadmissionOut;
                  }?>
                ],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
              }]
            },
            options: {
              scales: {
                yAxes: [{
                  ticks: {
                    beginAtZero: true
                  }
                }]
              },
              legend: {
                display: false
              }
            }
          })
        }())
    </script>

код страницы, на которую он будет перенаправлен тоже admin / report.blade.php

@extends('layouts.admin')
@section('page_title')
<h1 class="h2">Report</h1>

@endsection
@section('content')
<div class="card">
    <div class="card-body">
        <h4>Documents</h4>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>Facility Name</th>
                    <th>Document Name</th>
                    <th>Patient Completed</th>
                    <th>Responsible Completed</th>
                    <th>2nd Reponsible Completed</th>
                    <th>Witness Completed</th>
                    <th>Community Completed</th>
                    <th>Download</th>
                </tr>
            </thead>
            <tbody>
            @foreach ($documents as $document)
                <tr>
                    <td>{{$document->packet->facility->name}}</td>
                    <td>{{$document->packet->name}}</td>
                        @if($document->completed_by_patient == true)
                            <td bgcolor="green">Yes</td>
                        @else
                            <td bgcolor="red">No</td>
                        @endif
                        @if($document->completed_by_responsible == true)
                            <td bgcolor="green">Yes</td>
                        @else
                            @if($user->responsible_party_id != null)
                                <td bgcolor="red">No</td>
                            @else
                                <td bgcolor="yellow">Not Applicable</td>
                            @endif
                        @endif
                        @if($document->completed_by_responsible_two == true)
                            <td bgcolor="green">Yes</td>
                        @else
                            `@if($user->responsible_party_two_id != null)
                                <td bgcolor="red">No</td>
                            @else
                                <td bgcolor="yellow">Not Applicable</td>
                            @endif
                        @endif
                        @if($document->completed_by_witness == true)
                            <td bgcolor="green">Yes</td>
                        @else
                        @if($user->witness_id != null)
                                <td bgcolor="red">No</td>
                            @else
                                <td bgcolor="yellow">Not Applicable</td>
                            @endif
                        @endif
                        @if($document->completed_by_community == true)
                            <td bgcolor="green">Yes</td>
                        @else
                            <td bgcolor="red">No</td>
                        @endif
                    <td><strong><a href="{{route('adminDocuments.download', $document)}}">Download Documents</a></strong></td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
</div>
@endsection

ожидаемый результат состоит в том, что когда я нажимаю на холст, он должен перенаправить на страницу отчета, в настоящее время ссылка не устанавливается.

первый щелчок на холсте

<h2>Pending Packets per Location<h2>
<canvas class="my-4 w-100" id="pending" width="600" height="115"></canvas>

затем он переходит к admin / report.blade.php, передавая следующее как $ documents

$pending[] = DB::table('documents')->whereNull('completed_at')->where('historical', 0)->where('readmission_packet', 0)->where('facility_id', $facility->id)->get();;

, щелкает по этому холсту

<h2>Completed Packets per Location</h2>
<canvas class="my-4 w-100" id="completed" width="600" height="115"></canvas>

, затем переходит к admin / report.blade.php, передавая следующее как $ documents

$completed[] = DB::table('documents')->whereNotNull('completed_at')->where('historical', 0)->where('facility_id',   $facility->id)->get();

, щелкните по этому холсту

<h2>Pending Expedited Re-admission packets per location</h2>
<canvas class="my-4 w-100" id="pendingreadmission" width="600" height="115"></canvas>

, затем он переходит к admin / report.blade.php, передавая следующее как $ documents

$pendingReadmission[] = DB::table('documents')->whereNull('completed_at')->where('user_id', $readmitting->id)->where('readmission_packet', 1)->where('facility_id', $facility->id)->get();   

нажмите на этот холст

 <h2>Completed Expedited Re-admission packets per location</h2>
    <canvas class="my-4 w-100" id="completedreadmission" width="600" height="115"></canvas>

, затем он перейдет к admin / report.blade.php, передавая следующее как $ documents

$completedReadmission[] = DB::table('documents')->whereNotNull('completed_at')->where('readmission_packet', 1)->where('facility_id', $facility->id)->get();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...