Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/pages/taskprovider/
Upload File :
Current File : /home/emeraadmin/public_html/pages/taskprovider/viewservice.php

<?php include('head.php'); ?>
<?php
require_once '../../Classes/Database.php';
require_once '../../Service/ServiceService.php';
require_once '../../Classes/System.php';

$System = new System();
$serviceService = new ServiceService();

if (!isset($_GET['id'])) {
    echo '<p>No service ID provided.</p>';
    exit;
}

$serviceId = $System->decryptData($_GET['id']);
// show error if the provided id is not valid with Swal alert
if (!$serviceId) {
    echo '<script>
            Swal.fire({
                title: "Invalid Service ID",
                text: "The URL parameter is invalid. Please go back and try again.",
                icon: "error",
                confirmButtonText: "Ok"
            }).then(() => window.location.href = "viewservices.php");
        </script>';
    exit;
}

$service = $serviceService->getServiceById($serviceId);
if (!$service) {
    echo '<p>Service not found.</p>';
    exit;
}

$latitude = $service->latitude;
$longitude = $service->longitude;
?>

<div class="main-content">
    <div class="container-fluid">
        <div class="page-header row align-items-end">
            <div class="col-lg-8">
                <div class="page-header-title">
                    <i class="ik ik-layers bg-blue"></i>
                    <div class="d-inline">
                        <h5>View Service</h5>
                        <span>View details of a service</span>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <nav class="breadcrumb-container" aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="../../index.html"><i class="ik ik-home"></i></a></li>
                        <li class="breadcrumb-item"><a href="#">Services</a></li>
                        <li class="breadcrumb-item active" aria-current="page">View Service</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <div class="card-header-left">
                            <a href="javascript:history.back()" class="btn btn-outline-primary">Back</a>
                        </div>
                        <div class="card-header-right">



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





        <div class="card">
            <div class="card-body">
                <div class="row align-items-center mb-30">
                    <div class="col-md-6">
                        <h4>General Information</h4>
                        <table>
                            <tbody>
                            <tr>
                                <td><i class="ik ik-layers icon-large"></i></td>
                                <td><h3 class="mb-0 fw-700 text-black"><?php echo $service->name?: 'Name not provided'; ?></h3></td>
                            </tr>
                            <tr>
                                <td><i class="ik ik-map-pin icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->region; ?></h5></td>
                            </tr>
                            </tbody>
                        </table>

                        <h4>Address Details</h4>
                        <table>
                            <tbody>
                            <tr>
                                <td><i class="ik ik-home icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->address_line1 ?: 'Address Line 1 not provided'; ?></h5></td>

                                <td><i class="ik ik-home icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->address_line2 ?: 'Address Line 2 not provided'; ?></h5></td>
                            </tr>
                            <tr>
                                <td><i class="ik ik-map icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->suburb ?: 'Suburb not provided'; ?></h5></td>

                                <td><i class="ik ik-map-pin icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->city?: 'City not provided'; ?></h5></td>
                            <tr>
                                <td><i class="ik ik-globe icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->state ?: 'State not provided'; ?></h5></td>

                                <td><i class="ik ik-mail icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->postal_code ?: 'Postal code not provided'; ?></h5></td>
                            </tr>
                            <tr>
                                <td><i class="ik ik-flag icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->country?: 'Country not provided'; ?></h5></td>
                            </tr>
                            <tr>
                                <td><i class="ik ik-phone icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->phone?: 'Phone not provided'; ?></h5></td>
                            </tr>
                            
                            </tbody>
                        </table>
                        <h4>On Site Location</h4>
                        <table>
                            <tbody>
                            <tr>
                                <td><i class="ik ik-map-pin icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->on_site_location ?: 'Not provided'; ?></h5></td>
                            </tr>
                            </tbody>
                        </table>
                        <h4>Longitude and Latitude</h4>
                        <table>
                            <tbody>
                            <tr>
                                <td><i class="ik ik-map-pin icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->latitude ?: 'Not provided'; ?></h5></td>

                                <td><i class="ik ik-map-pin icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo $service->longitude ?: 'Not provided'; ?></h5></td>
                            </tr>
                            </tbody>
                        </table>

                        <h4>Timestamps</h4>
                        <table>
                            <tbody>
                            <tr>
                                <td><i class="ik ik-calendar icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo date('F j, Y, g:i a', strtotime($service->created_at)); ?></h5></td>

                                <td><i class="ik ik-clock icon-large"></i></td>
                                <td><h5 class="mb-0 fw-500 text-black"><?php echo date('F j, Y, g:i a', strtotime($service->updated_at)); ?></h5></td>
                            </tr>
                            </tbody>
                        </table>

                        <style>
                            table {
                                width: 100%;
                                border-collapse: collapse;
                                margin-bottom: 20px;
                            }
                            td {
                                padding: 10px 15px;
                                vertical-align: middle;
                            }
                            .icon-large {
                                font-size: 24px;
                                color: #333;
                            }
                            .mb-0 {
                                margin-bottom: 0;
                            }
                            .fw-700 {
                                font-weight: 700;
                            }
                            .fw-500 {
                                font-weight: 500;
                            }
                            .text-black {
                                color: #000;
                            }
                        </style>
                    </div>
                    <div class="col-md-6">
                        <div id="map" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
        </div>

        <?php if ($latitude !== null && $longitude !== null): ?>
            <script>
                function initMap() {
                    var latitude = <?php echo $latitude; ?>;
                    var longitude = <?php echo $longitude; ?>;

                    var map = new google.maps.Map(document.getElementById('map'), {
                        center: {lat: parseFloat(latitude), lng: parseFloat(longitude)},
                        zoom: 12
                    });

                    var marker = new google.maps.Marker({
                        position: {lat: parseFloat(latitude), lng: parseFloat(longitude)},
                        map: map,
                        title: 'Service Location'
                    });
                }
            </script>
            <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD9O5PAsTaFPCHlIlM4XSK7ei-gaLMYpzk&callback=initMap">
            </script>
        <?php endif; ?>
    </div>
</div>

<?php include('footer.php'); ?>