@extends('layouts.main')
@section('container')
    @if (session()->has('success'))
        <div class="alert alert-success alert-dismissible show fade">
            <div class="alert-body">
                <button class="close" data-dismiss="alert">
                    <span>×</span>
                </button>
                {{ session('success') }}
            </div>
        </div>
    @endif
    <div class="card shadow mb-4" id="printableCard">


        <div class="card m-3">
            <div class="row no-gutters">
                <div class="col-md-2 bg-gray-100 d-flex justify-content-center align-items-center ">
                    <img src="{{ asset('img/avatar-1.png') }}" class="card-img rounded-circle mb-2 mt-2" style="width: 25vh"
                        alt="...">
                </div>

                <div class="col-md-10">
                    <div class="card-body">

                        <h5 class="card-title text-center" style="text-transform: uppercase">Ibu
                            {{ $data->details->nama_ibu }}
                        </h5>
                        <hr>
                        <div class="row ">
                            <div class="col-md-6 mb-2">
                                <div class="card bg-gray-100 p-2">
                                    <p class="card-text">
                                        Biodata :
                                    </p>
                                    <ul class="aligned-list">
                                        <li>
                                            <span class="v1">NIK Ibu</span>
                                            <span>:</span>
                                            <span>{{ $data->details->nik_ibu }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Tanggal Lahir Ibu</span>
                                            <span>:</span>
                                            <span>{{ \Carbon\Carbon::parse($data->details->tanggal_lahir_ibu)->format('d - F - Y') }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Nama Ibu</span>
                                            <span>:</span>
                                            <span>{{ $data->details->nama_ibu }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Umur Ibu</span>
                                            <span>:</span>
                                            <span>{{ $data->details->umur_ibu }}</span>
                                        </li>

                                        <li>
                                            <span class="v1">Nama Ayah</span>
                                            <span>:</span>
                                            <span>{{ $data->details->nama_ayah }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Umur Ayah</span>
                                            <span>:</span>
                                            <span>{{ $data->details->umur_ayah }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Alamat</span>
                                            <span>:</span>
                                            <span>{{ $data->details->alamat }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Status Ibu</span>
                                            <span>:</span>
                                            <span>{{ $data->details->status_ibu }}</span>
                                        </li>
                                        <li>
                                            <span class="v1">Status Ayah</span>
                                            <span>:</span>
                                            <span>{{ $data->details->status_ayah }}</span>
                                        </li>
                                    </ul>
                                    @can('admin_is')
                                        <p class="card-text ">
                                            <button id="showFormBtnv2" class="btn btn-primary btn-sm float-right">
                                                <span class="icon text-white">
                                                    <i class="far fa-edit"></i>
                                                </span>
                                            </button>
                                        </p>
                                    @endcan
                                    <div id="formContainerv2" style="display: none">
                                        <hr>
                                        <form
                                            action ="/edit_biodata/{{ $data->details->id }}/edit/data_ibu_hamil/data_balita"
                                            method="post">
                                            @method('patch')
                                            @csrf
                                            <div class="form-group">
                                                <label>NIK Ibu</label>
                                                <input type="number" name="nik_ibu"
                                                    class="form-control @error('nik_ibu')is-invalid @enderror"
                                                    value="{{ old('nik_ibu', $data->details->nik_ibu) }}">
                                                @error('nik_ibu')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>

                                            <div class="form-group">
                                                <label>Tanggal Lahir Ibu</label>
                                                <input type="date" name="tanggal_lahir_ibu"
                                                    class="form-control @error('tanggal_lahir_ibu')is-invalid @enderror"
                                                    value="{{ old('tanggal_lahir_ibu', $data->details->tanggal_lahir_ibu) }}">
                                                @error('tanggal_lahir_ibu')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Nama Ibu</label>
                                                <input type="text" name="nama_ibu"
                                                    class="form-control @error('nama_ibu')is-invalid @enderror"
                                                    value="{{ old('nama_ibu', $data->details->nama_ibu) }}">
                                                @error('nama_ibu')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            {{-- <div class="form-group">
                                                <label>Umur Ibu</label>
                                                <input type="number" name="umur_ibu"
                                                    class="form-control @error('umur_ibu')is-invalid @enderror"
                                                    value="{{ old('umur_ibu', $data->details->umur_ibu) }}">
                                                @error('umur_ibu')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div> --}}
                                            <div class="form-group">
                                                <label>Tanggal Lahir Ayah</label>
                                                <input type="date" name="tanggal_lahir_ayah"
                                                    class="form-control @error('tanggal_lahir_ayah')is-invalid @enderror"
                                                    value="{{ old('tanggal_lahir_ayah', $data->details->tanggal_lahir_ayah) }}">
                                                @error('tanggal_lahir_ayah')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Nama Ayah</label>
                                                <input type="text" name="nama_ayah"
                                                    class="form-control @error('nama_ayah')is-invalid @enderror"
                                                    value="{{ old('nama_ayah', $data->details->nama_ayah) }}">
                                                @error('nama_ayah')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Umur Ayah</label>
                                                <input type="text" name="umur_ayah"
                                                    class="form-control @error('umur_ayah')is-invalid @enderror"
                                                    value="{{ old('umur_ayah', $data->details->umur_ayah) }}">
                                                @error('umur_ayah')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Alamat</label>
                                                <input type="text" name="alamat"
                                                    class="form-control @error('alamat')is-invalid @enderror"
                                                    value="{{ old('alamat', $data->details->alamat) }}">
                                                @error('alamat')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label for="status_ibu">Status Ibu</label>
                                                <select class="form-control @error('status_ibu') is-invalid @enderror"
                                                    name="status_ibu" id="status_ibu">
                                                    <option value="" {{ old('status_ibu') == '' ? 'selected' : '' }}>
                                                        ---
                                                        Pilih ---
                                                    </option>
                                                    <option value="Hamil"
                                                        {{ old('status_ibu', $data->details->status_ibu) == 'Hamil' ? 'selected' : '' }}>
                                                        Hamil
                                                    </option>
                                                    <option value="Sudah Melahirkan"
                                                        {{ old('status_ibu', $data->details->status_ibu) == 'Sudah Melahirkan' ? 'selected' : '' }}>
                                                        Sudah Melahirkan
                                                    </option>
                                                    <option value="Meninggal"
                                                        {{ old('status_ibu', $data->details->status_ibu) == 'Meninggal' ? 'selected' : '' }}>
                                                        Meninggal
                                                    </option>
                                                </select>
                                                @error('status_ibu')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label for="status_ayah">Status Ayah</label>
                                                <select class="form-control @error('status_ayah') is-invalid @enderror"
                                                    name="status_ayah" id="status_ayah">
                                                    <option value=""
                                                        {{ old('status_ayah') == '' ? 'selected' : '' }}>
                                                        ---
                                                        Pilih ---
                                                    </option>
                                                    <option value="Masih Hidup"
                                                        {{ old('status_ayah', $data->details->status_ayah) == 'Masih Hidup' ? 'selected' : '' }}>
                                                        Masih Hidup
                                                    </option>
                                                    <option value="Cerai"
                                                        {{ old('status_ayah', $data->details->status_ayah) == 'Cerai' ? 'selected' : '' }}>
                                                        Cerai
                                                    </option>
                                                    <option value="Meninggal"
                                                        {{ old('status_ayah', $data->details->status_ayah) == 'Meninggal' ? 'selected' : '' }}>
                                                        Meninggal
                                                    </option>
                                                </select>
                                                @error('status_ayah')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>


                                            <div class="modal-footer">
                                                <button class="btn btn-primary" type="submit">Update</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6 ">
                                <div class="card bg-gray-100 p-2">
                                    <p class="card-text ">
                                        Biodata Balita:
                                    </p>
                                    <ul class="aligned-list">
                                        <li>
                                            <span class="v2">Anak Ke </span>
                                            <span>:</span>
                                            <span>{{ $data->details->anak_ke }}</span>
                                        </li>
                                        <li>
                                            <span class="v2">NIK Balita</span>
                                            <span>:</span>
                                            <span>{{ $data->nik_balita }}</span>
                                        </li>
                                        <li>
                                            <span class="v2">Nama Balita</span>
                                            <span>:</span>
                                            <span>{{ $data->nama_balita }}</span>
                                        </li>
                                        <li>
                                            <span class="v2">Jenis Kelamin</span>
                                            <span>:</span>
                                            <span>{{ $data->jenis_kelamin }}</span>
                                        </li>
                                        <li>
                                            <span class="v2">Tanggal Lahir</span>
                                            <span>:</span>
                                            <span>{{ \Carbon\Carbon::parse($data->tanggal_lahir)->format('d - F - Y') }}</span>
                                        </li>

                                        <li>
                                            <span class="v2">Jam Lahir</span>
                                            <span>:</span>
                                            <span>{{ $data->jam_lahir }}</span>
                                        </li>
                                    </ul>
                                    @can('admin_is')
                                        <p class="card-text ">
                                            <button id="showFormBtnv4" class="btn btn-primary btn-sm float-right">
                                                <span class="icon text-white">
                                                    <i class="far fa-edit"></i>
                                                </span>
                                            </button>
                                        </p>
                                    @endcan
                                    <div id="formContainerv4" style="display: none">
                                        <hr>
                                        <form action ="/edit_biodata/{{ $data->details->id }}/edit/data_balita"
                                            method="post">
                                            @method('patch')
                                            @csrf
                                            <div class="form-group">
                                                <label>NIk Balita</label>
                                                <input type="number" name="nik_balita"
                                                    class="form-control @error('nik_balita')is-invalid @enderror"
                                                    value="{{ old('nik_balita', $data->nik_balita) }}">
                                                @error('nik_balita')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Nama Balita</label>
                                                <input type="text" name="nama_balita"
                                                    class="form-control @error('nama_balita')is-invalid @enderror"
                                                    value="{{ old('nama_balita', $data->nama_balita) }}">
                                                @error('nama_balita')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label for="jenis_kelamin">Jenis Kelamin</label>
                                                <select class="form-control @error('jenis_kelamin') is-invalid @enderror"
                                                    name="jenis_kelamin" id="jenis_kelamin">
                                                    <option value=""
                                                        {{ old('jenis_kelamin') == '' ? 'selected' : '' }}>---
                                                        Pilih ---
                                                    </option>
                                                    <option value="Laki Laki"
                                                        {{ old('jenis_kelamin', $data->jenis_kelamin) == 'Laki Laki' ? 'selected' : '' }}>
                                                        Laki
                                                        Laki
                                                    </option>
                                                    <option value="Perempuan"
                                                        {{ old('jenis_kelamin', $data->jenis_kelamin) == 'Perempuan' ? 'selected' : '' }}>
                                                        Perempuan
                                                    </option>
                                                </select>
                                                @error('jenis_kelamin')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Tanggal Lahir</label>
                                                <input type="date" name="tanggal_lahir"
                                                    class="form-control @error('tanggal_lahir')is-invalid @enderror"
                                                    value="{{ old('tanggal_lahir', $data->tanggal_lahir) }}">
                                                @error('tanggal_lahir')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label>Jam Lahir</label>
                                                <input type="time" name="jam_lahir"
                                                    class="form-control @error('jam_lahir')is-invalid @enderror"
                                                    value="{{ old('jam_lahir', $data->jam_lahir) }}">
                                                @error('jam_lahir')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>

                                            <div class="form-group">
                                                <label for="status">Status</label>
                                                <select class="form-control @error('status') is-invalid @enderror"
                                                    name="status" id="status">
                                                    <option value="" {{ old('status') == '' ? 'selected' : '' }}>
                                                        ---
                                                        Pilih ---
                                                    </option>
                                                    <option value="Sudah Dilahirkan"
                                                        {{ old('status', $data->status) == 'Sudah Dilahirkan' ? 'selected' : '' }}>
                                                        Sudah Dilahirkan
                                                    </option>
                                                    <option value="Meninggal"
                                                        {{ old('status', $data->status) == 'Meninggal' ? 'selected' : '' }}>
                                                        Meninggal
                                                    </option>
                                                </select>
                                                @error('status')
                                                    <div class="invalid-feedback">
                                                        {{ $message }}
                                                    </div>
                                                @enderror
                                            </div>
                                            <div class="modal-footer">
                                                <button class="btn btn-primary" type="submit">Update</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class=" col-md-12 mb-4">
            <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class=" py-3 d-flex justify-content-between align-items-center">
                                <h6 class="m-0 font-weight-bold text-primary">Status Periksa balita {{ $data->nama_bayi }}
                                </h6>
                                @cannot('admin_is')
                                    <button id="showFormBtn" class="btn btn-primary btn-icon-split btn-sm">
                                        <span class="icon text-white-50">
                                            <i class="fas fa-plus" id="iconToggle"></i>
                                        </span>
                                        <span class="text" id="textToggle">Tambah</span>
                                    </button>
                                @endcannot
                            </div>

                            <div id="formContainer" style="display: none">
                                <form action ="/status_periksa_data_balita/{{ $data->id }}/create" method="post">
                                    @csrf
                                    <div class="form-group">
                                        <label>Tanggal Kunjungan</label>
                                        <input type="date" name="tanggal_kunjungan"
                                            class="form-control @error('tanggal_kunjungan')is-invalid @enderror"
                                            value="{{ old('tanggal_kunjungan') }}">
                                        @error('tanggal_kunjungan')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>

                                    {{-- <div class="form-row">
                                        <div class="form-group col-md-6">
                                            <label>Usia Balita (Tahun)</label>
                                            <input type="number" name="usia_balita_tahun"
                                                class="form-control @error('usia_balita_tahun') is-invalid @enderror"
                                                value="{{ old('usia_balita_tahun') }}" min="0" max="5">
                                            @error('usia_balita_tahun')
                                                <div class="invalid-feedback">
                                                    {{ $message }}
                                                </div>
                                            @enderror
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Usia Balita (Bulan)</label>
                                            <input type="number" name="usia_balita_bulan"
                                                class="form-control @error('usia_balita_bulan') is-invalid @enderror"
                                                value="{{ old('usia_balita_bulan') }}" min="0" max="11">
                                            @error('usia_balita_bulan')
                                                <div class="invalid-feedback">
                                                    {{ $message }}
                                                </div>
                                            @enderror
                                        </div>
                                    </div> --}}


                                    <div class="form-group">
                                        <label>Tinggi Badan (cm)</label>
                                        <input type="number" name="tinggi_badan"
                                            class="form-control @error('tinggi_badan')is-invalid @enderror"
                                            value="{{ old('tinggi_badan') }}">
                                        @error('tinggi_badan')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>
                                    <div class="form-group">
                                        <label>Berat Badan (kg)</label>
                                        <input type="number" name="berat_badan"
                                            class="form-control @error('berat_badan')is-invalid @enderror"
                                            value="{{ old('berat_badan') }}">
                                        @error('berat_badan')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>
                                    <div class="form-group">
                                        <label>Lingkar Kepala Balita (cm)</label>
                                        <input type="number" name="lingkar_kepala_balita"
                                            class="form-control @error('lingkar_kepala_balita')is-invalid @enderror"
                                            value="{{ old('lingkar_kepala_balita') }}">
                                        @error('lingkar_kepala_balita')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>
                                    <div class="form-group">
                                        <label>Jenis Vitamin</label>
                                        <select class="form-control @error('vitamin_id') is-invalid @enderror"
                                            name="vitamin_id" id="vitamin_id">
                                            <option value="" {{ old('vitamin_id') == '' ? 'selected' : '' }}>---
                                                Pilih ---
                                            </option>
                                            @foreach ($data_vitamin->where('jenis_obat', 'Vitamin') as $dv)
                                                <option value="{{ $dv->id }}"
                                                    {{ old('vitamin_id') == $dv->id ? 'selected' : '' }}>
                                                    {{ $dv->nama_obat }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label for="imunisasi_id">Jenis Imunisasi</label>
                                        <select class="form-control @error('imunisasi_id') is-invalid @enderror"
                                            name="imunisasi_id" id="imunisasi_id">
                                            <option value="" {{ old('imunisasi_id') == '' ? 'selected' : '' }}>---
                                                Pilih ---
                                            </option>
                                            @foreach ($data_vitamin->where('jenis_obat', 'Imunisasi') as $dv)
                                                <option value="{{ $dv->id }}"
                                                    {{ old('imunisasi_id') == $dv->id ? 'selected' : '' }}>
                                                    {{ $dv->nama_obat }}
                                                </option>
                                            @endforeach
                                        </select>

                                        @error('imunisasi_id')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>


                                    <div class="modal-footer">
                                        <button class="btn btn-primary" type="submit">Tambah</button>
                                    </div>
                                </form>
                            </div>
                            {{-- <hr> --}}
                            {{-- <div class="h5 mb-0 font-weight-bold text-gray-800"> --}}
                            <div class="table-responsive">
                                <table id="example" class="table table-stripped table-hover">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Tanggal Kunjungan</th>
                                            <th>Usia</th>
                                            <th>TB</th>
                                            <th>BB</th>
                                            <th>LKB</th>
                                            <th>Jenis Vitamin</th>
                                            <th>Jenis Imunisasi</th>
                                            @cannot('admin_is')
                                                <th>Action</th>
                                            @endcannot

                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($status_periksa_balita as $spb)
                                            <tr>
                                                <td>{{ $loop->iteration }}</td>
                                                <td style="width: 10%">
                                                    {{ \Carbon\Carbon::parse($spb->tanggal_kunjungan)->format('d - F - Y') }}
                                                </td>
                                                <td style="width: 9%">
                                                    @if ($spb->usia_balita_tahun > 0)
                                                        {{ $spb->usia_balita_tahun }} Tahun
                                                    @endif
                                                    {{ $spb->usia_balita_bulan }} Bulan
                                                </td>
                                                <td style="width: 8%">{{ $spb->tinggi_badan }} Cm</td>
                                                <td style="width: 8%">{{ $spb->berat_badan }} Kg</td>
                                                <td style="width: 8%">{{ $spb->lingkar_kepala_balita }} Cm</td>
                                                <td>{{ $spb->info->nama_obat }}</td>
                                                <td>{{ $spb->infov2->nama_obat }}</td>
                                                @cannot('admin_is')
                                                    <td style="width: 15%">
                                                        <a href="/status_periksa_balita/{{ $spb->id }}/edit"
                                                            class="btn btn-warning">
                                                            <span class="icon text-white">
                                                                <i class="fas fa-edit"></i>
                                                            </span>
                                                        </a>
                                                        <a href="#" data-toggle="modal"
                                                            data-target="#hapusData{{ $spb->id }}"
                                                            class="btn btn-danger">
                                                            <span class="icon text-white">
                                                                <i class="fas fa-trash"></i>
                                                            </span>
                                                        </a>
                                                    </td>
                                                @endcannot
                                            </tr>
                                            <div class="modal fade" id="hapusData{{ $spb->id }}" tabindex="-1"
                                                role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <h5 class="modal-title" id="exampleModalLabel">Apakah Kamu
                                                                Akan Menghapus Data Status Periksa Balita Pada Tanggal
                                                                {{ \Carbon\Carbon::parse($spb->tanggal_kunjungan)->format('d - F - Y') }}

                                                            </h5>
                                                            <button class="close" type="button" data-dismiss="modal"
                                                                aria-label="Close">
                                                                <span aria-hidden="true">×</span>
                                                            </button>
                                                        </div>
                                                        <div class="modal-body">Pilih "Hapus" di bawah jika Anda ingin
                                                            menghapus data admin
                                                            {{ $spb->nama_lengkap }}
                                                        </div>
                                                        <div class="modal-footer">
                                                            <form
                                                                action="/status_periksa_balita/delete/{{ $spb->id }}"
                                                                method="post" class="d-inline">
                                                                @method('delete')
                                                                @csrf
                                                                <button class="btn btn-secondary" type="button"
                                                                    data-dismiss="modal">Cancel</button>
                                                                <button class="btn btn-danger">Hapus</button>
                                                            </form>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>

                </div>
            </div>
        </div>



        <div class="col-md-12 mb-4">
            <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class=" py-3 d-flex justify-content-between align-items-center">
                                <h6 class="m-0 font-weight-bold text-primary">Grafik Pertumbuhan Tinggi Badan
                                    {{ $data->nama_bayi }}</h6>
                            </div>
                            <canvas id="chartTinggiBadan"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-12 mb-4">
            <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class=" py-3 d-flex justify-content-between align-items-center">
                                <h6 class="m-0 font-weight-bold text-primary">Grafik Pertumbuhan Berat Badan
                                    {{ $data->nama_bayi }}</h6>
                            </div>
                            <canvas id="chartBeratBadan"></canvas>

                        </div>
                    </div>
                </div>
            </div><br>
            <div class="row justify-content-end mr-2">
                <a class="btn btn-custom btn-icon icon-left btn-primary"
                    href="/cetak/hasil_pemeriksaan/{{ $data->id }}" target="blank">Cetak</a>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        // Chart
        var ctxTinggi = document.getElementById('chartTinggiBadan').getContext('2d');
        var chartTinggi = new Chart(ctxTinggi, {
            type: 'line',
            data: {
                labels: {!! json_encode(array_keys($tinggi_badan_balita)) !!},
                datasets: [{
                    label: 'Tinggi Badan (cm)',
                    backgroundColor: 'rgba(255, 99, 132, 0.2)',
                    borderColor: 'rgba(255, 99, 132, 1)',
                    data: {!! json_encode(array_values($tinggi_badan_balita)) !!},
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true,
                        }
                    }]
                }
            }
        });

        var ctxBerat = document.getElementById('chartBeratBadan').getContext('2d');
        var chartBerat = new Chart(ctxBerat, {
            type: 'line',
            data: {
                labels: {!! json_encode(array_keys($berat_badan_balita)) !!},
                datasets: [{
                    label: 'Berat Badan (kg)',
                    backgroundColor: 'rgba(54, 162, 235, 0.2)',
                    borderColor: 'rgba(54, 162, 235, 1)',
                    data: {!! json_encode(array_values($berat_badan_balita)) !!},
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true,
                        }
                    }]
                }
            }
        });




        // hello world
        var formContainer = document.getElementById('formContainer');
        var showFormBtn = document.getElementById('showFormBtn');
        var formContainerv2 = document.getElementById('formContainerv2');
        var showFormBtnv2 = document.getElementById('showFormBtnv2');
        // var formContainerv3 = document.getElementById('formContainerv3');
        // var showFormBtnv3 = document.getElementById('showFormBtnv3');
        var formContainerv4 = document.getElementById('formContainerv4');
        var showFormBtnv4 = document.getElementById('showFormBtnv4');
        var iconToggle = document.getElementById('iconToggle');
        var iconTogglev2 = document.getElementById('iconTogglev2');
        var textToggle = document.getElementById('textToggle');
        var textTogglev2 = document.getElementById('textTogglev2');

        var isFormVisible = false;



        if (showFormBtnv2) {

            showFormBtnv2.addEventListener('click', function() {
                if (!isFormVisible) {
                    formContainerv2.style.display = 'block';
                    // iconTogglev2.className = 'fas fa-times';
                    // textTogglev2.textContent = 'Tutup';
                    isFormVisible = true;
                } else {
                    formContainerv2.style.display = 'none';
                    // iconTogglev2.className = 'fas fa-check';
                    // textTogglev2.textContent = 'Selesai';
                    isFormVisible = false;
                }
            });
        }
        // showFormBtnv3.addEventListener('click', function() {
        // if (!isFormVisible) {
        // formContainerv3.style.display = 'block';
        // iconTogglev2.className = 'fas fa-times';
        // textTogglev2.textContent = 'Tutup';
        // isFormVisible = true;
        // } else {
        // formContainerv3.style.display = 'none';
        // iconTogglev2.className = 'fas fa-check';
        // textTogglev2.textContent = 'Selesai';
        // isFormVisible = false;
        // }
        // });
        if (showFormBtnv4) {
            showFormBtnv4.addEventListener('click', function() {
                if (!isFormVisible) {
                    formContainerv4.style.display = 'block';
                    isFormVisible = true;
                } else {
                    formContainerv4.style.display = 'none';
                    isFormVisible = false;
                }
            });
        }





        window.addEventListener('DOMContentLoaded', function() {
            var errorMessages = document.querySelectorAll('#formContainer .invalid-feedback');
            if (errorMessages.length > 0) {
                formContainer.style.display = 'block';
                isFormVisible = true;
            }
        });
        window.addEventListener('DOMContentLoaded', function() {
            var errorMessages = document.querySelectorAll('#formContainerv2 .invalid-feedback');
            if (errorMessages.length > 0) {
                formContainerv2.style.display = 'block';
                isFormVisible = true;
            }
        });
        window.addEventListener('DOMContentLoaded', function() {
            var errorMessages = document.querySelectorAll('#formContainerv3 .invalid-feedback');
            if (errorMessages.length > 0) {
                formContainerv3.style.display = 'block';
                isFormVisible = true;
            }
        });
        window.addEventListener('DOMContentLoaded', function() {
            var errorMessages = document.querySelectorAll('#formContainerv4 .invalid-feedback');
            if (errorMessages.length > 0) {
                formContainerv4.style.display = 'block';
                isFormVisible = true;
            }
        });

        document.addEventListener('DOMContentLoaded', function() {

            var inputs = document.querySelectorAll('.form-control');
            inputs.forEach(function(input) {
                input.addEventListener('focus', function() {
                    this.classList.remove('is-invalid');
                    var feedback = this.parentNode.querySelector('.invalid-feedback');
                    if (feedback) {
                        feedback.style.display = 'none';
                    }
                });
            });
        });

        showFormBtn.addEventListener('click', function() {
            if (!isFormVisible) {
                formContainer.style.display = 'block';
                iconToggle.className = 'fas fa-minus';
                textToggle.textContent = 'Tutup';
                isFormVisible = true;
            } else {
                formContainer.style.display = 'none';
                iconToggle.className = 'fas fa-plus';
                textToggle.textContent = 'Tambah';
                isFormVisible = false;
            }
        });
    </script>
@endsection
