You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							320 lines
						
					
					
						
							13 KiB
						
					
					
				
			
		
		
	
	
							320 lines
						
					
					
						
							13 KiB
						
					
					
				@extends('layouts.admin.app')
 | 
						|
 | 
						|
@section('title',translate('Update Branch'))
 | 
						|
 | 
						|
 | 
						|
@section('content')
 | 
						|
 | 
						|
    <div class="content container-fluid">
 | 
						|
        <!-- Page Header -->
 | 
						|
        <div class="page-header">
 | 
						|
            <div class="row align-items-center">
 | 
						|
                <div class="col-sm mb-2 mb-sm-0">
 | 
						|
                    <h1 class="page-header-title text-capitalize"><i class="tio-edit"></i> {{translate('messages.zone')}} {{translate('messages.update')}}</h1>
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
        <!-- End Page Header -->
 | 
						|
        <div class="row gx-2 gx-lg-3">
 | 
						|
            <div class="col-sm-12 col-lg-12 mb-3 mb-lg-2">
 | 
						|
            <form action="{{route('admin.zone.update', $zone->id)}}" method="post"  class="shadow--card">
 | 
						|
                    @csrf
 | 
						|
                    <div class="row">
 | 
						|
                        <div class="col-md-5">
 | 
						|
                            <div class="zone-setup-instructions">
 | 
						|
                                <div class="zone-setup-top">
 | 
						|
                                    <h6 class="subtitle">{{translate('messages.instructions')}}</h6>
 | 
						|
                                    <p>
 | 
						|
                                        {{translate('messages.create_zone_by_click_on_map_and_connect_the_dots_together')}}
 | 
						|
                                    </p>
 | 
						|
                                </div>
 | 
						|
                                <div class="zone-setup-item">
 | 
						|
                                    <div class="zone-setup-icon">
 | 
						|
                                        <i class="tio-hand-draw"></i>
 | 
						|
                                    </div>
 | 
						|
                                    <div class="info">
 | 
						|
                                        {{translate('messages.use_this_drag_map_to_find_proper_area')}}
 | 
						|
                                    </div>
 | 
						|
                                </div>
 | 
						|
                                <div class="zone-setup-item">
 | 
						|
                                    <div class="zone-setup-icon">
 | 
						|
                                        <i class="tio-voice-line"></i>
 | 
						|
                                    </div>
 | 
						|
                                    <div class="info">
 | 
						|
                                        {{translate('messages.click_this_icon_to_start_pin_points_in_the_map_and_connect_them_to_draw_a_zone._minimum_3_points_required')}}
 | 
						|
                                    </div>
 | 
						|
                                </div>
 | 
						|
                                <div class="instructions-image mt-4">
 | 
						|
                                    <img src={{asset('public/assets/admin/img/instructions.gif')}} alt="instructions">
 | 
						|
                                </div>
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
                        <div class="col-md-6 col-xl-7 zone-setup">
 | 
						|
                            <div class="form-group mb-3">
 | 
						|
                                <label class="input-label"
 | 
						|
                                        for="exampleFormControlInput1">{{translate('messages.zone')}} {{translate('messages.name')}}</label>
 | 
						|
                                <input id="zone_name" type="text" name="name" class="form-control" placeholder="{{translate('messages.new_zone')}}" value="{{$zone->name}}" required>
 | 
						|
                            </div>
 | 
						|
                            <div class="form-group mb-3 initial-hidden">
 | 
						|
                                <label class="input-label"
 | 
						|
                                        for="exampleFormControlInput1">{{translate('messages.Coordinates')}}<span
 | 
						|
                                        class="input-label-secondary" title="{{translate('messages.draw_your_zone_on_the_map')}}">{{translate('messages.draw_your_zone_on_the_map')}}</span></label>
 | 
						|
                                        <textarea  type="text" name="coordinates"  id="coordinates" class="form-control">@foreach($zone->coordinates[0] as $key=>$coords)<?php if(count($zone->coordinates[0]) != $key+1) {if($key != 0) echo(','); ?>({{$coords->getLat()}}, {{$coords->getLng()}})<?php } ?>@endforeach</textarea>
 | 
						|
                            </div>
 | 
						|
 | 
						|
                            <div class="initial-60">
 | 
						|
                                <input id="pac-input" class="controls rounded initial-8" title="{{translate('messages.search_your_location_here')}}" type="text" placeholder="{{translate('messages.search_here')}}"/>
 | 
						|
                                <div id="map-canvas" class="h-100 m-0 p-0"></div>
 | 
						|
                            </div>
 | 
						|
                            <div class="btn--container mt-3 justify-content-end">
 | 
						|
                                <button id="reset_btn" type="reset" class="btn btn--reset">{{translate('messages.reset')}}</button>
 | 
						|
                                <button type="submit" class="btn btn--primary">{{translate('messages.update')}}</button>
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
                    </div>
 | 
						|
                </form>
 | 
						|
            </div>
 | 
						|
            <!-- End Table -->
 | 
						|
        </div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    </div>
 | 
						|
 | 
						|
@endsection
 | 
						|
 | 
						|
@push('script_2')
 | 
						|
<script src="https://maps.googleapis.com/maps/api/js?v=3.45.8&key={{ \App\Models\BusinessSetting::where('key', 'map_api_key')->first()->value }}&libraries=drawing,places"></script>
 | 
						|
<script>
 | 
						|
    auto_grow();
 | 
						|
    function auto_grow() {
 | 
						|
        let element = document.getElementById("coordinates");
 | 
						|
        element.style.height = "5px";
 | 
						|
        element.style.height = (element.scrollHeight)+"px";
 | 
						|
    }
 | 
						|
 | 
						|
</script>
 | 
						|
 | 
						|
<script>
 | 
						|
    var map; // Global declaration of the map
 | 
						|
    var lat_longs = new Array();
 | 
						|
    var drawingManager;
 | 
						|
    var lastpolygon = null;
 | 
						|
    var bounds = new google.maps.LatLngBounds();
 | 
						|
    var polygons = [];
 | 
						|
 | 
						|
 | 
						|
    function resetMap(controlDiv) {
 | 
						|
        // Set CSS for the control border.
 | 
						|
        const controlUI = document.createElement("div");
 | 
						|
        controlUI.style.backgroundColor = "#fff";
 | 
						|
        controlUI.style.border = "2px solid #fff";
 | 
						|
        controlUI.style.borderRadius = "3px";
 | 
						|
        controlUI.style.boxShadow = "0 2px 6px rgba(0,0,0,.3)";
 | 
						|
        controlUI.style.cursor = "pointer";
 | 
						|
        controlUI.style.marginTop = "8px";
 | 
						|
        controlUI.style.marginBottom = "22px";
 | 
						|
        controlUI.style.textAlign = "center";
 | 
						|
        controlUI.title = "Reset map";
 | 
						|
        controlDiv.appendChild(controlUI);
 | 
						|
        // Set CSS for the control interior.
 | 
						|
        const controlText = document.createElement("div");
 | 
						|
        controlText.style.color = "rgb(25,25,25)";
 | 
						|
        controlText.style.fontFamily = "Roboto,Arial,sans-serif";
 | 
						|
        controlText.style.fontSize = "10px";
 | 
						|
        controlText.style.lineHeight = "16px";
 | 
						|
        controlText.style.paddingLeft = "2px";
 | 
						|
        controlText.style.paddingRight = "2px";
 | 
						|
        controlText.innerHTML = "X";
 | 
						|
        controlUI.appendChild(controlText);
 | 
						|
        // Setup the click event listeners: simply set the map to Chicago.
 | 
						|
        controlUI.addEventListener("click", () => {
 | 
						|
            lastpolygon.setMap(null);
 | 
						|
            $('#coordinates').val('');
 | 
						|
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    function initialize() {
 | 
						|
        var myLatlng = new google.maps.LatLng({{trim(explode(' ',$zone->center)[1], 'POINT()')}}, {{trim(explode(' ',$zone->center)[0], 'POINT()')}});
 | 
						|
        var myOptions = {
 | 
						|
            zoom: 13,
 | 
						|
            center: myLatlng,
 | 
						|
            mapTypeId: google.maps.MapTypeId.ROADMAP
 | 
						|
        };
 | 
						|
        map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
 | 
						|
 | 
						|
        const polygonCoords = [
 | 
						|
 | 
						|
            @foreach($zone->coordinates[0] as $coords)
 | 
						|
            { lat: {{$coords->getLat()}}, lng: {{$coords->getLng()}} },
 | 
						|
            @endforeach
 | 
						|
        ];
 | 
						|
 | 
						|
        var zonePolygon = new google.maps.Polygon({
 | 
						|
            paths: polygonCoords,
 | 
						|
            strokeColor: "#050df2",
 | 
						|
            strokeOpacity: 0.8,
 | 
						|
            strokeWeight: 2,
 | 
						|
            fillOpacity: 0,
 | 
						|
        });
 | 
						|
 | 
						|
        zonePolygon.setMap(map);
 | 
						|
 | 
						|
        zonePolygon.getPaths().forEach(function(path) {
 | 
						|
            path.forEach(function(latlng) {
 | 
						|
                bounds.extend(latlng);
 | 
						|
                map.fitBounds(bounds);
 | 
						|
            });
 | 
						|
        });
 | 
						|
 | 
						|
 | 
						|
        drawingManager = new google.maps.drawing.DrawingManager({
 | 
						|
            drawingMode: google.maps.drawing.OverlayType.POLYGON,
 | 
						|
            drawingControl: true,
 | 
						|
            drawingControlOptions: {
 | 
						|
            position: google.maps.ControlPosition.TOP_CENTER,
 | 
						|
            drawingModes: [google.maps.drawing.OverlayType.POLYGON]
 | 
						|
            },
 | 
						|
            polygonOptions: {
 | 
						|
            editable: true
 | 
						|
            }
 | 
						|
        });
 | 
						|
        drawingManager.setMap(map);
 | 
						|
 | 
						|
        google.maps.event.addListener(drawingManager, "overlaycomplete", function(event) {
 | 
						|
            var newShape = event.overlay;
 | 
						|
            newShape.type = event.type;
 | 
						|
        });
 | 
						|
 | 
						|
        google.maps.event.addListener(drawingManager, "overlaycomplete", function(event) {
 | 
						|
            if(lastpolygon)
 | 
						|
                {
 | 
						|
                    lastpolygon.setMap(null);
 | 
						|
                }
 | 
						|
                $('#coordinates').val(event.overlay.getPath().getArray());
 | 
						|
                lastpolygon = event.overlay;
 | 
						|
                auto_grow();
 | 
						|
        });
 | 
						|
        const resetDiv = document.createElement("div");
 | 
						|
        resetMap(resetDiv, lastpolygon);
 | 
						|
        map.controls[google.maps.ControlPosition.TOP_CENTER].push(resetDiv);
 | 
						|
 | 
						|
        // Create the search box and link it to the UI element.
 | 
						|
        const input = document.getElementById("pac-input");
 | 
						|
            const searchBox = new google.maps.places.SearchBox(input);
 | 
						|
            map.controls[google.maps.ControlPosition.TOP_CENTER].push(input);
 | 
						|
            // Bias the SearchBox results towards current map's viewport.
 | 
						|
            map.addListener("bounds_changed", () => {
 | 
						|
                searchBox.setBounds(map.getBounds());
 | 
						|
            });
 | 
						|
            let markers = [];
 | 
						|
            // Listen for the event fired when the user selects a prediction and retrieve
 | 
						|
            // more details for that place.
 | 
						|
            searchBox.addListener("places_changed", () => {
 | 
						|
                const places = searchBox.getPlaces();
 | 
						|
 | 
						|
                if (places.length == 0) {
 | 
						|
                return;
 | 
						|
                }
 | 
						|
                // Clear out the old markers.
 | 
						|
                markers.forEach((marker) => {
 | 
						|
                marker.setMap(null);
 | 
						|
                });
 | 
						|
                markers = [];
 | 
						|
                // For each place, get the icon, name and location.
 | 
						|
                const bounds = new google.maps.LatLngBounds();
 | 
						|
                places.forEach((place) => {
 | 
						|
                if (!place.geometry || !place.geometry.location) {
 | 
						|
                    console.log("Returned place contains no geometry");
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                const icon = {
 | 
						|
                    url: place.icon,
 | 
						|
                    size: new google.maps.Size(71, 71),
 | 
						|
                    origin: new google.maps.Point(0, 0),
 | 
						|
                    anchor: new google.maps.Point(17, 34),
 | 
						|
                    scaledSize: new google.maps.Size(25, 25),
 | 
						|
                };
 | 
						|
                // Create a marker for each place.
 | 
						|
                markers.push(
 | 
						|
                    new google.maps.Marker({
 | 
						|
                    map,
 | 
						|
                    icon,
 | 
						|
                    title: place.name,
 | 
						|
                    position: place.geometry.location,
 | 
						|
                    })
 | 
						|
                );
 | 
						|
 | 
						|
                if (place.geometry.viewport) {
 | 
						|
                    // Only geocodes have viewport.
 | 
						|
                    bounds.union(place.geometry.viewport);
 | 
						|
                } else {
 | 
						|
                    bounds.extend(place.geometry.location);
 | 
						|
                }
 | 
						|
                });
 | 
						|
                map.fitBounds(bounds);
 | 
						|
            });
 | 
						|
    }
 | 
						|
    google.maps.event.addDomListener(window, 'load', initialize);
 | 
						|
 | 
						|
    function set_all_zones()
 | 
						|
    {
 | 
						|
        $.get({
 | 
						|
            url: '{{route('admin.zone.zoneCoordinates')}}/{{$zone->id}}',
 | 
						|
            dataType: 'json',
 | 
						|
            success: function (data) {
 | 
						|
 | 
						|
                console.log(data);
 | 
						|
                for(var i=0; i<data.length;i++)
 | 
						|
                {
 | 
						|
                    polygons.push(new google.maps.Polygon({
 | 
						|
                        paths: data[i],
 | 
						|
                        strokeColor: "#FF0000",
 | 
						|
                        strokeOpacity: 0.8,
 | 
						|
                        strokeWeight: 2,
 | 
						|
                        fillColor: "#FF0000",
 | 
						|
                        fillOpacity: 0.1,
 | 
						|
                    }));
 | 
						|
                    polygons[i].setMap(map);
 | 
						|
                }
 | 
						|
 | 
						|
            },
 | 
						|
        });
 | 
						|
    }
 | 
						|
    $(document).on('ready', function(){
 | 
						|
        set_all_zones();
 | 
						|
    });
 | 
						|
 | 
						|
 | 
						|
    $('#reset_btn').click(function(){
 | 
						|
        // $('#zone_name').val('');
 | 
						|
        // $('#coordinates').val('');
 | 
						|
        // $('#min_delivery_charge').val('');
 | 
						|
        // $('#delivery_charge_per_km').val('');
 | 
						|
        location.reload(true);
 | 
						|
    })
 | 
						|
    $(document).on('ready', function() {
 | 
						|
 | 
						|
$("#maximum_shipping_charge_status").on('change', function() {
 | 
						|
    if ($("#maximum_shipping_charge_status").is(':checked')) {
 | 
						|
        $('#maximum_shipping_charge').removeAttr('readonly');
 | 
						|
    } else {
 | 
						|
        $('#maximum_shipping_charge').attr('readonly', true);
 | 
						|
        $('#maximum_shipping_charge').val('Ex : 0');
 | 
						|
    }
 | 
						|
});
 | 
						|
$("#max_cod_order_amount_status").on('change', function() {
 | 
						|
    if ($("#max_cod_order_amount_status").is(':checked')) {
 | 
						|
        $('#max_cod_order_amount').removeAttr('readonly');
 | 
						|
    } else {
 | 
						|
        $('#max_cod_order_amount').attr('readonly', true);
 | 
						|
        $('#max_cod_order_amount').val('Ex : 0');
 | 
						|
    }
 | 
						|
});
 | 
						|
});
 | 
						|
</script>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
@endpush
 | 
						|
 |